#david-Elements

1 messages · Page 1 of 1 (latest)

icy sinew
#

Hi there, when you create a PaymentIntent, did you specify a customer?

covert crater
#

Hi Jack. No, at the moment the only data being passed during the creation of the payment intent is the amount and currency

icy sinew
#

Ok, you can create and specify a customer so that Dashboard won't display the customer as guest customer

covert crater
#

Okay Jack

Just to clarify, my process for creating the payment intent is in an API route (Next.js).

So would I just need to use the customers.create API (https://stripe.com/docs/api/customers/create?lang=node) (before creating the payment intent), then pass the returned id in the 'customer' field when creating the intent, all within the same Next API route?

Is there anything I need to do to handle potential duplicate customers?

icy sinew
#

You should pass an existing customer (if any), or create a new old if necessary.

covert crater
#

How do I handle that situation? Do I need to query the API by email address or something to see if the customer already exists?

dull mural
#

Hi! I'm taking over this thread.

#

Ideally you would keep track of customers on your end, for example by storing the Stripe customer ID in your own database.

covert crater
#

We don't have the infrastructure set up for this as our setup is serverless and we don't have a database.

Is it a problem to create a duplicate customer?

dull mural
#

Is it a problem to create a duplicate customer?
From Stripe point's of view: no. You can create as many customers as you want.
Another option is to use this endpoint to list all customers with a specific email address: https://stripe.com/docs/api/customers/list

covert crater
#

Okay that's useful thanks. It seems that this should work for us.

I can see that there is also an 'update customer' part of the API too so we can update details (address etc.) if required.

#

Another semi-related question.

We also allow the customer to set up subscription payments on our form.

This process works as follows:
• Create payment method on the front end using card elements
• Pass payment method to Next API route, within which we:
• Create the customer (using the payment method id from the created payment method)
• Create the subscription, using the customer id

We're not using payment intent in there, but it seems to be working fine. Is this set up okay?

dull mural
#

This works, this is basically the old way to implement Stripe.

#

The new way is to use PaymentIntent (or SetupIntent) + the Payment Element.

covert crater
#

Is there a problem with using the old way?

dull mural
covert crater
#

Thanks 🙂