Got Http response code 400 when accessing https://api.sandbox.paypal.com/v1/payments/billing-agreement code example

Example: Got Http response code 400 when accessing https://api.sandbox.paypal.com/v1/payments/payment.

There may be two major reason for such kind of issues on paypal please check 
below:-

1) Check your subTotal, tax, shipping in case of single item and multiple items
and its sum should be equal to total i.e subTotal + tax + shipping = total

2) Check your returnUrl and cancelUrl there should be no space and special 
character use urlencode for this.

3) The currency should be the same for both total amount and items of the order

For more detailed version of the error check the log file. For me log was 
showing : 
PayPal\Core\PayPalHttpConnection : ERROR: Got Http response code 400 when accessing https://api.sandbox.paypal.com/v1/payments/payment. {"name":"VALIDATION_ERROR","message":"Invalid request - see details","debug_id":"8a04d1969fd33","information_link":"https://developer.paypal.com/docs/api/payments/#errors","details":[{"field":"transactions","location":"body","issue":"Item currency codes should be same as the transaction currency code in all buckets"},{"field":"transactions[0].item_list.items[0].currency","location":"body","issue":"Value is not supported at this time"}]}

Tags:

Misc Example