According to meeting with Maksuturva today. It's quite common that you might get pmtq_returncode as 00 for cases where consumer is in bank and haven't returned back yet.

That means that we shouldn't remove scheduled job for payment status check when getting pmtq_returncode as value 00.

Comments

juhaniemi’s picture

I can confirm this and run into this problem on a site using this module (I temporarily commented out the job removing)

Should we remove the removing of job_scheduler entirely, or set some expiry timestamp, and after expiration the job scheduler is removed?

imiksu’s picture

To deal with this, we could have an evaluation that if the job has been created more than 30mins ago, it can be removed. Otherwise just wait for next run.

imiksu’s picture

And maybe an extra check for how many times is was previously failed?

Maybe something like:

    // When transaction status is failed
    case '01':
    case '00':
      $transaction->data['failed_count']++;
      if ($transaction->data['failed_count'] > 5 && $transaction->created+30*60 > time()) {
        $transaction->status = COMMERCE_PAYMENT_STATUS_FAILURE;
        JobScheduler::get('commerce_maksuturva_check_payments')->remove($job);
      }
    break;

And add extra condition on failed_count when doing conditional $transaction save.

juhaniemi’s picture

Status: Active » Needs work

Looks good. A tested patch welcome. :-)