API Documentation
Integrate Fripal Connect Gh data bundle purchasing directly into your own website, app or system. Buy MTN, Telecel, AirtelTigo and BigTime bundles programmatically using your API key.
Every request must include your X-API-KEY and X-API-SECRET in the request headers.
Generate your credentials from your dashboard under Developer API.
X-API-KEY: bgk_your_api_key_here X-API-SECRET: bgs_your_api_secret_here Content-Type: application/json Accept: application/json
| Environment | Base URL |
|---|---|
| Live | http://www.fripalconnectgh.com/api/v1 |
All responses are JSON. All amounts are in GHS (Ghana Cedis). Timestamps are in Africa/Accra timezone (UTC+0).
When you exceed a limit, the API returns 429 Too Many Requests. The response includes a Retry-After header indicating when you can retry. Bulk orders count as a single request regardless of how many recipients are included.
| HTTP Code | Error Type | Description |
|---|---|---|
400 | VALIDATION_ERROR | Missing or invalid request parameters |
401 | UNAUTHORIZED | Invalid, missing or disabled API key/secret |
402 | INSUFFICIENT_BALANCE | Wallet balance too low to place order |
404 | NOT_FOUND | Order reference or bundle not found |
409 | PENDING_ORDER | A pending order already exists for that phone number |
422 | UNPROCESSABLE | Request understood but cannot be processed |
429 | RATE_LIMIT | Too many requests — slow down |
500 | SERVER_ERROR | Internal error — contact support |
{
"success": false,
"error": "Insufficient wallet balance",
"type": "INSUFFICIENT_BALANCE",
"message": "Your wallet balance (GH₵2.50) is too low for this order (GH₵5.00)."
}
Returns all active bundles with prices based on your account type (user, agent, dealer, merchant). Prices shown are what will be deducted from your wallet when placing an order.
Query Parameters (optional)| Parameter | Type | Description |
|---|---|---|
| network optional | string | Filter by network: MTN, Telecel, AirtelTigo, BigTime |
GET http://www.fripalconnectgh.com/api/v1/bundles
X-API-KEY: bgk_your_api_key_here
X-API-SECRET: bgs_your_api_secret_here
{
"success": true,
"account_type": "agent",
"bundles": [
{
"id": 1,
"network": "MTN",
"volume": "1GB",
"price": 5.00,
"offer_slug": "mtn_master_beneficiary_portal",
"status": "active"
},
{
"id": 2,
"network": "MTN",
"volume": "2GB",
"price": 9.50,
"offer_slug": "mtn_master_beneficiary_portal",
"status": "active"
}
]
}
Places a single data bundle order for the given phone number. The bundle price is immediately deducted from your wallet. If there is already a pending order for the same phone number, the request will be rejected.
Request Body| Field | Type | Required | Description |
|---|---|---|---|
| bundle_id | integer | Required | Bundle ID from GET /bundles |
| phone | string | Required | Recipient phone number in format 0XXXXXXXXX (10 digits) |
| webhook_url | string | Optional | URL to receive status update callbacks |
POST http://www.fripalconnectgh.com/api/v1/order Content-Type: application/json X-API-KEY: bgk_your_api_key_here X-API-SECRET: bgs_your_api_secret_here { "bundle_id": 1, "phone": "0241234567", "webhook_url": "https://yoursite.com/webhooks/bundles" }
{
"success": true,
"message": "Order placed successfully",
"order": {
"id": 143,
"reference": "BUD-API-A1B2C3D4-143022",
"network": "MTN",
"volume": "1GB",
"phone": "0241234567",
"price": 5.00,
"status": "processing",
"placed_at": "2025-04-17T10:30:00+00:00"
},
"wallet_balance": 145.00
}
Place one order to multiple recipients at once. All recipients get the same bundle. The total cost (price × quantity) is deducted from your wallet in a single transaction. Maximum 100 numbers per request.
Request Body| Field | Type | Required | Description |
|---|---|---|---|
| bundle_id | integer | Required | Bundle ID from GET /bundles |
| phones | array | Required | Array of phone numbers (max 100). Each must be 0XXXXXXXXX format |
| webhook_url | string | Optional | URL to receive delivery callbacks |
POST http://www.fripalconnectgh.com/api/v1/order/bulk Content-Type: application/json X-API-KEY: bgk_your_api_key_here X-API-SECRET: bgs_your_api_secret_here { "bundle_id": 1, "phones": [ "0241234567", "0201234567", "0551234567" ], "webhook_url": "https://yoursite.com/webhooks/bundles" }
{
"success": true,
"message": "Bulk order placed successfully",
"bulk_order": {
"id": 22,
"reference": "BUD-BULK-X9Y8Z7W6-143045",
"bundle_id": 1,
"total_quantity": 3,
"total_price": 15.00,
"status": "processing",
"placed_at": "2025-04-17T10:31:00+00:00"
},
"wallet_balance": 130.00
}
Get the current status of an order. Pass the reference returned when the order was placed. Works for both single orders and bulk orders.
| Parameter | Type | Description |
|---|---|---|
| reference required | string | Order reference e.g. BUD-API-A1B2C3D4-143022 |
GET http://www.fripalconnectgh.com/api/v1/order/status/BUD-API-A1B2C3D4-143022
X-API-KEY: bgk_your_api_key_here
X-API-SECRET: bgs_your_api_secret_here
{
"success": true,
"order": {
"reference": "BUD-API-A1B2C3D4-143022",
"type": "single",
"network": "MTN",
"volume": "1GB",
"phone": "0241234567",
"price": 5.00,
"status": "delivered",
"placed_at": "2025-04-17T10:30:00+00:00",
"delivered_at": "2025-04-17T10:30:45+00:00"
}
}
| Status | Meaning |
|---|---|
placed | Order received, queued for processing |
processing | Order sent to provider, awaiting confirmation |
delivered | Data bundle successfully delivered ✓ |
failed | Delivery failed — wallet will be refunded |
cancelled | Order was cancelled — wallet refunded |
refunded | Amount has been returned to your wallet |
Returns your current wallet balance in GHS. Use this to verify you have sufficient funds before placing orders.
GET http://www.fripalconnectgh.com/api/v1/wallet/balance
X-API-KEY: bgk_your_api_key_here
X-API-SECRET: bgs_your_api_secret_here
{
"success": true,
"balance": 150.50,
"currency": "GHS",
"account_type": "agent",
"timestamp": "2025-04-17T10:30:00+00:00"
}
Returns your most recent wallet transactions (credits and debits). Paginated — 20 per page by default.
Query Parameters| Parameter | Type | Default | Description |
|---|---|---|---|
| page | integer | 1 |
Page number |
| per_page | integer | 20 |
Results per page (max 100) |
{
"success": true,
"transactions": [
{
"id": 201,
"type": "debit",
"amount": 5.00,
"description": "MTN 1GB order for 0241234567",
"reference": "BUD-API-A1B2C3D4-143022",
"balance_after": 145.00,
"created_at": "2025-04-17T10:30:00+00:00"
}
],
"pagination": {
"current_page": 1,
"per_page": 20,
"total": 142,
"last_page": 8
}
}
1. Reusable PHP Helper Class
Copy this class into your project and use it for all API calls.
<?php class BundlesGhana { private $apiKey; private $apiSecret; private $baseUrl = 'http://www.fripalconnectgh.com/api/v1'; public function __construct($apiKey, $apiSecret) { $this->apiKey = $apiKey; $this->apiSecret = $apiSecret; } private function request($method, $endpoint, $data = []) { $url = $this->baseUrl . $endpoint; $ch = curl_init(); $headers = [ 'X-API-KEY: ' . $this->apiKey, 'X-API-SECRET: ' . $this->apiSecret, 'Content-Type: application/json', 'Accept: application/json', ]; curl_setopt_array($ch, [ CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => $headers, CURLOPT_TIMEOUT => 30, CURLOPT_SSL_VERIFYPEER => true, ]); if ($method === 'POST') { curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); } $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); return json_decode($response, true); } public function getBundles($network = null) { $ep = '/bundles' . ($network ? '?network=' . $network : ''); return $this->request('GET', $ep); } public function placeOrder($bundleId, $phone, $webhookUrl = null) { $data = ['bundle_id' => $bundleId, 'phone' => $phone]; if ($webhookUrl) $data['webhook_url'] = $webhookUrl; return $this->request('POST', '/order', $data); } public function placeBulkOrder($bundleId, array $phones, $webhookUrl = null) { $data = ['bundle_id' => $bundleId, 'phones' => $phones]; if ($webhookUrl) $data['webhook_url'] = $webhookUrl; return $this->request('POST', '/order/bulk', $data); } public function getOrderStatus($reference) { return $this->request('GET', '/order/status/' . urlencode($reference)); } public function getBalance() { return $this->request('GET', '/wallet/balance'); } }
2. Usage Examples
$api = new BundlesGhana( 'bgk_your_api_key_here', 'bgs_your_api_secret_here' ); // 1. Get all MTN bundles $bundles = $api->getBundles('MTN'); if ($bundles['success']) { foreach ($bundles['bundles'] as $bundle) { echo $bundle['volume'] . ' — GH₵' . $bundle['price'] . "\n"; } } // 2. Check balance before ordering $wallet = $api->getBalance(); if ($wallet['balance'] < 5.00) { die('Insufficient balance!'); } // 3. Place order (bundle_id 1 = MTN 1GB at GH₵5.00) $order = $api->placeOrder( 1, // bundle_id '0241234567', // recipient phone 'https://yoursite.com/webhook/bundles' // optional webhook ); if ($order['success']) { $ref = $order['order']['reference']; echo "Order placed! Reference: " . $ref; // Save $ref to your database for tracking } else { echo "Error: " . $order['message']; }
$api = new BundlesGhana('bgk_your_api_key', 'bgs_your_secret'); // Send MTN 1GB (bundle_id=1) to 3 numbers $result = $api->placeBulkOrder( 1, ['0241234567', '0201234567', '0551234567'], 'https://yoursite.com/webhook/bundles' ); if ($result['success']) { $bulkRef = $result['bulk_order']['reference']; $totalCost = $result['bulk_order']['total_price']; echo "Bulk order ref: {$bulkRef} — Cost: GH₵{$totalCost}"; }
$api = new BundlesGhana('bgk_your_api_key', 'bgs_your_secret'); $ref = 'BUD-API-A1B2C3D4-143022'; // saved from order placement $maxAttempts = 10; $attempt = 0; while ($attempt++ < $maxAttempts) { $result = $api->getOrderStatus($ref); $status = $result['order']['status'] ?? 'unknown'; if ($status === 'delivered') { echo "✓ Delivered at: " . $result['order']['delivered_at']; break; } if (in_array($status, ['failed', 'cancelled'])) { echo "✗ Order {$status}"; break; } echo "Status: {$status} — waiting...\n"; sleep(8); // wait 8 seconds before next check }
When you include a webhook_url in your order request, we will send a POST request to that URL every time the order status changes. Your server must respond with HTTP 200 within 5 seconds.
{
"event": "order.status.updated",
"reference": "BUD-API-A1B2C3D4-143022",
"status": "delivered",
"network": "MTN",
"volume": "1GB",
"phone": "0241234567",
"delivered_at": "2025-04-17T10:30:45+00:00",
"timestamp": "2025-04-17T10:30:46+00:00"
}
<?php // webhook.php — your webhook endpoint $payload = json_decode(file_get_contents('php://input'), true); if (!$payload || $payload['event'] !== 'order.status.updated') { http_response_code(400); exit; } $reference = $payload['reference']; $status = $payload['status']; // Update your database switch ($status) { case 'delivered': // Mark order as complete in your DB, notify customer etc. markOrderDelivered($reference, $payload['delivered_at']); break; case 'failed': // Handle failed order, trigger refund logic etc. markOrderFailed($reference); break; } // Always return 200 quickly http_response_code(200); echo json_encode(['received' => true]);
reference in your database when placing orders and use it to match incoming webhooks.
Handle duplicate webhooks gracefully (we may retry on failure).