Can't we share the same Stripe Customer ID for Card Element and Payment Element?

Created on 1 December 2023, over 1 year ago

Hi,

I am trying to use Payment Element on a site that was using Card Element so far.
I noticed that the Payment Intents created with Payment Element were creating new Customers on Stripe's end instead of keeping my already created Customers in the past with Card Element.

I debugged and saw the 'customer' parameter was indeed empty in StripePaymentElement::createPaymentIntent line 874 $customer_remote_id = $this->getRemoteCustomerId($order->getCustomer());

I had a look at user__commerce_remote_id and noticed that there is a commerce_remote_id_provider and I was surprised to see that it does not keep the same value wether I use Card Element (stripe|test) or Payment Element (stripe_payment_element|test).

So we are creating separate Stripe Customers wether we use Card Element or Payment Element.

Is this done on purpose or this a consequence of Payment Element being a new Payment Gateway that you had not anticipated?

From my understanding, Card Element and Payment Element are just two JS components that provide a different user experience when choosing the pay they want to pay. But I have not read and I would be surprised to learn that both JS components cannot be used on one same Stripe Customer. Is it the case ??

In my case, I am hoping that previously stored payment methods (with Card Element) in my Stripe Customer can be suggested and used inside the new Payment Element. So I am hoping that as soon as I will be able to give the already existing Customer ID instead of null, it will work...

πŸ’¬ Support request
Status

Active

Version

1.1

Component

Payment Element

Created by

πŸ‡«πŸ‡·France nicolas bouteille

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

Comments & Activities

  • Issue created by @nicolas bouteille
  • πŸ‡«πŸ‡·France nicolas bouteille

    Ok I contacted Stripe Developers on Discord and asked them if it was required to separate Customer accounts between Card Element and Payment Element and they confirmed me that it isn't. We can totally reuse the same Customer object no matter if we use Card Element or Payment Element.
    So I think perhaps this deserves a higher priority so switching to major and that even the Payment Element gateway should keep using 'stripe' in commerce_remote_id_provider instead of 'stripe_payment_element'

  • Status changed to Closed: duplicate over 1 year ago
  • Status changed to Active 17 days ago
  • πŸ‡¬πŸ‡§United Kingdom jonathanshaw Stroud, UK

    I think this may be an achievable and desirable feature. The multiple customer ids are a consequence of commerce's default assumption of one remote id per gateway, but there are valid circumstances for having differntly configured gateways on the same provider that share the same remote customer id.

    PaymentGatewayBase assumes that the remote id is gateway specific:
    $provider = $this->parentEntity->id() . '|' . $this->getMode();

    I think our payment gateway plugin could just override get/setRemoteCustomerId:
    $provider = 'commerce_stripe_shared|' . $this->getMode();

    Backwards compatability here is not trivial as there may be custom code making expectations about the provider id. Unfortunately there is no getProvider() method on the PaymentGatewayInterface to help with this.

    We could adopt a permissive approach where if getRemoteCustomerId finds no customer id, it identifies all of the other stripe payment gateway plugins and gets the remote customer id from any of them that have one.

  • πŸ‡ΊπŸ‡ΈUnited States torgosPizza Portland, OR

    I agree that Stripe Customer IDs should be decoupled from payment gateways and considered as a property or field of a Drupal User. For our own integrations in Drupal 7, we wrote custom code that stored the Stripe Customer ID as a field value on the User Entity so that we could correctly process webhooks from Stripe for payment processing (recurring transactions for Subscriptions).

    I think if a Drupal User is storing a payment method as a card on file for the Commerce store, it should be stored on the user so that they may reuse the same customer ID for any future purchases; this will help keep Stripe records consolidated and will avoid having multiple Customers listed for Users which could lead to data loss and would require reconciling them later, which can be very challenging and time consuming. So +1 to decoupling Stripe Customer IDs and making them a shared value for Drupal Users.

Production build 0.71.5 2024