For some reason I keep getting the following error in my logs when trying to authorise a PayPal payment using the SDK:
ERROR: Got Http response code 400 when accessing https://api.sandbox.paypal.com/v1/payments/payment. {"name":"VALIDATION_ERROR","details":[{"field":"transactions[0].amount","issue":"Transaction amount details (subtotal, tax, shipping) must add up to specified amount total"}],"message":"Invalid request - see details"
My transaction amount seems to add up fine so I don't know why PayPal is throwing an error, here is my transaction amount:
'transactions' => [
0 => PayPal\Api\Transaction#5
(
[PayPal\Common\PayPalModel:_propMap] => [
'amount' => PayPal\Api\Amount#6
(
[PayPal\Common\PayPalModel:_propMap] => [
'currency' => 'GBP'
'total' => '675.00'
'details' => PayPal\Api\Details#7
(
[PayPal\Common\PayPalModel:_propMap] => [
'fee' => '75.00'
'subtotal' => '600.00'
]
)
]
)
'item_list' => PayPal\Api\ItemList#8
(
[PayPal\Common\PayPalModel:_propMap] => [
'items' => [
0 => PayPal\Api\Item#9
(
[PayPal\Common\PayPalModel:_propMap] => [
'name' => 'Day 1: 30-12-2017'
'currency' => 'GBP'
'quantity' => 1
'price' => '300.00'
]
)
1 => PayPal\Api\Item#10
(
[PayPal\Common\PayPalModel:_propMap] => [
'name' => 'Day 2: 27-01-2018'
'currency' => 'GBP'
'quantity' => 1
'price' => '300.00'
]
)
]
]
)
Could it be something to do with the number_format
function? I am using that function to ensure all values are consistant with their decimal places: $grandTotal = number_format($data['job']['grandTotalAmount'], 2, '.', '');