Payments — PHP SDK

Create a transaction

$transaction = $simiz->transactions->create([
    'amount' => 5000,
    'currency' => 'XAF',
    'payment_method' => 'ORANGE_MONEY',
    'payer' => [
        'phone' => '237690000000',
        'name' => 'John Doe',
        'email' => 'john@example.com',
    ],
    'description' => 'Order #12345',
    'reference' => 'ORDER-123',
    'metadata' => ['order_id' => '123'],
    'callback_url' => 'https://your-site.com/webhooks/simiz',
]);

Retrieve a transaction

$transaction = $simiz->transactions->retrieve('tx_xxx');

if ($transaction->status === 'COMPLETED') {
    echo 'Payment successful!';
}

List transactions

$transactions = $simiz->transactions->list([
    'limit' => 20,
    'status' => 'COMPLETED',
]);

foreach ($transactions->data as $tx) {
    echo "{$tx->id}: {$tx->amount} {$tx->currency}\n";
}

Create a refund

$refund = $simiz->refunds->create([
    'transaction_id' => 'tx_xxx',
    'amount' => 2500,
    'reason' => 'Item returned',
]);

Error handling

use Simiz\Exception\ApiException;
use Simiz\Exception\AuthenticationException;

try {
    $tx = $simiz->transactions->create([...]);
} catch (AuthenticationException $e) {
    echo 'Invalid API key';
} catch (ApiException $e) {
    echo "Error {$e->getCode()}: {$e->getMessage()}";
} catch (\Exception $e) {
    echo "Unexpected error: {$e->getMessage()}";
}