#peform_api
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1488837905542549635
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
I'd guess you've leveraging a webhook for this? e.g. payment fails, you're notified, do thing?
Yes that is the plan, when I recieve payment failed webhook i plan on contacting the user telling them what happened
for subscriptions btw, so if a subscription renewal payment fails ^
Yeah that's what we'd recommend. Two options to test this:
- (Easiest) Use the CLI to 'trigger' an event, like
invoice.payment_failed - Create a subscription in your integration and attach a card that will fail payment, and subsequent events fired
thank you
How would I put in a fake card that will fail the payment in development mode? If I put in fake card details it says "invalid card". Previously I have been using the stripe test card with value 4242 4242 4242 4242, but this one does not fail.
You'd use a test card that will simulate a decline: https://docs.stripe.com/testing#declined-payments
amazing ty ๐
I am struggling to update the subscriptions card details, if i try to update the card it says "card has insufficient funds" so the payment decline webhook (for subscriptions) wont be sent, as I am unable to change the cards details for the next payment
Its not time for the subscription to be charged yet.
Yeah, it's because that surface (customer portal) is likely running an authorisation on the card to check its valid before it attaches it
The scenario you likely want to simulate is not really possible to do in our UIs, you'd need to do it programmatically (e.g. write code to make API requests that create a sub with a valid card, update the card to be a decline card, advance the test clock time, next invoice payment fails)
That's facilitated via a test clock: https://docs.stripe.com/billing/testing/test-clocks
As I said, easier to use the CLI
Okay thank you
when using the cli stripe trigger invoice.payment_failed, is it possible to tell the event to use a specific subscription id?
I do see its possible to link a customer with flags, but i dont see anything for subscriptions
Hmm, I think you'd need to create your own fixture: https://docs.stripe.com/cli/fixtures
The invoice.payment_failed fixture doesn't use a subscription: https://github.com/stripe/stripe-cli/blob/master/pkg/fixtures/triggers/invoice.payment_failed.json
So if you want it tied to a specific sub, you'll need to create a fixture file that does that full sequence (customer -> attach failing PM -> price -> sub)
okay, thank you very much ๐
This should work:
"_meta": {
"template_version": 0
},
"fixtures": [
{
"name": "customer",
"path": "/v1/customers",
"method": "post",
"params": {
"description": "(created by Stripe CLI)"
}
},
{
"name": "payment_method",
"path": "/v1/payment_methods/pm_card_chargeCustomerFail/attach",
"method": "post",
"params": {
"customer": "${customer:id}"
}
},
{
"name": "customer_update",
"path": "/v1/customers/${customer:id}",
"method": "post",
"params": {
"invoice_settings": {
"default_payment_method": "${payment_method:id}"
}
}
},
{
"name": "price",
"path": "/v1/prices",
"method": "post",
"params": {
"unit_amount": 2000,
"currency": "usd",
"recurring": {
"interval": "month"
},
"product_data": {
"name": "CLI test product"
}
}
},
{
"name": "subscription",
"path": "/v1/subscriptions",
"method": "post",
"params": {
"customer": "${customer:id}",
"items": [
{
"price": "${price:id}"
}
],
"default_payment_method": "${payment_method:id}",
"description": "(created by Stripe CLI)"
}
}
]
}