#ledevfoufoufou

1 messages · Page 1 of 1 (latest)

hollow shadowBOT
inner owl
#

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?

shell lynx
#

👋 happy to help

#

so these are 2 different questions

#

let's try to tackle them one by one

inner owl
#

it's the same issue

shell lynx
#

ok

inner owl
#

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

shell lynx
#

in all cases if there's something to be paid on the first billing_cycle we will generate an invoice

inner owl
#

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"

shell lynx
#

and invoices should track the payment attempts

shell lynx
#

instead listen to invoice.paid

#

that's how you are sure that you are providing access when the subscription is getting paid

inner owl
#

ok thanks

hollow shadowBOT