I am Writing a Payment Gateway(Onsite) Plugin For Commerce 2, I am Stuck with Checkout Flow Step Transitions.

Let Me Explain: I am extending the OnsitePaymentGatewayBase and in the createPayment() Method I am setting the payment states to 'pending' [if the payment gateway accepted the request]and the payment state is setting well(no issues with payment state), Since My Payment Gateway is Async I need to implement onNotify() to change the payment state to 'completed'.

My Issue: Since Payment Gateway is Async(payment notification will be sent after a day) My order Sates also be needed to be in 'Pending' or something similar states but when I use default checkout flow I am getting the order completed even before the notification is processed. means after I checkout the order state is 'completed',

What I want: I want the order state to pending or review ..etc even after the checkout. only after the processing of notification the order state to be 'completed'

Or Simply: How can I set Order state to Pending or Review or darft..etc and Not 'completed' Only after receiving the Notification from Gateway, I have to set order state to completed

Github LINK


1 Answer 1


Unfortunately, the "Default" order workflow for Commerce 2.x is fairly naive. It only has states for Draft (i.e. shopping carts), Completed (i.e. any placed order), and Canceled. If you need more states, you'll need to supply an alternate workflow. Core ships with a "Default, with validation" workflow you can set for your order type that includes a "Validation" step you could make use of instead.

Generally speaking, it's likely your payment gateway module shouldn't be controlling the actual order state transition. It can and should update the payment transition, and then a separate module specific to your site can be responsible for defining exactly what you want your workflow to be and automating the transition based on the order paid event (cf. OrderEvents::ORDER_PAID).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.