#nathanahoy_api

1 messages ¡ Page 1 of 1 (latest)

lucid reefBOT
#

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

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

finite vigil
#

The steps taken to render the payment element are as follows:

  • First create a customer session with the stripe customer id (only if we have previous created a stripe customer), to display saved payment methods if available
  • We then render a @stripe/react-stripe-js Elements component with the optional customer session
  • Inside the Element component, we render a @stripe/react-stripe-js PaymentElement
  • In the on submit function for the PaymentElement, we create a setup intent (creating a new stripe customer at this point if one does not exist) for teh customer, then with the returned setup intent client secret, we call stripe.confirmSetup() from useStripe()
  • There is a webhook listener for the payment_method.attached event that will set the newly added payment method id as the invoice_settings.default_payment_method id (to ensure the method can be used to pay for invoices)
  • If that succeeds, we then call our start subscriptions endpoint, that creates a new subscription using the customer id (this subscription contains 2 prices, one Usage-based and one fixed price)

While testing I've been unable to get the acss_debit payment method type working, even if I explicitly set it for the create setup intent call. Just wondering if you had any guidance on how to use both credit cards and acss_debit in this type of flow. Also if any further clarification is required please let me us know.

thorny pulsar
#

Hi there. So you're rendering the Payment Element without a client secret from a SetupIntent, correct?

finite vigil
#

Yes, we are using the client secret from the customer session

thorny pulsar
finite vigil
#

What would be the recommended flow?

#

Client is very keen to use Canadian Pre-Authorised Debits

thorny pulsar
#

Which used to be the only way to do it / was the default integration until a couple of years ago