#Eranga
1 messages ยท Page 1 of 1 (latest)
Hello @echo rune! let me test something and get back to you
@echo rune yep it's possible. You would need to get the underlying PaymentIntent for that particular invoice of the subscription
Could you guide me through the workflow you did?
assuming you're using Stripe Elements, and you have a Subscription with an unpaid Invoice.
-
get client_secret [0] of the PaymentIntent for that Invoice
-
Using Stripe Elements and stripe.confirmCardPayment, you can collect the customer card details and charge the card for that PaymentIntent.
[0] https://stripe.com/docs/api/payment_intents/object#payment_intent_object-client_secret
Wow... I am not using Stripe Elements for now
how were you planning to charge the user when they added a new card?
I didn't explore Stripe elements. I am going to create a customer, and a subscription using API. Then I am going to show the user the customer portal to add a credit card. Then I wanted to charge the customer as soon as they entered the card details
And that is where I don't know how to trigger a payment for the customer
@echo rune the use case you just mentioned seems a bit different from the original use case - Originally, it was about when a recurring payment fails. This recent scenario is about charging a customer when they first sign up for a subscription
Yes, sorry about the confusion. So let's say I have created a customer and the subscription in Stripe using the API. Assume the customer have a credit card setup as payment source as well.
One day the payment fails. I want to know how can I ask the customer to add a payment source and charge immediately when the user added it ๐
I feel there are a couple of options :
you can leave it to Stripe to send a reminder. Stripe will send an email reminder to the customer to update their billing info if a recurring payment fails. I'm not 100% certain if the new card will be charged immediately once it's been provided - you'd have to test this out. In any case though, if you've configured the subscriptions to retry if payments fail, it'll automatically retry eventually
the other option is like what i mentioned - use Stripe Elements. You can probably show this immediately upon customer login to your app
Otherwise like what you mentioned, you can probably also redirect the user to the Customer Portal to update their card details. I'm not sure if it'll charge immediately either, but again, if you've configured automatic retries, if the limit for retries hasn't been reached, it should work out eventually
I'm not 100% certain if the new card will be charged immediately once it's been provided
This doesn't happen
I mean it will not try to charge immediately
ah, sorry to hear that then, i guess it looks like using Stripe Elements might be the way to go then
if you've configured the subscriptions to retry if payments fail, it'll automatically retry eventually
We have enabled this feature but we won't know when the retry will happen. So we need a way to unblock the user in this case. This is what I am trying to find out
I haven't worked with Stripe Elements
But in any case, this is also documented in API documentation, right?
give me a sec to find the page, my connection is a bit slow today
No hurry at all. Thank you for your support
the page still isn't loading for me, but it should be this one : https://stripe.com/docs/payments/integration-builder
It's loading for me
something i want to add on, if you decide to go with this, remember to include setup_future_usage : 'off_session' when you confirm the card payment, so that the card will be automatically attached to the customer
and after that, you would need to update this parameter on the customer : https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method to that recent card
Great, just what I needed. I think I have some research and tests to do now with the information you provided.
great! let us know if you run into any issues!
@echo rune i think what i said is briefly mentioned in these two docs as well, in case they're useful :
https://stripe.com/docs/billing/subscriptions/overview#requires-payment-method
https://stripe.com/docs/billing/subscriptions/overview#build-your-own-handling-for-recurring-charge-failures
I'll look into these as well. Thanks again ๐
@echo rune just curious, why is important to charge the customer immediately and not eventually?
Do you restrict their access until their subscription payment is in good standing?
Yes, we need to restrict them from doing any actions until they complete the payment.
In our scenario, we allow the user to create the subscription without any payment information. In the beginning, it will be on trial for about 14 days. We allow the user to enter their payment info in our system (using Stripe customer portal) in the trial period.
When the trial is finished and the Stripe tried to charge the customer, if the customer does not have a payment source we don't want to allow them to use the app unless they add a proper payment source and we are able to charge immediately
Ok so in your case, if you wait for their subscription to be eventually charged, you'd have the scenario where they've:
- added a new card
- but their subscription payment hasn't been made
- so they'd still be restricted in the app
Exactly, we don't want the customer to feel like, Hey I added the card and why am I still blocked scenario
Yeah makes sense, thats a crappy experience
I ask because I wrote some code recently to handle updating the customer's default payment method when they add a new card
Initially I was unaware it was a two step process, I forgot that adding a card is only step one, step two is the customer update call
I ask because I wrote some code recently to handle updating the customer's default payment method when they add a new card
Yes, I asked about this in an earlier discussion
Apparently, Stripe doesn't make it default
This third step seems like a natural next thing to check for
We have to manually call the API
Yep yep, thanks for sharing more info, appreciate it
No worries. Happy to share the knowledge ๐ผ
Im guessing once the customer has that fresh valid payment method attached, you could look up the invoice of that subscription and call invoices.pay
@valid grove that would work right?
if you confirm the underlying PaymentIntent using stripe.confirmCardPayment, the corresponding invoice will automatically be marked as paid as well
But if you just add a new payment method and set is as the customers default, that wouldn't update the invoice right?
if you just add a new payment method and set it as the customer's default, no it wouldn't immediately attempt to charge. If you have automatic retries, then when the Stripe attempts payment again, it would automatically attempt to charge the new payment method set as the customer's default
Ok thanks for clarifying
So same as before, Stripe will eventually mark the invoice as paid when the next payment attempt kicks in, but in between that, the customer could have added a new valid payment method but be restricted from using the app because feature access is tied to a subscription being in good standing