#WhySoAsync-subscriptions

1 messages · Page 1 of 1 (latest)

hollow linden
#

Hello!

  1. If add an additional level nesting to your expand parameter it should work: xpand: ['latest_invoice.payment_intent.payment_method']
lost wave
#

const activeSubscriptions = await stripe.subscriptions.list({
customer: customerDetails.data[0].id,
expand: ['latest_invoice.payment_intent.payment_method']
});

hollow linden
lost wave
#

i get 404

#

rawType: "invalid_request_error"
requestId: "req_rME7xs96ojI2iu"
statusCode: 400
type: "StripeInvalidRequestError"
status: "error"

hollow linden
#

Hmm, let me check

#

expand: ['data.latest_invoice.payment_intent.payment_method']

lost wave
#

yea it works, i was trying to find the payments methods , the last 4 digits and stuff like that

#

but i can't find them

#

i don't want to make a GET call to payment methods and mutate the subscription array

#

i was courious if i could get them by subscription object

#

and then add/edit/delete payment methods

#

by subscription

hollow linden
lost wave
#

in the subscription object?

#

or i need to make a GET call to payment method

hollow linden
#

No, in the latest_invoice.payment_intent object

#

Expand those fields

lost wave
#

It's null

hollow linden
#

Can you share the ID of that Invoice?

#

My guess it it was a zero amount

#

i.e. trial, discount (no payment needed)

lost wave
#

in_1KZ0hPDmVlmqORBIAbQtnr1U

#

ah.. i think i tried to force try last night

#

to expire

#

lemme create the subscription again one sec

hollow linden
#

Yeah, $0. No there's no Payment Intent on the initial invoice

lost wave
#

Yeah payment intent is coming now

#

one more question

#

can i add more payment intents to the subscription?

#

it will be array instead of object or?

hollow linden
#

There's no direct relationship between a Subscription and Payment Intents

#

They're facilitated through Invoices

#

There's a new Invoice generated for each billing cycle, and the Payment Intent facilitates payment for that invoice if required

lost wave
#

Ah.. so i need to add payment methods to customer if i want to add multiple cards right?

hollow linden
lost wave
#

How can i have 2 different subscriptions and each subscription to have multiple cards

hollow linden
lost wave
#

Is that possible?

hollow linden
lost wave
#

But if i keep only one card per subscription

If i show him the last 4 digits and card type on that subscription and he would have the ability to remove card then i can update subscription on cancel_on_period end until he adds another card?

#

And when he adds another card i can activate it again and it will be invoiced the same as it was before

#

Can i do this from payment methods API only?

hollow linden
#

Generally you'd create a new pm_xxx object via a Setup Intent and then set the default_payment_method field on the Subscription

lost wave
#

Oh okay.
Please tell me if this flow is good.

  1. User buys subscription, i show him the payment_method and last 4 digits from subscriptions.list({})
  2. User deletes his payment_method, i will update the subscription to cancel on period end true, he will not be invoiced anymore.
  3. If he adds another card, i create the payment method through setup intent, get the payment method and update subscription with that payment method while adding cancel on period end false
hollow linden
#

You can't 'delete' a payment method, FYI. The outcome is still the same but it can only be 'detached' (then its not reusable)

lost wave
#

My concern is here

hollow linden
#

Looks good to me! Obviously is it cancels before they add a new card the subscription will have cancelled

lost wave
#

i need to send payment_method to setup intent

#

i need to use PaymentCard from react stripe

#

how do i collect data from frontend with new card?

hollow linden
lost wave
#

Thank you !

hollow linden
#

Sure, np!