Drupal\commerce_paypal\CustomCardFieldsBuilder::build(): Argument #1 ($order) must be of type Drupal\commerce_order\Entity\OrderInterface, null given

Created on 21 November 2023, 7 months ago
Updated 16 January 2024, 5 months ago

Problem/Motivation

When i try to add a payment method into payment user page /user/7/payment-methods
i get this error

TypeError: Drupal\commerce_paypal\CustomCardFieldsBuilder::build(): Argument #1 ($order) must be of type Drupal\commerce_order\Entity\OrderInterface, null given, called in /var/www/html/web/modules/contrib/commerce_paypal/src/PluginForm/Checkout/PaymentMethodAddForm.php on line 85 in Drupal\commerce_paypal\CustomCardFieldsBuilder->build() (line 48 of modules/contrib/commerce_paypal/src/CustomCardFieldsBuilder.php).

Drupal\commerce_paypal\PluginForm\Checkout\PaymentMethodAddForm->buildConfigurationForm(Array, Object) (Line: 108)
Drupal\commerce_payment\Plugin\Commerce\InlineForm\PaymentGatewayForm->buildInlineForm(Array, Object) (Line: 225)
Drupal\commerce_payment\Form\PaymentMethodAddForm->buildPaymentMethodForm(Array, Object) (Line: 119)
Drupal\commerce_payment\Form\PaymentMethodAddForm->buildForm(Array, Object, Object)
call_user_func_array(Array, Array) (Line: 536)
Drupal\Core\Form\FormBuilder->retrieveForm('commerce_payment_method_add_form', Object) (Line: 283)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 592)
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: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->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: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Steps to reproduce

Go to payment page of user account.
Click to "add payment method"

Thank you

🐛 Bug report
Status

Fixed

Version

1.0

Component

PayPal Checkout

Created by

🇮🇹Italy trickfun

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

Comments & Activities

  • Issue created by @trickfun
  • First commit to issue fork.
  • Status changed to Needs review 7 months ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.3 & MySQL 5.7
    last update 7 months ago
    2 pass
  • 🇮🇳India viren18febS

    Hi @trickfun
    I have fixed the issue & added patch, please review.

  • 🇮🇳India Jaspreet-Kaur

    verified! patch #3 worked for me.

  • 🇮🇹Italy trickfun

    Patch works fine but when i try to save payment i get this new error

    TypeError: Drupal\commerce_paypal\Plugin\Commerce\PaymentGateway\Checkout::createPaymentMethod(): Argument #2 ($payment_details) must be of type array, null given, called in /var/www/html/web/modules/contrib/commerce/modules/payment/src/PluginForm/PaymentMethodAddForm.php on line 83 in Drupal\commerce_paypal\Plugin\Commerce\PaymentGateway\Checkout->createPaymentMethod() (line 842 of modules/contrib/commerce_paypal/src/Plugin/Commerce/PaymentGateway/Checkout.php).
    Drupal\commerce_payment\PluginForm\PaymentMethodAddForm->submitConfigurationForm(Array, Object) (Line: 104)
    Drupal\commerce_paypal\PluginForm\Checkout\PaymentMethodAddForm->submitConfigurationForm(Array, Object) (Line: 169)
    Drupal\commerce_payment\Plugin\Commerce\InlineForm\PaymentGatewayForm->submitInlineForm(Array, Object) (Line: 159)
    Drupal\commerce\Plugin\Commerce\InlineForm\InlineFormBase::runSubmit(Array, Object)
    call_user_func_array(Array, Array) (Line: 141)
    Drupal\commerce\Plugin\Commerce\InlineForm\InlineFormBase::doExecuteSubmitHandlers(Array, Object) (Line: 134)
    Drupal\commerce\Plugin\Commerce\InlineForm\InlineFormBase::doExecuteSubmitHandlers(Array, Object) (Line: 86)
    Drupal\commerce\Plugin\Commerce\InlineForm\InlineFormBase::executeElementSubmitHandlers(Array, Object)
    call_user_func_array(Array, Array) (Line: 82)
    Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object) (Line: 275)
    Drupal\Core\Form\FormValidator->doValidateForm(Array, Object, 'commerce_payment_method_add_form') (Line: 118)
    Drupal\Core\Form\FormValidator->validateForm('commerce_payment_method_add_form', Array, Object) (Line: 593)
    Drupal\Core\Form\FormBuilder->processForm('commerce_payment_method_add_form', Array, Object) (Line: 325)
    Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
    Drupal\Core\Controller\FormController->getContentResult(Object, Object)
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 592)
    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: 58)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->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: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
    
  • 🇮🇱Israel jsacksick

    @trickfun: Well, PayPal checkout doesn't support card tokenization if that is what you're trying to do... So saving the payment method from the user pages isn't supported.

  • 🇮🇹Italy trickfun

    Fine.
    But why if i try to add payment i get paypal options available?

    • jsacksick committed 23ef4bf9 on 8.x-1.x
      Issue #3403214 by viren18febS, jsacksick: Drupal\commerce_paypal\...
  • Status changed to Fixed 6 months ago
  • 🇮🇱Israel jsacksick

    Committed a slightly different patch, but again the payment method tokenization isn't supported.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024