Send apple pay payment source

This commit is contained in:
Alex P. 2025-06-11 15:14:56 +03:00
parent 55b9f49eba
commit 0e815c819d
No known key found for this signature in database
GPG key ID: 54487A734A204D71

View file

@ -11,6 +11,7 @@ namespace WooCommerce\PayPalCommerce\Applepay;
use WC_Payment_Gateway;
use Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry;
use WooCommerce\PayPalCommerce\ApiClient\Factory\ExperienceContextBuilder;
use WooCommerce\PayPalCommerce\Applepay\Assets\ApplePayButton;
use WooCommerce\PayPalCommerce\Applepay\Assets\AppleProductStatus;
use WooCommerce\PayPalCommerce\Applepay\Assets\PropertiesDictionary;
@ -198,6 +199,31 @@ class ApplepayModule implements ServiceModule, ExtendingModule, ExecutableModule
}
);
add_filter(
'ppcp_create_order_request_body_data',
static function ( array $data, string $payment_method, array $request ) use ( $c ) : array {
if ( $payment_method !== ApplePayGateway::ID ) {
return $data;
}
$experience_context_builder = $c->get( 'wcgateway.builder.experience-context' );
assert( $experience_context_builder instanceof ExperienceContextBuilder );
$data['payment_source'] = array(
'apple_pay' => array(
'experience_context' => $experience_context_builder
->with_endpoint_return_urls()
->build()->to_array(),
),
);
return $data;
},
10,
3
);
return true;
}