added popup
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user