#.suryamani

1 messages · Page 1 of 1 (latest)

wooden vergeBOT
slim light
#

Hi there!

#

How can I help?

twin verge
#

4000000000000341 i will use this card for subscribe, when i click subscribe it show this card is declined but in webhook event it trigger customer.subscription.created event

#

But in Stripe cli Command prompt it shows invoice.payment_failed event

slim light
#

How are you create Subscriptions? With Checkout Session, the Subscription endpoint, something else?

twin verge
#

I'm using graduation pricing

slim light
#

But how do you create the Subscription? Which API do you use?

#

Can you share an example Subscription ID (sub_xxx)?

twin verge
#

sub_1NuT7pLabf7E4J4FX3yJZwRG

slim light
#

4000000000000341 i will use this card for subscribe, when i click subscribe it show this card is declined but in webhook event it trigger customer.subscription.created event
But to me all of this seems normal. Can you clarify what is the issue here?

twin verge
#

if the payment is failure when subscribe which event event will trigger in webhook events

slim light
#

For subscriptions payment failures, the main event is invoice.payment_failed.

twin verge
#

but for me In webhook event API customer.subscription.created event will trigger

slim light
#

The Checkout Session had to create a Subscription. It's just that the first payment failed. So it's expected.

#

You can ignore the customer.subscription.created event since you are using Checkout Session

#

Instead listen to checkout.session.completed, to know when the Subscription is created with the first payment successful.

twin verge
#

I'm testing the sequence for email generate using webhook events. So, I test like Enter card details and click subscribe if I enter wrong details the payment will fail. My question is on that time which event will trigger?

slim light
#

The best way is to try this yourself, and look at all the events in https://dashboard.stripe.com/events
However I don't understand why you do all of this? If you are using Checkout Session to create Subscription, there are only one event you should listen to: checkout.session.completed. And then to monitor Subscriptions you can listen to invoice.paid and invoice.payment_failed. That's it. Everything else you can ignore.

twin verge
#

I'm using pricing table

slim light
#

It's the same, you should listen to checkout.session.completed and ignore almost everything else.

twin verge
#

First thing is I will insert a breakpoint in Webhook evnent API method and In command prompt i will run stripe.exe , stripe login and stripe listen --forward-to https://localhost:7150/api/Stripe/WebhookEvent these commands. Then If i will subscribe it hit the breakpoint and the event customer.subscription.created is trigger, or if i will cancel subscription it will hit the breakpoint and the event customer.subscription.deleted is trigger, or if i will upgrade or downgrade plan it will hit the breakpoint and the event customer.subscription.updated is trigger like that when the payment is failed it will hit the breakpoint but the event invoice.payment_failed is not trigger

slim light
#

Can you clarify: what are you trying to do, and what's the issue exactly?

twin verge
#

I'm testing in local the events are correctly trigger or not

#

When i try to subscribe customer.subscription.created event is trigger, when i try to cancel customer.subscription.deleted event is trigger, but when the card detail is wrong then invoice.payment_failed event is not trigger

#

How will i test in local for payment failed and for this event invoice.payment_failed?

slim light
#

I just tried using this test card 4000000000000341 in a Chekcout Session, and I do get a invoice.payment_failed event.

#

But again you shouldn't listen to that event in this case. The Checkout Session will take care of telling the user to try a new card. There's nothing to do on your end.

twin verge
#

No i need to send mail when the payment is failed so only I'm asking to you When invoice.payment_failed this event is triggered the Email will go to customer automatically

restive granite
#

Hi! I'm taking over from my colleague. Please, give me a moment to catch up.

twin verge
#

ok

restive granite
twin verge
#

No when the payment is failed i need to send email to my customers

restive granite
twin verge
#

Yes I'm testing Email in my local

restive granite
#

Is it working?

twin verge
#

other events are correctly working only payment failed is not working

#

Can you explain me to how to test payment failed in local

restive granite
#

What do you mean by "not working" exactly?
What steps are you following?

twin verge
#

I have stripe_Exe file in my file manager then open the file path in command prompt and run these commands 1.stripe.exe 2. stripe login 3. stripe listen --forward-to https://localhost:7150/api/Stripe/WebhookEvent after run these commands I will insert breakpoint to Wenhooks API method and i will try to subscribe it will hit the breakpoint and i will check the event

