Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Stripe.NET 28.2 Update #31
Running this code, I get exceptions thrown on the webhook
Removing the Expand on the relevant call seems to fix this.
Ok, made another big update to this.
Ultimately there is an issue in that Stripes API is rapidly updating, but the webooks need to be registered against a specific API version as determined by the Stripe.NET dll version. This was fine on initial release when the latest version was the same as that in the dll used, but the problem now is their latest API is now newer than the one used in the dll and when manually registering webhooks via their dashboard, like we currently require people to, you can't unfortunately choose an explicit version (you can only choose the version your account is using or the very latest).
In order to get around this, it needs to be the code that registers the webhook. The webhook registration API supports passing an API version and when passed, means any webhook notifications to that endpoint will use that explicit API version. What this means however is that the Stripe provider needs to auto generate the webhook for you.
In this latest update I've added some startup handlers that listen for a payment method being saved, and if that provider uses the Stripe payment provider, then it looks through the payment methods settings and trys to work out if you have a valid webhook configured. If not, it will use the Stripe API credentials in the settings to register one for you, updating the payment method with a webhook ID and Secret.
This registration also takes into account the "mode" of the provider. So if you save it in test mode, it will generate a test webhook and save the details in "test_webhook_id" / "test_webhook_secret" settings. And when in live mode, it will create a live webhook and store the details in "live_webhook_id" / "live_webhook_secret" settings.
If you need to regenerate a webhook endpoint at any time (such as if you upgrade later to a newer release using a newer Stripe.NET dll) then you can edit the provider and clear those settings out and then on save, it will regenerate them.
In addition, I've also added 2 new settings "test_base_url" and "live_base_url". These are used to set an explicit base URL when registering the webhook URL. This is handy for occasions where you want to test the webhook locally, so you can pass an ngrok URL as the base URL instead of localhost.
I need to do some more testing on this and also to update the docs. This update has also force the payment providers to be based on the TC 3.3.0 dlls so anyone wanting the latest providers will need to uprgade TC too.