white-nl / commerce-mollie-plus

Mollie Klarna integration for Craft Commerce
Other
3 stars 5 forks source link

Add currency support #21

Closed Romanavr closed 3 months ago

Romanavr commented 4 months ago

See Issue https://github.com/white-nl/commerce-mollie-plus/issues/22

Some short explanation of what I did and why:

  1. Overriding total amount $request['amount'] = Currency::round($calculatedItemsTotal, $paymentCurrency); Due how to craft commerce calculates the total, to be more detailed, it uses Currency::round under the hood in the total calculation изображение I calculate the total amount by summing the total cost of each item manually. Otherwise, a situation arises where, with a different currency, the difference may be 0.01 compared to the total cost from craft commerce, and then Molly will swear that the total amount does not match the sum of all line items.

  2. Sending VAT rate as a string: $mollieItem->setVatRate(sprintf('%0.2f', $vatRate)); I saw that you sending VAT rate as a string instead of the regular int/float. Firstly didn't realize why, but then encountered the issue when the VAT Rate was the 0.00 (as a float) Molly API throw an error, can't remember what exactly, but something like VAT Rate can't be null

WHITE-developer commented 3 months ago

Added currency support by https://github.com/white-nl/commerce-mollie-plus/commit/051fb0205d231fec87409c43161ff9ce588e0988