Describe your bug or feature request.

The Drupal\commerce_payment\Plugin\Commerce\PaymentGateway\PaymentGatewayBase::getRemoteCustomerId() method uses $account->isAuthenticated() to check if the user is not the anonymous user before trying to load a stored commerce_remote_id value, which works fine in normal circumstances. The Decoupled User Authentication module introduces the concept of users without logins and overrides the base isAuthenticated() method to also include a check on whether the user has a login.

When using these two module together, it means that if a purchase is made for a user that does not have a login, their remote customer id can never be loaded, which can cause future payments to fail for some providers.

If a bug, provide steps to reproduce it from a clean install.

Install both Drupal Commerce and Decoupled User and a payment method provider like Commerce Stripe. Set up the site to have a product that can be bought on behalf of a user without a login. When trying to make a second payment using their stored card, you will get a Stripe error because the remote customer id is not set against the payment intent.

Steps to resolve

This is a very niche issue, so I'm not convinced there's a need for Commerce to cope with it, but it would be a relatively minor change with exactly the same results without Decoupled User Authentication if the code in Drupal\commerce_payment\Plugin\Commerce\PaymentGateway\PaymentGatewayBase::getRemoteCustomerId() was altered to check !$account->isAnonymous() instead of $account->isAuthenticated().

Issue fork commerce-3345465

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

MrDaleSmith created an issue. See original summary.

mrdalesmith’s picture

Status: Active » Needs review

jsacksick’s picture

Status: Needs review » Fixed

Fine with the fix, committed, thank you!

Status: Fixed » Closed (fixed)

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