#ledevfoufoufou
1 messages · Page 1 of 1 (latest)
Hello, I'm having an issue with my subscription renewals that are processed through webhooks. When a payment for a subscription fails, the subscription is updated, but before it changes to "past_due", an initial webhook marks it as active, which triggers an invoice generation. How can I prevent this?
👋 happy to help
so these are 2 different questions
let's try to tackle them one by one
it's the same issue
ok
what payment_behavior are you using?
https://stripe.com/docs/api/subscriptions/create#create_subscription-payment_behavior
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
i'm using :
$subscription = $stripe->subscriptions->create([
'customer' => $id_stripe,
'items' => [[
'price' => $price_code,
]],
'payment_behavior' => 'default_incomplete',
'payment_settings' => [
'save_default_payment_method' => 'on_subscription',
'payment_method_options' => [
'card' => [
'request_three_d_secure' => 'any'
]
],
'payment_method_types' => ['card']
],
'expand' => ['latest_invoice.payment_intent'],
'coupon' => $coupon_code,
'metadata' => [
'type' => $type,
'reccurence' => $rec,
'email' => $email
]
]);
with stripe.elements
in all cases if there's something to be paid on the first billing_cycle we will generate an invoice
even if it has failed to pay?
It's the customer.subscription.updated event that's causing me a problem. because it's him that I listen to to generate the invoice, and firstly it sends me "active" then "past_due"
yes invoices and payment attempts are two separate entities
and invoices should track the payment attempts
that's not what you should listen to
instead listen to invoice.paid
that's how you are sure that you are providing access when the subscription is getting paid
ok thanks