API Reference
Welcome to the PaysGator API Reference. This documentation provides detailed information about our API endpoints, request structures, and response formats.
Base URL
All API requests should be made to the following base URL:
https://paysgator.com/api/v1
Authentication
The API uses API Key authentication. Include your key in the X-Api-Key header of every request. You can use LIVE or TEST keys to control the transaction mode.
X-Api-Key: YOUR_API_KEY
Endpoints
Payments
Create Payment
Creates a payment transaction with an associated payment link.
- URL:
/payment/create - Method:
POST - Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
amount | number | Yes | Payment amount (e.g., 100.00). |
currency | string | Yes | ISO 4217 Currency code (e.g., USD, MZN). |
payment_methods | array | No | List of allowed payment methods (e.g., ["MPESA", "CARD"]). |
returnUrl | string | No | URL to redirect after payment. |
fields | array | No | Fields to collect from customer (name, email, phone, address). |
externalTransactionId | string | No | Your external reference ID. |
metadata | object | No | Additional metadata. |
- Response (200 OK):
success:truedata:paymentlinkId: UUIDcheckoutUrl: Payment page URLtransactionId: UUID
Confirm Payment
Confirms a payment directly from a payment link (for "Confirm" type methods).
- URL:
/payment/confirm - Method:
POST - Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
paymentLinkId | string | Yes | The ID of the payment link. |
paymentMethod | string | Yes | The method to use (e.g., MPESA). |
payment_fields | object | No | Method-specific fields (e.g., { "phoneNumber": "..." }). |
customer | object | No | Customer info (name, email, phone, address, country). |
- Response (200 OK):
success:truedata:transactionId: UUIDfee: Transaction feenetAmount: Net amount
Wallet
Get Wallet Balance
Retrieves the balance for the wallet associated with the API key.
- URL:
/wallet/balance - Method:
GET - Response (200 OK):
walletId: UUIDcurrency: Currency codebalance: Balance stringmode:LIVEorTEST
Transactions
Get Transaction
Retrieves details of a specific transaction.
- URL:
/transactions/{id} - Method:
GET - Parameters:
id(path): Transaction UUID
- Response (200 OK):
id: UUIDamount: numbercurrency: stringstatus:PENDING,SUCCESS,FAILED,REFUNDEDmethod: payment method usedcreatedAt: ISO datemode:LIVEorTEST
Subscriptions
Create Subscription
Initiates a new subscription in PAUSED state and returns a checkout URL.
- URL:
/subscription/create - Method:
POST - Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
planId | string | Yes | ID of the subscription plan. |
customerEmail | string | Yes | Email address of the customer. |
customerName | string | No | Name of the customer. |
metadata | object | No | Additional metadata. |
- Response (200 OK):
success:truedata:subscriptionId: UUIDcheckoutUrl: Payment page URLstatus:PAUSED
Get Subscription
Retrieves details of a specific subscription.
- URL:
/subscription/{id} - Method:
GET - Parameters:
id(path): Subscription UUID
- Response (200 OK):
success:truedata:id: UUIDplanId: UUIDcustomerEmail: stringstatus:ACTIVE,CANCELED,PAST_DUE,PAUSEDcurrentPeriodStart: ISO datecurrentPeriodEnd: ISO datecreatedAt: ISO date
List Subscriptions
Lists all subscriptions for the company.
- URL:
/subscriptions - Method:
GET - Parameters (Query):
customerEmail: (Optional) Filter by customer email.status: (Optional) Filter by status.planId: (Optional) Filter by plan ID.
- Response (200 OK):
success:truedata: Array of Subscription objects.
Update Subscription
Updates a subscription status (cancel, pause, resume).
- URL:
/subscriptions/{id} - Method:
PATCH - Parameters:
id(path): Subscription UUID
- Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
action | string | Yes | One of: cancel, pause, resume. |
- Response (200 OK):
id: UUIDstatus:ACTIVE,CANCELED,PAST_DUE,PAUSEDcurrentPeriodEnd: ISO date
Errors
The API uses standard HTTP status codes to indicate success or failure. Error responses follow this format:
{
"error": {
"message": "Human-readable error message",
"code": "MACHINE_READABLE_CODE"
}
}
Common Error Codes:
UNAUTHORIZEDNOT_FOUNDMISSING_FIELDSWALLET_NOT_FOUNDCURRENCY_MISMATCHPAYMENT_FAILEDINTERNAL_ERROR