RuntimeException: Parent resource reference is not set!

Created on 19 March 2024, 9 months ago
Updated 5 April 2024, 9 months ago

Problem/Motivation

Unable to proceed to offsite payment as an anonymous user.

Steps to reproduce

1. Add a product to the cart as an anonymous user
2. Go through the checkout flow until the selection of offsite payment with Unzera.
3. Upon redirection to the external payment service, an error occurs:

RuntimeException: Parent resource reference is not set! in UnzerSDK\Resources\AbstractUnzerResource->getParentResource() (line 115 of /var/www/drupal/vendor/unzerdev/php-sdk/src/Resources/AbstractUnzerResource.php).

Proposed resolution

This is caused by the lack of Parent resource in Customer object.

If the user is anonymous, after creating $customer, let's execute $unzer->createCustomer($customer):

      // Create or retrieve an Unzer customer object
      if ($order_user->isAnonymous()) {
        // Always create a new Unzer customer, there is no way to recognize
        // recurring customers if they are anonymous.
        $customer = CustomerFactory::createCustomer($converted_address[UnzerAddressConverter::FIRSTNAME], $converted_address[UnzerAddressConverter::LASTNAME]);
        $unzer->createCustomer($customer);
      }
🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇵🇱Poland michal_liszka

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.71.5 2024