PayGateway Pro API Documentation

Welcome to the PayGateway Pro API documentation. Our RESTful API allows you to integrate payment processing, manage transactions, and access account information programmatically.

Base URL

https://api.paygateway.com/v1

API Version

The current API version is v1. All API requests should include the version in the URL path.

Authentication

PayGateway Pro uses API keys to authenticate requests. You can generate and manage your API keys from your dashboard.

API Key Authentication

Include your API key in the request headers:

X-API-Key: your_api_key_here

Example Request

curl -X GET "https://api.paygateway.com/v1/transactions" \
  -H "X-API-Key: your_api_key_here" \
  -H "Content-Type: application/json"

Payments

Process payments using various payment methods including cards, mobile money, and bank transfers.

POST /payments

Create Payment

Process a new payment transaction.

Parameters
Parameter Type Required Description
amount decimal Yes Payment amount
currency string Yes Currency code (USD, EUR, KES, etc.)
payment_method string Yes Payment method (card, mobile_money, bank)
customer object No Customer information
metadata object No Additional data
Example Request
{
  "amount": 100.00,
  "currency": "USD",
  "payment_method": "card",
  "customer": {
    "email": "customer@example.com",
    "phone": "+1234567890"
  },
  "metadata": {
    "order_id": "ORD-123",
    "product": "Premium Plan"
  }
}
Example Response
{
  "success": true,
  "transaction_id": "TXN_ABC123_1640995200",
  "amount": 100.00,
  "currency": "USD",
  "fee": 2.50,
  "net_amount": 97.50,
  "status": "processing"
}
GET /payments

Get Payment Status

Retrieve the status of a payment transaction.

Parameters
Parameter Type Required Description
transaction_id string Yes Transaction ID to query
Example Response
{
  "transaction_id": "TXN_ABC123_1640995200",
  "status": "completed",
  "amount": 100.00,
  "currency": "USD",
  "fee": 2.50,
  "net_amount": 97.50,
  "created_at": "2024-01-01T12:00:00Z",
  "updated_at": "2024-01-01T12:05:00Z"
}

Error Handling

PayGateway Pro uses conventional HTTP response codes to indicate the success or failure of an API request.

HTTP Status Codes

Code Description
200 OK - Request successful
201 Created - Resource created successfully
400 Bad Request - Invalid request parameters
401 Unauthorized - Invalid API key
404 Not Found - Resource not found
500 Internal Server Error - Server error

Error Response Format

{
  "error": "Invalid API key",
  "code": "INVALID_API_KEY",
  "details": "The provided API key is not valid or has been revoked"
}

SDKs and Libraries

We provide official SDKs for popular programming languages to make integration easier.

PHP SDK

composer require paygateway/php-sdk

// Initialize
$gateway = new PayGateway\Client('your_api_key');

// Create payment
$payment = $gateway->payments->create([
    'amount' => 100.00,
    'currency' => 'USD',
    'payment_method' => 'card'
]);

echo $payment->transaction_id;

JavaScript SDK

npm install @paygateway/js-sdk

// Initialize
const PayGateway = require('@paygateway/js-sdk');
const gateway = new PayGateway('your_api_key');

// Create payment
const payment = await gateway.payments.create({
    amount: 100.00,
    currency: 'USD',
    payment_method: 'card'
});

console.log(payment.transaction_id);

Python SDK

pip install paygateway-python

# Initialize
import paygateway
gateway = paygateway.Client('your_api_key')

# Create payment
payment = gateway.payments.create(
    amount=100.00,
    currency='USD',
    payment_method='card'
)

print(payment.transaction_id)