#krishna008

1 messages · Page 1 of 1 (latest)

plain basinBOT
sonic sedge
#

what event type are you listening for?

outer junco
#

stripe trigger subscription_schedule.updated

sonic sedge
#

why not listen for the subscription.updated event instead?

outer junco
#

ohh is it for the each month subscription payment. I mean I want to listen event when subscription amount is paid each month.

sonic sedge
#

it's customer.subscription.updated

#

or alternatively, you would may want to listen for the invoice.paid event : https://stripe.com/docs/billing/subscriptions/webhooks#events and check. the billing_reason : https://stripe.com/docs/api/invoices/object#invoice_object-billing_reason

Learn to use webhooks to receive notifications of subscription activity.

outer junco
#

The event ‘customer.subscription.update’ is not supported by the Stripe CLI.

sonic sedge
#

you can always use the Billing Clock, create a Subscription and then advance the time on the Billing Clock to see what's returned in the events

outer junco
#

I want to test it locally. I was using CLI

#

Don't I need to use that one?

sonic sedge
#

you can still test it locally, events generated will be forwarded to your localhost still

outer junco
#

So using advance clock I can charge subscription anytime

sonic sedge
#

you can simulate what will happen at a certain period of time because you can advance the clock

outer junco
#

Is there any different command for that?

sonic sedge
#

CLI doesn't support generating that event. There's no way to do it using the CLI

outer junco
#

Okay sir.

#

I am using connected account. Is it possible to trigger that event for connected account.

sonic sedge
outer junco
#

Is it okay sir?

#

Sorry

#

I think subscription

#

I missed

sonic sedge
#

i'll suggest listening for invoice.paid too, to see if that's an event which you want to use too

outer junco
#

I am at India so If I want to make this subscription charge now what will I have to do sir?

sonic sedge
#

you advance it to a date in the future

outer junco
#

Sir, I did not understand this concept.

#

If I want to charge subscription now do I have to set current time?

sonic sedge
#

a test clock is to simulate time passing

#

so you can advance the time to simulate time passing

#

if you want to charge it now, then try advancing the time to a few hours past

#

if you want to see it charge 1 month later, then advance the time to a future date i.e. 1 month later

outer junco
#

I have simulate time in the past but

#

Webhook has not hit

sonic sedge
#

can you share the subscription id?

outer junco
#

sub_1OOgceDBfYojrB0Wo9YN61Jw

plain basinBOT
outer junco
#

Hello

lament tangle
#

👋 Taking over this thread, catching up now

outer junco
#

I have resolved the issue.

#

But I am not able to use singnature.

#

const sig = req.headers["stripe-signature"];

let event = req.body;

Secure webhook using signature and endpoint secret.
try {
  event = stripe.webhooks.constructEvent(req.body, sig, endpointSecret);
} catch (err) {
  console.log("HERE 3 ERROR", err.message);
  res.status(400).send(`Webhook Error: ${err.message}`);
  return;
}
#

I am getting error

lament tangle
#

Are you passing the request body in the raw form? More specifically express.raw({type: 'application/json'}) in

app.post('/webhook', express.raw({type: 'application/json'}), (request, response) => {
  let event = request.body;

Reference: https://stripe.com/docs/webhooks/quickstart

Learn how to set up and deploy a webhook to listen to events from Stripe.

outer junco
#

**Yes

lament tangle
#

In your middleware, do you parse all requests in json prior to this? For example,

app.use(express.json());
outer junco
#

YEs

lament tangle
#

This is the reason why problem occurs. If you parse the requests to json with app.use(bodyParser.json()) first, then the request will no longer be raw form

#

Can you remove app.use(bodyParser.json()) to check if the signature validation error is resolved?