enqueue and respect merchant option for disabling stripe express pay (https://github.com/woocommerce/woocommerce-blocks/pull/2920)
* enqueue and respect merchant option for disabling stripe express pay * don't even register express payment method if merchant has disabled it * add StripeServerData.allowPaymentRequest to typedef
This commit is contained in:
parent
de65c2ff8e
commit
e2b82561bd
|
@ -11,8 +11,15 @@ import {
|
||||||
*/
|
*/
|
||||||
import stripeCcPaymentMethod from './credit-card';
|
import stripeCcPaymentMethod from './credit-card';
|
||||||
import PaymentRequestPaymentMethod from './payment-request';
|
import PaymentRequestPaymentMethod from './payment-request';
|
||||||
|
import { getStripeServerData } from './stripe-utils';
|
||||||
|
|
||||||
|
// Register Stripe Credit Card.
|
||||||
registerPaymentMethod( ( Config ) => new Config( stripeCcPaymentMethod ) );
|
registerPaymentMethod( ( Config ) => new Config( stripeCcPaymentMethod ) );
|
||||||
|
|
||||||
|
// Register Stripe Payment Request (Apple/Chrome Pay) if enabled.
|
||||||
|
if ( getStripeServerData().allowPaymentRequest ) {
|
||||||
registerExpressPaymentMethod(
|
registerExpressPaymentMethod(
|
||||||
( Config ) => new Config( PaymentRequestPaymentMethod )
|
( Config ) => new Config( PaymentRequestPaymentMethod )
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -296,6 +296,8 @@
|
||||||
* @property {{[k:string]:CreditCardIcon}} icons Contains supported cc icons.
|
* @property {{[k:string]:CreditCardIcon}} icons Contains supported cc icons.
|
||||||
* @property {boolean} allowSavedCards Used to indicate whether saved cards
|
* @property {boolean} allowSavedCards Used to indicate whether saved cards
|
||||||
* can be used.
|
* can be used.
|
||||||
|
* @property {boolean} allowPaymentRequest True if merchant has enabled payment
|
||||||
|
* request (Chrome/Apple Pay).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -98,6 +98,7 @@ final class Stripe extends AbstractPaymentMethodType {
|
||||||
'inline_cc_form' => $this->get_inline_cc_form(),
|
'inline_cc_form' => $this->get_inline_cc_form(),
|
||||||
'icons' => $this->get_icons(),
|
'icons' => $this->get_icons(),
|
||||||
'allowSavedCards' => $this->get_allow_saved_cards(),
|
'allowSavedCards' => $this->get_allow_saved_cards(),
|
||||||
|
'allowPaymentRequest' => $this->get_allow_payment_request(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,6 +145,16 @@ final class Stripe extends AbstractPaymentMethodType {
|
||||||
return apply_filters( 'wc_stripe_allow_prepaid_card', true );
|
return apply_filters( 'wc_stripe_allow_prepaid_card', true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if store allows Payment Request buttons - e.g. Apple Pay / Chrome Pay.
|
||||||
|
*
|
||||||
|
* @return bool True if merchant has opted into payment request.
|
||||||
|
*/
|
||||||
|
private function get_allow_payment_request() {
|
||||||
|
$option = isset( $this->settings['payment_request'] ) ? $this->settings['payment_request'] : false;
|
||||||
|
return filter_var( $option, FILTER_VALIDATE_BOOLEAN );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the button type for the payment button.
|
* Return the button type for the payment button.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue