#praine-charges
1 messages ยท Page 1 of 1 (latest)
@spice maple what's the charge for though? Is it for a subscription? or a single time payment?
well, in any case, it's possible for both, you would simply need to implement the necessary logic
it's for subscriptions
In our case we have a "premium until" date on our system
This date is updated every time a card is successfully charged
the problem is that updating the customers card is not sufficient
we also need to immediately retry the failed charge
otherwise they will still be locked out of their account
ah that's fine, so for a subscription, there's also an underlying invoice and payment intent, so you would just need to charge the card for the underlying payment intent of that particular unpaid invoice
yes, that's what we want to do. and if the charge fails, they remain locked out of their account.
one point i'd want to highlight is that you would want to remember to set invoice_settings.default_payment_method [0] after collecting the new card details
[0] https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method
sounds like you're all good to go then
not really because the failed charge doesn't get re-tried immediately
you need to manually charge it
so we need to expedite that failed charge
can you point me in the right direction for the api documentation
probably this bit : https://stripe.com/docs/api/payment_intents/confirm
feel free to reach out again if you're having trouble ๐
๐
hey
this situation is quite hard to test
is there any way to simulate a failed charge?
also..
what about the case where a customer simply wants to change their card
and there are no outstanding charges
use this test card : 4000000000000341 -> Attaching this card to a Customer object succeeds, but attempts to charge the customer fail.
so attach the card to a customer, then create a new subscription on the customer
payment intent confirmation.. how does it work? if there are outstanding charges, it will attempt to retry them, but if there are no outstanding charges, it will simply return success?
@spice maple then you would simply add the card to the customer using a setup intent : https://stripe.com/docs/payments/save-and-reuse
we want to use the same flow for changing cards .. whether this is initiated by a customer or is the result of a failed charge
the only additional step, is whether or not you run the confirm payment intent request
right
you're going to need to add the logic to determine if there is a outstanding payment
so i would have to detect outstanding payments and then run paymentintent confirm, or does paymentintent confirm perform this check itself?
ah
jinx
ok
can you point me in the right direction for the api call to detect outstanding payments
@spice maple sorry, i'm going to need to step away for a bit, someone else will be following up on your question here. Just give them a while to catch up on things!
@spice maple hello, I will take over. Let me catch up
orakaro, thanks
Hello @spice maple , I am not following the "outstanding payments". What are you referring as an outstanding payment?
How are you creating a PaymentIntent? Isn't the result of that API call telling you the authorization result?
first, the customer sets up a subscription using stripe checkout
but weeks or months later
the card might reject the payment
due to insufficient funds or whatever
and if this happens
we lock them out of the app
until they update their payment method
but updating the payment method does not trigger a new attempt on failed charges
indeed it does not
so we need to trigger a new attempt on failed charges
before we allow them access to the app again
then you call the same API you use to charge the card, just again, it's all code you write
so you use Subscriptions?
yes
will that tell us whether the payment was successful?
will that only charge where there are outstanding failed charges?
or will it charge in all cases?
it will charge the invoice you tell us to charge
you need to keep track of what subscriptions and invoice payments failed
for example you could use https://stripe.com/docs/api/invoices/list#list_invoices-subscription to get the recent invoices for a given customer
and then you retry them
so I can pull a list of invoices and filter it by failed charges
then re-attempt the failed ones?
yes
on the list of invoices
is there an easy way to tell if the payment failed?
i can look at "amount_due" and "amount_paid"
and see the discrepancy
but is there another property?
Invoice should have "status"
yes, status "open"
also "paid" -> false
thanks
what about the reason for payment failure?
that's part of the charge object