Skip to content

Commit cebe078

Browse files
authored
Merge branch 'develop' into refactor/data-massaging-for-ece-and-hk-based-addresses
2 parents 1e09cb8 + b81cadc commit cebe078

10 files changed

+525
-200
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: fix
3+
4+
fix: set the correct payment method title when processing the payment with wechat pay, multibanco, and others

includes/class-duplicates-detection-service.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
use WCPay\Payment_Methods\P24_Payment_Method;
2424
use WCPay\Payment_Methods\Sepa_Payment_Method;
2525
use WCPay\Payment_Methods\Grabpay_Payment_Method;
26-
use WCPay\Payment_Methods\Wechatpay_Payment_Method;
2726
use WCPay\PaymentMethods\Configs\Registry\PaymentMethodDefinitionRegistry;
2827

2928
/**
@@ -111,7 +110,6 @@ private function search_for_additional_payment_methods() {
111110
'clearpay' => Afterpay_Payment_Method::PAYMENT_METHOD_STRIPE_ID,
112111
'klarna' => Klarna_Payment_Method::PAYMENT_METHOD_STRIPE_ID,
113112
'grabpay' => Grabpay_Payment_Method::PAYMENT_METHOD_STRIPE_ID,
114-
'wechatpay' => Wechatpay_Payment_Method::PAYMENT_METHOD_STRIPE_ID,
115113
];
116114

117115
// Get all payment method definitions.

includes/class-wc-payment-gateway-wcpay.php

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
use WCPay\Payment_Methods\UPE_Payment_Method;
7070
use WCPay\Payment_Methods\Multibanco_Payment_Method;
7171
use WCPay\Payment_Methods\Grabpay_Payment_Method;
72-
use WCPay\Payment_Methods\Wechatpay_Payment_Method;
7372
use WCPay\PaymentMethods\Configs\Registry\PaymentMethodDefinitionRegistry;
7473

7574
/**
@@ -1777,6 +1776,34 @@ public function process_payment_for_order( $cart, $payment_information, $schedul
17771776

17781777
$this->maybe_add_customer_notification_note( $order, $processing );
17791778

1779+
// ensuring the payment method title is set before any early return paths to avoid incomplete order data.
1780+
if ( empty( $_POST['payment_request_type'] ) && empty( $_POST['express_payment_type'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
1781+
// Extract payment method details for setting the payment method title.
1782+
if ( $payment_needed ) {
1783+
$charge = $intent ? $intent->get_charge() : null;
1784+
$payment_method_details = $charge ? $charge->get_payment_method_details() : [];
1785+
// For payment intents, get payment method type from the intent itself, fallback to charge details.
1786+
$payment_method_type = $intent ? $intent->get_payment_method_type() : null;
1787+
if ( ! $payment_method_type && $payment_method_details ) {
1788+
$payment_method_type = $payment_method_details['type'] ?? null;
1789+
}
1790+
1791+
if ( 'card' === $payment_method_type && isset( $payment_method_details['card']['last4'] ) ) {
1792+
$order->add_meta_data( 'last4', $payment_method_details['card']['last4'], true );
1793+
if ( isset( $payment_method_details['card']['brand'] ) ) {
1794+
$order->add_meta_data( '_card_brand', $payment_method_details['card']['brand'], true );
1795+
}
1796+
$order->save_meta_data();
1797+
}
1798+
} else {
1799+
$payment_method_details = false;
1800+
$token = $payment_information->is_using_saved_payment_method() ? $payment_information->get_payment_token() : null;
1801+
$payment_method_type = $token ? $this->get_payment_method_type_for_setup_intent( $intent, $token ) : null;
1802+
}
1803+
1804+
$this->set_payment_method_title_for_order( $order, $payment_method_type, $payment_method_details );
1805+
}
1806+
17801807
if ( isset( $status ) && Intent_Status::REQUIRES_ACTION === $status && $this->is_changing_payment_method_for_subscription() ) {
17811808
// Because we're filtering woocommerce_subscriptions_update_payment_via_pay_shortcode, we need to manually set this delayed update all flag here.
17821809
if ( isset( $_POST['update_all_subscriptions_payment_method'] ) && wc_clean( wp_unslash( $_POST['update_all_subscriptions_payment_method'] ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
@@ -1797,27 +1824,6 @@ public function process_payment_for_order( $cart, $payment_information, $schedul
17971824
$cart->empty_cart();
17981825
}
17991826

1800-
if ( $payment_needed ) {
1801-
$charge = $intent ? $intent->get_charge() : null;
1802-
$payment_method_details = $charge ? $charge->get_payment_method_details() : [];
1803-
$payment_method_type = $payment_method_details ? $payment_method_details['type'] : null;
1804-
1805-
if ( 'card' === $payment_method_type && isset( $payment_method_details['card']['last4'] ) ) {
1806-
$order->add_meta_data( 'last4', $payment_method_details['card']['last4'], true );
1807-
if ( isset( $payment_method_details['card']['brand'] ) ) {
1808-
$order->add_meta_data( '_card_brand', $payment_method_details['card']['brand'], true );
1809-
}
1810-
$order->save_meta_data();
1811-
}
1812-
} else {
1813-
$payment_method_details = false;
1814-
$payment_method_type = $this->get_payment_method_type_for_setup_intent( $intent, $token );
1815-
}
1816-
1817-
if ( empty( $_POST['payment_request_type'] ) && empty( $_POST['express_payment_type'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
1818-
$this->set_payment_method_title_for_order( $order, $payment_method_type, $payment_method_details );
1819-
}
1820-
18211827
return [
18221828
'result' => 'success',
18231829
'redirect' => $this->get_return_url( $order ),
@@ -4106,7 +4112,6 @@ public function get_upe_available_payment_methods() {
41064112
$available_methods[] = Klarna_Payment_Method::PAYMENT_METHOD_STRIPE_ID;
41074113
$available_methods[] = Multibanco_Payment_Method::PAYMENT_METHOD_STRIPE_ID;
41084114
$available_methods[] = Grabpay_Payment_Method::PAYMENT_METHOD_STRIPE_ID;
4109-
$available_methods[] = Wechatpay_Payment_Method::PAYMENT_METHOD_STRIPE_ID;
41104115

41114116
// This gets all the registered payment method definitions. As new payment methods are converted from the legacy style, they need to be removed from the list above.
41124117
$payment_method_definitions = PaymentMethodDefinitionRegistry::instance()->get_all_payment_method_definitions();

includes/class-wc-payments.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
use WCPay\Payment_Methods\Sofort_Payment_Method;
2323
use WCPay\Payment_Methods\Ideal_Payment_Method;
2424
use WCPay\Payment_Methods\Eps_Payment_Method;
25-
use WCPay\Payment_Methods\Wechatpay_Payment_Method;
2625
use WCPay\Payment_Methods\UPE_Payment_Method;
2726
use WCPay\Payment_Methods\Multibanco_Payment_Method;
2827
use WCPay\WooPay_Tracker;
@@ -443,7 +442,6 @@ public static function init() {
443442
include_once __DIR__ . '/payment-methods/class-klarna-payment-method.php';
444443
include_once __DIR__ . '/payment-methods/class-multibanco-payment-method.php';
445444
include_once __DIR__ . '/payment-methods/class-grabpay-payment-method.php';
446-
include_once __DIR__ . '/payment-methods/class-wechatpay-payment-method.php';
447445
include_once __DIR__ . '/inline-script-payloads/class-woo-payments-payment-methods-config.php';
448446
include_once __DIR__ . '/express-checkout/class-wc-payments-express-checkout-button-helper.php';
449447
include_once __DIR__ . '/class-wc-payment-token-wcpay-sepa.php';
@@ -591,7 +589,6 @@ public static function init() {
591589
Klarna_Payment_Method::class,
592590
Multibanco_Payment_Method::class,
593591
Grabpay_Payment_Method::class,
594-
Wechatpay_Payment_Method::class,
595592
];
596593

597594
$payment_methods = [];

0 commit comments

Comments
 (0)