-
Notifications
You must be signed in to change notification settings - Fork 210
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
Add APM support for Subscriptions and tokens with split UPE with deferred intent #2883
Changes from all commits
bfa3f24
992ccec
e56c418
6333f2a
36fda59
744f4d6
c46f9e6
0d84171
80c0e81
580f399
5d92694
5f76377
7e0569d
9463060
6e06360
6911378
52a741d
b13c162
b99580b
d1f7541
9516976
d6690c9
e1e3926
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 |
---|---|---|
|
@@ -364,6 +364,14 @@ public function add_payment_request_order_meta( PaymentContext $context, Payment | |
// Strip "Stripe_" from the payment method name to get the payment method type. | ||
$payment_method_type = substr( $context->payment_method, strlen( $this->name ) + 1 ); | ||
$is_stripe_payment_method = isset( $main_gateway->payment_methods[ $payment_method_type ] ); | ||
|
||
/** | ||
* When using the block checkout and a saved token is being used, we need to set a flag | ||
* to indicate that deferred intent should be used. | ||
*/ | ||
if ( $is_stripe_payment_method && isset( $data['issavedtoken'] ) && $data['issavedtoken'] ) { | ||
$context->set_payment_data( array_merge( $data, [ 'wc-stripe-is-deferred-intent' => true ] ) ); | ||
} | ||
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. Using a saved payment token on the block checkout doesn't go via This change makes sure we set this flag early in the request to process the block checkout. |
||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -933,12 +933,12 @@ private function build_base_payment_intent_request_params( $payment_information | |
* @return bool True if a mandate must be shown and acknowledged by customer before deferred intent UPE payment can be processed, false otherwise. | ||
*/ | ||
public function is_mandate_data_required( $selected_payment_type ) { | ||
$gateway = $this->get_upe_gateway(); | ||
|
||
$is_stripe_link_enabled = 'card' === $selected_payment_type && in_array( 'link', $gateway->get_upe_enabled_payment_method_ids(), true ); | ||
$is_sepa_debit_payment = 'sepa_debit' === $selected_payment_type; | ||
if ( in_array( $selected_payment_type, [ 'sepa_debit', 'bancontact', 'ideal', 'sofort' ], true ) ) { | ||
return true; | ||
} | ||
|
||
return $is_stripe_link_enabled || $is_sepa_debit_payment; | ||
return 'card' === $selected_payment_type && in_array( 'link', $this->get_upe_gateway()->get_upe_enabled_payment_method_ids(), true ); | ||
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. Because Bancontact and iDEAL resolve to SEPA debit payment tokens, Stripe also requires that mandate data be set when attempting to use Bancontact and save it. |
||
} | ||
|
||
/** | ||
|
@@ -951,11 +951,12 @@ public function is_mandate_data_required( $selected_payment_type ) { | |
* @return array | ||
*/ | ||
public function create_and_confirm_setup_intent( $payment_information ) { | ||
$request = [ | ||
$request = [ | ||
'payment_method' => $payment_information['payment_method'], | ||
'payment_method_types' => [ $payment_information['selected_payment_type'] ], | ||
'customer' => $payment_information['customer'], | ||
'confirm' => 'true', | ||
'return_url' => $payment_information['return_url'], | ||
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. Now that Bancontact and iDEAL can be used for set up intents, we need to pass a return URL here. |
||
]; | ||
|
||
// SEPA setup intents require mandate data. | ||
|
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.
This change makes sure that when a subscription is in the cart, or if saving the method is allowed these terms are displayed to the user.