#john_dev_

1 messages · Page 1 of 1 (latest)

graceful nicheBOT
woeful mica
#

Hi there

#

Are you following a certain set of docs or anything?

#

Curious why you are trying to create a PaymentMethod in this way?

gentle anchor
#

So we are trying to create a subscription with a card

woeful mica
#

Overall Card Element is our legacy Element. It still works, but Payment Element is our new Element and our recommended flow.

gentle anchor
#

To create a subscription we require a paymentMethod and I thought this is the correct function to use

woeful mica
#

Gotcha

gentle anchor
#

After creating the payment. Method I am attaching to the client

woeful mica
gentle anchor
#

then I am creating the subscripton

woeful mica
#

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

gentle anchor
#

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

woeful mica
#

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

gentle anchor
#

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!

woeful mica
#

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.

gentle anchor
#

let me take a look

#

why do i have to create first hte subscription?

#

without the paymentMethod attached to it

woeful mica
#

You create it using payment_behavior: default_incomplete

gentle anchor
#

Isn't there another way to do it

#

?

#

By just creating a payment Method first?

woeful mica
#

But really that still creates the Subscription before confirming with the PaymentMethod

#

Then you would use stripe.createPaymentMethod client-side as you originally discussed

#

But I highly recommend integrating Payment Element instead

gentle anchor
#

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

woeful mica
#

Which flow do you want to use? Card Element or Payment Element?

gentle anchor
#

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

woeful mica
#

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

gentle anchor
#

We might require to do refactoring but we are out of time

#

This is why I ask about the paymentMethod.
if it is feasible

woeful mica
#

So the flow is:

  1. create a Subscription server-side using payment_behavior: default_incomplete and expand the latest_invoice.payment_intent when you do so (https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=elements#create-subscription)
  2. Pass the latest_invoice.payment_intent.client_secret back to your frontend to render Payment Element (https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=elements#add-the-payment-element-to-your-page)
  3. 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

gentle anchor
#

let me check

#

Quick question.
We are talking about custom implementation correct?

woeful mica
#

Yep unless you want to use Stripe Checkout, which it didn't sound like that was what you are using previously, correct?

gentle anchor
#

you are correct. let me check in more detail

graceful nicheBOT
gentle anchor
#

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

oak linden
#

👋 hopping in here since bismark has to head out soon

gentle anchor
#

Hi Karbi

oak linden
#

Yes, the flow bismark described is meant to also work for future payments