restive granite
#

Is this setup working for other events?

twin verge
#

Yes

#

When i try to subscribe customer.subscription.created event is trigger, when i try to cancel customer.subscription.deleted event is trigger, but when the card detail is wrong then invoice.payment_failed event is not trigger

restive granite
#

So the problem is not in the setup.

#

Could you please share the PaymentIntent/Subscription ID pi_xxx sub_xxx that you're making fail?

twin verge
#

sub_1NuT7pLabf7E4J4FX3yJZwRG

restive granite
#

The payment for this Subscription was successful.

twin verge
#

Sorry When the subscription is completed then only id will store in our database

restive granite
#

I thought you're trying to get the invoice.payment_failed event.

twin verge
#

Yes

#

For testing purpose

restive granite
#

What steps are you following to trigger an invoice.payment_failed event?

twin verge
#

Enter the declined card or insufficient amount card and click subscribe but it shows error in subscribe page and that same time it will hit the breakpoint in API but it will trigger the customer.subscription.created event

restive granite
#

Have you tried this? Does this work? Why is the Subscription crated successfully then?

twin verge
#

I don't know that why I'm asking you

restive granite
#

Could you please share a screen recording of your process, as I am not following.

twin verge
#

ok wait

restive granite
#

Sorry, I only see one window in this recording.

twin verge
#

sorry i will resend

wooden vergeBOT
twin verge
chilly mirage
#

Hey! Taking over for my colleague. Let me catch up.

twin verge
#

Did you see this video?

chilly mirage
#

No I can't open them

#

Cna you please summarize your latest follow up question ?

twin verge
#

When i try to subscribe customer.subscription.created event is trigger, when i try to cancel customer.subscription.deleted event is trigger, but when the card detail is wrong then invoice.payment_failed event is not trigger

chilly mirage
#

Can you share the Subscipriton Id ?

twin verge
#

No when the subscription is completed then only subscription I'd will generate

chilly mirage
#

but when the card detail is wrong
Then the failure you are seeing, is a client side validation maybe

#

what card tests are you using ?

twin verge
#

I can't complete the subscription. I'm testing payment failed or trying to trigger invoice.payment.failed

chilly mirage
#

What is the test card you are using?

twin verge
#

4000000000000341

chilly mirage
#

What guide are you following for building a subscription integration with Stripe ?

twin verge
#

I'm testing in my local to send separate emails for seperate events of webhook

#

I will record what should i do to testing

#

I will send that videos please see that

chilly mirage
#

Let's focus on building the integration first correctly

#

No we don't need a video for now.

#

Could you please describe enumerate the API calls you are doing ?

twin verge
#

I'm using webhooks event API

chilly mirage
#

What API?

#

ok that's the webhook handler

twin verge
chilly mirage
#

and what event you want to consume ?

twin verge
#

InvoicePaymentFailed

chilly mirage
#

try this in your terminal:
stripe trigger invoice.payment_failed

twin verge
#

I need to test to send mail by trigger this event when subscribe payment failed

chilly mirage
#

Ok, now what about your Stripe Integration ?

#

How you are accepting payment ?

twin verge
#

credit card

chilly mirage
#

You are using Stripe Element or Checkout ?

twin verge
#

graduation pricing table

chilly mirage
#

Try this card: 4000000000000002

twin verge
chilly mirage
#

Ah I see what you want to do

#

invoice.payment_failed is generated for a recurring payment

#

and not the first time

#

You need to create a Subscription first time with a valid payment

#

and test clock

#

After the first attempt

#

you update the Subscirption's default payment method with this payment pm_card_visa_chargeDeclined

#

and then advice time to the next period

twin verge
#

If im trying to paying with wrong card on second time then it will trigger invoice.payment failed, am i right?

chilly mirage
#

yes

twin verge
#

"customer.subscription.pending_update_expired" I get this event when change plan using 4000000000000341 this card

#

Can you explain about this event?

chilly mirage
#

can you share that eventId ?

twin verge
#

customer.subscription.pending_update_expired

chilly mirage
#

I meant the eventId evt_1234

twin verge
#

"evt_1NyCHXLabf7E4J4FbTpsD7Tg"

chilly mirage
#

here is the event you are looking for evt_1NyCHYLabf7E4J4FEyCwDmnW

wooden vergeBOT