0

I'm using Commerce Recurring Framework latest version (8.x-1.0-beta5) with Commerce Datatrans (also latest version, 8.x-1.0-beta1). When first payment happens (customer gets redirected to Datatrans, does the payment and gets redirected back to site) everything works fine.

But since it's recurring payment when user account should be charged again (after some time, from cron job) I get following error:

The website encountered an unexpected error. Please try again later. Error: Call to undefined method Drupal\commerce_datatrans\Plugin\Commerce\PaymentGateway\Datatrans::createPayment() in Drupal\commerce_recurring\RecurringOrderManager->closeOrder() (line 157 of modules/contrib/commerce_recurring/src/RecurringOrderManager.php).

Stack trace shows:

#0 /var/www/html/drupal/web/modules/contrib/commerce_recurring/src/Plugin/AdvancedQueue/JobType/RecurringOrderClose.php(32): Drupal\commerce_recurring\RecurringOrderManager->closeOrder(Object(Drupal\commerce_order\Entity\Order))
#1 /var/www/html/drupal/web/modules/contrib/advancedqueue/src/Processor.php(95): Drupal\commerce_recurring\Plugin\AdvancedQueue\JobType\RecurringOrderClose->process(Object(Drupal\advancedqueue\Job))
#2 /var/www/html/drupal/web/modules/contrib/advancedqueue/src/Processor.php(75): Drupal\advancedqueue\Processor->processJob(Object(Drupal\advancedqueue\Job), Object(Drupal\advancedqueue\Entity\Queue))
#3 /var/www/html/drupal/web/modules/contrib/advancedqueue/advancedqueue.module(19): Drupal\advancedqueue\Processor->processQueue(Object(Drupal\advancedqueue\Entity\Queue))
#4 [internal function]: advancedqueue_cron()
#5 /var/www/html/drupal/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(392): call_user_func_array('advancedqueue_c...', Array)
#6 /var/www/html/drupal/web/core/lib/Drupal/Core/Cron.php(236): Drupal\Core\Extension\ModuleHandler->invoke('advancedqueue', 'cron')
#7 /var/www/html/drupal/web/core/lib/Drupal/Core/Cron.php(134): Drupal\Core\Cron->invokeCronHandlers()
#8 /var/www/html/drupal/web/core/lib/Drupal/Core/ProxyClass/Cron.php(75): Drupal\Core\Cron->run()
#9 /var/www/html/drupal/web/core/modules/automated_cron/src/EventSubscriber/AutomatedCron.php(65): Drupal\Core\ProxyClass\Cron->run()
#10 /var/www/html/drupal/web/modules/contrib/devel/webprofiler/src/EventDispatcher/TraceableEventDispatcher.php(76): Drupal\automated_cron\EventSubscriber\AutomatedCron->onTerminate(Object(Symfony\Component\HttpKernel\Event\PostResponseEvent), 'kernel.terminat...', Object(Drupal\webprofiler\EventDispatcher\TraceableEventDispatcher))
#11 /var/www/html/drupal/vendor/symfony/http-kernel/HttpKernel.php(88): Drupal\webprofiler\EventDispatcher\TraceableEventDispatcher->dispatch('kernel.terminat...', Object(Symfony\Component\HttpKernel\Event\PostResponseEvent))
#12 /var/www/html/drupal/vendor/stack/builder/src/Stack/StackedHttpKernel.php(32): Symfony\Component\HttpKernel\HttpKernel->terminate(Object(Symfony\Component\HttpFoundation\Request), Object(Symfony\Component\HttpFoundation\Response))
#13 /var/www/html/drupal/web/core/lib/Drupal/Core/DrupalKernel.php(686): Stack\StackedHttpKernel->terminate(Object(Symfony\Component\HttpFoundation\Request), Object(Symfony\Component\HttpFoundation\Response))
#14 /var/www/html/drupal/web/index.php(22): Drupal\Core\DrupalKernel->terminate(Object(Symfony\Component\HttpFoundation\Request), Object(Symfony\Component\HttpFoundation\Response))
#15 {main}

Simply put createPayment() method doesn't not exist at Datatrans class?!? I assume that because Datatrans is not maintained regularry it get outdated, even I have the latest varsion. But again, I used compser for installing - it should take care of compatibilities, right?

I also downloaded other Datatrans payment module - "Payment Datatrans" and searched it's code for same createPayment() method, but didn't find it?!?

Then I downloaded the oldest version of Commerce Recurring module and it also has the same call, which btw looks like:

// The createPayment() call might throw a decline exception, which is
// supposed to be handled by the caller, to allow for dunning.
$payment_gateway_plugin->createPayment($payment);

So I'm really stuck here - what module is "guilty" for this error? Recurring Payment for calling unexsiting method or Commerce Datatrans for not having it? How to solve this problem?

1 Answer 1

1

Module is simply not supporting recurring payment (yet). It is kinda prepared for it (stores alias returned from payment service), but main functionality of making API call is missing. I created missing code on my own and it can be found here:

https://www.drupal.org/project/commerce_datatrans/issues/3168477#comment-13823549

To repeat - it's not official and you can use it on your own risk.

Your Answer

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

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