Skip to content

Commit

Permalink
Rollback button early validation and add support for Credit Card Gate…
Browse files Browse the repository at this point in the history
…way.
  • Loading branch information
pedrosilva-pt committed Jan 3, 2024
1 parent a375946 commit 282d1a7
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class CheckoutActionHandler {
try {
await validateCheckoutForm(this.config);
} catch (error) {
throw { type: 'form-validation-error' };
throw {type: 'form-validation-error'};
}

return actions.subscription.create({
Expand Down Expand Up @@ -49,12 +49,6 @@ class CheckoutActionHandler {
configuration() {
const spinner = this.spinner;
const createOrder = async (data, actions) => {
try {
await validateCheckoutForm(this.config);
} catch (error) {
throw { type: 'form-validation-error' };
}

const payer = payerData();
const bnCode = typeof this.config.bn_codes[this.config.context] !== 'undefined' ?
this.config.bn_codes[this.config.context] : '';
Expand Down Expand Up @@ -142,7 +136,7 @@ class CheckoutActionHandler {
console.error(err);
spinner.unblock();

if (err && (err.type === 'create-order-error' || err.type === 'form-validation-error')) {
if (err && (err.type === 'create-order-error')) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,6 @@ class CardFieldsRenderer {
.catch((error) => {
this.spinner.unblock();
console.error(error)

if (error.type === 'form-validation-error') {
return;
}

this.errorHandler.message(this.defaultConfig.hosted_fields.labels.fields_not_valid);
});
});
Expand Down
2 changes: 1 addition & 1 deletion modules/ppcp-button/src/Endpoint/CreateOrderEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public function handle_request(): bool {
if ( $this->early_validation_enabled
&& $this->form
&& '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 );
}
Expand Down

0 comments on commit 282d1a7

Please sign in to comment.