#bruno_code

1 messages ยท Page 1 of 1 (latest)

hardy kindleBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฑ๏ธ We automatically close idle threads, which makes them read-only. Make sure you stick around to chat in realtime!

๐Ÿ”— 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/1212396615873204315

๐Ÿ“ Have more to share? You can add more detail below, including code, screenshots, videos, etc.

โฒ๏ธ 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. Thank you for your patience!

fickle harness
#

Full code, since it won't fit into the form:

return await stripe.subscriptions.create({
      customer: customerId,
      items,
      payment_behavior: 'default_incomplete',
      payment_settings: { save_default_payment_method: 'on_subscription' },
      expand: ['latest_invoice.payment_intent', 'pending_setup_intent'],
      automatic_tax: { enabled: true },
    });
green lightBOT
cobalt dagger
#

Hi, let me help you with this.

fickle harness
#

Hey, sure, just one sec

#

Currently, we get customer billing information on the payment step, using PaymentElement:

#

But since we need to create a subscription to then generate a payment intent, we are not sure how to store the location before making the POST v1/subscription call

green lightBOT
cobalt dagger
hollow lance
fickle harness
#

Hey, thank you for the feedback.

That's exactly what we do at the moment:

  • We create the customer
  • We render the component to collect payment details
  • We create a subscription that will be treated as incomplete by stripe
  • The front-end uses the payment intent to use payment details to charge the customer

But when we try to create the subscription on step #3 without having a card linked to the customer, after adding the automatic_tax flag, it fails, since Stripe hasn't received the card details yet

hollow lance
#

The flow we linked above collects the PaymentMethod details without requiring an Intent

#

Step 3 is where you collect the payment method details and tokenize it.

Step 7 is where you confirm the subscription (where the payment method gets charged)

fickle harness
#

Ah, perfect!
I couldn't find on the documentation the call we use to "tokenize" the payment method on step 3... Here we are not sending that data to the back-end, are we?

hollow lance
#

You're not sending it to your backend, no.
But if you're listening to Webhook events then you'd likely receive appropriate events.

fickle harness
#

Ah, sorry. When i said back-end I meant sending the data to Stripe.

Here we are just rendering the component from what I understood, but where to we generate a payment method?

hollow lance
#

Submitting the element sends the payment method info to Stripe and creates a PaymentMethod

fickle harness
#

Aah, ok ๐Ÿค” now it's clear

#

Thanks for the explanation ๐Ÿ™‚ I will give it a try