Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stripe.NET 28.2 Update #31

Merged
merged 8 commits into from Sep 2, 2019

Conversation

@mattbrailsford
Copy link
Contributor

commented Aug 17, 2019

Update to Stripe provider to use the latest 28.2 Stripe.NET DLL / latest API version. In addition this also brings back the "Capture" option.

Still to do:

  • Test the updates
  • Update the docs
…er before continuing. Also disabled the submit button in the payment form.
…uced the "Charge" option in settings to enable capture + authorize only payments [NEEDS TESTING]
@mattbrailsford mattbrailsford changed the title Stripe 28.2 Update Stripe.NET 28.2 Update Aug 17, 2019
@mattbrailsford mattbrailsford modified the milestones: 3.1.1, 3.1.2 Aug 17, 2019
@steroberts89

This comment has been minimized.

Copy link
Contributor

commented on a1c056b Aug 19, 2019

Running this code, I get exceptions thrown on the webhook

Stripe.StripeException: This property cannot be expanded (Charges).
   at Stripe.StripeClient.ProcessResponse[T](StripeResponse response)
   at Stripe.StripeClient.<RequestAsync>d__25`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Stripe.Service`1.<RequestAsync>d__23`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Stripe.Service`1.Request[T](HttpMethod method, String path, BaseOptions options, RequestOptions requestOptions)
   at TeaCommerce.PaymentProviders.Inline.Stripe.ProcessWebhookRequest(Order order, HttpRequest request, IDictionary`2 settings)
   at TeaCommerce.PaymentProviders.Inline.Stripe.ProcessRequest(Order order, HttpRequest request, IDictionary`2 settings) 

Removing the Expand on the relevant call seems to fix this.

This comment has been minimized.

Copy link
Contributor Author

replied Aug 19, 2019

@steroberts89 cool, thanks for testing. I'll get that removed 👍

Let me know if you find any other issues. Appreciate the feedback.

@mattbrailsford

This comment has been minimized.

Copy link
Contributor Author

commented Aug 27, 2019

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.

@mattbrailsford mattbrailsford merged commit a6dda86 into dev Sep 2, 2019
@mattbrailsford mattbrailsford deleted the wip/stripe-28-2-update branch Sep 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.