RESTful

For information about Postpay’s RESTful API, see the RESTful API Docs.

Usage

use Postpay\Exceptions\RESTfulException;

$params = [
    'status' => 'captured',
];

try {
    $response = $postpay->get('/orders', $params);
} catch (RESTfulException $e) {
    echo $e->getErrorCode();
    exit;
}
print_r($response->json());

Create a checkout

For more information about Create a checkout and how to define the $payload variable, see API Docs.

try {
    $response = $postpay->post('/checkouts', $payload);
} catch (RESTfulException $e) {
    echo $e->getErrorCode();
    exit;
}
echo $response->json()['redirect_url'];

Capture

For more information about Capture, see API Docs.

try {
    $response = $postpay->post('/orders/$order_id/capture');
} catch (RESTfulException $e) {
    echo $e->getErrorCode();
    exit;
}
print_r($response->json());

Create a refund

For more information about Refunds, see API Docs.

$payload = [
    'refund_id' => 'refund-01',
    'amount' => 2050,
    'description' => 'Item returned by user',
];

try {
    $response = $postpay->post('/orders/$order_id/refunds', $payload);
} catch (RESTfulException $e) {
    echo $e->getErrorCode();
    exit;
}
print_r($response->json());

Create a hook

For more information about Webhooks, see API Docs.

$payload = [
    'active' => true,
    'events' => [
        'order',
    ],
    'url' => 'https://www.example.ae/hooks',
    'secret' => 'dolphins',
];

try {
    $response = $postpay->post('/hooks', $payload);
} catch (RESTfulException $e) {
    echo $e->getErrorCode();
    exit;
}
print_r($response->json());