SDK & code

You can integrate using any HTTP client. If you use PHP, a CardPlusPay SDK is available to call the API with a simple client interface.

PHP SDK

Requirements: PHP 7.4+, Composer, Guzzle. Install via Composer (if the package is published) or include the SDK in your project.

Initialize the client

use CardPlusPay\CardPlusPayClient;

$client = new CardPlusPayClient('your-api-key');

Optionally pass a custom base URL as the second argument if you use a different environment (e.g. sandbox). Production base URL is https://api.cardpluspay.com/v1.

Get balance

$response = $client->getBalance();
$balance = $response->getBalance();
echo $balance->getBalance() . ' ' . $balance->getCurrency();

Get catalog

$response = $client->getCatalog(['per_page' => 10]);
foreach ($response->getProducts() as $product) {
    echo $product->getProductName() . ' - ' . $product->getItemCode() . "\n";
}

To fetch one product by item code: getCatalog(['item_id' => 'GOOGLE-5USD-KOXx']).

Check stock

$response = $client->checkStock('GOOGLE-5USD-KOXx', 1);
if ($response->isSuccess()) {
    // Product is in stock
}

Create order

$response = $client->createOrder('GOOGLE-5USD-KOXx', 1, 'customer@example.com');
$order = $response->getOrder();
$orderId = $order->getOrderId();
foreach ($order->getCodes() as $code) {
    echo $code['code'] . "\n";
}

Get order by ID

$response = $client->getOrder(123);
$order = $response->getOrder();
echo $order->getStatus();
foreach ($order->getCodes() as $code) {
    echo $code['code'];
}

Direct HTTP

You can skip the SDK and use cURL, Guzzle, or any HTTP library. Send X-API-Key and Accept: application/json; for POST, use Content-Type: application/json. See the Quick start and how-to guides for examples.

← Reference summary · Integration Guide · Security →