#mick23_code
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1225551814066307164
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- mick23_best-practices, 21 hours ago, 80 messages
Hello! To clarify, you're only saving payment details at this point, not taking a payment?
Correct
In that case you wouldn't use a Payment Intent, you should be using a Setup Intent. Have a look here: https://docs.stripe.com/payments/save-and-reuse
You're right, and I already knew that. Getting confused in the docs as usual (too much info)
So, which is the Elements guide I need to follow to get this bit working?
I was following this guide, https://docs.stripe.com/payments/payment-element - but I think that's the wrong one to be following
Probably this one: https://docs.stripe.com/payments/save-and-reuse?platform=web&ui=elements
https://docs.stripe.com/payments/accept-a-payment-deferred?type=setup <-- This is another tab I have open too
Feels like it's either that last one I posted, or the last one you posted.
Let me have a read of those two and try again
If you want to do this without creating an Intent first it would be that last one you linked to, yeah.
Could you help clarify terminology here. What is an "Intent" - Seems something different than a "Setup Intent" or a "Payment Intent", at least according to that link
Or is "Intent" used here just as a generic Either a Setup Intent or a Payment Intent"?
"Intent" refers to either a Setup Intent or a Payment Intent.
So that last one, a generic term.
Thanks
Happy to help!
So just looking at Step 5 here, https://docs.stripe.com/payments/accept-a-payment-deferred?platform=web&type=setup#create-intent
Think I'm starting to understand what I need to do.
The bit that I'm missing is that when a user clicks on Submit after they have entered in their card details, how is that linked back to the customer?
Is that all obscured in the code samples for ease? (I find it more confusing if I can't see it)
My understanding is Stripe.js (aka. the Elements UI Components) - Does it basically do a Pre-FormOnSubmit to pass the card details to Stripe API and get the Tokenised info, but then how does it pass that token to my /add-card-details/submit page so I can link that Token back to the Customer that I created in a previous step?
When you create the Setup Intent you set the customer parameter to your existing Customer ID. When the Setup Intent is confirmed successfully it will attach the Payment Method to that Customer.
"When the Setup Intent is confirmed successfully it will attach the Payment Method to that Customer." - so if I've understood correctly.
Stripe.js --> Fire card details to Stripe API, get Token as response
AddCard.html --> Fire /create-setup-attempt.server, pull existing customer details from DB that we created earlier, send this to Stripe API via Stripe SDK, Response will have "something in it"
Stripe.js then uses that "something" to connect the dots and re-send both bits of data back to Stripe API to essentially "Add Card to Customer in Stripe"
Is that right?
There is no Token involved. Tokens that represent payment info are legacy and are no longer used in flows like this.
And I'm guessing that "something" I'm referring to is the Setup Intent Object as outlined here - https://docs.stripe.com/api/setup_intents/create and also the confirmation is this one here - https://docs.stripe.com/api/setup_intents/confirm
At a high level the steps are that you initialize Stripe Elements in setup mode and display the Payment Element to the customer. That all happens client-side. They fill in their payment info and then press a button that triggers creation of a Setup Intent on your server, and your server passes the Setup Intent's client secret back to the client so you can run elements.submit() and then stripe.confirmSetup() which will attempt to confirm the Setup Intent with the payment info provided in the Payment Element.
When I say Token, I mean in the conceptual way rather than the older actual tokens that have been used, I'm guessing it's all running off these IDs now "id": "seti_1Mm8s8LkdIwHu7ix0OXBfTRG",
?
When you create the Setup Intent on your server you specify which customer it belongs to. During the confirmation process (stripe.confirmSetup()) a Payment Method is created and attached to the Customer if the process succeeds.
Conceptually the closest thing to a Token would be the Payment Method. The Setup Intent is basically a state machine that governs the process of setting up payment information for future use.
Does that help, or is it still unclear?
Yeah I think that is making sense now. I'm going to turn that into a diagram for my own benefit of the flow as I struggle to join the dots together with complex things like this with just words but what you have said there has been 1000x more clear than I've been reading in the docs. So it should give me enough to go off to get to the next step on this journey.
Leave it with me, I'll have another play and see if I can get something working.
Sounds good. If you need anything else let us know!
Yeah just been doing a bit more reading, this is the "token" thing which I think is what I was referring to before I knew what it was called - "client_secret": "seti_1Mm8s8LkdIwHu7ix0OXBfTRG_secret_NXDICkPqPeiBTAFqWmkbff09lRmSVXe",
(that's from the Setup Intent Object)
When I've been reading the phrase "client_secret" in the code samples to date, I've been thinking this was the Stripe Secret Key for my account, but seems like this "client secret" terminology is used quite generically in Stripe
Yes this is making sense now.
It's basically a complex handshake between 3 parties passing around the public/private versions of keys/tokens/secrets (generic terms) so things can be re-connected up at the relevant point.
Just on the point you mentioned about the State Machine. Is there a State Workflow documented anywhere i.a. A --> B --> C etc. ?
The client secret is unique to a given Intent (both Setup Intents and Payment Intents have them). They give whoever has the client secret additional access to that specific Intent, and are thus considered sensitive information.
We document the Setup Intent state machine here: https://docs.stripe.com/payments/setupintents/lifecycle