phpjsonapicurlmercadopago

Seaching payments does not filter by date


I'm trying to search and filter some of my recieved mercadopago payments via it's API. I'm making a Curl request using PHP7. One of my filters is a range date (begin_date, end_date), but that filter is not working propertly!. Here is my code, thanks in advance!

    $begin = '2018-08-01';
    $end = '2018-09-01';
    $curl = curl_init();
    curl_setopt_array($curl, array(
        CURLOPT_RETURNTRANSFER => 1,
        CURLOPT_URL => 'https://api.mercadopago.com/v1/payments/search?collector.id=me&'.
            'access_token='.'MY_ACCESS_TOKEN'.'&'.
            'begin_date='.$begin.'&'.
            'end_date='.$end.'&'.
            'status=approved'.'&'.
            'offset=0'.'&'.
            'limit=1000'
    ));
    $payments = curl_exec($curl);
    curl_close($curl);

I made a try using a rest console but the output was the same! an out-of-range list of payments, starting in the begining of times and finishing on the limit (1000).

The API response is:

{
"paging": {
    "total": 2739,
    "limit": 2,
    "offset": 0
},
"results": [
    {
        "id": SOME_INT,
        "date_created": "2018-03-01T19:25:24.000-04:00",
        "date_approved": "2018-03-01T19:25:26.000-04:00",
        "date_last_updated": "2018-03-20T13:18:43.000-04:00",
        "money_release_date": "2018-03-03T19:25:26.000-04:00",
        "..." : "...",
        .
        .
        .

    },
    {
        ...
    },
  ]
}

Also I tried using the "friendly" date range given by documentation:

$begin = "NOW-1MONTH";
$end = "NOW";

Solution

  • According to the documentation the format is 2018-08-01T00:00:00Z

    curl -G -X GET \ -H "accept: application/json" \
    "https://api.mercadopago.com/v1/payments/search" \
    -d "access_token=ACCESS_TOKEN" \
    -d "payment_type_id=credit_card" \
    -d "operation_type=regular_payment" \
    -d "range=date_created" \
    -d "begin_date=2014-10-21T00:00:00Z" \
    -d "end_date=2014-10-25T24:00:00Z"
    

    Note that this code is copied directly from the documentation