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

Unable to get order reference (Umb 11) #6

Open
philipdanielhayton opened this issue May 12, 2023 · 8 comments
Open

Unable to get order reference (Umb 11) #6

philipdanielhayton opened this issue May 12, 2023 · 8 comments

Comments

@philipdanielhayton
Copy link

Hi Matt,

We recently upgraded to Umbraco 11 and our PayPal payment method has stopped working.

When the PayPal checkout flow is complete and the user is redirected back to our site, the order is placed in a kind of limbo state where it's cleared from the current order, but still classed as a cart.

Having checked the logs it seems PayPal is unable to get the order refernece (see error below). I've done some digging and think it could possibly be related to a breaking change introduced in dot net 7, so the jump to Umbraco 11 probably caused that, but I'm not 100% certain just yet.

I've forked a copy of the repo to continue my digging but I thought I'd raise the issue incase it's something you're already aware of and / or have a fix for.

We're using the following versions:

Umbraco: 11.3.1
Vendr: 3.0.11
Vendr.PaymentProviders.PayPal: 2.0.1

Here's the full error:

PayPal - GetOrderReference

System.ArgumentException: The value cannot be null or empty. (Parameter 'mediaType')
   at System.Net.Http.Headers.MediaTypeHeaderValue.CheckMediaTypeFormat(String mediaType, String parameterName)
   at Flurl.Http.Content.CapturedStringContent..ctor(String content, Encoding encoding, String mediaType)
   at Flurl.Http.GeneratedExtensions.PostStringAsync(IFlurlRequest request, String data, CancellationToken cancellationToken, HttpCompletionOption completionOption)
   at Vendr.PaymentProviders.PayPal.Api.PayPalClient.<>c__DisplayClass12_0.<<ParseWebhookEventAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Vendr.PaymentProviders.PayPal.Api.PayPalClient.RequestAsync[TResult](String url, Func`2 func)
   at Vendr.PaymentProviders.PayPal.Api.PayPalClient.ParseWebhookEventAsync(HttpRequestMessage request)
   at Vendr.PaymentProviders.PayPal.PayPalPaymentProviderBase`1.GetPayPalWebhookEventAsync(PayPalClient client, PaymentProviderContext`1 ctx)
   at Vendr.PaymentProviders.PayPal.PayPalCheckoutOneTimePaymentProvider.GetOrderReferenceAsync(PaymentProviderContext`1 ctx)

As always any help is greatly appreciated!

@mattbrailsford
Copy link
Member

Hmm, interesting, I've recently been porting this over for thew new Umbraco version of Vendr and that seems to have been working fine. I have upgraded all dependencies though so I wonder if upgrading Flurl would fix that? 🤔

@philipdanielhayton
Copy link
Author

Hi Matt,

Just wanted to drop you a quick update on this.

I created a custom payment provider within my project that targetted the .net7 framework. It uses 99% of the code from the original PayPal provider, the only changes really are to account for the updated APIs in the dependencies.

I was able to drop a couple of dependencies for Microsoft.AspNet.WebApi.Client and NETStandard.Library, and bumped the other two upto Flurl.Http 3.2.4 and Vendr.Core 3.0.11.

There was one 'gotcha' to be careful of, it doesn't throw a build error but it causes issues at run time:

On the second line of the PayPalClient.ParseWebhookEventAsync method, the headers were originally coming from request.Content.Headers, but during runtime they didn't contain the correct headers. Turns out the correct headers are now on request.Headers. I'm assuming this is just a quirk caused by the updated APIs.

Anyway, the callbacks now seem to be working correctly, and orders are being finalized as expected.

I've still got some more testing to do but just thought I'd keep you in the loop.

@TQ-Benji
Copy link

Hi,

Experiencing this issue too. Is the fix going to be brought back from Umbraco Commerce?

Thanks

@mattbrailsford
Copy link
Member

mattbrailsford commented Jul 20, 2023

I'm not sure if the original issue was raised against 2.0.1 beta but looking at the 2.0.1 tagged codebase it is set to use request.Headers https://github.com/vendrhub/vendr-payment-provider-paypal/blob/v2.0.1/src/Vendr.PaymentProviders.PayPal/Api/PayPalClient.cs#L90

What version are you using using @TQ-Benji ?

@TQ-Benji
Copy link

We are using 2.0.1

@mattbrailsford
Copy link
Member

Ok, so I've pushed a v2.0.2-beta0003 build to our unstable feed at https://nuget.outfield.digital/unstable/vendr/v3/index.json I believe this should work around the issue. Unfortunately I don't currently have a PayPal test environment setup so if anyone is able to test it and provide feedback that would be super useful.

@mattbrailsford
Copy link
Member

I've basically swapped this bit to construct my own content object passing in the media type which is what appears to be missing in specific .NET versions https://github.com/vendrhub/vendr-payment-provider-paypal/blob/v2/hotfix/2.0.2/src/Vendr.PaymentProviders.PayPal/Api/PayPalClient.cs#L118

@TQ-Benji
Copy link

Hi Matt, that beta looks to be working. Not getting the error anymore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants