#arsalan-retry-payment
1 messages ยท Page 1 of 1 (latest)
hmm i'm not sure exactly what you mean by this. can you provide an example of what you expect?
or when you would expect to find something like this?
user's card gets declined for any reason or charge fails, now in the webhook I get charge.failed event, I wanna get details of failure, plus I want to get retry link on which user clicks, and goes to stripe page, and enters card again
let me give you an example
any luck
bear with me, lots of folks here
sure Boss
ah ok
so from the invoice payment failed webhook:
note this is an invoice object: https://stripe.com/docs/api/events/types#event_types-invoice.payment_failed
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
rather, the payload data is an invoice object
so the hosted invoice payment page is available at the hosted_invoice_url attribute:
https://stripe.com/docs/api/invoices/object#invoice_object-hosted_invoice_url
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
but this is not available at charge.failed right ? but on invoice.payment_failed only ?
if the charge is related to an invoice, you can see that in the invoice attribute:
https://stripe.com/docs/api/charges/object#charge_object-invoice
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
so you then retrieve that invoice to get the hosted url:
https://stripe.com/docs/api/invoices/retrieve
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
oh great. thanks Boss. I will implement it.
you're welcome -- thanks for your patience!
so just clearing one thing, that retry option is only for subscription items ie invoice ones ?
also one last question, is there any way of knowing why the card was declined e.g insufficient funds / banned card / wrong card details etc
nope, you can use the hosted invoice page for one-off invoices, too
if the charge failed, that would be specified in the failure code:
https://stripe.com/docs/api/charges/object#charge_object-failure_code
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Understand what decline codes mean and how you can resolve them when a charge is declined.
alright thanks a lot. thats all for now !
np! good luck ๐