davidtsadler / ebay-sdk-php

An eBay SDK for PHP. Use the eBay API in your PHP projects.
Apache License 2.0
349 stars 341 forks source link

Double type values (like amounts) in locale configuration with comma as decimal separator #97

Closed bernatfabregat closed 4 years ago

bernatfabregat commented 7 years ago

Hi, In my locale configuration (Spain), the decimal separator is comma and, I suppose, the direct conversion of a double value (like amounts) to string in xml request build, sets the property with comma, and API rejects it. I cannot change my locale configuration (Spanish users use to use the comma). But, anyway, the conversion should always use a dot. Now I correct this in my code using number_format (\DTS\eBaySDK\Types\BaseType::encodeValueXml, line 586) but, it will be interesting to keep on using the repository code. And, thanks for the great work with this SDK!

davidtsadler commented 7 years ago

Do you have some example code that can explain the issue?

bernatfabregat commented 7 years ago

Yes, just setting a price with decimals in a addItem request of Tradding API, like this: $item->StartPrice = new Types\AmountType(["value" => 19.99]); when I look up the generated xml, there is a comma! We have a standard Spanish configuration, and the direct conversion puts a comma. Thanks!

davidtsadler commented 7 years ago

Cheers for the example. Will take a look into the issue.

davidtsadler commented 7 years ago

So just to confirm. At the moment doing the below in the SDK.

$item->StartPrice = new Types\AmountType(["value" => 19.99]);

Results in the following incorrect XML been generated?

<StartPrice>19,99</StartPrince>

And that the SDK should ignore the locale settings and instead generate

<StartPrice>19.99</StartPrince>

bernatfabregat commented 7 years ago

Exactly!