changes
This commit is contained in:
@@ -45,6 +45,22 @@ patch(PaymentForm.prototype, {
|
||||
this._setupCardFormatting(poyntContainer);
|
||||
this._setupTerminalToggle(poyntContainer);
|
||||
this._setupSurcharge(poyntContainer);
|
||||
this._prefillBillingAddress(poyntContainer);
|
||||
},
|
||||
|
||||
_prefillBillingAddress(container) {
|
||||
const billing = this.poyntFormData.billing_details;
|
||||
if (!billing || !billing.address) return;
|
||||
const addr = billing.address;
|
||||
const setVal = (id, val) => {
|
||||
const el = container.querySelector(id);
|
||||
if (el && val) el.value = val;
|
||||
};
|
||||
setVal('#poynt_billing_address', addr.line1);
|
||||
setVal('#poynt_billing_city', addr.city);
|
||||
setVal('#poynt_billing_state', addr.state);
|
||||
setVal('#poynt_billing_zip', addr.postal_code);
|
||||
setVal('#poynt_billing_country', addr.country);
|
||||
},
|
||||
|
||||
_detectCardBrand(number) {
|
||||
@@ -317,6 +333,36 @@ patch(PaymentForm.prototype, {
|
||||
return checked ? checked.value : 'other';
|
||||
},
|
||||
|
||||
_showProcessingOverlay(container) {
|
||||
const overlay = container.querySelector('.o_poynt_processing_overlay');
|
||||
if (overlay) {
|
||||
// Hide all form field sections
|
||||
Array.from(container.children).forEach(child => {
|
||||
if (!child.classList.contains('o_poynt_processing_overlay')) {
|
||||
child.style.display = 'none';
|
||||
}
|
||||
});
|
||||
overlay.style.display = 'block';
|
||||
}
|
||||
},
|
||||
|
||||
_hideProcessingOverlay(container) {
|
||||
const overlay = container.querySelector('.o_poynt_processing_overlay');
|
||||
if (overlay) {
|
||||
overlay.style.display = 'none';
|
||||
Array.from(container.children).forEach(child => {
|
||||
if (!child.classList.contains('o_poynt_processing_overlay')) {
|
||||
child.style.display = '';
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
_updateProcessingMessage(container, message) {
|
||||
const msgEl = container.querySelector('.o_poynt_processing_message');
|
||||
if (msgEl) msgEl.textContent = message;
|
||||
},
|
||||
|
||||
async _processCardPayment(processingValues, inlineForm) {
|
||||
const cardNumber = inlineForm.querySelector('#poynt_card_number').value.replace(/\D/g, '');
|
||||
const expiry = inlineForm.querySelector('#poynt_expiry').value;
|
||||
@@ -328,6 +374,13 @@ patch(PaymentForm.prototype, {
|
||||
|
||||
const [expMonth, expYear] = expiry.split('/').map(Number);
|
||||
|
||||
const formContainer = inlineForm.closest('.o_poynt_payment_form')
|
||||
|| inlineForm.querySelector('.o_poynt_payment_form')
|
||||
|| inlineForm;
|
||||
|
||||
// Show processing animation
|
||||
this._showProcessingOverlay(formContainer);
|
||||
|
||||
try {
|
||||
const result = await rpc('/payment/poynt/process_card', {
|
||||
reference: processingValues.reference,
|
||||
@@ -338,9 +391,15 @@ patch(PaymentForm.prototype, {
|
||||
cvv: cvv,
|
||||
cardholder_name: cardholder,
|
||||
card_type: cardType,
|
||||
billing_address: inlineForm.querySelector('#poynt_billing_address')?.value || '',
|
||||
billing_city: inlineForm.querySelector('#poynt_billing_city')?.value || '',
|
||||
billing_state: inlineForm.querySelector('#poynt_billing_state')?.value || '',
|
||||
billing_zip: inlineForm.querySelector('#poynt_billing_zip')?.value || '',
|
||||
billing_country: inlineForm.querySelector('#poynt_billing_country')?.value || '',
|
||||
});
|
||||
|
||||
if (result.error) {
|
||||
this._hideProcessingOverlay(formContainer);
|
||||
this._displayErrorDialog(
|
||||
_t("Payment Failed"),
|
||||
result.error,
|
||||
@@ -349,8 +408,10 @@ patch(PaymentForm.prototype, {
|
||||
return;
|
||||
}
|
||||
|
||||
this._updateProcessingMessage(formContainer, _t("Payment successful! Redirecting..."));
|
||||
window.location.href = processingValues.return_url;
|
||||
} catch (error) {
|
||||
this._hideProcessingOverlay(formContainer);
|
||||
this._displayErrorDialog(
|
||||
_t("Payment Processing Error"),
|
||||
error.message || _t("An unexpected error occurred."),
|
||||
|
||||
Reference in New Issue
Block a user