#bhavi-evrig

1 messages · Page 1 of 1 (latest)

cedar boltBOT
lost charm
#

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?

buoyant gulch
#

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

lost charm
#

Okay so that is going to be triggered from the Customer paying (or not) their invoice

buoyant gulch
#

then I need to update the expiry date if it renew successfully

lost charm
#

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

buoyant gulch
#

I am trying with the CLI giving me the error like this

lost charm
#

Oh, where are you running this?

#

Where is your account registered?

buoyant gulch
#

i installed stripe cli in my Ubuntu

#

its in India

lost charm
#

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

#

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

buoyant gulch
#

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;
lost charm
#

Yes, for that you would use another Stripe CLI command stripe listen

#

You can then forward Stripe events to a webserver running locally

buoyant gulch
lost charm
#

You cannot register an endpoint locally