#praine-charges

1 messages ยท Page 1 of 1 (latest)

modest cargo
#

@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

spice maple
#

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

modest cargo
#

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

spice maple
#

yes, that's what we want to do. and if the charge fails, they remain locked out of their account.

modest cargo
spice maple
#

i've done that bit

#

i've managed to change the default payment method

modest cargo
#

sounds like you're all good to go then

spice maple
#

not really because the failed charge doesn't get re-tried immediately

modest cargo
#

you need to manually charge it

spice maple
#

so we need to expedite that failed charge

#

can you point me in the right direction for the api documentation

modest cargo
spice maple
#

ok i'll give it a go

#

thanks

modest cargo
#

feel free to reach out again if you're having trouble ๐Ÿ˜„

spice maple
#

๐Ÿ‘

#

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

modest cargo
#

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

spice maple
#

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?

modest cargo
spice maple
#

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

modest cargo
#

the only additional step, is whether or not you run the confirm payment intent request

spice maple
#

right

modest cargo
#

you're going to need to add the logic to determine if there is a outstanding payment

spice maple
#

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

modest cargo
#

@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!

winged tendon
#

@spice maple hello, I will take over. Let me catch up

spice maple
#

orakaro, thanks

winged tendon
#

Hello @spice maple , I am not following the "outstanding payments". What are you referring as an outstanding payment?

spice maple
#

when a card declines a payment

#

because it cannot be charged

#

a rejected payment

winged tendon
#

okie

#

So you want to know how to detect a rejected payment?

spice maple
#

yes

#

and then retry it immediately

winged tendon
#

How are you creating a PaymentIntent? Isn't the result of that API call telling you the authorization result?

spice maple
#

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

leaden tartan
#

indeed it does not

spice maple
#

so we need to trigger a new attempt on failed charges

#

before we allow them access to the app again

leaden tartan
#

then you call the same API you use to charge the card, just again, it's all code you write

spice maple
#

we are not charging the card right now

#

it's all being done by stripe automatically

leaden tartan
#

so you use Subscriptions?

spice maple
#

yes

leaden tartan
#

then you call invoice.pay

spice maple
#

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?

leaden tartan
#

it will charge the invoice you tell us to charge

spice maple
#

ok

#

so i need to find the failed charge invoice

#

how would I do that?

leaden tartan
#

you need to keep track of what subscriptions and invoice payments failed

#

and then you retry them

spice maple
#

so I can pull a list of invoices and filter it by failed charges

#

then re-attempt the failed ones?

leaden tartan
#

yes

spice maple
#

ok thanks

#

i will give it a go

spice maple
#

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?

winged tendon
#

Invoice should have "status"

spice maple
#

yes, status "open"

#

also "paid" -> false

#

thanks

#

what about the reason for payment failure?

leaden tartan
#

that's part of the charge object