#stickyjams-checkout

1 messages · Page 1 of 1 (latest)

frozen spoke
#

hi, what do you mean exactly by "send in email"?

#

I can for example add something like <input type="text" name="email" id="email" placeholder="Enter email address" /> but I'm not sure how to get this to actually send through so that I can access it on the PaymentIntent on the return_url, or sent in as a GET paramater?
I don't understand you. Checkout collects the email address, the hosted Checkout page from Stripe lets the customer enter their email.

plain horizon
#

I'm not using a hosted checkout page

frozen spoke
#

ah right

plain horizon
#

I'm using payments with elements

frozen spoke
#

then you use billingDetails on confirmPayment

plain horizon
#

would this also be what I use if I wanted to have a field like "Color" or something odd like that?

frozen spoke
#

when calling confirmPayment you can pass the information you get from your own HTML inputs according to the shape in the docs there

frozen spoke
#

if you mean "what did the user buy", you need to set that on the backend instead, by setting metadata on the PaymentIntent exactly

plain horizon
#

so like first I create the payment intent

#

and then I have the elements thing collecting the payment info

#

then when it confirms the card, it sends to return_url

#

from that return url, I am using the payment intent id to get the info from the order

#

I'm just a bit confused how I send the data from the form (that is separate from the payment info)

#

<form id="payment-form">
@csrf
<input type="text" name="email" id="email" placeholder="Enter email address" />
<input type="text" name="color" id="color" placeholder="Enter a color" />
<div id="payment-element">
<!--Stripe.js injects the Payment Element-->
</div>
<button id="submit">
<div class="spinner hidden" id="spinner"></div>
<span id="button-text">Pay now</span>
</button>
<div id="payment-message" class="hidden"></div>
</form>

#

since it is automatically sending to the return_url, how do I bring along the data from inputs on the form that I've added?

#

I have successfully brought along email with payment_method_data: {
billing_details: {email: email},
},

frozen spoke
#

well you can't really, that's not how this is supposed to work. If you need extra information you should collect it before creating the PaymentElement

plain horizon
#

hmm, okay so anything besides billing info should be collected before or afterwards

frozen spoke
#

i.e. it's designed for having a page where the user picks what they want and sets up their shopping cart and so on, then you submit that to your server, your sever creates a PaymentIntent for the right amount and saved other details, returns the PI to the frontend, the frontend does the payment, you listen to a webhook on the server to then fulfill the order after the successful payment

plain horizon
#

once it sends to return_url, we can basically be certain the card payment has gone through successfully right?

#

where I could then use that payment intent id to get the info

#

such as the payment method to store on a customer

plain horizon
#

otherwise, wouldn't it give errors like insufficient funds, etc?

frozen spoke
#

https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements#web-post-payment

Listen for these events rather than waiting on a callback from the client. On the client, the customer could close the browser window or quit the app before the callback executes, and malicious clients could manipulate the response. Setting up your integration to listen for asynchronous events is what enables you to accept different types of payment methods with a single integration.

plain horizon
#

(obviously the person could go to the return url manually)

plain horizon
#

once it sends to return url though, I am using payment intent id to get that info from Stripe, so wouldnt I avoid any of that tomfoolery

frozen spoke
#

what if the return_url is never visited?

#

webhooks are a required part of the integration with Stripe today

plain horizon
#

hmm okay

#

i suppose they could send the request and then close the window, but then it would succeed

#

thereby them never getting access automatically

#

makes sense