Fix AXO Ryan flow submission.

This commit is contained in:
Pedro Silva 2024-04-17 10:14:27 +01:00
parent 80f8edb594
commit 0fd27144ae
No known key found for this signature in database
GPG key ID: E2EE20C0669D24B3
2 changed files with 16 additions and 4 deletions

View file

@ -82,7 +82,7 @@ class AxoManager {
registerEventHandlers() {
jQuery(document).on('change', 'input[name=payment_method]', (ev) => {
this.$(document).on('change', 'input[name=payment_method]', (ev) => {
const map = {
'ppcp-axo-gateway': 'card',
'ppcp-gateway': 'paypal',
@ -598,7 +598,7 @@ class AxoManager {
if (this.data.card) { // Ryan flow
log('Ryan flow.');
jQuery('#ship-to-different-address-checkbox').prop('checked', 'checked');
this.$('#ship-to-different-address-checkbox').prop('checked', 'checked');
let data = {};
this.billingView.toSubmitData(data);
@ -684,6 +684,18 @@ class AxoManager {
})
.then(response => response.json())
.then(responseData => {
if (responseData.result === 'failure') {
if (responseData.messages) {
const $notices = this.$('.woocommerce-notices-wrapper').eq(0);
$notices.html(responseData.messages);
this.$('html, body').animate({
scrollTop: $notices.offset().top
}, 500);
}
console.error('Failure:', responseData);
enable(submitContainerSelector);
return;
}
if (responseData.redirect) {
window.location.href = responseData.redirect;
}

View file

@ -95,8 +95,8 @@ class CardView {
const name = this.group.dataValue('name');
const { firstName, lastName } = this.splitName(name);
data['firstName'] = firstName;
data['lastName'] = lastName;
data['billing_first_name'] = firstName;
data['billing_last_name'] = lastName ? lastName : firstName;
return this.group.toSubmitData(data);
}