#dragon.frost

1 messages · Page 1 of 1 (latest)

white jackalBOT
rain elk
#

👋 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

north girder
#

is invoice.paid called even when a subscription is paid for with a trial?

rain elk
#

yes

north girder
#

so, invoice.payment_succeeded is created when a invoice is craeted with amount > 0 regardless the payment has been made or not?

rain elk
#

no the payment has to succeed as well

north girder
#

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

rain elk
#

this means that the invoice has an amount > 0 and the payment succeeded

north girder
#

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?

rain elk
#

would you mind sharing the request ID or the subscription ID?

north girder
#

"sub_1Nuq0OAm3EUKVZDoI1byWGmp"

#

event ID: "evt_1Nuq0PAm3EUKVZDoaDgKVlg3"

#

another one: "sub_1NupmLAm3EUKVZDoUBnOTl6m"

rain elk
#

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

rain elk
#

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

north girder
#

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?

rain elk
north girder
#

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?

rain elk
#

no in that case there's no payment attempt unless the customer already has a invoice_settings.default_payment_method

north girder
#

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?

white jackalBOT
cinder forum
#

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)

north girder
#

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?

cinder forum
#

what's the use case, what does the code rely on that event in order to trigger?

north girder
#

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

cinder forum
#

then that works, but it's better to use invoice.paid so I'd use that