When I tried these values in price and amount fields, it gives an error. It works fine if the value is not a float or decimal:
code :
"intent": "sale",
"payer": {
"payment_method": "paypal"
},
"redirect_urls": {
"return_url": "http://localhost:2300/success",
"cancel_url": "http://localhost:2300/cancel"
},
"transactions": [{
"item_list": {
"items": [{
"name": "Item",
"sku": "Item",
"price": '0.0015',
"currency": "INR",
"quantity": 1
}]
},
"amount": {
"currency": "INR",
"total": '0.0015'
},
"description": 'Item description.'
}]
};
Error :
response:
{ name: 'VALIDATION_ERROR',
message: 'Invalid request - see details',
debug_id: 'f42749ec22229',
information_link: 'https://developer.paypal.com/docs/api/payments/#errors',
details: [ [Object] ],
httpStatusCode: 400 },
httpStatusCode: 400 }
2
Answers
It worked! Thank you all for help. I used "Math.round((100.01151)*100)/100;" for price and total amount which gives 100.01.
You should be printing out
details: [ [Object] ],
If you look into that details array of the JSON response, it should sayINVALID_CURRENCY_AMOUNT_FORMAT
Most PayPal-supported currencies,
INR
included, only allow two decimal places, i.e. nothing smaller/beyond.01