mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-04 08:47:23 +08:00
Rollback button early validation and add support for Credit Card Gateway.
This commit is contained in:
parent
a37594643a
commit
282d1a73e0
3 changed files with 3 additions and 14 deletions
|
@ -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({
|
||||
|
@ -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] : '';
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -294,7 +294,7 @@ class CreateOrderEndpoint implements EndpointInterface {
|
|||
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 );
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue