PaymentElement assumes next step should be 'complete'

Created on 27 March 2025, about 1 month ago

Problem/Motivation

It's not unreasonable to want to have steps at the end of the checkout that gather information from the customer that is useful but not critical to fulfilling their order. In these cases it makes sense for the order to be paid and placed part-way through the checkout, once only the critical steps have been completed, in case the customer fails to go through all later non-critical steps. For example, #3047103: Make it easier to use checkout with non-draft orders β†’ made a change in commerce core to make this easier.

The StripePaymentElement gateway redirects the checkout in its onReturn method. There may be a good reason of sorts for this, in order to avoid the payment step which isn't relevant when using this gateway. (although the default payment_process pane does nothing if the order is already paid, so I'm not really sure how necessary it is).

The problem is that the StripePaymentElement assumes that the next step is 'complete', blocking the possiblity of any other steps after payment but before complete.

Proposed resolution

Redirect to the first step after payment, rather than assuming that should be 'complete'.

Remaining tasks

User interface changes

None.

API changes

None.

Data model changes

None.

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom jonathanshaw Stroud, UK

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @jonathanshaw
  • Pipeline finished with Running
    about 1 month ago
    #458923
  • πŸ‡ΊπŸ‡ΈUnited States TomTech
  • πŸ‡ΊπŸ‡ΈUnited States TomTech

    @jonathanshaw, thanks again for the report and MR.

    The MR has been merged.

    A few things to note:

    1. It is necessary for the payment step to be bypassed.

    The nature of the PaymentProcess Pane is to be "visible" and create a payment. When that occurs, it will not succeed, an exception would be generated, and the customer redirected back to a previous step...leaving the checkout flow and order in an incongruent state, given the payment was actually successful.

    While it might seem that the PaymentProcess would be "invisible" if the order is paid, this only occurs if the payment is "complete". If the payment was only an authorization, (what Stripe calls "manual") the order would still have a balance, until the authorized payment is "captured".

    Additionally, if the payment was less than the total, it would also cause the PaymentProcess pane to be "visible". This can happen if the review page with the Stripe payment component was reached with a discount applied, and/or a specific tax rate in effect...but the payment is not completed until later. e.g. Payment started at 11:55 pm December 31st, with a 10% discount applied, and a 7% tax rate, but the customer completes the order at 12:05am an January 1st, when the discount has expired, and the tax rate has changed to 8%.

    2. It is possible that the customer completed the payment with Stripe, but the onReturn is NOT invoked. (This can happen when the customer's network connection drops, battery dies, etc...) In this case, the webhook necessarily handles creating the payment and placing the order. In the OOTB handling, the order will move the checkout to the complete step. If you are adding additional steps between payment and complete, be sure to consider this possibility.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024