-
Notifications
You must be signed in to change notification settings - Fork 12
Description
Describe the bug
-
First, document https://docs.paytrail.com/#/?id=item doesn't say that
item.unitPrice
must have minimum value of 0. -
Second, old
E2 Interface
fieldITEM_UNIT_PRICE
allowed prices to be negative. You ask why this is needed? Well in our store (Zen Cart) user can use his/hers accountstokens
in their order. These tokens are acquired by gift vouchers and are processed as negative items in the order. Other items that fall in to this category arecustomer group discounts
andcoupons
that make discounts from the totals etc. They both are also processed as negative items.
Here's payload that fails:
[stamp] => 69-691805221041180
[reference] => 691805221041180
[amount] => 1750
[currency] => EUR
[language] => FI
[orderId] => 69
[items] => Array
(
[0] => Array
(
[unitPrice] => 850
[units] => 1
[vatPercentage] => 24
[productCode] => A123456789
[description] => Asetoni 1 l
)
[1] => Array
(
[unitPrice] => 1000
[units] => 1
[vatPercentage] => 24
[productCode] => -1
[description] => Posti (Kotipaketti - kotiovelle klo 21 mennessä)
)
[2] => Array
(
[unitPrice] => -100
[units] => 1
[vatPercentage] => 0
[productCode] => -1
[description] => Tilin varat
)
)
..
Paytrail Response:
Array (
[status] => error
[message] => Request payload schema validation failed. Validate request against the provided schema.
[meta] => Array
(
[0] => instance.items[2].unitPrice must have a minimum value of 0
)
)
Question: How can I get this to work with new API?
If I take this negative items[2]
out of the payload or zero it, then the amount
is not going to match total sum of items.
[status] => error
[message] => Sum of purchase item amounts does not match total amount.
Expected behaviour
item.unitPrice
should also allow negative values.
Actual behaviour
item.unitPrice
must have a minimum value of 0.