Skip to main content

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

FieldTypeDescriptionRequired
amountnumberThe amount to charge (e.g., 100.00)Yes
currencystringISO 4217 Currency code (e.g., USD, MZN)Yes
externalTransactionIdstringYour internal reference ID for the orderNo
payment_methodsarrayAllowed payment methods (e.g., ["MPESA", "CARD"])No
fieldsarrayFields to collect from customer (e.g., ["name", "email"])No
returnUrlstringURL to redirect the customer after paymentNo
metadataobjectAdditional custom data attached to the transactionNo

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

FieldTypeDescriptionRequired
paymentLinkIdstringThe ID of the payment link to confirmYes
paymentMethodstringThe payment method to use (e.g., MPESA)Yes
payment_fieldsobjectMethod-specific fields (e.g., phoneNumber)No
customerobjectCustomer 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
}
}