Reputation: 818
I am trying to understand how to integrate PayPal Express Checkout in Java, now at first I was successful to apply the scenario where customer approve payment by sending the below request and then getting the approve HATEOAS ref link:
curl -v -X POST https://api.sandbox.paypal.com/v2/checkout/orders \
-H "Content-Type: application/json" \
-H "Authorization: Bearer Access-Token" \
-d '{
"intent": "AUTHORIZE",
"purchase_units": [
{
"amount": {
"currency_code": "USD",
"value": "100.00"
}
}
]
}'
After that I capture the request where it appears that both customer and seller transactions are okay. But when trying to pay with another currency_code
like for example MAD
I get the below error:
{"name":"UNPROCESSABLE_ENTITY","details":[{"location":"body","issue":"CURRENCY_NOT_SUPPORTED","description":"Currency code is not currently supported. Please refer https://developer.paypal.com/docs/integration/direct/rest/currency-codes/ for list of supported currency codes."}],"message":"The requested action could not be performed, semantically incorrect, or failed business validation.","debug_id":"","links":[{"href":"https://developer.paypal.com/docs/api/orders/v2/#error-CURRENCY_NOT_SUPPORTED","rel":"information_link","method":"GET"}]}
Is there any workaround to force multiple currencies on checkout? Or how to implement currency conversion?
Upvotes: 0
Views: 2922
Reputation: 30377
MAD
is not a PayPal-supported currency
Here is the complete list: https://developer.paypal.com/docs/api/reference/currency-codes/
If the buyer has a funding source in a different local currency (such as a credit card with MAD
) a conversion will be shown to them in the checkout. But your transaction must be denominated in one of the PayPal supported currencies, and you will receive that currency.
The best approval flow is not link or redirect-based, but rather keeping your site loaded in the background and opening an in-context window. Here is the front-end UI for that: https://developer.paypal.com/demo/checkout/#/pattern/server
It does require the currency to be known at page load time (or a later async load).
You'll need two corresponding routes on your server, one for 'Set Up Transaction' like in your question, and one for 'Capture Transaction'. There is a guide for them here: https://developer.paypal.com/docs/checkout/reference/server-integration/
Upvotes: 1