umbraco / Umbraco.Commerce.PaymentProviders.PayPal

MIT License
0 stars 3 forks source link

ArgumentNullException in GetAccessTokenAsync #2

Closed BenWhite27 closed 8 months ago

BenWhite27 commented 9 months ago

I'm getting a Null Reference Exception when using the latest version. I've cloned the repository and tested my end that the AccessToken is deserialised as null even though it is present in the http response from paypal.

It appears that the Model objects in this library are configured for Newtonsoft.Json and v4 of Flurl replaced the default serialiser with System.Text.Json.

From: https://flurl.dev/docs/configuration/#serializers

Flurl provides default implementations for both. It's very unlikely you'll need to use a different UrlEncodedSerializer, but there's a couple reasons you may want to swap out the JsonSerializer:

  1. You prefer the Newtonsoft-based version from 3.x and earlier. (4.0 replaced this with a System.Text.Json-based version.) This is available with the the Flurl.Http.Newtsonsoft companion package.

I'm not that familiar with Flurl, but I can't seem to find anything suggesting it's been configured for Newtonsoft.Json.

@mattbrailsford Sorry for the ping but this seems pretty critical.

mattbrailsford commented 9 months ago

@BenWhite27 good spot, and that does indeed look to be the issue.

We have a task to test these against System.Text.Json but for the time being I've added a dependency to Flurl.Http.Newtonsoft and update the code to use the NewtonsoftSerializer. I've pushed this to our nightly server https://docs.umbraco.com/umbraco-cms/fundamentals/setup/install/installing-nightly-builds if you want to give v13.0.1-preview.1 a try and see if that resolves the issue for you?

BenWhite27 commented 9 months ago

Thanks Matt, I'll see if I can get the nightly feed configured and working on Umbraco Cloud and report back.

mattbrailsford commented 9 months ago

I believe you should be able to add a NuGet.config to your project root https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file#packagesources

BenWhite27 commented 9 months ago

Hi Matt Thanks for the links, just tested and everything appears to be functional now. This is a new site and my first test with Umbraco Commerce Checkout so can't say I've tested everything but no HTTP 500's this time.

Merry Christmas

mattbrailsford commented 9 months ago

Excellent. I’ll get a full release pushed out tomorrow but hopefully the preview gets you making progress on your build. Thanks for raising the issue 👍🏻

mattbrailsford commented 8 months ago

Version 13.0.1 has now been pushed out with this fix in. Thanks again for reporting 👍