#maha-Subscription
1 messages ยท Page 1 of 1 (latest)
So basically, lets say there is a card that won't error out or require 3D secure when making the payment (payment needs to be made since the customer may be upgrading to a more expensive price). This payment would transition directly to the paid state instead of transitioning to pending state. I don't want to do that, since I want to fetch the client_secret for the payment_intent of the pending update invoice and then confirm the payment intent over on client side
Basically without being able to do so, I won't be able to fetch client secret when initializing stripe payment element for the payment since the payment intent would already have been confirmed over on the server side
In short, I would like to always confirm the payment intent over on client side
@trail perch
Got it, so you want your customer to confirm the upgrade on the client side, am I right?
Yupp
Great. I'll suggest you to use Customer Portal to allow your customer to manage the subscription upgrade (https://stripe.com/docs/billing/subscriptions/integrating-customer-portal)
You can generate a portal link and send to your customer where they can choose what subscription they want to upgrade to, and confirm the payment in the page.
Yes I understand that the customer portal would be a good solution to this, but would there be another way to do this via API calls?
We unfortunately may not be able to follow a redirect based approach
OK, you can listen to invoice.created, and turn auto_advance off so that your customer won't be charged automatically https://stripe.com/docs/api/invoices/update?lang=curl#update_invoice-auto_advance
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Thanks, I'll try doing this
https://stripe.com/docs/billing/subscriptions/upgrade-downgrade#changing
it says here that stripe would try to pay the invoice immediately if its not the same billing cycle...the thing with auto_advance that you mention should work, but what if we receive the invoice.created webhook a bit after the payment has been attempted (this is possible due to network delays?)
Stripe will only attempt the payment when the invoice is finalized.
yes and wouldn't it be finalized in this case immediately after I attempt to update the subscription?
invoice would get created and then immediately finalized (in case billing period of the updated price is different from the current price)
Here's how it works
- you update the subscription
- a invoice is generated and you'll receive
invoice.createdevent - set the invoice's
auto_advanceto false so Stripe won't charge the customer automatically when the invoice is finalized.
But there is not going to much of a gap between the invoice.created and invoice.finalized events...right?
What gap do you mean?
Since stripe is almost immediately gonna attempt to finalize the invoice...isn't it possible that the invoice is finalized before I receive the webhook?
by gap I mean the amount of time between the creation and finalization of the invoice
since the docs say that the payment is attempted immediately...I would assume that the update invoice would get created and then be finalized right away
๐ stepping in for Jack and gimme a few mins to catch up
sure
Ok so about the auto_advance approach that Jack suggested above...it doesn't work precisely because the invoice is already paid when I receive the webhook
That's what I suppose. To clarify we are talking about interval change, correct? Monthly to Yearly
yes
You're right, it's attempted automatically. Let me look around to see if there is some convenience parameter
But taking a step back why would you need to intercept this Invoice? You already collected your customer payment info, so you can just charge them right away
Stripe build the API to maximize your revenue, so we attempt immediately since we think we can
like lets say a customer has a bunch of payment methods on stripe due to past payments. now, they wanna upgrade to a new plan but they want to use a new card. Now to use a new card with this payment, it would be ideal that a payment element could be created using the payment intent of the update
but I can't use the payment intents client_secret since the payment gets immediately attempted and the invoice gets finalized
Sounds like you want to let your customer specify which card to use
yes
before making the change
yes
we basically have it such that they could use any of their existing cards or add a new card
we were previously using the tokens api so it wasn't an issue since no client secret is required in that case...but obviously we couldn't keep using it since its outdated and doesn't support additional factor authentication
Ok I found it
set payment_behavior to default_incomplete
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I just tested it. It will stop the Invoice to be paid, leave at "Open" and its PaymentIntent at unconfirmed
But wouldn't the subscription update be applied in this case?
Like what if the payment later fails..would I need to roll back the update?
The Sub will remain in "Past Due" until that PI is confirmed
is there a way to not update the sub until the PI has been confirmed?
kinda like with pending_if_incomplete
but without updating immediately
basically:
- user should be able to choose a card when making payment for subscription update
- the update should only apply if the payment is successful
- in case the payment is not successful...the subscription continues as it is
If I understand correctly, you want the Sub to be completely untouched?
In that case I think the only feasible solution would be, pre-collect the new PaymentMethod then making the Subscription change
You can collect via a SetupIntent/PaymentElement. After it's confirmed, extract SetupIntent's payment method and set back as default payment method for the subscription
and make the change
but then what if its a card that always requires authentication? customers would first authentication when adding the card and then when making the change
PaymentElement would handle the 3D Secure authentication for you
Yes but doing what you suggested would split the flow into two, right?
- Collecting the payment info using setup intent
- changing plan by extracting payment method from the confirmed setup intent
but isnt it a possibility that the customer needs to authenticate their card twice (once when adding it using setup intent and then when changing plan)
it may affect the user experience?
especially since there are cards that always require auth
ideal flow would be to only have the user authenticate their card once (either while making the payment or when adding the card using setup intent)
No I don't think so. SetupIntent is an agreement to charge later, including authentication. When you make the Subscription change it shouldn't ask for authentication again
hmmm alright, I'll test it
I just tested this with 4000002500003155 this test card (authenticate unless setup) and the invoice wasn
wasn't paid
card was created using setup_intent
Invoice Id plz!
Ah
After you confirm the setup intent, take the pm and set into the Subscription
then make the change normally
And don't set payment_behavior to default_incomplete
in_1KrGTLKHqIuz5QBfgdePZm1D
payment_behvaiour is set to pending_if_incomplete
i basically made the pm the default pm before upgrading the subscription
also would this card 4000002760003184 (test card that needs to be authenticated for all transactions) work with the above approach
https://stripe.com/docs/payments/save-and-reuse ok according to this, there are cards that will require authentication after being initially setup...essentially requiring authentication once for the payment and once for the setup
hmmm
You tried multiple times with different cards, right?
Yeah cards behaves differently
sorry your concern was correct
hmmm yeah I guess I'll need to think about a workaround
there are cards that required authentication every single time
yes