working charge
This commit is contained in:
@@ -485,6 +485,13 @@ export default defineComponent({
|
|||||||
|
|
||||||
const response = await axios.post(authPath, authPayload, { withCredentials: true, headers: authHeader() });
|
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
|
// On successful authorization, show success and redirect
|
||||||
this.success = `Preauthorization successful! Transaction ID: ${response.data?.auth_net_transaction_id || 'N/A'}`;
|
this.success = `Preauthorization successful! Transaction ID: ${response.data?.auth_net_transaction_id || 'N/A'}`;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -513,6 +520,13 @@ export default defineComponent({
|
|||||||
|
|
||||||
const response = await axios.post(chargePath, chargePayload, { withCredentials: true, headers: authHeader() });
|
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)
|
// Status codes: 0 = APPROVED, 1 = DECLINED (based on backend TransactionStatus enum)
|
||||||
if (response.data && response.data.status === 0) { // 0 = APPROVED
|
if (response.data && response.data.status === 0) { // 0 = APPROVED
|
||||||
this.success = `Charge successful! Transaction ID: ${response.data.auth_net_transaction_id || 'N/A'}`;
|
this.success = `Charge successful! Transaction ID: ${response.data.auth_net_transaction_id || 'N/A'}`;
|
||||||
|
|||||||
Reference in New Issue
Block a user