#dragon.frost
1 messages · Page 1 of 1 (latest)
👋 happy to help
invoice.paid is the event to use
you can ignore invoice.payment_succeeded which only fires when the invoice's amount is > 0
is invoice.paid called even when a subscription is paid for with a trial?
so, invoice.payment_succeeded is created when a invoice is craeted with amount > 0 regardless the payment has been made or not?
no the payment has to succeed as well
So for me, the invoice.payment_succeeded is firing after I create a subscription with payment intent. can you please let me know what can be the reason for this
this means that the invoice has an amount > 0 and the payment succeeded
my create subscription object is something like this
const stripeSubscriptionData = {
customer: stripeUser.id,
items: [{ plan: stripePlanId }],
metadata: { id: user._id.toString(), rebuild: true as any },
collection_method: "charge_automatically" as const,
payment_behavior: "default_incomplete" as any,
expand: ["latest_invoice.payment_intent", "pending_setup_intent"],
payment_settings: { save_default_payment_method: "on_subscription" },
{ trial_end: trialExpiration },
{ coupon: stripeCoupon.stripe_id },
};
const stripeSubscription = await stripe.subscriptions.create(
stripeSubscriptionData,
);
I have not moved forward with the purchase on frontend. Just created a subcription intent after selecting a subcription plan. But invoice.payment_succeeded webhook is being called.
Am I missing something?
would you mind sharing the request ID or the subscription ID?
"sub_1Nuq0OAm3EUKVZDoI1byWGmp"
event ID: "evt_1Nuq0PAm3EUKVZDoaDgKVlg3"
another one: "sub_1NupmLAm3EUKVZDoUBnOTl6m"
taking a look
yes this is a bit odd! there's a trial which means that there should be no payment there
I'm still digging
sorry about the delay
so this is a misunderstanding from my side, the only time that invoice.payment_succeeded wouldn't fire is when the invoice is paid out-of-band
What does this mean: invoice is paid out-of-band?
So my previous assumption was correct?
invoice.payment_succeeded is created when a invoice is craeted with amount > 0 regardless the payment has been made or not?
invoice.payment_succeeded is fired whenever an invoice payment succeeds whether it's because the amount is 0 (trial or discount) or a real payment attempt happened and succeeded
So when we create an incomplete subscription with payment_behavior: "default_incomplete" does that count as a real payment attempt even if customer has not gone through the checkout process?
no in that case there's no payment attempt unless the customer already has a invoice_settings.default_payment_method
oh. So if the customer already has a invoice_settings.default_payment_method and I create an incomplete subscription with payment_behavior: "default_incomplete" then the invoice.payment_succeeded can trigger?
if it's a trial yes
if it's not a trial, no, since default_incomplete means we will not try to charge the customer's saved payment method ( we default to creating the subscription incomplete, hence the name)
I am working on an old code base before the paymentIntent, that subscribes to invoice_settings.default_payment_method which event should be appropriate to replace this one?
what's the use case, what does the code rely on that event in order to trigger?
sorry
its invoice.payment_succeeded
what's the use case, what does the code rely on that event in order to trigger?
event after a payment was successfull
then that works, but it's better to use invoice.paid so I'd use that