Warning: Undefined array key "payment_process" in Drupal\commerce_barion_payment\Plugin\Commerce\PaymentGateway\BarionPaymentGateway->preparePayment()

Created on 26 May 2025, 13 days ago

Problem/Motivation

    /** @var \Drupal\commerce_checkout\Entity\CheckoutFlowInterface $checkout_flow */
    $checkout_flow = $order->get('checkout_flow')->entity;
    $capture = $checkout_flow->get('configuration')['panes']['payment_process']['capture'];
    if ($capture) {
      $prepare_payment->PaymentType = PaymentType::Immediate;
    }
    else {
      $prepare_payment->PaymentType = PaymentType::Reservation;
      $prepare_payment->ReservationPeriod = $this->configuration['reservation_period'] ?: '0.00:30:00';
    }

The code above introduced in ✨ Support "authorize only" mode Fixed does not seem to work as with the Default checkout flow there's no 'payment_process' in the pane settings

This means every payment will be a PaymentType::Reservation now and the following things are logged:

Warning: Undefined array key "payment_process" in Drupal\commerce_barion_payment\Plugin\Commerce\PaymentGateway\BarionPaymentGateway->preparePayment() (line 425 of modules/contrib/commerce_barion_payment/src/Plugin/Commerce/PaymentGateway/BarionPaymentGateway.php).
Drupal\commerce_barion_payment\Plugin\Commerce\PaymentGateway\BarionPaymentGateway->preparePayment(Object, 'https://drupal10commerce.localhost/checkout/13/payment/return') (Line: 28)
Drupal\commerce_barion_payment\PluginForm\BarionRedirectForm->buildConfigurationForm(Array, Object) (Line: 110)
Drupal\commerce_payment\Plugin\Commerce\InlineForm\PaymentGatewayForm->buildInlineForm(Array, Object) (Line: 180)
Drupal\commerce_payment\Plugin\Commerce\CheckoutPane\PaymentProcess->buildPaneForm(Array, Object, Array) (Line: 546)
Drupal\commerce_checkout\Plugin\Commerce\CheckoutFlow\CheckoutFlowWithPanesBase->buildForm(Array, Object, 'payment')
call_user_func_array(Array, Array) (Line: 536)
Drupal\Core\Form\FormBuilder->retrieveForm('commerce_checkout_flow_multistep_default', Object) (Line: 284)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 224)
Drupal\Core\Form\FormBuilder->getForm(Object, 'payment') (Line: 143)
Drupal\commerce_checkout\Controller\CheckoutController->formPage(Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 741)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Warning: Trying to access array offset on value of type null in Drupal\commerce_barion_payment\Plugin\Commerce\PaymentGateway\BarionPaymentGateway->preparePayment() (line 425 of modules/contrib/commerce_barion_payment/src/Plugin/Commerce/PaymentGateway/BarionPaymentGateway.php).
Drupal\commerce_barion_payment\Plugin\Commerce\PaymentGateway\BarionPaymentGateway->preparePayment(Object, 'https://drupal10commerce.localhost/checkout/13/payment/return') (Line: 28)
Drupal\commerce_barion_payment\PluginForm\BarionRedirectForm->buildConfigurationForm(Array, Object) (Line: 110)
Drupal\commerce_payment\Plugin\Commerce\InlineForm\PaymentGatewayForm->buildInlineForm(Array, Object) (Line: 180)
Drupal\commerce_payment\Plugin\Commerce\CheckoutPane\PaymentProcess->buildPaneForm(Array, Object, Array) (Line: 546)
Drupal\commerce_checkout\Plugin\Commerce\CheckoutFlow\CheckoutFlowWithPanesBase->buildForm(Array, Object, 'payment')
call_user_func_array(Array, Array) (Line: 536)
Drupal\Core\Form\FormBuilder->retrieveForm('commerce_checkout_flow_multistep_default', Object) (Line: 284)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 224)
Drupal\Core\Form\FormBuilder->getForm(Object, 'payment') (Line: 143)
Drupal\commerce_checkout\Controller\CheckoutController->formPage(Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 741)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΈπŸ‡°Slovakia kaszarobert

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

Comments & Activities

  • Issue created by @kaszarobert
  • πŸ‡ΈπŸ‡°Slovakia kaszarobert

    So this happens if you enable commerce, commerce_product, commerce_checkout without commerce_payment first. That way the payment_process checkout pane will not be in configuration. And even if you enable commerce_payment after it together with installing commerce_barion_payment, the payment_process checkout pane will not be in the configuration until you reopen the checkout flow settings (/admin/commerce/config/checkout-flows/manage/default) and click to save there.

    The question is how to deal with a case where it cannot be determined if we use capture or not. Right now, the default is authorize only due to the $capture variable being NULL after reading from non-existing array element. I'd suggest the other way around just like how the web/modules/contrib/commerce/modules/payment/src/Plugin/Commerce/CheckoutPane/PaymentProcess.php is doing it. Plus, logging it so that the site admins will know something is not set up properly in the checkout. I attach a
    patch with this change.

Production build 0.71.5 2024