digipay/digipay-php

Official DigiPay PHP SDK — Accept Mobile Money payments, query transactions, manage payouts.

Maintainers

Package info

github.com/black-heart-sketch/digipay-php

Homepage

Issues

pkg:composer/digipay/digipay-php

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

dev-main 2026-04-13 02:03 UTC

This package is not auto-updated.

Last update: 2026-04-28 00:50:34 UTC


README

Official PHP SDK for the DigiPay Mobile Money payment gateway.

Requirements

  • PHP 8.0+
  • ext-curl
  • ext-json

Installation

composer require digipay/digipay-php

Quick Start

<?php
require_once 'vendor/autoload.php';

use DigiPay\DigiPay;
use DigiPay\DigiPayException;

$client = new DigiPay('dpk_YOUR_API_KEY');
// or use env var: putenv('DIGIPAY_API_KEY=dpk_...');
// then: $client = new DigiPay();

// 1. Check your balance
$balance = $client->settlements->getBalance();
echo "Balance: " . number_format($balance['balance']) . " XAF\n";

// 2. Initiate a pay-in (customer gets a Mobile Money push notification)
$payin = $client->payments->initiate(
    amount: 5000,
    customerPhone: '237699000000',
    customerEmail: 'customer@example.com',
    metadata: ['orderId' => 'ORDER_123'],
    webhookUrl: 'https://your-domain.com/webhook'
);
echo "Transaction ID: " . $payin['transactionId'] . "\n";
echo "Status: " . $payin['status'] . "\n"; // "pending"

// 3. Check transaction status
$txn = $client->payments->getStatus($payin['transactionId']);
echo "Status: " . $txn['status'] . "\n"; // "pending" | "success" | "failed"

// 4. Request a payout (withdraw funds to Mobile Money)
$payout = $client->settlements->requestPayout(
    amount: 10000,
    recipientPhone: '237699000000'
);
echo "Settlement ID: " . $payout['settlementId'] . "\n";

Error Handling

use DigiPay\DigiPayException;

try {
    $payin = $client->payments->initiate(5000, '237699000000');
} catch (DigiPayException $e) {
    echo "Error: " . $e->getMessage() . "\n";
    echo "HTTP Status: " . $e->getStatusCode() . "\n";
}

API Reference

new DigiPay($apiKey, $environment, $baseUrl, $timeout)

Param Type Default Description
$apiKey string $DIGIPAY_API_KEY env Your dpk_ API key
$environment string 'production' 'production' or 'sandbox'
$baseUrl string|null null Override the API base URL
$timeout int 30 cURL timeout in seconds

$client->payments->initiate($amount, $customerPhone, $customerEmail, $metadata, $webhookUrl)

$client->payments->getStatus($transactionId)

$client->settlements->getBalance()

$client->settlements->requestPayout($amount, $recipientPhone)

License

MIT