Payments
Create and manage payment transactions using the PaysGator API.
Create Payment
Creates a new payment transaction and generates a checkout link for the customer.
Endpoint: POST /payment/create
Request Body
| Field | Type | Description | Required |
|---|---|---|---|
amount | number | The amount to charge (e.g., 100.00) | Yes |
currency | string | ISO 4217 Currency code (e.g., USD, MZN) | Yes |
externalTransactionId | string | Your internal reference ID for the order | No |
payment_methods | array | Allowed payment methods (e.g., ["MPESA", "CARD"]) | No |
fields | array | Fields to collect from customer (e.g., ["name", "email"]) | No |
returnUrl | string | URL to redirect the customer after payment | No |
metadata | object | Additional custom data attached to the transaction | No |
Example Request
{
"amount": 100.00,
"currency": "USD",
"externalTransactionId": "order_12345",
"payment_methods": ["MPESA", "CARD"],
"fields": ["name", "email"],
"returnUrl": "https://example.com/success",
"metadata": {
"title": "Premium Subscription",
"description": "Monthly premium plan"
}
}
Success Response
{
"success": true,
"data": {
"paymentlinkId": "uuid-v4-payment-link-id",
"checkoutUrl": "https://paysgator.com/checkout/uuid-v4",
"transactionId": "uuid-v4-transaction-id"
}
}
Confirm Payment
Confirms a payment directly if you are collecting payment details on your own checkout page.
Endpoint: POST /payment/confirm
Request Body
| Field | Type | Description | Required |
|---|---|---|---|
paymentLinkId | string | The ID of the payment link to confirm | Yes |
paymentMethod | string | The payment method to use (e.g., MPESA) | Yes |
payment_fields | object | Method-specific fields (e.g., phoneNumber) | No |
customer | object | Customer details (name, email, phone, etc.) | No |
Example Request
{
"paymentLinkId": "uuid-v4-payment-link-id",
"paymentMethod": "MPESA",
"payment_fields": {
"phoneNumber": "841234567"
},
"customer": {
"name": "John Doe",
"email": "john@example.com"
}
}
Success Response
{
"success": true,
"data": {
"transactionId": "uuid-v4-transaction-id",
"fee": 2.50,
"netAmount": 97.50
}
}