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

Split PE - Add WooCommerce Pre-Order support for SEPA, iDEAL, Bancontact, Sofort purchases #2933

Merged
merged 13 commits into from
Feb 27, 2024

Conversation

james-allan
Copy link
Contributor

@james-allan james-allan commented Feb 23, 2024

Closes #2780

Changes proposed in this Pull Request:

This PR fixes a number of issues I encountered when adding APM support for pre-orders.

  1. APMs that support pre orders, iDEAL, Sofort, Bancontact, and SEPA weren't being displayed as options on the checkout.
  2. Using those APMs, I noticed 2 follow up issues:
    1. The save payment method option was being shown, despite it being required when purhcasing pre-order products that are charged "upon release" (at a later time).
    2. The order was automatically transitioning to processing rather than 'pre-ordered'. *

This PR fixes all those issues.

Note

* This was partly fixed in #2911, however I was still experiencing that issue because is_pre_order wasn't being set to true here. I suspect it was because the original logic (maybe_process_pre_orders()) checks if the order already has a saved payment method on it, I suspect it might have had a token saved earlier and that was leading the order to be processed.

Testing instructions

Prerequisites

  • Install WooCommerce Pre-orders - you can get the lates from your woo.com downloads page (https://woo.com/my-account/downloads/).
  • UPE enabled in the Advanced Stripe plugin settings.
  • A Stripe account with access to Bancontact, SEPA, iDEAL and Sofort and enabled in the Stripe plugin settings.

⚠️ Sofort cannot be enabled via the UI anymore so you can enable it running the following code snippet.

$settings = get_option( 'woocommerce_stripe_settings' );
if ( ! in_array( 'sofort', $settings['upe_checkout_experience_accepted_payments'] ) ) {
    $settings['upe_checkout_experience_accepted_payments'][] = 'sofort';
}
update_option( 'woocommerce_stripe_settings', $settings );

Pre Order charged upon release

  1. Create a new product with any price (not free).
  2. In the product settings, enter a pre-order release date in the "Pre orders" tab.
  3. Set the product to charge "upon release".

Screenshot 2024-02-23 at 4 24 50 pm

  1. Add that preorder product to your cart.
  2. Go to the checkout page and on add/deferred-intent note 2 things:
    1. All the APMs (Bancontact, SEPA, iDEAL, Sofort) aren't shown.
    2. If you select the card payment method, you should see the option to Save the payment method.
Screenshot 2024-02-23 at 4 34 08 pm Screenshot 2024-02-23 at 4 33 41 pm
  1. Checkout this branch (issue/2780) and all available APMs should be listed.
  2. All APMs shouldn't show the option to save, it's being forced on.
Screenshot 2024-02-23 at 4 55 20 pm Screenshot 2024-02-23 at 4 54 47 pm
  1. Purchase the product using any or all APMs
  2. Go to the Admin orders list table and you should have orders with pre-ordered statuses.

Screenshot 2024-02-23 at 5 24 01 pm

  1. Go to the WooCommerce > Pre-orders table.
  2. Go to the Actions tab (at the top) **> Complete.
  3. Choose your product and complete the pre-orders.

Screenshot 2024-02-23 at 5 26 07 pm

  1. Once that has finished return to the Orders table and those pre-orders should now be on-hold.
  2. Wait a minute for Stripe to process those SEPA payments and for the webhooks to be processed and all orders should eventually go to processing or completed.
  3. Check your Stripe payments in the dashboard and confirm that the payments are processed.

Screenshot 2024-02-23 at 5 29 45 pm

Pre Order charged upfront

  1. Create a new product with any price (not free).
  2. In the product settings, enter a pre-order release date in the "Pre orders" tab.
  3. Set the product to charge "upon release".

Screenshot 2024-02-23 at 5 40 23 pm

  1. Add that preorder product to your cart.
  2. Go to the checkout page and note 3 things:
    1. All the APMs (Bancontact, SEPA, iDEAL, Sofort) are shown.
    2. If you select a payment method, you should see the option to Save the payment method. Charging upfront means we don't require a saved token so it's optional just like standard purchases.
  3. Purchase the product using any or all APMs
  4. Go to the Admin orders list table and you should have orders with pre-ordered statuses.

Screenshot 2024-02-23 at 6 12 09 pm

  1. Check your Stripe payments dashboard and confirm that the payments have been processed. Remember these are charged upfront so will be paid before the pre-order is complete.

Screenshot 2024-02-23 at 6 13 13 pm

  1. Once again, go to the WooCommerce > Pre-orders table.
  2. Go to the Actions tab (at the top) **> Complete.
  3. Choose your upfront product and complete the pre-orders.
  4. Review the order list table and payments in Stripe and confirm all orders are now processing and there was no duplicate charge.
Screenshot 2024-02-23 at 6 15 06 pm
Screenshot 2024-02-23 at 6 16 29 pm

  • 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 james-allan marked this pull request as ready for review February 23, 2024 09:06
@james-allan james-allan requested review from a team and wjrosa and removed request for a team February 23, 2024 09:06
return;
}

self::$has_attached_pre_order_integration_hooks = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

If there are any possibility for this to fail, I would move the filter inclusion above this (so we can be sure the hook was attached).

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 think the risk is fairly low for this but happy to change the order of things here. I've changed it in: c643fa3

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.

Looking good! Worked as expected:

Screenshot 2024-02-26 at 18 54 32
Screenshot 2024-02-26 at 19 10 56
Screenshot 2024-02-26 at 19 11 01

@james-allan james-allan merged commit 9ea38d0 into add/deferred-intent Feb 27, 2024
32 checks passed
@james-allan james-allan deleted the issue/2780 branch February 27, 2024 00:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants