#abishek-checkout-subs

1 messages ยท Page 1 of 1 (latest)

upbeat basinBOT
#

Hello! We'll be with you shortly. 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.

hard rain
#

No, that's not something Checkout supports today

hallow wasp
#

we have a cart functionality where a parent can subscribe to a plan for 2 of their kids. We currently allow our customers to use the Customer Portal to manage their plans. If they want to unsubscribe one of their kids, it is currently not possible, unless we create 2 separate subscriptions

#

does it make sense. They can only cancel the whole subscription and not just one

hard rain
#

Gotcha.. The other option would be that you just collect the payment method using the checkout session and then use Subscriptions API directly to create separate subscriptions when the customer wants to checkout from the cart.

Stripe Checkout won't be able to create multiple subscriptions unfortunately.

hallow wasp
#

how would that work? will the checkout session show the final amount to be charged?

hard rain
hallow wasp
#

ok, thank you. i think in this case, the embedded-form would be the ideal way to do from a UX perspective. Does the embedded-form support all the features of Stripe Checkout ? Like Link, enabled Payment methods and other terms and conditions info?

hard rain
hallow wasp
#

thank you

#

a bit confused. I am going through the docs. if I am using the embedded form or hosted checkout to only setup the payment method, the customer gets redirected to the return url, so am not sure what to do next.

#

how do I add the items to the checkout

hard rain
#

Thinking... maybe return URL could be the same URL as the cart page? but since the customer already provided their payment method details, you could hide the embedded checkout form..

#

remember, you'd create the subscriptions separately by calling the API

hallow wasp
#

ok, the reason I ask is because, we have a cart functionality, that may include a couple of one-time items and a couple of membership items in one go. So if the customer adds all the items to the cart and clicks checkout, we launch the embed form and get the payment info as we discussed above. Once they complete adding the payment info, I am assuming, stripe will automatically redirect to the return URL (which would be our intermediate page).

Now I need to get the payment method as shown here (https://docs.stripe.com/payments/save-and-reuse?platform=web&ui=embedded-checkout) and using that payment method we can create multiple subscriptions using the API, but how do we go about purchasing the one-time items?

Let me know if it makes sense

hard rain
#

Ah okay, so mix carts makes it more complicated

hallow wasp
#

thats why we went with Stripe Checkout, but the subscription getting grouped complicated things

hard rain
#

I don't think checkout would be a good fit for your usecase if you need subscriptions to be separate

hallow wasp
#

can you advice how I can do it using the above scenario I discussed without Stripe Checkout

upbeat basinBOT
hard rain
#

The only way I can think of is to use the PaymentIntents API (for one-time payments) + Subscriptions API (for recurring payments) + Stripe Elements (to collect payment method details)

Alternatively, you could build your own UI to handle subscription updates rather than using Customer Portal

hallow wasp
#

ok, at this point building our own UI to handle subscription updates is easier, since we have done all our checkout functionality

#

i have one other question, this is after I saw the UI of customer portal

hard rain
#

sure

upbeat basinBOT
#

abishek-checkout-subs

hallow wasp
#

Actually a couple of questions. The screenshot is from the Customer Portal.

  • Each subscription has an edit payment method functionality. Will updating one update the others also?
  • When I click on the edit payment info button as shown on the screenshot, the URL seems to be specific to the subscriptions payment method and not the payment method in general. How does that work?
hard rain
#

I think it depends on how you create the subscription.

by default we'd use customer's default payment method under customer.invoice_settings.default_payment_method

but if you want to individually assign payment methods to subscription then you can pass the payment method to subscription's default_payment_method parameter
https://docs.stripe.com/api/subscriptions/create#create_subscription-default_payment_method

That sets the payment method on the subscription (and doesnt' use customer's default payment method from invoice_settings)

#

^that also allows you to use a payment method that's attached to a customer (but isn't default)

hallow wasp
#

i am going to use the Stripe Checkout

burnt sandal
#

๐Ÿ‘‹ Stepping in for my teammate! Give me a minute to catch up

hallow wasp
#

sure

burnt sandal
#

If you use Checkout for Subscriptions, we'll automatically create a Customer object and attach the PaymentMethod to the customer. We'll also set that PaymentMethod as the value for the Subscription's default_payment_method

#

If you want to use that PaymentMethod for any future Subscriptions for this Customer, you'll need to update the Customer to set the value of invoice_settings.default_payment_method

