โšก DEVELOPER DOCUMENTATION ยท API v1

Pay2Fast Mobile Recharge Api Selling API Integration Guide

Complete guide for API Users: configuration, IP whitelist, Bearer Token authentication, recharge, transaction status and callback handling.

๐Ÿš€ Quick Start

To enable an API User, first complete the configuration on the API Configuration page. An API request is accepted only when the token, API User status, callback URL, and source IP all pass validation.

1 ConfigureEnter a Callback URL and at least 1 IP address.
2 Generate TokenGenerate the API Token and store it securely.
3 Call APISend the JSON request with the Bearer Token.
4 Receive ResultReceive the callback or check the status using the Status API.

โš™๏ธ API Configuration

After logging in as an API User, configure the following information from Sidebar โ†’ API Configuration.

FieldRequiredWhat to enter
Response / Callback PageYesYour server's public http:// or https:// callback URL
IP Address 1YesThe server IP from which API requests will originate
IP Address 2NoSecond authorized server IP
IP Address 3NoThird authorized server IP
API TokenYesCreate it using Generate Token
PINYes on configurationYour configuration PIN
Authorization rule: The API request source IP must match one of the configured IP 1/2/3 addresses. The API User must be active and a Callback URL must be configured.

๐Ÿ” Authentication

Every customer API request must send the generated API Token as a Bearer Token.

HeaderAuthorization
FormatBearer YOUR_API_TOKEN
Content Typeapplication/json
Authorization: Bearer YOUR_API_TOKEN
Content-Type: application/json
Accept: application/json
401 Unauthorized: This response is returned when the token is missing or incorrect, the configuration is inactive, or authentication is invalid. 403 Forbidden This usually occurs for an inactive user, missing callback configuration, or an unauthorized IP.
Never expose your token: Do not store the API Token in an Android APK, browser JavaScript, HTML source, GitHub repository, or public frontend code. Use server-to-server API calls.

๐Ÿ“ฑ Recharge API

POST /api/v1/recharge.php

Use this endpoint to create a mobile recharge request.

Request Body

FieldRequiredExample / Notes
mobileYes10 digit mobile number
operatorYesJIO, AIRTEL, VI, etc.
operator_codeRecommendedCanonical operator code
amountYesRecharge amount, e.g. 199
client_txn_idYesYour unique order/reference ID
service_typeNoDefault: prepaid
curl -X POST "https://samadigital.us.cc/api/v1/recharge.php" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "mobile": "9876543210",
    "operator": "JIO",
    "operator_code": "JIO",
    "service_type": "prepaid",
    "amount": 199,
    "client_txn_id": "ORDER-10001"
  }'

Typical Response

{
  "status": "pending",
  "transaction_id": "RCH_123",
  "client_txn_id": "ORDER-10001",
  "provider_txn_id": null,
  "message": "Accepted"
}
Wallet: The accepted recharge amount is debited from the API User's wallet. If the provider directly returns failed, the amount is automatically refunded.

๐Ÿ”Ž Transaction Status API

GET /api/v1/status.php?transaction_id=RCH_123

Use this endpoint to get the latest status of a recharge transaction. An API User can only view their own transactions.

curl -X GET "https://samadigital.us.cc/api/v1/status.php?transaction_id=RCH_123" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Accept: application/json"
{
  "status": "success",
  "transaction_id": "RCH_123",
  "client_txn_id": "ORDER-10001",
  "provider_txn_id": "PROV-778899"
}

Possible status: pending, success, failed.

๐Ÿ“ฉ Your Response / Callback URL

When a transaction result is available, Pay2Fast sends a JSON POST to the URL configured under the API User's API Configuration โ†’ Response / Callback Page.

POST https://your-domain.com/api/callback.php
Content-Type: application/json

{
  "status": "success",
  "transaction_id": "RCH_123",
  "client_txn_id": "ORDER-10001",
  "provider_txn_id": "PROV-778899",
  "message": "Recharge successful"
}
Recommended: Your callback endpoint should quickly return a 200 response and update the transaction using the same client_txn_id. Your application should handle duplicate callbacks safely.

๐Ÿ” Provider Callback Endpoint

POST /api/v1/callback.php

This is for the upstream recharge provider โ†’ Pay2Fast callback. It is different from the API User's own callback URL.

POST https://samadigital.us.cc/api/v1/callback.php
Content-Type: application/json
X-Callback-Signature: YOUR_HMAC_SHA256_SIGNATURE

{
  "transaction_id": "RCH_123",
  "client_txn_id": "ORDER-10001",
  "provider_txn_id": "PROV-778899",
  "status": "success",
  "message": "Recharge successful"
}

If a callback secret is configured under Admin โ†’ API Providers, generate an HMAC-SHA256 signature from the exact raw JSON body and send it in the X-Callback-Signature header.

Automatic refund: When a provider callback marks a transaction as failed for the first time, the debited recharge amount is refunded to the wallet. Repeated failed callbacks do not trigger duplicate refunds.

๐Ÿ“‹ Supported Operator Codes

Operator CodeOperatorService
AIRTELAirtelPrepaid
JIOReliance JioPrepaid
VIVodafone Idea (Vi)Prepaid
BSNLBSNLPrepaid
MTNLMTNLPrepaid

If the provider uses its own operator IDs, Admin-side mapping can translate them into the provider code.

โš ๏ธ HTTP Response Codes

HTTPMeaningCommon reason
200Success / processedRequest accepted or status returned
400Bad RequestInvalid JSON body
401UnauthorizedMissing or invalid Bearer Token
402Payment RequiredInsufficient wallet balance
403ForbiddenInactive user, callback not configured, or IP not authorized
405Method Not AllowedWrong HTTP method
422Validation ErrorMissing/invalid request field
502Provider ErrorUpstream provider failure

๐Ÿ’ป PHP Server-to-Server Example

<?php
$token = 'YOUR_API_TOKEN';
$url = 'https://samadigital.us.cc/api/v1/recharge.php';

$data = [
    'mobile' => '9876543210',
    'operator' => 'JIO',
    'operator_code' => 'JIO',
    'service_type' => 'prepaid',
    'amount' => 199,
    'client_txn_id' => 'ORDER-10001'
];

$ch = curl_init($url);
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . $token,
        'Content-Type: application/json',
        'Accept: application/json'
    ],
    CURLOPT_POSTFIELDS => json_encode($data)
]);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

echo $httpCode . "\n";
echo $response;

JavaScript / Browser Note

Sending the production API token directly from a browser/Android client is not recommended. Call the Pay2Fast API from your own backend/server so the token is not exposed publicly.

๐Ÿ›ก๏ธ Security Checklist

โœ“ Use an HTTPS callback URL
โœ“ Keep the API Token secret
โœ“ Whitelist the production server IP
โœ“ Use a unique client_txn_id for every recharge
โœ“ Handle duplicate callbacks safely
โœ“ Log 401/403/402 responses
If the token is compromised: Do not use the old token. Generate a new token from API Configuration and update the token in your application/server configuration.

๐Ÿ“ž Integration Support

If you have an issue with API configuration, authentication, recharge, callbacks, or transaction status, check your API User account and request/response details. Never share the secret token, PIN, or callback secret publicly.