API Documentation

Comprehensive guide to integrating RexPayments into your application

Overview

Secure Payment Processing Made Simple

RexPayments provides three powerful APIs to handle all your payment needs. Choose the right endpoint for your use case and start accepting payments in minutes.

Generate Payments API

Create one-time payment links for individual transactions with automatic customer redirects.

Best for: Checkout flows, one-off purchases, and direct customer payments

Customers are redirected to complete payment and then back to your Success/Failure URL.

Payment Links API

Create shareable, reusable payment links with complete control over product details and payment limits.

Best for: Limited-time offers, stock-limited sales, service slots, and shareable invoices

Set expiration dates, payment limits, and manage link status programmatically.

Transaction Details API

Retrieve complete payment information using a payment ID for verification and reconciliation.

Best for: Payment verification, status checks, and order reconciliation

Access full transaction details including payment method, amount, currency, and status.

All API requests require authentication using your API key as a Bearer token.

Step 1: Registration & API Key

To get started with RexPayments:

  • Register at https://portal.rexpayments.com/
  • Provide your Callback URL for post-payment redirects
  • Log in to your Profile Page to obtain your API Key
  • Include the API key in every request as a Bearer token

Authentication

All API requests require authentication using your API token. The token can be found in your merchant profile page.

Authentication Header (Recommended)

HTTP
Authorization: Bearer rx_your_api_token_here

Query Parameter Alternative

URL
?api_token=rx_your_api_token_here

Example Request

BASH
curl -X GET "https://portal.rexpayments.com/api/payment-links" \
  -H "Authorization: Bearer rx_your_api_token_here" \
  -H "Content-Type: application/json"

Generate Payment API

What this API does:

Instantly create a unique payment link for a specific transaction. Use this when you need to generate payment links programmatically during checkout. Customers are redirected to complete payment and then returned to your specified Success or Failure URL.

Endpoint

POST https://portal.rexpayments.com/api/generate-payment-link

Headers

Key Value
Authorization Bearer YOUR_API_KEY
Content-Type application/json
Origin https://yourdomain.com

Request Parameters

Field Type Status Description
order_id String Required Unique identifier for the order
amount Decimal Required Payment amount to be charged (in currency units)

Example Request

BASH
curl --location 'https://portal.rexpayments.com/api/generate-payment-link' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
  "order_id": "123456",
  "amount": "500.00"
}'

Response

Success Response
JSON
{
  "paymentLink": "https://portal.rexpayments.com/pay-now?o=hbvt&a=g73u&us=hA%3D%3D"
}

Payment Transaction Details

What this API does:

Retrieve complete details about a specific payment transaction using its Payment ID. Use this after customers complete payments to verify transaction status, amount, currency, payment method, and other details for reconciliation and order fulfillment.

Endpoint

GET https://portal.rexpayments.com/api/transactions/{payment_id}

Response Fields

Field Type Description
id String Unique payment identifier
amount Integer Amount charged (in minor units)
currency String Currency code (e.g., usd)
status String Payment status (succeeded, failed, pending)
created Integer Timestamp in UNIX format
payment_method String ID of payment method used
livemode Boolean Indicates live or test mode

Complete Workflow

1
Register & Get API Key

Register at RexPayments portal and obtain your API key from the profile page.

2
Choose Your API

Select the appropriate endpoint for your use case. Use Generate Payment API for one-time transactions or Payment Links API for shareable, reusable links.

3
Redirect Customer

Redirect your customer to the generated payment link to complete the transaction.

4
Capture Payment Result

Customer is redirected to your callback URL with Order ID, Transaction ID, and Status.

5
Verify Transaction

Use the Transaction Details API to retrieve full details and update your order status accordingly.

Code Examples

JavaScript/Node.js

JAVASCRIPT
const axios = require("axios");

const apiToken = "rx_your_api_token_here";
const baseUrl = "https://portal.rexpayments.com/api";

// Create payment link
const createPaymentLink = async () => {
    try {
        const response = await axios.post(
            `${baseUrl}/payment-links`,
            {
                product_name: "Premium Plan",
                amount: 99.99,
                description: "Monthly subscription",
                expires_days: 30,
                payment_limit: 10
            },
            {
                headers: {
                    Authorization: `Bearer ${apiToken}`,
                    "Content-Type": "application/json"
                }
            }
        );
        console.log("Payment Link URL:", response.data.data.url);
        return response.data;
    } catch (error) {
        console.error("Error:", error.response.data);
    }
};

createPaymentLink();

Python

PYTHON
import requests

api_token = "rx_your_api_token_here"
base_url = "https://portal.rexpayments.com/api"

headers = {
    "Authorization": f"Bearer {api_token}",
    "Content-Type": "application/json"
}

payload = {
    "product_name": "Premium Plan",
    "amount": 99.99,
    "description": "Monthly subscription",
    "expires_days": 30,
    "payment_limit": 10
}

response = requests.post(
    f"{base_url}/payment-links",
    json=payload,
    headers=headers
)

if response.status_code == 201:
    payment_link = response.json()
    print(f"Payment Link: {payment_link['data']['url']}")
else:
    print(f"Error: {response.text}")