#Steve Sizer

1 messages ยท Page 1 of 1 (latest)

obtuse geyserBOT
gusty sapphire
#

Hi ๐Ÿ‘‹

No this isn't something you can do AFAIK.

tired ermine
#

I'm just using the new payment element at the moment and you have to create a payment intent first, so i dont have any client details at that point...

gusty sapphire
#

Does the Payment Intent have a value in the customer property?

tired ermine
#

intent = Stripe::PaymentIntent.create({
amount: price.to_i,
currency: 'usd',
automatic_payment_methods: {
enabled: true,
},
})

#

no. I just create the payment intent

flat stratus
#

๐Ÿ‘‹ stepping in as Snufkin needs to step away

tired ermine
#

Can i create a customer just before the confirm payment?

flat stratus
#

Yep you can

#

There are basically two options

#

You can either update the PaymentIntent before confirmation to include a Customer ID

#

Or you can use setup_future_usage with the PaymentIntent, then you attach the PaymentMethod to the Customer after the PaymentIntent is confirmed

#

That will associate the PaymentIntent and PaymentMethod to that Customer

tired ermine
#

so before i call confirm payment i do the following which returns a customer

#

const {
data: { error, customer, amount },
} = await axiosInstance.post(/playlists/${playlist.slug}/purchase, {
coupon_code: coupon.current.value,
first_name: firstName,
last_name: lastName,
email: email,
phone: phone,
});

#

so what i could do is pass the payment intent as a param in the above call and attach it to the customer here

#

This only seemed to occur though with testing google payments i don't know if that has anything to do with it?

flat stratus
#

The above code is frontend code where you are making an Axios request, no?

#

That is not where you create a Customer nor PaymentIntent

#

That all happens in your backend

#

Let's back up a second

#

What are you trying to accomplish?

tired ermine
#

I've already created a payment intent, so in the above axios request where i create and return the customer could i not pass the payment intent previously created on the initial page load. And attach it to said returned customer?

#

hope this makes sense

flat stratus
#

No not really. You don't "attach PaymentIntents to customers". You attach PaymentMethods to Customers, and then any PaymentIntent paid with that PaymentMethod would also be associated with that Customer.

#

This allows you to later attach a PaymentMethod created from that PaymentIntent to a Customer

tired ermine
#

awesome thank you ๐Ÿ™‚