craftcms / commerce-paypal-checkout

PayPal Checkout gateway for Craft Commerce.
https://plugins.craftcms.com/commerce-paypal-checkout
MIT License
5 stars 10 forks source link

Error: Expected an order id to be passed (again) #16

Closed sjelfull closed 3 years ago

sjelfull commented 4 years ago
{"name":"INVALID_REQUEST","message":"Request is not well-formed, syntactically incorrect, or violates schema.","debug_id":"c189692123250","details":[{"location":"body","issue":"INVALID_SYNTAX","description":"Cannot deserialize instance of `java.lang.String` out of START_OBJECT token line: 1, column: 303"}],"links":[{"href":"https://developer.paypal.com/docs/api/orders/v2/#error-INVALID_SYNTAX","rel":"information_link","encType":"application/json"}]}

Settings seems fine - test mode is enabled: image

nfourtythree commented 4 years ago

Hi @sjelfull

I am unable to replicate this issue. Could you please provide more information.

What did the cart look like? Products, shipping, adjustments etc.

Thanks.

nfourtythree commented 3 years ago

Closing this issue due to no further information.

Thanks.

onetdev commented 3 years ago

I've tested the flow with test creds and everything was good but then I've tried the live credentials (the gateway was still in test mode) and I've got the aforementioned alert too when I clicked the PayPal button.

image

I found this related network request:

POST /index.php?p=actions/commerce/payments/pay
cart: {number: "d1c7cd18c8c00b559e9b74ac33ccbd0a", reference: null, couponCode: null, isCompleted: false,…}
error: "{"error":"invalid_client","error_description":"Client Authentication failed"}"
paymentFormErrors: []

While the alert was right it was misleading. Having a better error message would help devs to debug this issue faster (if it occures).

rob-baker-ar commented 3 years ago

I'm seeing this exact situation @orosznyet Searching through the code base, I can only find "invalid_client" within the Stripe gateway code (I am using 2 different gateways - Stripe and this PayPal one). It seems like for the request to /index.php?p=actions/commerce/payments/pay it's using the wrong gateway.

Also, I am only seeing this in my live environment (i.e. not in PayPal sandbox), dev works OK.

nfourtythree commented 3 years ago

Hi

As @orosznyet mentioned it seems like this issue is coming from a situation where the wrong credentials are being used (live credentials but with test mode enabled) or an issue with the PayPal account.

@rob-baker-ar if the payments controller pay action is using the wrong gateway that would seem to suggest an issue elsewhere with your code rather than the PayPal plugin. It would be worth checking to see which gateway is being passed/which is set on the cart.

Thanks.

rob-baker-ar commented 3 years ago

Sorry, should have updated this. My issue with PayPal disappeared when I ditched the older PayPal integration plugin in favour of the new. Some templates were looking at the gateway handle to decide what to do / show, which stayed the same during the transfer between plugins, hence the confusion. I resolved it in the end by removing all the PayPal specific gateway / payment stage of checkout customisations that it turned out were not needed with the new gateway implementation anyway.