-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Register only reusable payment methods when adding a payment method #4427
Changes from 4 commits
3a47448
41197d9
5975605
47f4e1b
a5e6b95
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Significance: patch | ||
Type: fix | ||
Comment: This is a minor fix to a larger PR that is forthcoming. | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -170,11 +170,24 @@ jQuery( function ( $ ) { | |
*/ | ||
const getSelectedGatewayPaymentMethod = () => { | ||
const gatewayCardId = getUPEConfig( 'gatewayId' ); | ||
const selectedGatewayId = $( | ||
'li.wc_payment_method input.input-radio:checked' | ||
).attr( 'id' ); | ||
let selectedGatewayId = null; | ||
|
||
if ( $( 'li.wc_payment_method' ).length ) { | ||
selectedGatewayId = $( | ||
'li.wc_payment_method input.input-radio:checked' | ||
).attr( 'id' ); | ||
} else if ( $( 'li.woocommerce-PaymentMethod' ).length ) { | ||
selectedGatewayId = $( | ||
'li.woocommerce-PaymentMethod input.input-radio:checked' | ||
).attr( 'id' ); | ||
} | ||
|
||
if ( 'payment_method_woocommerce_payments' === selectedGatewayId ) { | ||
selectedGatewayId = 'payment_method_woocommerce_payments_card'; | ||
} | ||
|
||
let selectedPaymentMethod = null; | ||
|
||
for ( const paymentMethodType in paymentMethodsConfig ) { | ||
if ( | ||
`payment_method_${ gatewayCardId }_${ paymentMethodType }` === | ||
|
@@ -422,7 +435,6 @@ jQuery( function ( $ ) { | |
useSetUpIntent | ||
); | ||
} | ||
mountUPEElement( useSetUpIntent ); | ||
} | ||
} | ||
|
||
|
@@ -743,15 +755,6 @@ jQuery( function ( $ ) { | |
|
||
// Handle the add payment method form for WooCommerce Payments. | ||
$( 'form#add_payment_method' ).on( 'submit', function () { | ||
if ( | ||
'woocommerce_payments' !== | ||
$( | ||
"#add_payment_method input:checked[name='payment_method']" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we removing this because in http://localhost:8082/my-account/add-payment-method/, it will no longer be only "Credit Card/debit card"? Do you know why we needed to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yep.
I don't exactly 🤔. |
||
).val() | ||
) { | ||
return; | ||
} | ||
|
||
if ( ! $( '#wcpay-setup-intent' ).val() ) { | ||
const paymentMethodType = getSelectedGatewayPaymentMethod(); | ||
const paymentIntentId = | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -491,15 +491,27 @@ public static function add_plugin_links( $links ) { | |
* @return array The list of payment gateways that will be available, including WooCommerce Payments' Gateway class. | ||
*/ | ||
public static function register_gateway( $gateways ) { | ||
$gateways[] = self::$legacy_card_gateway; | ||
$gateways[] = self::$legacy_card_gateway; | ||
$reusable_methods[] = self::$legacy_card_gateway; | ||
|
||
if ( WC_Payments_Features::is_upe_enabled() ) { | ||
foreach ( self::$card_gateway->get_payment_method_ids_enabled_at_checkout() as $payment_method_id ) { | ||
if ( 'card' === $payment_method_id ) { | ||
continue; | ||
} | ||
$upe_gateway = self::get_payment_gateway_by_id( $payment_method_id ); | ||
$gateways[] = $upe_gateway; | ||
$upe_gateway = self::get_payment_gateway_by_id( $payment_method_id ); | ||
$upe_payment_method = self::get_payment_method_by_id( $payment_method_id ); | ||
|
||
if ( $upe_payment_method->is_reusable() ) { | ||
$reusable_methods[] = $upe_gateway; | ||
} | ||
|
||
$gateways[] = $upe_gateway; | ||
|
||
} | ||
|
||
if ( is_add_payment_method_page() ) { | ||
return $reusable_methods; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it makes sense that http://localhost:8082/my-account/add-payment-method/ only display payment methods that are saved, but not every single payment method we support. 👍 |
||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see,
'li.woocommerce-PaymentMethod'
is used inside http://localhost:8082/my-account/add-payment-method/. I was trying to look for this on the http://localhost:8082/checkout/ but I can't find it.I wonder if it's worth adding a comment here so we don't accidentally remove it in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! This was a head-scratcher for me as well. Comment added.