Skip to content

Latest commit

 

History

History
102 lines (80 loc) · 2.23 KB

CHARGE_DETAIL.md

File metadata and controls

102 lines (80 loc) · 2.23 KB

Detailing charges

Instantiate the module:

require __DIR__.'/../../vendor/autoload.php';
use Gerencianet\Exception\GerencianetException;
use Gerencianet\Gerencianet;

$options = [
    'client_id' => 'client_id',
    'client_secret' => 'client_secret',
    'sandbox' => true
];

try {
    $api = new Gerencianet($options);

} catch (GerencianetException $e) {
    print_r($e->code);
    print_r($e->error);
    print_r($e->errorDescription);
} catch (Exception $e) {
    print_r($e->getMessage());
}

It's very simple to get details from a charge. You just need the id:

$params = ['id' => 1000];

try {
    $api = new Gerencianet($options);
    $charge = $api->detailCharge($params, []);

    print_r($charge);
} catch (GerencianetException $e) {
    print_r($e->code);
    print_r($e->error);
    print_r($e->errorDescription);
} catch (Exception $e) {
    print_r($e->getMessage());
}

As response, you will receive all the information about the charge (including if it belongs to a subscription or carnet):

Array
(
    [code] => 200
    [data] => Array
        (
            [charge_id] => 1024
            [total] => 5000
            [status] => canceled
            [custom_id] =>
            [created_at] => 2015-07-27 09:43:05
            [notification_url] =>
            [items] => Array
                (
                    [0] => Array
                        (
                            [name] => Item 1
                            [value] => 1000
                            [amount] => 1
                        )

                    [1] => Array
                        (
                            [name] => Item 2
                            [value] => 2000
                            [amount] => 2
                        )

                )

            [history] => Array
                (
                    [0] => Array
                        (
                            [status] => new
                            [created_at] => 2015-07-27 09:43:05
                        )

                    [1] => Array
                        (
                            [status] => canceled
                            [created_at] => 2015-07-27 10:22:43
                        )

                )

        )

)