#Naveed | Web3Auth

1 messages · Page 1 of 1 (latest)

primal prawnBOT
errant cedar
austere turtle
errant cedar
#

yep

austere turtle
#

OK ill give that a try!

On a similar note though, what about after doing that user wishes to upgrade further from growth -> scale?

Case 1 was:

  • no credit card, has subscription
    Now Case 2:
  • has credit card, has subscription

In case 2, user has a choice. Either
a) use pre-existing card or
b) add new card

I assume that for a, I can use pending updates again, but this time add payment method as part of subscription item params.

params := &stripe.SubscriptionParams{
  Items: []*stripe.SubscriptionItemsParams{
    {
      ID:   stripe.String(subscription.Items.Data[0].ID),
      Price: stripe.String("price_CBb6IXqvTLXp3f"),
    },
  },
  PaymentBehavior:   stripe.String(string(stripe.SubscriptionPaymentBehaviorPendingIfIncomplete)),
  ProrationBehavior: stripe.String(string(stripe.SubscriptionProrationBehaviorAlwaysInvoice)),
}

As for b, I will just have to do exactly what you'd mentioned above.

errant cedar
#

for b, it's going to be slightly different. You should collect the new card details up front and attach it to the customer first.

#

then depending on where you set the default_payment_method - you would update it either on the Subscription or on the Customer

austere turtle
#

Hmm why is that? isn't b similar to Case 1: no card, has sub

#

I will probably set subscriptions to charge default payment method, and any cards that get attached will be set to default

#

maybe it will make things easier

errant cedar
#

doesn't b already have an existing card set as the default payment method on the customer [0] or subscription?

austere turtle
#

hmm seems like it'll be a bit complex to make it into one atomic flow

errant cedar
#

hrm, i guess another way about it is to identify the card to use upfront, and/or collect the new payment details first : https://stripe.com/docs/payments/save-and-reuse
Then perform the update on your backend by setting default_payment_method

austere turtle
#

so using set up intents u mean?

errant cedar
#

yep

#

so it would be like :

  1. identify the existing PaymentMethod to use, or create new PaymentMethod to use
  2. create the update to the subscription and make sure to also update the default payment method on the subscription or on the customer with the PaymentMethod (if required)
austere turtle
#

I see, from user's perspective probably they wouldn't know the difference. So it may be like

  1. set up card (if no payment method found on customer)
  2. Either update sub's payment method or update customer invoice settings.default payment method (whichever one I've chosen)
  3. Update subscription price items
errant cedar
#

yup, that's right!

austere turtle
#

ok ill try it out and see if it can handle this matrix of scenarios.

Is there a way to continue the same thread later on as this might take time to evaluate?

errant cedar