#john_dev_
1 messages · Page 1 of 1 (latest)
Hi there
Are you following a certain set of docs or anything?
Curious why you are trying to create a PaymentMethod in this way?
So we are trying to create a subscription with a card
Overall Card Element is our legacy Element. It still works, but Payment Element is our new Element and our recommended flow.
To create a subscription we require a paymentMethod and I thought this is the correct function to use
Gotcha
After creating the payment. Method I am attaching to the client
In that case you want to follow our integration guide here: https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=elements
then I am creating the subscripton
So in this flow you actually create the Subscription and pass the latest_invoice.payment_intent.client_secret to your frontend to use with Payment Element
Sorry I am confused I do not understand
Before I used the paymentMethodId and I attached to the subscription in order to create the subscription for the sepa
I was expecting to do the same thing with the card
You can go that route if you so desire
It just isn't necessarily the recommended flow.
If you use Payment Element then you can provide the customer the option for both SEPA and Card all in the same Element
Instead of having to deal with multiple flows
I do not understand what is the payment element
Can you be more specfiic and tell me which function I need to use?
I need a paymentMethodId
Thank you a lot!
Did you read through the docs I provided above?
I can't really explain it step by step better than that does.
Please give that a read.
let me take a look
why do i have to create first hte subscription?
without the paymentMethod attached to it
You create it using payment_behavior: default_incomplete
If you want to create the PaymentMethod first then you woudl use the deferred-intent flow: https://stripe.com/docs/payments/accept-a-payment-deferred?platform=web&type=subscription
But really that still creates the Subscription before confirming with the PaymentMethod
If you really want to use Card Element in your current flow then you can do that by creating a Card Element similar to how we show in this sample: https://stripe.com/docs/payments/card-element
Then you would use stripe.createPaymentMethod client-side as you originally discussed
But I highly recommend integrating Payment Element instead
let me check
Sorry I might asking wrong questions due to limited knowledge
At which point do I create a payment method and I am attaching to the subscription
Which flow do you want to use? Card Element or Payment Element?
I will tell you what we did with Sepa.
-create payment Intent
- create confirmSepaDebitSetup
- get paymentMethod id from the confirmSepaDebitSetup
- attach to the subscription the paymentMethod id
and it worked fine
This is why I was expecting similar behavior for the card
Yeah okay that is a lot of extra requests and then you are going to need two separate flows if you do the same thing for card.
Would really recommend just using Payment Element and doing this all in one -- you can support both card and SEPA Debit at the same time with Payment Element
We might require to do refactoring but we are out of time
This is why I ask about the paymentMethod.
if it is feasible
So the flow is:
- create a Subscription server-side using
payment_behavior: default_incompleteand expand thelatest_invoice.payment_intentwhen you do so (https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=elements#create-subscription) - Pass the
latest_invoice.payment_intent.client_secretback to your frontend to render Payment Element (https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=elements#add-the-payment-element-to-your-page) - use
stripe.confirmPayment()(https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=elements#complete-payment) to complete the initial Invoice payment. This will automatically attach the PaymentMethod to the Customer and set it as the default for the Subscription going forward.
That is really all you have to do and will work for both cards and SEPA Debit
Yep unless you want to use Stripe Checkout, which it didn't sound like that was what you are using previously, correct?
you are correct. let me check in more detail
But this will work for future payments?
Because what we are doing is that we want first to validate the card if it is correct etc
we do not save the card information on our db for security reasons
then 2 forms later they activate the subscription
this is why we create a payment Method first. Then we attach it to subscription in the last step. Where the subscription is created
👋 hopping in here since bismark has to head out soon
Hi Karbi
Yes, the flow bismark described is meant to also work for future payments