postpay/postpay-php

Postpay SDK for PHP


Keywords
rest, api, client, payments, sdk, graphql, postpay, php, restful
License
MIT

Documentation

Latest Version Build Status Scrutinizer Coverage

Postpay SDK for PHP

PHP library for Postpay API.

Installation

The recommended way to install postpay-php is through Composer:

composer require postpay/postpay-php

After installing, you need to require Composer's autoloader:

require 'vendor/autoload.php';

Quickstart

All configs are passed around as a single variable config:

$postpay = new \Postpay\Postpay([
    'merchant_id' => 'id_ ...',
    'secret_key' => 'sk_live_ ...',
]);

RESTful

For information about Postpay's RESTful API, see the API documentation.

use Postpay\Exceptions\RESTfulException;

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

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

GraphQL

For information about Postpay's GraphQL API, see the API documentation.

use Postpay\Exceptions\GraphQLException;

$query = <<<'QUERY'
query OrderList($status: String!) {
  orders(status: $status) {
    edges {
      node {
        orderId
      }
    }
  }
}
QUERY;

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

try {
    $response = $postpay->query($query, $variables);
} catch (GraphQLException $e) {
    print_r($e->getErrors());
    exit;
}
print_r($response->json());

Sandbox

Set sandbox config variable to true for sandbox requests:

$postpay = new \Postpay\Postpay([
    'sandbox' => true,
    'merchant_id' => 'id_ ...',
    'secret_key' => 'sk_test_ ...',
]);

Documentation

Fantastic documentation is available at https://php.postpay.io.