From 86acc00f853599cb2d32db36ae9e5e86b6ffc2d1 Mon Sep 17 00:00:00 2001 From: Emili Castells Guasch Date: Mon, 12 Aug 2024 17:19:40 +0200 Subject: [PATCH] Hide bancontact from PayPal buttons --- modules/ppcp-api-client/src/Endpoint/Orders.php | 5 +++-- .../src/BancontactGateway.php | 8 ++------ .../src/LocalAlternativePaymentMethodsModule.php | 11 +++++++++++ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/modules/ppcp-api-client/src/Endpoint/Orders.php b/modules/ppcp-api-client/src/Endpoint/Orders.php index 555404b21..82da943c3 100644 --- a/modules/ppcp-api-client/src/Endpoint/Orders.php +++ b/modules/ppcp-api-client/src/Endpoint/Orders.php @@ -73,8 +73,9 @@ class Orders { $url = trailingslashit( $this->host ) . 'v2/checkout/orders'; $default_headers = array( - 'Authorization' => 'Bearer ' . $bearer->token(), - 'Content-Type' => 'application/json', + 'Authorization' => 'Bearer ' . $bearer->token(), + 'Content-Type' => 'application/json', + 'PayPal-Request-Id' => uniqid( 'ppcp-', true ), ); $headers = array_merge( $default_headers, diff --git a/modules/ppcp-local-alternative-payment-methods/src/BancontactGateway.php b/modules/ppcp-local-alternative-payment-methods/src/BancontactGateway.php index e013fcfc1..e6d511ee0 100644 --- a/modules/ppcp-local-alternative-payment-methods/src/BancontactGateway.php +++ b/modules/ppcp-local-alternative-payment-methods/src/BancontactGateway.php @@ -129,15 +129,11 @@ class BancontactGateway extends WC_Payment_Gateway { 'application_context' => array( 'locale' => 'en-BE', 'return_url' => $this->get_return_url( $wc_order ), - 'cancel_url' => $this->get_return_url( $wc_order ), + 'cancel_url' => wc_get_checkout_url(), ), ); - $headers = array( - 'PayPal-Request-Id' => uniqid( 'ppcp-', true ), - ); - - $response = $this->orders_endpoint->create( $request_body, $headers ); + $response = $this->orders_endpoint->create( $request_body ); $body = json_decode( $response['body'] ); $payer_action = ''; diff --git a/modules/ppcp-local-alternative-payment-methods/src/LocalAlternativePaymentMethodsModule.php b/modules/ppcp-local-alternative-payment-methods/src/LocalAlternativePaymentMethodsModule.php index ab6956728..9450929bf 100644 --- a/modules/ppcp-local-alternative-payment-methods/src/LocalAlternativePaymentMethodsModule.php +++ b/modules/ppcp-local-alternative-payment-methods/src/LocalAlternativePaymentMethodsModule.php @@ -53,5 +53,16 @@ class LocalAlternativePaymentMethodsModule implements ModuleInterface { $payment_method_registry->register( $c->get( 'ppcp-local-apms.bancontact.payment-method' ) ); } ); + + add_filter( + 'woocommerce_paypal_payments_localized_script_data', + function ( array $data ) { + $default_disable_funding = $data['url_params']['disable-funding'] ?? ''; + $disable_funding = array_merge( array( 'bancontact' ), array_filter( explode( ',', $default_disable_funding ) ) ); + $data['url_params']['disable-funding'] = implode( ',', array_unique( $disable_funding ) ); + + return $data; + } + ); } }