paytrail / paytrail-for-woocommerce

Paytrail payment service for WooCommerce
MIT License
4 stars 10 forks source link

2.1.0 version payment fails if order total is not integer #162

Closed artio-fi closed 3 months ago

artio-fi commented 3 months ago

Payment fails with error message

Request payload schema validation failed. Validate request against the provided schema. instance.items[1].vatPercentage is not a multiple of (divisible by) 0.1

This happen at least when delivery cost is in use.

We use gross prices in the online store, but the shipping costs have to be entered there without tax, they are calculated differently than other prices - if this has any significance in finding that error.

Vat is rounded wrong to 23.99

object(Paytrail\SDK\Request\PaymentRequest)#7563 (14) { ["stamp":protected]=> string(18) "XXXX" ["reference":protected]=> string(5) "43385" ["amount":protected]=> int(7080) ["currency":protected]=> string(3) "EUR" ["language":protected]=> string(2) "FI" ["items":protected]=> array(2) {

[0]=> object(Paytrail\SDK\Model\Item)#7346 (11) { ["unitPrice":protected]=> int(6490) ["units":protected]=> int(1) ["vatPercentage":protected]=> float(24) ["productCode":protected]=> string(34) "product/1470310003" ["deliveryDate":protected]=> NULL ["description":protected]=> string(36) "Product, 42" ["category":protected]=> NULL ["stamp":protected]=> string(5) "97112" ["reference":protected]=> NULL ["merchant":protected]=> NULL ["commission":protected]=> NULL }

[1]=> object(Paytrail\SDK\Model\Item)#7347 (11) { ["unitPrice":protected]=> int(590) ["units":protected]=> int(1) ["vatPercentage":protected]=> float(23.99) ["productCode":protected]=> string(8) "toimitus" ["deliveryDate":protected]=> NULL ["description":protected]=> string(39) "Postnord, valitse haluamasi noutopiste." ["category":protected]=> NULL ["stamp":protected]=> string(5) "97113" ["reference":protected]=> NULL ["merchant":protected]=> NULL ["commission":protected]=> NULL }

}

loueranta-paytrail commented 3 months ago

@artio-fi Thanks for the details. We are currently working on a fix, but haven't been able to reproduce the error in our test environments, so any additional details are appreciated!

artio-fi commented 3 months ago

We use gross prices (bruttohinnat) in the online store, but the shipping costs have to be entered there without tax, they are calculated differently than other prices - if this has any significance in finding that error.

Screenshot WooCommercen asetukset postnord

Wordpress 6.5.5 and Woocommerce 8.8.5

loueranta-paytrail commented 3 months ago

Thanks for sharing, this is clearly a rounding problem affecting only certain price/tax combinations. We had to modify our rounding logic when we introduced the VAT decimal support which in turn seems to have caused this.

loueranta-paytrail commented 3 months ago

@artio-fi: We just released 2.1.1 with the fix. Could you please verify if the problem is now solved?

artio-fi commented 3 months ago

Thank you! 2.1.1 version fixed this.