Hide bancontact from PayPal buttons

This commit is contained in:
Emili Castells Guasch 2024-08-12 17:19:40 +02:00
parent 1628f86d4c
commit 86acc00f85
3 changed files with 16 additions and 8 deletions

View file

@ -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,

View file

@ -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 = '';

View file

@ -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;
}
);
}
}