vendure-ecommerce / vendure

The commerce platform with customization in its DNA.
https://www.vendure.io
MIT License
5.41k stars 952 forks source link

Stripe Customer ID #2285

Open nonlinearcom opened 11 months ago

nonlinearcom commented 11 months ago

Hi, we have a multi-channel setup, where every channel is connected to a different Stripe accounts with a dedicated payment method. When a registered user completes an order for the first time in a channel, they get assigned a Stripe Customer ID. In the Admin UI, this id seems to be shared across different channels.

The problem arises when the same user tries to order on a different channel (that is connected to a different Stripe Account), with the service returning the error No such customer: cus_ODbndK2cjtK3kC.

The id cus_ODbndK2cjtK3kC is the same the user got in the initial channel where they completed the first order. I would expect also this ID to be channel aware, but it seems not.

On a side note: setting the storeCustomersInStripe: false seems to fix this problem, but I wonder if it's ok to create a new customer for every order?

michaelbromley commented 11 months ago

Thank for the report. This would be a good use case for channel-aware custom fields (#490) which have not yet been implemented because I've not arrived at a satisfactory design so far.

A solution for the time being could be for the plugin to use its own serialized data structure which stores it like:

{
  "channel1ID": "cus_ODbndK2cjtK3kC ",
  "channel2ID": "....",
}