#TheKents
1 messages ยท Page 1 of 1 (latest)
after completing the payment, the payment tab looks like this
You need to specify a customer (https://stripe.com/docs/api/payment_intents/object#payment_intent_object-customer) if you want to associate a customer to a PaymentIntent.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
how do i do that
and do i need to update paymentIntent after LinkAuthenticationElement is no longer in focus?
or at which point
https://stripe.com/docs/api/payment_intents/create#create_payment_intent-customer I'd recommend you associate one when creating a PaymentIntent.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
what about if i dont have users email before checkout
only time they insert their email is in LinkAuthenticationElement
Here's my suggestions
- listen to
payment_intent.suceededevent - Get the email address from the latest's charge's billing_details, use it to create a customer
- Update the PaymentIntent with the newly created customer
hasnt the paymentIntent already completed by then?
You can still update a PaymentIntent with a customer even if it's already suceeded.
how can i update that specific one?
the receiptEmail is null btw, for now
oh
the event id is the paymentIntent id
so probably like await stripe.paymentIntents.update(event.id, customer...)
Can i also ask another question here or do i need to create another ticket?
but does it automatically send the receipt then?
since "Stripe automatically sends email receipts after a successful payment or refund when you provide an email address", but the payment intent already succeeded without customer
Hmm, you are right, you need to specify a customer or receipt_email (https://stripe.com/docs/api/payment_intents/create?lang=curl#create_payment_intent-receipt_email) for Stripe to send the emails
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Let me think
https://stripe.com/docs/payments/link/accept-a-payment?platform=web&ui=elements#retrieving-email-address You can listen to this event to get the email address that your customer enters
In the event handler, you can send a request to you backend so that you can create a customer with this email address and then associate it to the PaymentIntent.
yeah, thats what i was thinking, but doesnt it fire off multiple times? like when user types one letter it fires? or only when user clicks out of focus
The onChange handler fires whenever the user updates the email field, or when a saved customer email is auto-filled.
It won't fire when the customer is still typing
Sure
how can i handle payment Intent success return url to get order details to custom success page
like when customer pays for the order
for now i have this
confirmParams: {
// Make sure to change this to your payment completion page
return_url: 'http://localhost:3000',
},
can i manipulate the url like "api/checkout/success?true&session_id={SESSION_ID}&alias_id=${aliasId}`"
Hey! Taking over for my colleague. You can set the return_url with the parameter you want... but {SESSION_ID} won't work as this is not a checkout session, you can simply hardcode these values in the url..
what about webcrawlers and such?
if the url is hardcoded with user data?
its unsafe right?
webcrawlers? the return url will be something like DOMAIN/URL?param1=value1¶m2=value2...
yeah i mean if i want to show customer info, like phone numbers and address for example
couldnt someone go thru all those urls
if for example i would have DOMAIN/orderid=ordernumber
You'll be creating the return url dynamically... and these pages are displayed only if the customer is authenticated or they filled their details...
interesting
so if someone would enter the exact url, they would get an error page or smth?
They can reach to the page but they can't intercept the params....as the url and its params are built after the customer enter your page and fills their data
@lost otter am not able to send you message privately
๐
yeah but after params are built
could they send the order comformation url to their friend for example, and their friend could open the link and see all the details there
Yeah and that's not a security issue... they simply don't need to share that link with their friend
hmm, okay
i think that i can go from this now
thanks for the help
have a nice day
Welcome!
one more thing
how can i target the correct payment intent id in the backend
@lost otter should i use this to get paymentintent id? stripe.retrievePaymentIntent(clientSecret).then(({ paymentIntent }) => {
You can yes using the clientSecret of the PaymentIntent:
https://stripe.com/docs/api/payment_intents/retrieve#retrieve_payment_intent-client_secret
thanks