#delgesu1745_api

1 messages ยท Page 1 of 1 (latest)

fair furnaceBOT
#

๐Ÿ‘‹ 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/1346906251849629699

๐Ÿ“ 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.

lone heath
#

Hi ๐Ÿ‘‹

In that case, you would specify mode: "setup" parameter when you create the Checkout Session

#

We have an integration guide specifically for this workflow here

hasty linden
#

๐Ÿ‘‹ Hey. Ok! So then then would I not show any of the product info details, or can I still show that so they know what they're going to be paying for, when we initiate the payment?

lone heath
#

If you are using Stripe Checkout to save a payment method, no you would not display product information in that UI.

Can you clarify why you want to save the payment method and then initiate payment?

#

Since you can do both with the same Checkout Session

hasty linden
#

Sorry if confusing! The primary thing I want to achieve is not charging them immediately upon checkout. We first have to verify that we can give them a scheduled time for the service before we bill them, but I do want to show them the breakdown of the things they're signing up for.

fair furnaceBOT
lone heath
#

Gotcha. Okay. Unfortunately when you specify Setup, you cannot provide line items so we won't be able to display any details on what the customer is purchasing in the Checkout Session UI.

In that case you would likely need to add your own UI displaying this information before you redirect the customer to Stripe Checkout.

hasty linden
covert flume
hasty linden
#

But if include the customer_id in the session do I need to followup with updating the customer invoice settings?

#

// Set your secret key. Remember to switch to your live secret key in production.
// See your keys here: https://dashboard.stripe.com/apikeys
const stripe = require('stripe')('sk_test_u7epv5S7nj4EDqZDGZNqyDUV');

const session = await stripe.checkout.sessions.create({
mode: 'setup',
currency: 'usd',
customer: '{{CUSTOMER_ID}}',
success_url: 'https://example.com/success?session_id={CHECKOUT_SESSION_ID}',
});

covert flume
#

That is up to you, you do not need to if you pass the payment method id when you create the invoice, https://docs.stripe.com/api/invoices/create#create_invoice-default_payment_method.

Or, you can update the customer in the first places, and just create the invoice to charge automatically at a later time.

hasty linden
#

Ok, but how does the session attach the payment method to the customer if passing a customer id to it? Does it set it as the default?

covert flume
#

It attaches the payment method to the customer but it does NOT set it as the deafult. Hence, you would need to make another request update the customer to set that

hasty linden
#

Ok got it. But if it's the only payment method on file for the customer then is it by default set as, uh, the default?

#

Another item I need clarified. The guide in step 2 says "Append the {CHECKOUT_SESSION_ID} template variable to the success_url to get access to the Session ID". Where do you get the checkout session id from exactly?

covert flume
#

No, it does not automatically become the default

#

You just add {CHECKOUT_SESSION_ID} template variable to the success_url and that would be pulled in for you. I recommend that you test that on your end.

hasty linden
#

Ah ok so you leave that as is. And so then I need to setup the template for the session in the dashboard or something?

covert flume
#

Hmm what do you mean by that? The URL will be appended and it has nothing to do with the 'Dashboard'

#

I highly recommend that you test this as it get fun to play around

hasty linden
#

I am in the Stripe Shell right now on the guide playing with it.

#

When I add my test account customer id and run the sessions create call it spits back the json for the sessionn.

#

Sorry for all the dumb questions, but how is this then rendered in the browser to the client?

#

Oh I see. It returns the url that you then have to serve up to the user by opening the url in a browser for them?

covert flume
#

Yes

#

No dumb questions, this is all new to you

hasty linden
#

Ok, I think I can test this all out now in a real example. Last question. So what I meant by customize the template above is that checkout session url that's returned, when you open that, where and how do I customize that?

covert flume
#

Are you able to reword it please?

hasty linden
#

Is that all done in the sessions.create call?

#

Or can I set some defaults up within my Stripe settings in our account?

#

But yeah is there a way to set some defaults in the settings for stuff like this?

covert flume
hasty linden
#

Yeah, ok, I'll check this all out more and will reach out if I have more questions. Thanks so much for all your help!

covert flume
#

Sure