Order payed in full event not triggered

Created on 9 February 2017, over 7 years ago
Updated 25 July 2023, 11 months ago

It seems that even though the transaction is correctly saved and the order gets completed successfully, the "order payed in full" event is not triggered.

The reason is that the transaction created is missing the currency_code property, leading to commerce_payment_order_balance() returning FALSE.

Sorry for not being able to file a patch right now but the correct code is found below:

// ...
if ($_POST['ResultCode'] == 0 && $_POST['StatusFlag'] == 'Success') {
    $payment = commerce_payment_method_instance_load('commerce_winbank_redirect|commerce_payment_commerce_winbank_redirect');
    $transaction = commerce_payment_transaction_new('commerce_winbank_redirect', $order_id);
    $transaction->currency_code = $payment['settings']['currency_code'];
    $transaction->amount = $order->commerce_order_total[LANGUAGE_NONE][0]['amount'];
    $transaction->payload[REQUEST_TIME] = $_POST;
    $transaction->status = COMMERCE_PAYMENT_STATUS_SUCCESS;
    $transaction->message = t('Payment was successful');
    commerce_payment_transaction_save($transaction);
    // ...
  }
πŸ› Bug report
Status

Closed: outdated

Version

1.0

Component

Code

Created by

πŸ‡¬πŸ‡·Greece vensires

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024