#krishna-awate_webhooks
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1406985927955447842
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
hi there!
Hello sir.
can you share more details about what you are trying to do exactly?
Im using invoice.payment_succeeded webhook to update my payment status after successful transaction.
For one time payment and recurring also.
I want below data in that webhook.
- Current cycle start date & Next due date.
- Subscription start & end date
- Paid cycle
- Total Cycel
- Remaining cycle.
and what's your question/issue?
I am nto getting required data in webhook event.
Also invoice.payment_succeeded is not working for one time payment.
I know that period_end and period_start are on the event. However, most of the other data, you would need to store that data on your end.
As for invoice.payment_succeeded events for one-time payment, can you share an example where you did not get one so I can look? It would start with evt _
pi_3RxSqfDBfYojrB0W0gtioiA6 This is payment id where webhook not triggered.
The reason being, you're not using the Invoice API in this case. Instead, you're using a different API, https://dashboard.stripe.com/test/logs/req_xhfHoIPR4Xcaym. With PaymentIntent, you would not get invoice events. You can only send post payment invoices with either Checkout or Link, https://support.stripe.com/questions/pricing-for-post-payment-invoices-for-one-time-purchases-via-checkout-and-payment-links for one-time payments.
Or, you can use the Invoices API, https://docs.stripe.com/api/invoices/object?api-version=2025-06-30.basil directly.
For my current API which webhook should I use.
You can listen to payment_intent.succeeded or charge.succeeded in this case
which one will be best to update payemnt status in databse application payment_intent.succeeded or charge.succeeded ?
Okay.
for Invoice.payment_succeeded for recurrng.
is period_end as next due? & period_start as current_cycle_start?
The period start, https://docs.stripe.com/api/invoices/object?api-version=2025-06-30.basil#invoice_object-period_start indicates the start of the period during which invoice items were added to this invoice and the end, https://docs.stripe.com/api/invoices/object?api-version=2025-06-30.basil#invoice_object-period_end indicated the end of the period which invoice items were added to the invoice.
Let me check after hitting this
I have got
period_end =1755526208
period_start =1755526208
both same.
I want next due date. Means current cycle period end date.
Can you share the event please?
pi_3RxTlEDBfYojrB0W1lYc1UlX
sub_1RxTlEDBfYojrB0W97kjoxXC
in_1RxTlEDBfYojrB0WkGn2tMtO
That is because that is the first subscription. The invoice items started and ended on the same date since it's a new subscription.
You could instead look at the line items data:
period: {
end: 1758204608,
start: 1755526208
},
It's likely waht you'd want
not able to see any object like this
period: {
end: 1758204608,
start: 1755526208
},
Are you looking under lines.data?
It is under: lines: {object: 'list', data: Array(1), has_more: false, total_count: 1, url: '/v1/invoices/in_1RxTz2DBfYojrB0Wl4sRz400/lines'}
Where are you copying this data from?
Can you retrieve the invoice and use JSON.stringify via node? I run into this issue and it's expalined here: https://stackoverflow.com/questions/38542265/why-does-json-stringify-return-empty-object-notation-for-an-object-that-see
If you look at the Stripe Dashboard for this event, evt_1RxTlRDBfYojrB0WS3ndKYmG you will see the data.
Let me check.
Did you see it?
Are you saying you're not seeing it in the Dashboard for that event?
Can you share more details here? What does your webhook builder look like? Are you following this guide, https://docs.stripe.com/webhooks/quickstart ?
Are you still here?
Yes.
Checking in dashboard
const event = req.body;
const eventType = event.type;
const eventData = event.data.object;
console.log(Processing webhook: ${eventType});
try {
switch (eventType) {
// Payment Intent Events
case "payment_intent.succeeded":
await handlePaymentIntentSucceeded(eventData);
break;
case "payment_intent.payment_failed":
await handlePaymentIntentFailed(eventData);
break;
// Invoice Events (Subscriptions)
case "invoice.payment_succeeded":
await handleInvoicePaymentSucceeded(eventData);
break;
case "invoice.payment_failed":
await handleInvoicePaymentFailed(eventData);
break;
// Subscription Events
case "customer.subscription.created":
await handleSubscriptionCreated(eventData);
break;
case "customer.subscription.updated":
await handleSubscriptionUpdated(eventData);
break;
case "customer.subscription.deleted":
await handleSubscriptionDeleted(eventData);
break;
// Refund Events
case "charge.refunded":
await handleChargeRefunded(eventData);
break;
// Dispute Events
case "charge.dispute.created":
await handleDisputeCreated(eventData);
break;
default:
console.log(`Unhandled event type: ${eventType}`);
}
return res.status(200).json({ status: "success" });
} catch (error) {
console.error("Webhook processing error:", error);
return res.status(500).json({ error: "Webhook processing failed" });
}
});
This is webhook following.
Added
customer.subscription.created
invoice.payment_succeeded
payment_intent.succeeded
this event
Hi ๐
I'm stepping in as my colleague needs to go
๐งโ๐ป How to format code on Discord
Inline code: wrap in single backticks (`)
This:
The variable `foo` contains the value `bar`.
Will turn into this:
The variable
foocontains the valuebar.
Code blocks: wrap in three backticks (```)
Also, you can specify the language after the first three backticks to get syntax highlighting.
This:
```javascript
function foo() {
return 'bar';
}
```
Will turn into this:
function foo() {
return 'bar';
}```
Notes about **code blocks**:
- Specifying the language is optional (e.g., you can omit `javascript` in the example above)
- If you don't specify the language you won't get syntax highlighting
- When you're inside a code block (after you type \`\`\`) the `Return`/`Enter` key will add a new line instead of sending your message
- Once you end the code block `Return`/`Enter` works normally again
You can [read more about message formatting on Discord's website.](https://support.discord.com/hc/en-us/articles/210298617)
Can you clearly state what the exact data is you are not receiving and provide the event ID for the event you are reviewing?
I want to get next due date for subscription payment and current cycle start date. Once recurring payment is successed. For that I am using event.
- invoice.payment_succeeded
Okay, and the event ID?
That's an Invoice ID but okay
we_1RrLPlDBfYojrB0WyrzvywFD
That's also not an event ID. But it's okay, I have what I need.
Okay
This is the invoice.payment_succeeded event for that Invoice: https://dashboard.stripe.com/test/events/evt_1RxTzEDBfYojrB0WurlLkPHs
Can you view this link and confirm that for me?
FYI I don't see a success response being sent back by your webhook endpoint, so we keep trying to deliver this webhook event
"period": {
"end": 1758205464,
"start": 1755527064
},
this event has
Yup, that defines the billing period
What do you mean by "my event console"? Where is that logged?
case "invoice.payment_succeeded":
await handleInvoicePaymentSucceeded(eventData);
break;
i am getting eventData
in this data not getting that period object.
Can you tell me the API version for your webhook enpoint?
How can I check.
You can see it in your dashboard
And what is in the lines parameter in the eventData object?
I din't get what exaclty
As you can see, we are sending the correct data that includes the period in the payload. This is what you say in that dashboard link. However, there appears to be some incorrect handling in your NodeJS code
case "invoice.payment_succeeded":
// Try adding this to your code
const period = eventData.lines[0].period
console.log(period)
await handleInvoicePaymentSucceeded(eventData);
break;
Can you test out making the modifications I just added and trigger a test Event?
stripe trigger invoice.payment_succeeded
Okay.
Okasy
Webhook processing error: TypeError: Cannot read properties of undefined (reading 'period')
I think there is no line object
Okay so that sounds like the lines data isn't being included, which seems odd
since we definitely send that data
How can I get that.
We are sending it so that is where I'm confused.
Can you try logging the lines? console.log(eventData.lines)
Okay
{
object: 'list',
data: [
{
id: 'il_1RxVs8DBfYojrB0WJZi0O1MU',
object: 'line_item',
amount: 20900,
amount_excluding_tax: 20900,
currency: 'inr',
description: '1 ร Test Product (at โน209.00 / month)',
discount_amounts: [],
discountable: true,
discounts: [],
invoice: 'in_1RxVs8DBfYojrB0WYrTi6R4g',
livemode: false,
metadata: {},
parent: [Object],
period: [Object],
plan: [Object],
pretax_credit_amounts: [],
price: [Object],
pricing: [Object],
proration: false,
proration_details: [Object],
quantity: 1,
subscription: 'sub_1RxVs8DBfYojrB0Wt3vwEdne',
subscription_item: 'si_StITYPSZpGUhIV',
tax_amounts: [],
tax_rates: [],
taxes: [],
type: 'subscription',
unit_amount_excluding_tax: '20900'
}
],
has_more: false,
total_count: 1,
url: '/v1/invoices/in_1RxVs8DBfYojrB0WYrTi6R4g/lines'
}
Okay so you do have the lines and we can see there is a period
So let's update our code
case "invoice.payment_succeeded":
// Try adding this to your code
const period = eventData.lines.data[0].period
console.log(period)
await handleInvoicePaymentSucceeded(eventData);
break;
Try this and see if that works
Okay I will check.
Yes I am gettng it now
Okay great!
So we know the data is there and you have access to it. Now you can revise your code to extract the period from the eventData and use it
Yes sir.
I have another query
I want to test payment failure webhook. How can I do that?
Use one of our Test Cards that will fail: https://docs.stripe.com/testing#declined-payments
For one time payment success I am using ** payment_intent.succeeded**
For recurring **invoice.payment_succeeded **
Do I have to use seperate webhook for failure for recurring and onte time payment?
why one time payment are not captured in invoice.payment_succeeded webhook
Not all payments generate Invoices
Are you referring to one-time payments that were created from an Invoice?
How are your one-time payments being generated?
Payment intent
right, so there is no Invoice
We would not send invoice.payment_succeeded events because the Payment Intent isn't related to an Invoice
Okay got it.
paid_cycle
remaining_cycle
total_cycle
subscription_start
subscription_end
Can I get above data from invoice?
Hi there. I'll be taking over for Snufkin here, who needed to step away
Okay
Can you please help me to get this data from invoice webhook
paid_cycle
remaining_cycle
total_cycle
subscription_start
subscription_end
I'm sorry this looks like some Invoice parameters and some Subscription parameters.
Have you tried testing webhook events to understand what information you receive from them?
https://docs.stripe.com/billing/testing#webhooks
Invoice webhooks - such as invoice.payment_succeeded will give you a copy of the Invoice object. If you need the Subscription as well, there are Subscription events, or you can retrieve the Subscription that created the Invoice (if there is one) by looking at the Invoice's parent
https://docs.stripe.com/api/invoices/object#invoice_object-parent-subscription_details-subscription
I have checked this but not getting
- subscription_start
- subscription_end
- paid_cycle
-remaining_cycle - total_cycle
In order to help you, I need you to be more specific. What does "I have checked this" mean? What did you check? In detail, please.
I have got invoice object in webhook event. invoice.payment_succeeded
In that object I checked each params
But did not get required data.
subscription_start isn't a parameter that exists on the Invoice object. You can see the parameters that you could expect to get on the Invoice here:
Okay got it.
How can I hit failure webhook.
I tried failure card but not hitting webhook.
Only showing UI error.
well, the simplest way is probably to just use the CLI to trigger the event you want
but you could also use the "decline after attaching" 0341 test card here
4000 0000 0000 0341
Tried this but givign UI error only. Not hitting webhook
For simplicity's sake can I suggest the Stripe CLI approach I mentioned?
We were unable to generate the requested SDK snippet.
Ensure that you've included all required parameters.
Unfortunately, that doesn't tell me anything about what you did do and why it didn't work
why aren't you able to use the CLI?
Yes, there's another way to make the payment fail. You just need to create a Customer, create/confirm a SetupIntent with the 0341 card, set the resulting payment method as the Customer's invoice_settings.default_payment_method, and then create an Invoice for that Customer and pay it. The payment will fail