Search code examples
phpapipaypalcurrency

paypal amount currency issue


I am trying to implement PayPal into our website. I used cURL to interact with the PayPal's Express Checkout API. The website is German in nature so payments will be handled in Euro currency.

I executed my cURL and the API returned an error. I found out my $price is causing the error.

By default, $price = 56,85 with these value PayPal's API returned an error. But if change this to $price = 56.85 the API succeeds.

I can simply use str_replace to replace comma with period. But what concerns me is the price value of the product. I am transacting in Euro.

Is there anyone care to explain how can I handle this issue?


Solution

  • You simply must use a dot . not a comma ,

    You could replace a comma with a dot in PHP like this:

    $price = "56,85";
    $price = str_replace(",", ".", $price);
    

    Now $price should be 56.85

    Also this won't affect the value. 56.85 is the amount, whatever currency you'll use. Just be sure to define the currency on paypal request as EUR.