Skip to content

Commit

Permalink
Register Expresss Checkout block only when enabled in the settings (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
gpressutto5 authored Oct 31, 2024
1 parent 8396b27 commit e1778b0
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
4 changes: 4 additions & 0 deletions changelog/fix-express-checkout-block-registering
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: fix

Register Expresss Checkout block only when enabled in the settings
20 changes: 11 additions & 9 deletions client/checkout/blocks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,17 @@ if ( getUPEConfig( 'isWooPayEnabled' ) ) {
}
}

if ( getUPEConfig( 'isTokenizedCartPrbEnabled' ) ) {
registerExpressPaymentMethod(
tokenizedCartPaymentRequestPaymentMethod( api )
);
} else if ( getUPEConfig( 'isExpressCheckoutElementEnabled' ) ) {
registerExpressPaymentMethod( expressCheckoutElementApplePay( api ) );
registerExpressPaymentMethod( expressCheckoutElementGooglePay( api ) );
} else {
registerExpressPaymentMethod( paymentRequestPaymentMethod( api ) );
if ( getUPEConfig( 'isPaymentRequestEnabled' ) ) {
if ( getUPEConfig( 'isTokenizedCartPrbEnabled' ) ) {
registerExpressPaymentMethod(
tokenizedCartPaymentRequestPaymentMethod( api )
);
} else if ( getUPEConfig( 'isExpressCheckoutElementEnabled' ) ) {
registerExpressPaymentMethod( expressCheckoutElementApplePay( api ) );
registerExpressPaymentMethod( expressCheckoutElementGooglePay( api ) );
} else {
registerExpressPaymentMethod( paymentRequestPaymentMethod( api ) );
}
}
window.addEventListener( 'load', () => {
enqueueFraudScripts( getUPEConfig( 'fraudServices' ) );
Expand Down
9 changes: 9 additions & 0 deletions includes/class-wc-payment-gateway-wcpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,15 @@ public function is_saved_cards_enabled() {
return 'yes' === $this->get_option( 'saved_cards' );
}

/**
* Checks if the setting to show the payment request buttons is enabled.
*
* @return bool Whether the setting to show the payment request buttons is enabled or not.
*/
public function is_payment_request_enabled() {
return 'yes' === $this->get_option( 'payment_request' );
}

/**
* Check if account is eligible for card present.
*
Expand Down
1 change: 1 addition & 0 deletions includes/class-wc-payments-checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ public function get_payment_fields_js_config() {
'isPreview' => is_preview(),
'isSavedCardsEnabled' => $this->gateway->is_saved_cards_enabled(),
'isExpressCheckoutElementEnabled' => WC_Payments_Features::is_stripe_ece_enabled(),
'isPaymentRequestEnabled' => $this->gateway->is_payment_request_enabled(),
'isTokenizedCartPrbEnabled' => WC_Payments_Features::is_tokenized_cart_prb_enabled(),
'isWooPayEnabled' => $this->woopay_util->should_enable_woopay( $this->gateway ) && $this->woopay_util->should_enable_woopay_on_cart_or_checkout(),
'isWoopayExpressCheckoutEnabled' => $this->woopay_util->is_woopay_express_checkout_enabled(),
Expand Down

0 comments on commit e1778b0

Please sign in to comment.