Fripal Connect Gh Fripal Connect Gh API

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.

Base URL:  http://www.fripalconnectgh.com/api/v1
Authentication
All API requests require your API key and secret

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.

Request Headers
X-API-KEY: bgk_your_api_key_here
X-API-SECRET: bgs_your_api_secret_here
Content-Type: application/json
Accept: application/json
Keep your credentials secret. Never expose your API key or secret in client-side code, public repos or logs. If compromised, regenerate immediately from your dashboard.
Base URL
All endpoints are relative to this URL
EnvironmentBase 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).

Rate Limits
Limits are applied per API key
60
Requests / minute
500
Requests / hour
5,000
Requests / day

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.

Error Codes
Standard error responses
HTTP CodeError TypeDescription
400VALIDATION_ERRORMissing or invalid request parameters
401UNAUTHORIZEDInvalid, missing or disabled API key/secret
402INSUFFICIENT_BALANCEWallet balance too low to place order
404NOT_FOUNDOrder reference or bundle not found
409PENDING_ORDERA pending order already exists for that phone number
422UNPROCESSABLERequest understood but cannot be processed
429RATE_LIMITToo many requests — slow down
500SERVER_ERRORInternal error — contact support
Error Response Format
{
  "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)."
}
List Available Bundles
Get all active data bundles with your account pricing
GET /api/v1/bundles Auth required

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)
ParameterTypeDescription
network optional string Filter by network: MTN, Telecel, AirtelTigo, BigTime
Example Request
GET http://www.fripalconnectgh.com/api/v1/bundles
X-API-KEY: bgk_your_api_key_here
X-API-SECRET: bgs_your_api_secret_here
200 OK Success Response
{
  "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"
    }
  ]
}
Place a Single Order
Purchase a data bundle for one phone number
POST /api/v1/order Auth required

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
FieldTypeRequiredDescription
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
Example Request
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"
}
201 Created Success Response
{
  "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 a Bulk Order
Send the same bundle to multiple phone numbers at once
POST /api/v1/order/bulk Auth required

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
FieldTypeRequiredDescription
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
Example Request
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"
}
201 Created Success Response
{
  "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 Order Status
Check the delivery status of any order by reference
GET /api/v1/order/status/{reference} Auth required

Get the current status of an order. Pass the reference returned when the order was placed. Works for both single orders and bulk orders.

Path Parameters
ParameterTypeDescription
reference required string Order reference e.g. BUD-API-A1B2C3D4-143022
Example Request
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
200 OK Success Response
{
  "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 Values
StatusMeaning
placedOrder received, queued for processing
processingOrder sent to provider, awaiting confirmation
deliveredData bundle successfully delivered ✓
failedDelivery failed — wallet will be refunded
cancelledOrder was cancelled — wallet refunded
refundedAmount has been returned to your wallet
Get Wallet Balance
Check your current wallet balance
GET /api/v1/wallet/balance Auth required

Returns your current wallet balance in GHS. Use this to verify you have sufficient funds before placing orders.

Example Request
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
200 OKSuccess Response
{
  "success": true,
  "balance": 150.50,
  "currency": "GHS",
  "account_type": "agent",
  "timestamp": "2025-04-17T10:30:00+00:00"
}
List Transactions
Get your recent wallet transactions
GET /api/v1/transactions Auth required

Returns your most recent wallet transactions (credits and debits). Paginated — 20 per page by default.

Query Parameters
ParameterTypeDefaultDescription
page integer 1 Page number
per_page integer 20 Results per page (max 100)
200 OKSuccess Response
{
  "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
  }
}
PHP Code Examples
Ready-to-use PHP snippets

1. Reusable PHP Helper Class

Copy this class into your project and use it for all API calls.

BundlesGhana.php
<?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

Example — Single Order
$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'];
}
Example — Bulk Order (send to multiple numbers)
$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}";
}
Example — Poll Order Status
$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
}
Webhooks
Receive real-time order status updates

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.

POSTWebhook Payload
{
  "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 Handler
<?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]);
Best practices: Always return HTTP 200 within 5 seconds — do heavy processing in a background job. Store the reference in your database when placing orders and use it to match incoming webhooks. Handle duplicate webhooks gracefully (we may retry on failure).
Fripal Connect Gh API v1  ·  Home  ·  Get API Key  ·  Support