davidtsadler / ebay-sdk-php

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

Types\AmountType cast as double #70

Closed uovidiu closed 7 years ago

uovidiu commented 7 years ago

Hi there, I think it's wrong to use double here. I know ebay ask for double but the problem is with prices without decimals.

Example:

$request = new Types\ReviseItemRequestType();
$item = new Types\ItemType();
$item->BuyItNowPrice = new Types\AmountType(['value' => 100]);

Request looks like this:

Array
(
    [Item] => Array
        (
            [BuyItNowPrice] => Array
                (
                    [value] => 120
                )

            [Description] => Microwave-safe.
Dishwasher-safe.
            [ItemID] => 110189540434
            [StartPrice] => Array
                (
                    [value] => 100.99
                )

            [Title] => Simple mug
        )

)

eBay error returned:

Error: Invalid start price/Buy It Now price. You have entered invalid start price or Buy It Now price.

I know that I'm supposed to send 120.00 but since prices are stored in DB and I get the values using sql query I'm getting a 'string' type for the price stored in DB. And I don't think it's possible to cast that value to a double with two zero decimals.

uovidiu commented 7 years ago

I'm sorry, the problem was elsewhere.

davidtsadler commented 7 years ago

No problem :)