#gunwantkumar_code

1 messages · Page 1 of 1 (latest)

lost copperBOT
#

👋 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/1306871869357686835

📝 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.

tired cairn
foggy steeple
#

out of curiosity, why don't you just create the Customer before hand, and pass the Customer id in when creating the Checkout Session?

#

This way, when the payment is completed, the PaymentMethod (card) will automatically be attached to the Customer

tired cairn
#

I know about this. In my case i want to show single page checkout so...

foggy steeple
#

what does including a customer id got to do with single page checkout?

tired cairn
#

Without customer id i can't identify the charge.

foggy steeple
#

yes, so why not include the customer id when you create the Checkout Session?

tired cairn
#

At that time, I don’t have the customer details. In my case, the customer enters their name, email, and card details on the same page and confirms the payment, so I need to manage everything on my end.

foggy steeple
#

alright. You mentioned that its not working in my case, what isn't working? Are you running into an error?

tired cairn
#

this function not working in my case, i'm getting error.
await stripe.paymentMethods.attach(
payment_method_id,
{ customer: customer_id },
{ stripeAccount:account_id },
);
and
await stripe.customers.update(customer_id, data, { stripeAccount: account_id });

#

I'll share error details.

tired cairn
#

Its working when i passed setup_future_usage: 'off_session', but i remove this its not working

foggy steeple
#

again, what's the error message?

tired cairn
#

The customer does not have a payment method with the ID pm_1QLJo4GHf1WlTIAfo3ZuHMy0. The payment method must be attached to the customer.

foggy steeple
#

So yes, you need to include setup_future_usage: 'off_session' otherwise the payment method is not setup for future usage and cannot be attached to a customer.

tired cairn
#

If i include setup_future_usage: 'off_session' apple pay element doesn't show in stripe payment element.

foggy steeple
tired cairn
#

It that case how can i attach and set default payment method set to customer.
Please guid me.

foggy steeple
#

can you share an example Checkout Session id or PaymentMethod id where you created Checkout Session with setup_future_usage?

tired cairn
#

with setup_future_usage, Its working fine.
without setup_future_usage its not working.

#

without setup_future_usage its not working.
Checkout Session id : cs_test_b1vGgxhpKCQxhINp17l38B6Tr1lWxRwpEF2rNPHCxfkIjhVwRUB9OWchgG
PaymentMethod id: pm_1QLJo4GHf1WlTIAfo3ZuHMy0

foggy steeple
#

yes, so you always need to include setup_future_usage. To clarify, if you want to save (attach) the card to the customer, you will not see Apple Pay as a payment method option right now

#

you cannot use setup_future_usage, and display apple pay. Does that make sense?

tired cairn
#

yup, Thank you for being so helpful.

foggy steeple
#

Do you still need help with setting the default payment method on the customer? Or that's not an issue right now after I've clarified how it works