PHP code example of cashela / payin

1. Go to this page and download the library: Download cashela/payin library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

cashela / payin example snippets



Cashela\PayIn\CashelaPayIn;
use Cashela\PayIn\CashelaApiError;

$client = new CashelaPayIn([
    'environment' => 'sandbox', // dev|staging|sandbox|production
    'apiKey' => $_ENV['CASHELA_API_KEY'],
    'apiSecret' => $_ENV['CASHELA_API_SECRET'],
]);

try {
    $countries = $client->listCountries();

    $deposit = $client->createDeposit(
        ['external_identifier' => 'order-123', /* ... */],
        idempotencyKey: 'order-123' // sent only on creation; never retry this call
    );
} catch (CashelaApiError $e) {
    // $e->status is the HTTP status, $e->raw is the decoded error envelope
    error_log("Cashela API error {$e->status}: {$e->getMessage()}");
}

$page = $client->listTransactions(['status' => 'COMPLETED', 'from' => '2026-01-01', 'limit' => 50]);
while ($page['next_cursor'] ?? null) {
    $page = $client->listTransactions(['limit' => 50, 'cursor' => $page['next_cursor']]);
}

$wallet = $client->getWallet();
$moves = $client->listWalletMovements(['type' => 'DEPOSIT', 'currency' => 'USD']);
$settlements = $client->listSettlements(['from' => '2026-01-01']);
$one = $client->getSettlement($settlements['data'][0]['id']);


Cashela\PayIn\Webhook;
use Cashela\PayIn\WebhookSignatureError;

$rawBody = file_get_contents('php://input');
$headers = getallheaders();

try {
    $payload = Webhook::verify($rawBody, $headers, $_ENV['CASHELA_WEBHOOK_SECRET']);
} catch (WebhookSignatureError $e) {
    http_response_code(400);
    exit;
}

// ... handle $payload (e.g. update the order matching $payload['ref'])
// $payload['status'] is one of COMPLETED | DECLINED | CANCELLED | REVERSED
http_response_code(200);