#bhavi-evrig
1 messages · Page 1 of 1 (latest)
When you say you need to trigger an event, do you mean for testing? Or do you want to listen for an event?
Or do you want the event that will fire every time the customer pays their invoice?
Yes first for testing I need to trigger and then I need to listen
This is the monthly subscription created using checkout session. I need to update the details in my SQL database when after a month subscription has been auto renew
Okay so that is going to be triggered from the Customer paying (or not) their invoice
then I need to update the expiry date if it renew successfully
Which event specifically?
Okay so for that you will want to listen to the invoice.paid event.
That will return an Invoice record with the ID of the Subscription and Customer it belongs to. The first Invoice paid event will fire when you create a Subscription
I am trying with the CLI giving me the error like this
Ah, in that case India has unique banking regulations. Hence the error message you are seeing
However there is a way around this
But you will need to create your own fixture file to define how you want the Stripe CLI to trigger events
Here is the file the CLI currently uses: https://github.com/stripe/stripe-cli/blob/master/pkg/fixtures/triggers/invoice.paid.json
You can see it creates a Customer record as it's first step but it only uses the description parameter
Per the error message you received, if you want to use the Stripe CLI to trigger this event, you will need to use your own fixture file that defines a Customer with a name and address properties.: https://stripe.com/docs/api/customers/create
Okay!
I need to call it in Yii2 ? For listen the webhook I am getting the msg like URL should be publically accepted
Can I set the local url instead of triggering it manually using CLI?
//set api key
\Stripe\Stripe::setApiKey(Yii::$app->params['STRIPE']['API_KEY']['TEST']);
$stripe = new \Stripe\StripeClient(
'sk_test_mDK8OgDcddPnQmhLTgkd76zj00KKu6EVEq'
);
$response = $stripe->webhookEndpoints->create([
'url' => 'http://localhost/site/stripe-end-point',
'enabled_events' => [
'customer.subscription.updated',
'charge.failed',
'charge.succeeded',
],
]);
var_dump($response);
exit;
Yes, for that you would use another Stripe CLI command stripe listen
You can then forward Stripe events to a webserver running locally
stripe listen --forward-to http://localhost/site/stripe-webhook
I am running this command
You cannot register an endpoint locally