stripe/stripe-dotnet

Create Customer with Id Pleasee

Closed this issue · 3 comments

Is your feature request related to a problem? Please describe.

In Python version we can create customer with Id in the object that gives us solid integration with any other auth system like firebase uuid
Python verison of the code

customer = stripe.Customer.create(
id=user_id, # Using DB user ID as Stripe customer ID may lead to errors unless handled correctly.
email=email
)

Describe the solution you'd like

var options = new CustomerCreateOptions
{
Id = Id,
Name = name,
Email = email
};

    Id can be set like this while creating customer

Describe alternatives you've considered

Tried to create customer then update the Id of existing customer it is not possible also

Additional context

No response

Hello @mbakir,

This is possible with .AddExtraParam.

var options = new CustomerCreateOptions
{
    Name = ...,
    Email = ...
    
}
options.AddExtraParam("id", <your id from firebase>);

var service = new CustomerService();
var customer = service.Create(options);

However, I setting custom ids is not part of the documented Stripe API and is not recommended. Have you considered using Metadata instead?

Hello @mbakir,

This is possible with .AddExtraParam.

var options = new CustomerCreateOptions
{
    Name = ...,
    Email = ...
    
}
options.AddExtraParam("id", <your id from firebase>);

var service = new CustomerService();
var customer = service.Create(options);

However, I setting custom ids is not part of the documented Stripe API and is not recommended. Have you considered using Metadata instead?

Hey Thank you for quick response If metadata is the recommended way to do it I will look for it is it possible to filter user by metadata like get the user with corresponding metadata ?

CustomerService.List doesn't support filtering by metadata, but you can

  1. Use CustomerService.Search (read more about search here) which does support filtering by metadata (but does have limitations).
  2. Store the relationship between Stripe id and Firebase id in your own database.

I'm closing the ticket as the initial question specific to stripe-dotnet about how to send the undocumented "id" parameter is answered. If you have further questions you should contact Stripe support as they are better equipped to handle integration questions.