craftcms/commerce-omnipay

Paypal API: The totals of the cart item amounts do not match order amounts

Opened this issue · 0 comments

Description

When using an Omnipay based gateway (In our case PayPal, https://github.com/craftcms/commerce-paypal) we've encountered some problems when trying to process a payment with a different currency than the primary currency. For example the USD as primary and GBP as secondary. I've found out that when creating the item bags to send to the gateway, the price of the items are noted in the primary currency, while in the transaction object, the price is noted in the secondary currency. This results in the following error from the gateway:
The totals of the cart item amounts do not match order amounts

I think the best way to fix this, would be to convert the price in the item bags to the currency that was selected as the paymentCurrency. (also see this related issue in commerce)

Steps to reproduce

  1. In Craft Commerce, Add a primary and secondary currency with a different rate
  2. Add some items in your shopping cart in the secondary currency
  3. Proceed to checkout with the Paypal gateway

Additional info

  • Craft version: 3.6.17
  • PHP version: 8.0.7
  • Database driver & version: PostgreSQL 12.6
  • Plugins & versions:
    • Commerce: 3.3.4.1
    • Commerce Omnipay: 3.0.2
    • Commerce Paypal: 3.0.0