Skip to content

Commit

Permalink
Minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
wjrosa committed Feb 26, 2025
1 parent 49851d3 commit e7d8eec
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
25 changes: 16 additions & 9 deletions includes/class-wc-stripe-blocks-support.php
Original file line number Diff line number Diff line change
Expand Up @@ -515,15 +515,22 @@ public function add_stripe_intents( PaymentContext $context, PaymentResult &$res
* @param string $payment_request_type The payment request type used for payment.
*/
private function add_order_meta( \WC_Order $order, $payment_request_type ) {
$payment_method_suffix = WC_Stripe_Express_Checkout_Helper::get_payment_method_title_suffix();
if ( 'apple_pay' === $payment_request_type ) {
$order->set_payment_method_title( WC_Stripe_Payment_Methods::APPLE_PAY_LABEL . $payment_method_suffix );
$order->save();
} elseif ( 'google_pay' === $payment_request_type ) {
$order->set_payment_method_title( WC_Stripe_Payment_Methods::GOOGLE_PAY_LABEL . $payment_method_suffix );
$order->save();
} elseif ( 'payment_request_api' === $payment_request_type ) {
$order->set_payment_method_title( 'Payment Request (Stripe)' );
$payment_method_title = '';
switch ( $payment_request_type ) {
case 'apple_pay':
$payment_method_title = WC_Stripe_Payment_Methods::APPLE_PAY_LABEL;
break;
case 'google_pay':
$payment_method_title = WC_Stripe_Payment_Methods::GOOGLE_PAY_LABEL;
break;
case 'payment_request_api':
$payment_method_title = 'Payment Request';
break;
}

if ( $payment_method_title ) {
$payment_method_suffix = WC_Stripe_Express_Checkout_Helper::get_payment_method_title_suffix();
$order->set_payment_method_title( $payment_method_title . $payment_method_suffix );
$order->save();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,14 +426,9 @@ public function filter_gateway_title( $title, $id ) {

$method_title = $theorder->get_payment_method_title();

$suffix = apply_filters( 'wc_stripe_payment_request_payment_method_title_suffix', 'Stripe' );

if ( ! empty( $suffix ) ) {
$suffix = " ($suffix)";
}

if ( 'stripe' === $id && ! empty( $method_title ) ) {
$express_method_titles = WC_Stripe_Express_Checkout_Helper::get_payment_method_titles();
$express_method_titles = WC_Stripe_Payment_Methods::METHODS_LABELS;
$suffix = WC_Stripe_Express_Checkout_Helper::get_payment_method_title_suffix();
array_walk(
$express_method_titles,
function( &$value, $key ) use ( $suffix ) {
Expand Down

0 comments on commit e7d8eec

Please sign in to comment.