Rollback button early validation and add support for Credit Card Gateway.

This commit is contained in:
Pedro Silva 2024-01-03 11:13:01 +00:00
parent a37594643a
commit 282d1a73e0
No known key found for this signature in database
GPG key ID: E2EE20C0669D24B3
3 changed files with 3 additions and 14 deletions

View file

@ -18,7 +18,7 @@ class CheckoutActionHandler {
try { try {
await validateCheckoutForm(this.config); await validateCheckoutForm(this.config);
} catch (error) { } catch (error) {
throw { type: 'form-validation-error' }; throw {type: 'form-validation-error'};
} }
return actions.subscription.create({ return actions.subscription.create({
@ -49,12 +49,6 @@ class CheckoutActionHandler {
configuration() { configuration() {
const spinner = this.spinner; const spinner = this.spinner;
const createOrder = async (data, actions) => { const createOrder = async (data, actions) => {
try {
await validateCheckoutForm(this.config);
} catch (error) {
throw { type: 'form-validation-error' };
}
const payer = payerData(); const payer = payerData();
const bnCode = typeof this.config.bn_codes[this.config.context] !== 'undefined' ? const bnCode = typeof this.config.bn_codes[this.config.context] !== 'undefined' ?
this.config.bn_codes[this.config.context] : ''; this.config.bn_codes[this.config.context] : '';
@ -142,7 +136,7 @@ class CheckoutActionHandler {
console.error(err); console.error(err);
spinner.unblock(); spinner.unblock();
if (err && (err.type === 'create-order-error' || err.type === 'form-validation-error')) { if (err && (err.type === 'create-order-error')) {
return; return;
} }

View file

@ -120,11 +120,6 @@ class CardFieldsRenderer {
.catch((error) => { .catch((error) => {
this.spinner.unblock(); this.spinner.unblock();
console.error(error) console.error(error)
if (error.type === 'form-validation-error') {
return;
}
this.errorHandler.message(this.defaultConfig.hosted_fields.labels.fields_not_valid); this.errorHandler.message(this.defaultConfig.hosted_fields.labels.fields_not_valid);
}); });
}); });

View file

@ -294,7 +294,7 @@ class CreateOrderEndpoint implements EndpointInterface {
if ( $this->early_validation_enabled if ( $this->early_validation_enabled
&& $this->form && $this->form
&& 'checkout' === $data['context'] && 'checkout' === $data['context']
&& in_array( $payment_method, array( PayPalGateway::ID, CardButtonGateway::ID ), true ) && in_array( $payment_method, array( PayPalGateway::ID, CardButtonGateway::ID, CreditCardGateway::ID ), true )
) { ) {
$this->validate_form( $this->form ); $this->validate_form( $this->form );
} }