Overview

The PayFlow Payment Gateway API allows you to seamlessly integrate secure and reliable payment processing into your applications. Our API supports multiple payment methods, real-time transaction status, and detailed reporting to help you manage your payments efficiently.

Diagram payment processor

Authentication

All API requests require authentication via an API key. You must include your API key in the Authorization header as a Bearer token.

Authorization: Bearer YOUR_API_KEY_HERE

You can generate and manage your API keys in your dashboard. Keep your keys secure and do not share them publicly.

API Endpoints

Create Payment

Initiate a new payment transaction.

POST /api/v1/payments

Request Body

{
  "amount": 1000,
  "currency": "USD",
  "payment_method": "card",
  "card": {
    "number": "4242424242424242",
    "expiry_month": "12",
    "expiry_year": "2025",
    "cvc": "123"
  },
  "description": "Order #1234"
}
          

Response

{
  "id": "pay_01F8XYZ1234567890",
  "status": "pending",
  "amount": 1000,
  "currency": "USD",
  "created_at": "2024-06-01T12:00:00Z"
}
          

Get Payment Status

Retrieve the status of a payment by its ID.

GET /api/v1/payments/{payment_id}

Response

{
  "id": "pay_01F8XYZ1234567890",
  "status": "completed",
  "amount": 1000,
  "currency": "USD",
  "paid_at": "2024-06-01T12:05:00Z"
}
          

Refund Payment

Refund a completed payment partially or fully.

POST /api/v1/payments/{payment_id}/refund

Request Body

{
  "amount": 500,
  "reason": "Customer requested partial refund"
}
          

Response

{
  "id": "refund_01F8XYZ9876543210",
  "payment_id": "pay_01F8XYZ1234567890",
  "amount": 500,
  "status": "processed",
  "created_at": "2024-06-02T09:00:00Z"
}
          

List Transactions

Retrieve a paginated list of transactions with filters.

GET /api/v1/transactions?limit=10&status=completed

Response

{
  "transactions": [
    {
      "id": "pay_01F8XYZ1234567890",
      "status": "completed",
      "amount": 1000,
      "currency": "USD",
      "paid_at": "2024-06-01T12:05:00Z"
    },
    {
      "id": "pay_01F8XYZ0987654321",
      "status": "completed",
      "amount": 2500,
      "currency": "USD",
      "paid_at": "2024-06-01T13:15:00Z"
    }
  ],
  "pagination": {
    "limit": 10,
    "offset": 0,
    "total": 25
  }
}
          

Code Examples

cURL - Create Payment

curl -X POST https://api.payflow.com/v1/payments \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 1000,
    "currency": "USD",
    "payment_method": "card",
    "card": {
      "number": "4242424242424242",
      "expiry_month": "12",
      "expiry_year": "2025",
      "cvc": "123"
    },
    "description": "Order #1234"
  }'
          

JavaScript (Fetch) - Get Payment Status

fetch('https://api.payflow.com/v1/payments/pay_01F8XYZ1234567890', {
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY'
  }
})
  .then(res => res.json())
  .then(data => console.log(data))
  .catch(err => console.error(err));
          

Python - Refund Payment

import requests

url = "https://api.payflow.com/v1/payments/pay_01F8XYZ1234567890/refund"
headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
}
data = {
    "amount": 500,
    "reason": "Customer requested partial refund"
}

response = requests.post(url, json=data, headers=headers)
print(response.json())
          

Node.js (Axios) - List Transactions

const axios = require('axios');

axios.get('https://api.payflow.com/v1/transactions?limit=10&status=completed', {
  headers: {
    Authorization: 'Bearer YOUR_API_KEY'
  }
})
.then(response => {
  console.log(response.data);
})
.catch(error => {
  console.error(error);
});