I'm using Commerce datatrans module which originally supports only offsite payments. However I added extra functionality for recurring payment and it works well.
Only issue I have is that when method createPayment() I added is called by cron job and payment is made that order gets status "Completed".
For default types of orders (non-recurring ones) they have status "Fulfillment" so when all items are shipped order status can manually be changed to "Completed". I expected same thing with recurring orders.
In createPayment() function I added code I found on official documentation for that method:
$next_state = $capture ? 'completed' : 'authorization'; $payment->setState($next_state); $payment->setRemoteId($transaction["uppTransactionId"]); $payment->setExpiresTime(strtotime('+5 days')); $payment->save();
Not sure should I change order status from that method. But again some other code is changing it form "Draft" to "Completed".
So my question is why it's not changed to "Fulfillment" but to "Completed" as soon as payment is done?