Skip to content

Commit

Permalink
Fix order placement with fixed address.
Browse files Browse the repository at this point in the history
  • Loading branch information
NickolasMalovanets committed Jul 30, 2024
1 parent 9350aff commit 25d7d07
Showing 1 changed file with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ define(
isVisible: ko.observable(true),
fastlanePaymentComponent: null,
error: $t('An error occurred while processing your payment. Please try again.'),
fastlanePaymentToken: null,
},

/**
Expand Down Expand Up @@ -167,8 +168,15 @@ define(
try {
this.updateQuoteBillingAddress(tokenResponse);
await this.sendGuestCustomerInfo();
const refreshResult = await boldFrontendClient.get('refresh');
const taxesResult = await boldFrontendClient.post('taxes');
await boldFrontendClient.get('refresh');
await boldFrontendClient.post('taxes');
if (this.fastlanePaymentToken) {
const orderPlacementResult = await boldFrontendClient.post('process_order');
if (orderPlacementResult.errors) {
return Promise.reject('An error occurred while processing your payment. Please try again.');
}
return;
}
if (fastlane.getType() === 'ppcp') {
const walletPayResult = await boldFrontendClient.post(
'wallet_pay/create_order',
Expand All @@ -184,23 +192,23 @@ define(
if (walletPayResult.errors) {
return Promise.reject('An error occurred while processing your payment. Please try again.');
}
tokenResponse.id = walletPayResult.data?.payment_data?.id;
this.fastlanePaymentToken = walletPayResult.data?.payment_data?.id;
}
if (fastlane.getType() === 'braintree') {
this.fastlanePaymentToken = tokenResponse.id;
}
const paymentPayload = {
'gateway_public_id': fastlane.getGatewayPublicId(),
'currency': quote.totals().quote_currency_code,
'amount': quote.totals().grand_total * 100,
'token': tokenResponse.id,
'token': this.fastlanePaymentToken,
};
if (fastlane.getType() === 'braintree') {
paymentPayload.type = 'fastlane';
}
const paymentResult = await boldFrontendClient.post(
'payments',
paymentPayload,
);
await boldFrontendClient.post('payments', paymentPayload,);
const orderPlacementResult = await boldFrontendClient.post('process_order');
if (refreshResult.errors || taxesResult.errors || paymentResult.errors || orderPlacementResult.errors) {
if (orderPlacementResult.errors) {
return Promise.reject('An error occurred while processing your payment. Please try again.');
}
} catch (e) {
Expand Down

0 comments on commit 25d7d07

Please sign in to comment.