contributte / gopay-inline

:credit_card: GoPay Inline Payment for Nette Framework
https://contributte.org/packages/contributte/gopay-inline.html
BSD 3-Clause "New" or "Revised" License
33 stars 32 forks source link

Cents rounding #7

Closed vojtasvoboda closed 8 years ago

vojtasvoboda commented 8 years ago

It is not issue, but I don't now how to solve when I have negative cents rounding (in czech "Haléřové vyrovnání"). Because it's not possible to send negative value to gateway.

Eshop owner don't want to turn off cents rounding for payment by card.

When I try to add product with price -0,30 Kč:

snimek obrazovky 2015-12-15 v 22 13 10

Guys, any idea?

f3l1x commented 8 years ago

Hmmm. Do you need it pass to paymet's items? Gopay does not accept negative values?

vojtasvoboda commented 8 years ago

Yes, customers should see what they pay for. Yes, Gopay does not accept negative amounts - see documentation -> Objects -> Items -> amount (long > 0).

There is also second problem, if you don't pass rounding as payment item, total sum doesn't match:

snimek obrazovky 2015-12-16 v 10 14 31

f3l1x commented 8 years ago

I get your point. If some webservice does not support it, you use it bad.

vojtasvoboda commented 8 years ago

So... how can I solve it? :-) Cents rounding is pretty common thing.

vojtasvoboda commented 8 years ago

Gopay technical support suggested me add this rounding to final price. So maybe some config switch "Turn off validation" will be great?

f3l1x commented 8 years ago

I'm not sure if it is allowed on Gopay side. You can pass different items price and payment price?

vojtasvoboda commented 8 years ago

Yes to Gopay you can send different items price, but in this library is some Validator, see last screenshot above.

f3l1x commented 8 years ago

Ok. I have added 2nd parameter validators.

PaymentFactory - https://github.com/Markette/GopayInline/blob/9a8be30ba3d160d91f0628a8d62e14d8b58fbb89/src/Api/Entity/PaymentFactory.php#L148-L152

Tests - https://github.com/Markette/GopayInline/blob/9a8be30ba3d160d91f0628a8d62e14d8b58fbb89/tests/cases/unit/Api/Entity/PaymentFactory.phpt#L120-L124

It is backward compatible. Just use create($data, $validators = [])

f3l1x commented 8 years ago

Please test it on master and I will tag it.

markette/gopay-inline: 1.1.0 should target to master, minimum-stability: dev

"markette/gopay-inline": "~1.1.0@dev"

vojtasvoboda commented 8 years ago

Thank you, works great!

f3l1x commented 8 years ago

Great.