I'm using commerce_multicurrency in conjunction with commerce_paypal. The user has the option to view and purchase products in a currency other than the one set in the WPP payment method. When this happens, the order total is converted from the user currency to the target paypal currency prior to sending the request to paypal. This can result in an order total with too many decimal places, which causes the paypal request to fail.

I was able to resolve the issue by rounding the result of the currency conversion on line 186 of commerce_paypal_wpp.module like so -

change this:

'AMT' => commerce_currency_amount_to_decimal(commerce_currency_convert($charge['amount'], $charge['currency_code'], $payment_method['settings']['currency_code']), $charge['currency_code']),

to this:

'AMT' => round(commerce_currency_amount_to_decimal(commerce_currency_convert($charge['amount'], $charge['currency_code'], $payment_method['settings']['currency_code']), $charge['currency_code']), 2),

This seems to be the approach taken to a similar issue (Issue #1172028), previously resolved on the commerce_paypal_wps component.

Comments

mikehues’s picture

Status: Active » Needs review
StatusFileSize
new1.02 KB

I've created a patch file. This is my first patch. Let me know if something is incorrect.

andyg5000’s picture

Status: Needs review » Closed (duplicate)