hallow wasp
#

if the Stripe Checkout has multiple items, 2 subscriptions and 2 one-off items, will the payment method be available on the checkout session object?

#

since there will be only one payment method for all these items together

burnt sandal
#

If this Customer uses the Portal, they will see the PaymentMethod they saved during Checkout as one of their available PaymentMethods. They can make this their default PaymentMethod, which will set their invoice_settings.default_payment_method

hallow wasp
#

I cannot use the Customer Portal because it has a disadvantage I mentioned in the above conversation, so I have to build our own UI

burnt sandal
#

if the Stripe Checkout has multiple items, 2 subscriptions and 2 one-off items
Not sure I follow this, as a single Checkout Session with multiple recurring items will create a single Subscription

hallow wasp
#

correct

#

so our site allows parents to create subscription for their kids, so assuming if a parent has 2 kids and they add 2 subscriptions to the checkout, then Checkout session combines them into a single subscription with 2 subscription items

#

currently the Customer Portal doesn't have the option to cancel one subscription item from the Subscription

burnt sandal
#

Right, understood

hallow wasp
#

you will have to cancel the whole subscription, which means it cancels both

#

that is why we have to build our own UI to manage subscription and orders

#

which is why I was asking questions regarding the payment method

#

I want to save the payment method info for the Checkout Session, so I can associate it to the total Order

burnt sandal
#

You had me until:

I want to save the payment method info for the Checkout Session, so I can associate it to the total Order

#

As my teammate mentioned, you can't use a Checkout Session in subscription mode to create multiple Subscriptions with one Session

#

You can use a Checkout Session in setup mode if you simply want to collect payment details from a parent and then create their Subscriptions off session/separately

#

Or, as my teammate mentioned, you can work with the PaymentElement

hallow wasp
#

Since we have already completed all the checkout functionality, we were planning to use the Customer Portal, since we cannot use the Customer Portal, we are going to build that part

#

We use the checkout.session.completed webhook trigger

#

once the checkout is completed by the customer

#

we use that to get the cart info and create the order on our end since the payment was successful

burnt sandal
#

Hold on a second. You mentioned you plan on using the PaymentElement instead of Checkout given the limitations with # of Subscriptions and the Portal.

hallow wasp
#

now what we want to do is to get the payment method used for the checkout session on the webhook trigger, so we can store the pm_id and we can use that to allow the customer to update info our own UI

burnt sandal
#

Since you plan on using the PaymentElement, you won't listen for checkout.session.completed since that event will no longer be emitted

hallow wasp
#

that was a suggestion from your other team mate

#

I mentioned that that would be too much effort since the checkout functionality is already implemented

#

our cart functionality with Stripe Checkout is final

#

we are only going to build our own UI instead of the Customer Portal

#

does it make sense till now?

burnt sandal
#

Okay, so you will continue to use Stripe Checkout even though that means parents can only create one Subscription per Session

hallow wasp
#

correct, so on our end, we will provide the option to delete a subscription item and that should solve it

#

we need to build the functionality to update the payment information that was used for the subscription item which is where the other team mate transferred to you ๐Ÿ™‚

#

so, I was asking how I can get the payment method used from the checkout session.

burnt sandal
#

You can look at the Subscription's default_payment_method as Checkout will automatically add the PM used during the Session here

hallow wasp
#

can I use checkout_session.payment_intent.payment_method ? will that be the same ?

hallow wasp
#

i will have to loop through line items to figure out the subscription and then read the default_payment_method. Just trying to see if there is a property that is easier to approach

burnt sandal
hallow wasp
#

else checkout_session.invoice.default_payment_method if it is subscription correct?

burnt sandal
#

checkout.session.completed events for subscription mode Checkout Sessions will have invoice populated, yes. This means you'd have to make a separate get call to retrieve the invoice and expand invoice.payment_intent to get the payment method or you can listen for customer.subscription.updated events which should include default_payment_method

hallow wasp
#

ok, that helps

#

Appreciate the help after all the confusion with the transfer ๐Ÿ™‚

burnt sandal
#

All good! I got a little mixed up after we started talking about the customer portal and what the different buttons/icons do

hallow wasp
#

Thank you for understanding and being polite about it ๐Ÿ™‚ Appreciate your help and time once again

#

take care

burnt sandal
#

you too!