1

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?

1 Answer 1

0

So my question is why it's not changed to "Fulfillment" but to "Completed" as soon as payment is done?

Because you're setting it to completed, the code you found is just an example.

For your case, it needs to be:

$next_state = $capture ? 'fulfillment' : 'authorization';
2
  • Yes, makes sense and I already tried that, but even if I change the row like that order state still becomes "Completed". And state I'm setting here is for payment, not for order directly if I understood well.
    – MilanG
    Sep 25, 2020 at 8:47
  • 1
    Ok figured out that for every order type I can change workflow. There are 4 default ones and one added by recurring module called "Recurring". Now I change workflow for recurring order type from "Recurring" to "Fulfillment" . That did the trick, but I'm not sure that I didn't mess out something else.
    – MilanG
    Sep 25, 2020 at 14:03

Your Answer

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

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