working charge

This commit is contained in:
2025-09-18 13:20:03 -04:00
parent 6baefe9f50
commit dc71eee4db

View File

@@ -2,7 +2,7 @@
<template>
<div class="flex">
<!-- Main Content -->
<div class="flex-1 px-8 py-6">
@@ -485,6 +485,13 @@ export default defineComponent({
const response = await axios.post(authPath, authPayload, { withCredentials: true, headers: authHeader() });
// Update payment type to 11 after successful preauthorization
try {
await axios.put(`${import.meta.env.VITE_BASE_URL}/payment/authorize/${this.delivery.id}`, {}, { headers: authHeader() });
} catch (updateError) {
console.error('Failed to update payment type after preauthorization:', updateError);
}
// On successful authorization, show success and redirect
this.success = `Preauthorization successful! Transaction ID: ${response.data?.auth_net_transaction_id || 'N/A'}`;
setTimeout(() => {
@@ -513,6 +520,13 @@ export default defineComponent({
const response = await axios.post(chargePath, chargePayload, { withCredentials: true, headers: authHeader() });
// Update payment type to 11 after successful charge
try {
await axios.put(`${import.meta.env.VITE_BASE_URL}/payment/authorize/${this.delivery.id}`, {}, { headers: authHeader() });
} catch (updateError) {
console.error('Failed to update payment type after charge:', updateError);
}
// Status codes: 0 = APPROVED, 1 = DECLINED (based on backend TransactionStatus enum)
if (response.data && response.data.status === 0) { // 0 = APPROVED
this.success = `Charge successful! Transaction ID: ${response.data.auth_net_transaction_id || 'N/A'}`;