Search code examples
phpapiomise

omise PHP get all charges


Omise PHP get all charges ref : https://www.omise.co/charges-api

$charges = OmiseCharge::retrieve();

this code gives me 20 records which is okay.

$response = OmiseCharge::retrieve('',OMISE_PUBLIC_KEY,OMISE_SECRET_KEY);

this also gives me first 20 records.

but my requirement is fetch all charges with date params.

$param = array(

            'from' => '2014-10-20 00:00:00',
            'to' => '2014-09-25 00:00:00'
        );
    $response = OmiseCharge::retrieve($param);

this gives an error.

Fatal error: Uncaught exception 'OmiseNotFoundException' with message 'charge Array was not found' 

what i am doing wrong.


Solution

  • $param = array(
                'from' => '2011-10-20 00:00:00',
                'to' => '2016-09-25 00:00:00'
            );
            $response = OmiseCharge::retrieve('?'.http_build_query($param));
    

    worked for me.