diff --git a/src/pages/card/addcard.vue b/src/pages/card/addcard.vue
index 871dd1e..9a05d09 100755
--- a/src/pages/card/addcard.vue
+++ b/src/pages/card/addcard.vue
@@ -152,6 +152,8 @@ export default defineComponent({
user: null,
customer: {} as any,
isLoading: false,
+ isLoadingAuthorize: true,
+ authorizeCheck: { profile_exists: false, has_payment_methods: false, missing_components: [] as string[], valid_for_charging: false },
CardForm: {
main_card: false,
card_number: '',
@@ -190,10 +192,36 @@ export default defineComponent({
})
.catch(() => { this.user = null; });
},
+ async checkAuthorizeAccount() {
+ if (!this.customer.id) return;
+
+ this.isLoadingAuthorize = true;
+
+ try {
+ const path = `${import.meta.env.VITE_AUTHORIZE_URL}/user/check-authorize-account/${this.customer.id}`;
+ const response = await axios.get(path, { headers: authHeader() });
+ this.authorizeCheck = response.data;
+ } catch (error) {
+ console.error("Failed to check authorize account:", error);
+ notify({ title: "Error", text: "Could not check payment account status.", type: "error" });
+ // Set default error state
+ this.authorizeCheck = {
+ profile_exists: false,
+ has_payment_methods: false,
+ missing_components: ['api_error'],
+ valid_for_charging: false
+ };
+ } finally {
+ this.isLoadingAuthorize = false;
+ }
+ },
getCustomer(user_id: any) {
const path = `${import.meta.env.VITE_BASE_URL}/customer/${user_id}`;
axios.get(path, { withCredentials: true, headers: authHeader() })
- .then((response: any) => { this.customer = response.data; })
+ .then((response: any) => {
+ this.customer = response.data;
+ this.checkAuthorizeAccount();
+ })
.catch(() => {
notify({ title: "Error", text: "Could not find customer", type: "error" });
});
@@ -249,7 +277,17 @@ export default defineComponent({
return; // End the function here
}
- // --- STEP 3: BEST-EFFORT CALL - TOKENIZE CARD VIA FASTAPI AND UPDATE LOCAL CARD ---
+ // --- CHECK IF AUTHORIZE.NET PROFILE EXISTS ---
+ if (!this.authorizeCheck.profile_exists) {
+ console.log("Skipping Authorize.Net tokenization as no profile exists for customer.");
+ // Show success and redirect (card saved locally without tokenization)
+ notify({ title: "Success", text: "Credit card has been saved.", type: "success" });
+ this.isLoading = false;
+ this.$router.push({ name: "customerProfile", params: { id: this.customer.id } });
+ return;
+ }
+
+ // --- STEP 3: BEST-EFFORT CALL - TOKENIZE CARD VIA AUTHORIZE
try {
const fastapiPath = `${import.meta.env.VITE_AUTHORIZE_URL}/api/payments/customers/${this.customer.id}/cards`;
console.log("Attempting to tokenize card with Authorize.Net via FastAPI:", fastapiPath);
diff --git a/src/pages/customer/profile/profile.vue b/src/pages/customer/profile/profile.vue
index 972f4e8..4666c8f 100755
--- a/src/pages/customer/profile/profile.vue
+++ b/src/pages/customer/profile/profile.vue
@@ -140,7 +140,7 @@
Authorize.net Profile ID:
-{{ createdProfileId }}
+{{ createdProfileId }}
Your payment account is now ready for transactions.
@@ -215,6 +215,51 @@ + +Duplicate Account in Authorize.net
++ A duplicate account was found in your Authorize.net merchant account. +
++ Customer ID: {{ customer.id }} +
++ Inconsistency between your system and Authorize.net detected. +
++ This profile may have been created previously and needs manual linking. +
+