PHP SDK - Payments#

M-Pesa (STK push) and Snippe (mobile money, hosted checkout).

Settings#

$db->payments->getSettings();

$db->payments->updateSettings(
    mpesaConsumerKey: '...',
    mpesaConsumerSecret: '...',
    snippeApiKey: '...',
);
PHP

M-Pesa STK push#

$result = $db->payments->stkPush(
    phone: '+255712345678',
    amount: 5000,
    description: 'Order #123',
);
PHP

The customer authorizes on their phone; RafikiDB receives the callback and records the transaction.

Snippe#

// Direct mobile money payment
$db->payments->snippeInitiate(
    amount: 15000,
    phone: '+255712345678',
    firstName: 'Asha',
    lastName: 'Mwinyi',
    email: 'asha@example.com',
    orderId: 'order_123',
);

// Hosted checkout session
$db->payments->snippeSession(
    amount: 15000,
    description: 'Checkout',
    redirectUrl: 'https://myapp.com/payments/callback',
    customerName: 'Asha Mwinyi',
    customerPhone: '+255712345678',
    orderId: 'order_123',
    expiresIn: 3600,
);
PHP

Status and transactions#

$db->payments->snippeStatus($reference);
$db->payments->listTransactions();
$db->payments->getTransaction($transactionId);
PHP

Payment callbacks are HMAC-signed like webhooks.

Next: Errors.