Order Status by payment type

Hey Guys,

Another question for you here…

Is there a way to be able to change the order status based on the payment type selected?

Use Case:

2 payment types: Stripe & E Transfer - E Transfers are not instant & need to be verified - would like to set the status to “pending” for these, but “finished” for stripe / credit cards

From what I can tell a pre-hook fires too early as it’s before the default status is applied, which means if it set it here it will just be changed to the default finished status.

Post-hooks are too late (for my use case) as they fire after the email is sent and the status has already been set to finished.

Can I override the system setting within the payment options - configuration?

Hey @nclark,

Generally speaking the payment method handles switching to a different order status, which in most cases is setting it to finish. In your E-transfer gateway you can choose to set it to a different status.

Not sure how to do this. I reviewed the stripe gateway and see where / how it changes status’s, however when it changes an item to “finished” it sets it to the default finished status, and not actually “finished”.

So for example, if I changed the default finished status to “payment failed” - stripe would set the status to payment failed and not finished, even though “finished” is called out in your code.

 // stripe.class.php
 // log the finishing status 
        $this->order->addLog('Stripe Charge ID', $charge['id']);
        $this->order->addLog('Stripe Card', $charge['source']['brand'] . ' ' . $charge['source']['last4']);
        $this->order->setStatus('finished'); // actually sets to default "finished" status not the actual "finished" status.
        $this->order->save();
        return true;

$order->setStatus looks up the actual status to use from the system settings (which is news to me, thanks for asking that question :stuck_out_tongue: ), in this case simplecart.finished_order_status.

You’d adjust your e-transfer gateway to do $order->setStatus(‘awaiting_payment’), no need to change the stripe gateway.

1 Like

Another option for this (which I just thought of when Graeme asked the same question: https://twitter.com/g_leighfield/status/763774605857263616) might be to use a finished order hook. That can look at the order to check the payment method, and update the status accordingly.

Finished hooks seem to fire before the final “set to finished” - but I ended up doing as you said and configured it on my gateway and it seems to be working now.

Just took a bit to wrap my head around :slight_smile: