diff --git a/changelog.txt b/changelog.txt index 4ea06d5753b..13f4ed780c8 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,8 @@ *** WooPayments Changelog *** += 6.4.2 - 2023-09-14 = +* Fix - Fix an error in the checkout when Afterpay is selected as payment method. + = 6.4.1 - 2023-09-06 = * Fix - checkout processing when fields are hidden via customizer * Fix - Potential fatal error when viewing WooCommerce home because we try to check if store has been fully onboarded but account service is not yet initialized. diff --git a/includes/class-wc-payment-gateway-wcpay.php b/includes/class-wc-payment-gateway-wcpay.php index 5f459e4c3a2..59f4d39527b 100644 --- a/includes/class-wc-payment-gateway-wcpay.php +++ b/includes/class-wc-payment-gateway-wcpay.php @@ -1128,6 +1128,9 @@ public function process_payment_for_order( $cart, $payment_information, $schedul $request->set_payment_methods( $payment_methods ); $request->set_cvc_confirmation( $payment_information->get_cvc_confirmation() ); + // Add specific payment method parameters to the request. + $this->modify_create_intent_parameters_when_processing_payment( $request, $payment_information, $order ); + // The below if-statement ensures the support for UPE payment methods. if ( $this->upe_needs_redirection( $payment_methods ) ) { $request->set_return_url( @@ -3599,4 +3602,19 @@ private function is_platform_payment_method( bool $is_using_saved_payment_method private function upe_needs_redirection( $payment_methods ) { return 1 === count( $payment_methods ) && 'card' !== $payment_methods[0]; } + + /** + * Modifies the create intent parameters when processing a payment. + * + * Currently used by child UPE_Split_Payment_Gateway to add required shipping information for Afterpay. + * + * @param Create_And_Confirm_Intention $request The request object for creating and confirming intention. + * @param Payment_Information $payment_information The payment information object. + * @param mixed $order The order object or data. + * + * @return void + */ + protected function modify_create_intent_parameters_when_processing_payment( Create_And_Confirm_Intention $request, Payment_Information $payment_information, $order ) { + // Do nothing. + } } diff --git a/includes/payment-methods/class-upe-payment-gateway.php b/includes/payment-methods/class-upe-payment-gateway.php index 8745cdefccf..305267c2786 100644 --- a/includes/payment-methods/class-upe-payment-gateway.php +++ b/includes/payment-methods/class-upe-payment-gateway.php @@ -45,7 +45,8 @@ use WCPay\Duplicate_Payment_Prevention_Service; use WP_User; use WC_Payments_Localization_Service; - +use WCPay\Payment_Information; +use WCPay\Core\Server\Request\Create_And_Confirm_Intention; /** * UPE Payment method extended from WCPay generic Gateway. diff --git a/includes/payment-methods/class-upe-split-payment-gateway.php b/includes/payment-methods/class-upe-split-payment-gateway.php index a8f77b4bd0b..dc5308fc829 100644 --- a/includes/payment-methods/class-upe-split-payment-gateway.php +++ b/includes/payment-methods/class-upe-split-payment-gateway.php @@ -28,7 +28,8 @@ use WCPay\Duplicate_Payment_Prevention_Service; use WP_User; use WC_Payments_Localization_Service; - +use WCPay\Payment_Information; +use WCPay\Core\Server\Request\Create_And_Confirm_Intention; /** @@ -529,4 +530,22 @@ public function get_payment_method() { public function get_stripe_id() { return $this->stripe_id; } + + + /** + * Modifies the create intent parameters when processing a payment. + * + * If the selected Stripe payment type is AFTERPAY, it updates the shipping data in the request. + * + * @param Create_And_Confirm_Intention $request The request object for creating and confirming intention. + * @param Payment_Information $payment_information The payment information object. + * @param mixed $order The order object or data. + * + * @return void + */ + protected function modify_create_intent_parameters_when_processing_payment( Create_And_Confirm_Intention $request, Payment_Information $payment_information, $order ) { + if ( Payment_Method::AFTERPAY === $this->get_selected_stripe_payment_type_id() ) { + $request->set_shipping( $this->get_shipping_data_from_order( $order ) ); + } + } } diff --git a/package-lock.json b/package-lock.json index 25a45ea4485..fcc0dc2f024 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "woocommerce-payments", - "version": "6.4.1", + "version": "6.4.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "woocommerce-payments", - "version": "6.4.1", + "version": "6.4.2", "hasInstallScript": true, "license": "GPL-3.0-or-later", "dependencies": { diff --git a/package.json b/package.json index 3e56b6f367b..f3c983d27ef 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "woocommerce-payments", - "version": "6.4.1", + "version": "6.4.2", "main": "webpack.config.js", "author": "Automattic", "license": "GPL-3.0-or-later", diff --git a/readme.txt b/readme.txt index 74cf3b8bde3..3cfeefbc70b 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: payment gateway, payment, apple pay, credit card, google pay, woocommerce Requires at least: 6.0 Tested up to: 6.2 Requires PHP: 7.3 -Stable tag: 6.4.1 +Stable tag: 6.4.2 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -94,6 +94,10 @@ Please note that our support for the checkout block is still experimental and th == Changelog == += 6.4.2 - 2023-09-14 = +* Fix - Fix an error in the checkout when Afterpay is selected as payment method. + + = 6.4.1 - 2023-09-06 = * Fix - checkout processing when fields are hidden via customizer * Fix - Potential fatal error when viewing WooCommerce home because we try to check if store has been fully onboarded but account service is not yet initialized. diff --git a/woocommerce-payments.php b/woocommerce-payments.php index 47198f4131a..07d9e9b01f7 100644 --- a/woocommerce-payments.php +++ b/woocommerce-payments.php @@ -12,7 +12,7 @@ * WC tested up to: 7.8.0 * Requires at least: 6.0 * Requires PHP: 7.3 - * Version: 6.4.1 + * Version: 6.4.2 * * @package WooCommerce\Payments */