#Shanto19
1 messages ยท Page 1 of 1 (latest)
HI ๐ you won't provide the ID of the Customer while creating the Element, instead you would provide it when creating the Payment Intent or Setup Intent along with specifying the payment method should be configured for future usage through the setup_future_usage parameter.
If you're trying to save payment method details while also processing a payment, then this guide is a good starting point:
https://stripe.com/docs/payments/save-during-payment
If you want to save the payment method without processing a payment at the same time, then this guide will be a better fit:
https://stripe.com/docs/payments/save-and-reuse
Hi Thank you so much for quick response
So This is my goal . This is what I am trying to achieve :
I have a form to get customer information.
So I need to create stripe customer with those information and after having the customer id I would like to use it in second window preferably an element to collect the payment info to save it for future payments
so what's the best way to do this ?
Like I saw the customer creation api calls which is fine.
Then the payment intent is also the next thing to make. However I would like to do the payment intent with stripe element
so I use the stripe element to collect the info and pass it/assign it to existing customer as future payment info to use
If you aren't processing a payment at the same time that you're collecting those payment method details, then the second link that I provided above is going to be the best fit.
yes it seems like the second link would work if I already have the customer
what if I don't have an existing customer and want to be created on the spot ?
can the api handle it ?
Sure, you can create a Customer object whenever you need a new one. That's why the guide provides a snippet on how to use the API or our libraries to create a Customer as part of this process.
Thank you so much it was very helpful
So I will look into it.
However I have one last question
var options = new CustomerCreateOptions{};
var service = new CustomerService();
var customer = service.Create(options);
This when I call this
if the info has the same email
Does it create twice or once ?
like what I am asking is the email is unique for a customer right ?
And if I try to create another customer with same name and email does it duplicate or ?
There is not functionality built to avoid creating multiple Customers with the same email address, if this is behavior that you would like to have then you will need to write your own code to handle that requirement.
Thank you for the clarification
so I will try to find a way to retrieve customer information based on email
I think there should be an api call that gets me the customer by email right ?
Yup, you can list Customers by email address using this approach:
https://stripe.com/docs/api/customers/list#list_customers-email
But you'll want to pay close attention to the fact that the email field I linked to there is case-sensitive.
If you want to do case-insensitive searching then you'd want to do a Customer search instead:
https://stripe.com/docs/api/customers/search
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Okay thank you so much for your help
Another question
but this is a different one
like what's the recommended way to save the api key in the JavaScript file ?
Hello toby has to step out but I can help. Catching up
We don't necessarily have recommended storage methods for the keys. We do often recommend making them part of some kind of environment or configuration file so that they are easier to swap out. Also of course keep your secret and restricted keys private as it can be used to do a lot of things on your account. Client side code should always work with either a public or ephemeral key
Okay thanks for your help