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 #8

Closed DarrylHardin closed 4 years ago

DarrylHardin commented 4 years ago

Not sure if this is user error on my side, or if there is something wrong with the gateway. I looked up how to fix this and it seems the error is in the plugin.

https://stackoverflow.com/questions/57197907/paypal-expected-an-order-id-to-be-passed

DarrylHardin commented 4 years ago

Just saw this was addressed before in closed tickets, I'll close this for now and see if that fixes my issue.

DarrylHardin commented 4 years ago

I toggled the test and that didn't fix it like the last person. Here is an image with JS errors included.

error

nfourtythree commented 4 years ago

Hi @importantcoding

Is this when you are in test mode or live mode?

Thanks.

DarrylHardin commented 4 years ago

It happens with both.

samhibberd commented 4 years ago

We are also running into this issue intermittently, not sure if it helps but there looks to be a few errors in the AJAX request, not sure if they are related:

{
  "error": "{\"name\":\"UNPROCESSABLE_ENTITY\",\"details\":[{\"field\":\"/purchase_units/0/amount/item_total/value\",\"value\":\"41.440000000000005\",\"issue\":\"DECIMAL_PRECISION\",\"description\":\"If the currency supports decimals, only two decimal place precision is supported.\"}],\"message\":\"The requested action could not be performed, semantically incorrect, or failed business validation.\",\"debug_id\":\"8a31df1978c7e\",\"links\":[{\"href\":\"https://developer.paypal.com/docs/api/orders/v2/#error-DECIMAL_PRECISION\",\"rel\":\"information_link\",\"method\":\"GET\"}]}",
  "paymentFormErrors": [],
  "orderErrors": []
}

Could this be it?

nfourtythree commented 4 years ago

Hi All

I have been looking into this.

@samhibberd I have pushed a fix for this if you could test it for me?

To do this, change your craftcms/commerce-paypal-checkout requirement in composer.json to:

"require": {
  "craftcms/commerce-paypal-checkout": "dev-develop#15974031a9f9963d82166febfc4c7869a02fbabd as 1.0.1",
  "...": "..."
}

Then run composer update.

@importantcoding I am unable to replicate your issue ([see video]( which leads me to believe that we have some different settings somehwere.

Would it be possible you drop your composer.json, composer.lock and a backup of your DB to support@craftcms.com so I can take a further look into what might be happening.

Thanks!

nfourtythree commented 4 years ago

Hi All

I have pushed an update that should give better error reporting on what is happening.

Could you please update your craftcms/commerce-paypal-checkout requirement in composer.json to:

"require": {
  "craftcms/commerce-paypal-checkout": "dev-develop#8e02944b57cff26abadca50880e3a498c7951845 as 1.0.1",
  "...": "..."
}

Then run composer update. Followed by running your tests again and we can see what the errors are.

Alternatively, you can find these errors in the transaction tab for the carts under the info icon.

samhibberd commented 4 years ago

@nfourtythree sorry for the delay, just tested your fix, if you also fix the rounding on the item total then all good for me, see:

https://github.com/craftcms/commerce-paypal-checkout/blob/15974031a9f9963d82166febfc4c7869a02fbabd/src/gateways/Gateway.php#L540

also needs to be

'value' => Currency::round($order->getItemSubtotal()),

Thanks.

nfourtythree commented 4 years ago

Hey

Thank you for that @samhibberd, depending on what version you are on this should already be rounded. However, I have pushed an update that makes sure this is rounded just in case.

Thanks.

nfourtythree commented 4 years ago

Hey All,

Have pushed a 1.0.2 release that includes the things discussed above.

I realise there may be further things that come out of this but now there is better error reporting it makes sense to close this issue.

Please feel free to open further issues if any more specific problems arise.

Thanks.