Skip to content
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 split UPE APMs (eg GiroPay) with deferred intent for Block Checkouts #2820

Merged

Conversation

james-allan
Copy link
Contributor

Fixes #2790

Changes proposed in this Pull Request:

This PR adds support for all APMs (eg GiroPay) with split UPE and deferred intents.

Screenshot 2024-01-05 at 12 26 11 pm

To achieve this I had to do 2 main things:

  1. Turn all our UPE payment method classes into WC_Payment_Gateways. This is required so that all our UPE methods get returned by get_available_payment_gateways() and are registrable as a block checkout payment method with registerPaymentMethod().
  2. Making sure that if you select a APM like GiroPay, you are redirected to the URL returned by Stripe in the intent response. This enables the customer to complete the payment at their bank or which ever page is specified by Stripe in the payment intent.

Testing instructions

  1. You will need a Stripe account with these APMs enabled.
  2. Set your store currency to Euros.
  3. Go to WooCommerce > Settings > Payments > Stripe and make sure you have all the APMs enabled.
  4. Checkout this branch, add a product to your cart and go to the Block checkout page.
  5. Note that all the APMs are now shown.
  6. Use each payment method type to make both successful and failed payments.
    • Successful payments
      • Giropay
      • EPS
      • Bancontact
      • iDEAL
      • SEPA (AT611904300234573201) *
      • Przelewy24
    • Failed payments
      • Giropay
      • EPS
      • Bancontact
      • iDEAL
      • SEPA (AT861904300235473202) *
      • Przelewy24
  7. After each test make sure:
    1. The order is created while offsite and has a pending status
    2. The order is set to processing or failed when returned to the store
    3. The payment is recorded in your Stripe dashboard appropriately.

Important

* You will need to test SEPA with webhooks enabled as the final status transition (processing or failure) is handled via webhook.


  • Covered with tests (or have a good reason not to test in description ☝️)
  • Added changelog entry in both changelog.txt and readme.txt (or does not apply)
  • Tested on mobile (or does not apply)

Post merge

@james-allan
Copy link
Contributor Author

james-allan commented Jan 5, 2024

Note that the changes on this PR go some way to laying the foundation for APMs on the shortcode checkout too. However none of them appear to work correctly.

eg
Screenshot 2024-01-05 at 2 55 36 pm

I want to take a look into that to see if there's a simple thing I'm missing that will make them work, or whether it will need to be a larger set of changes that should be handled by a separate PR.

@@ -30,7 +30,7 @@ abstract class WC_Stripe_UPE_Payment_Method {
*
* @var string
*/
protected $title;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that when I changed the WC_Stripe_UPE_Payment_Method class to extend WC_Payment_Gateway I had to make all these properties public to be consistant with that class.

@james-allan james-allan added the status: on hold The issue is currently not prioritized. label Jan 8, 2024
@james-allan james-allan added pr: needs review and removed pr: in progress status: on hold The issue is currently not prioritized. labels Jan 9, 2024
@wjrosa
Copy link
Contributor

wjrosa commented Jan 9, 2024

It is good to mention that the Stripe account needs to be configured for an EU country here (took me some minutes to find out).

Copy link
Contributor

@wjrosa wjrosa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested all the cases and LGTM! Left a (possible) minor comment

// If the payment intent requires action, respond with the pi and client secret so it can confirmed on checkout.
if ( 'requires_action' === $payment_intent->status ) {
// If the payment intent requires action, respond with redirect URL or the pi and client secret so it can confirmed on checkout.
if ( 'requires_action' === $payment_intent->status || 'requires_confirmation' === $payment_intent->status ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @james-allan I'm curious if you remember what this change was needed for? Is there a specific gateway that has 'requires_confirmation' as the payment intent status after it has already been confirmed inside create_and_confirm_payment_intent()?

I had to do somethign similar to this change in my PR for Boleto and Oxxo but I'm wondering if there's other gateways that need this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I was working on this PR I needed to change this section so payment methods that need to redirect the user offsite respond to client with the correct redirect URL. Eg this change:

$redirect = $payment_intent->next_action->redirect_to_url->url;

When I was looking into how WooPayments handled this I noticed they had this additional status. I don't recall ever confirming if I received a payment intent status with requires_confirmation though.

You needed it for Boleto and Oxxo though?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed you're changes in #2823.

I guess whichever one we merge first, we need to condense what that logic needs to look like.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ive consolidated that logic in 259ab86

@james-allan james-allan force-pushed the add/deferred-intent-split-apms-block-checkout branch from ef06684 to b60906f Compare January 16, 2024 05:25
@james-allan james-allan merged commit a7f2a5a into add/deferred-intent Jan 18, 2024
64 checks passed
@james-allan james-allan deleted the add/deferred-intent-split-apms-block-checkout branch January 18, 2024 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants