GoPay
GoPay
/ Developer Docs
REST API • Version 1.0.0

GoPay Merchant Gateway API

Integrate instant checkouts, wallet-to-wallet settlements, automated customer payouts, and cryptographic webhook verification in Pakistan.

Production Host
https://gopay.com.pk/api/v1

HTTPS with TLS 1.3 encryption required.

Payload Format
application/json

UTF-8 encoded JSON bodies and responses.

Authentication
Authorization: Bearer <key>

Private server-to-server secret token.

Authentication & API Security

Zero-exposure server-side secret tokens

All GoPay API requests must be authenticated using your website's private Secret Key. Pass your secret key in the HTTP request headers using either the standard Bearer authorization header or the custom X-API-SECRET header.

HTTP Request Headers
Authorization: Bearer sk_live_YOUR_SECRET_KEY
X-API-SECRET: sk_live_YOUR_SECRET_KEY
Content-Type: application/json
Accept: application/json
Approved Website Gating Policy

To protect the Pakistani payments ecosystem, API credentials (sk_live_...) are strictly generated only for approved eCommerce websites reviewed by GoPay administration. Apply via your Merchant Portal under Websites & Gateways. Each key can be scoped to Both (Deposit & Withdrawal), Deposit Only (payments), or Withdrawal Only (payouts) in your API Credentials dashboard.

API Endpoints Directory

10 Operational Methods
# Method Endpoint Function Auth Required
1 POST /v1/gateway/payments Create checkout payment session Secret Key
2 GET /v1/gateway/payments/{token} Check payment order status & receipt Secret Key
3 GET /checkout/{payment_token} Hosted browser checkout page for customers Public Web
4 POST /v1/gateway/check-user Verify user existence on GoPay Secret Key
5 POST /v1/gateway/pay-to-user Instant withdrawable payout to user wallet Secret Key
6 POST /v1/gateway/account-link/initiate Initiate Account Linking session & get hosted authorize URL Secret Key
7 GET /account-link/{token} Customer web authorization panel (User verifies MPIN) GoPay Web Panel
8 POST /v1/gateway/linked-account/deposit Direct deposit / payment from linked account with MPIN Secret Key
9 POST /v1/gateway/linked-account/withdraw Direct withdrawal / payout into customer's linked GoPay account Secret Key
10 GET /v1/gateway/linked-account/{link_token} Inspect linked account status (zero-balance privacy) Secret Key
1

Create Payment Session

POST https://gopay.com.pk/api/v1/gateway/payments

When your customer proceeds to payment, make a server-to-server POST request with order information. GoPay returns a secure checkout_url and a unique payment_token.

JSON Body Parameters

Field Type Requirement Description
order_id string Required Your store's unique order reference (e.g. ORD-98421). Strictly idempotent.
amount numeric Required Order amount in PKR (minimum: 1.00).
currency string Optional Currency code (default: PKR).
web_user string Optional Your platform's username / account handle for the purchasing user (also accepted as customer.username or customer.web_user). If omitted, GoPay displays Anonymous by default.
customer object Optional Customer details: {"name": "...", "email": "...", "phone": "...", "username": "..."}.
callback_url url Optional Browser redirect destination after customer completes or cancels payment.
webhook_url url Optional Custom server IPN webhook endpoint override for this specific order.
metadata object Optional Arbitrary key-value store returned in webhooks and status queries.
curl -X POST https://gopay.com.pk/api/v1/gateway/payments \
  -H "Authorization: Bearer «redac...e_…»" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "order_id": "ORD-98421",
    "amount": 1500.00,
    "currency": "PKR",
    "web_user": "hamza_akram",
    "customer": {
      "name": "Hamza Ali",
      "email": "hamza@example.com",
      "phone": "03001234567"
    },
    "callback_url": "https://yourwebsite.com/checkout/success",
    "metadata": { "cart_id": "1042" }
  }'
Example Gateway JSON Response (HTTP 201 Created)
{
  "success": true,
  "payment_token": "pay_9f8e7d6c5b4a3210...",
  "checkout_url": "https://gopay.com.pk/checkout/pay_9f8e7d6c5b4a3210...",
  "order_id": "ORD-98421",
  "amount": 1500.00,
  "fee_amount": 30.00,
  "net_amount": 1470.00,
  "currency": "PKR",
  "web_user": "hamza_akram",
  "status": "pending",
  "expires_at": "2026-11-02T18:30:00Z"
}
2

Hosted Checkout & 6-Digit MPIN Authorization

GET https://gopay.com.pk/checkout/{payment_token}

Direct your customer to the returned checkout_url in their browser, mobile webview, or iframe.

1-Click GoPay Wallet (6-Digit MPIN)

Registered GoPay customers pay instantly using their combined balances. Payment confirmation strictly requires the customer to enter their 6-digit security MPIN.

Universal Rails (EasyPaisa / JazzCash / Raast)

Customers who don't have an active GoPay account can pay via integrated mobile wallets (EasyPaisa, JazzCash) or bank transfer IBAN directly on the checkout screen.

Browser Return Query Parameters: When the customer pays, GoPay redirects to your callback_url:
https://yourwebsite.com/checkout/success?order_id=ORD-98421&status=paid&token=pay_9f8e7d6c5b4a3210...
3

Instant Payment Notification (IPN Webhook)

HMAC-SHA256 Cryptographic Signature Verification

To prevent fraud and front-channel manipulation, never fulfill orders solely based on the browser redirect. Always configure and verify incoming server-to-server webhook events delivered with the X-GoPay-Signature HTTP header.

Header Format
X-GoPay-Signature: t=1760012400,v1=5d41402abc4b2a76b9719d911017c592...
Where t is the UNIX timestamp and v1 is the hex-encoded HMAC-SHA256 signature calculated over {timestamp}.{raw_json_body} using your website's Webhook Secret.
PHP Webhook Verifier Implementation
<?php
$payload = file_get_contents('php://input');
$sigHeader = $_SERVER['HTTP_X_GOPAY_SIGNATURE'] ?? '';
$webhookSecret = 'whsec_YOUR_WEBHOOK_SECRET'; // From Merchant Dashboard

// Parse header: t={timestamp},v1={hash}
parse_str(str_replace(',', '&', $sigHeader), $sigParts);
$timestamp = $sigParts['t'] ?? '';
$receivedHash = $sigParts['v1'] ?? '';

// Check timestamp replay (within 5 minutes)
if (abs(time() - (int)$timestamp) > 300) {
    http_response_code(400);
    exit("Timestamp expired or clock skew.");
}

// Compute expected HMAC-SHA256
$expectedHash = hash_hmac('sha256', "{$timestamp}.{$payload}", $webhookSecret);

if (hash_equals($expectedHash, $receivedHash)) {
    $event = json_decode($payload, true);
    if ($event['event'] === 'payment.completed') {
        $orderId = $event['data']['order_id'];
        $amount = $event['data']['amount'];
        // TODO: Mark order as PAID in your database and fulfill goods!
    }
    http_response_code(200);
    echo json_encode(['received' => true]);
} else {
    http_response_code(400);
    echo "Invalid cryptographic signature";
}
4

Query Payment Status API

GET https://gopay.com.pk/api/v1/gateway/payments/{payment_token}

Check the latest status of any transaction programmatically using its payment_token.

// cURL Command
curl -X GET https://gopay.com.pk/api/v1/gateway/payments/pay_9f8e7d6c5b4a3210... \
  -H "Authorization: Bearer sk_live_YOUR_SECRET_KEY" \
  -H "Accept: application/json"
Example Response (HTTP 200 OK)
{
  "success": true,
  "order_id": "ORD-98421",
  "payment_token": "pay_9f8e7d6c5b4a3210...",
  "amount": 1500.00,
  "fee_amount": 30.00,
  "net_amount": 1470.00,
  "currency": "PKR",
  "web_user": "hamza_akram",
  "status": "paid",
  "payment_method": "gopay_wallet",
  "paid_at": "2026-11-02T14:15:30Z"
}
5

Check User Existence & Status API

POST https://gopay.com.pk/api/v1/gateway/check-user

Verify whether a customer is registered and verified on GoPay before rendering 1-click checkout buttons. Query by phone number, email, or username. Customer financial balances are strictly never disclosed.

// cURL Command
curl -X POST https://gopay.com.pk/api/v1/gateway/check-user \
  -H "Authorization: Bearer sk_live_YOUR_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "phone": "03001234567"
  }'
Example Response (HTTP 200 OK)
{
  "success": true,
  "exists": true,
  "user": {
    "name": "Hamza Ali",
    "username": "hamza_ali",
    "phone": "0300****567",
    "email": "h***@example.com",
    "status": "active",
    "is_active": true,
    "is_verified": true,
    "joined_at": "2026-04-12T10:00:00Z"
  }
}
6

Send Payment to User Wallet (Pay to User API)

POST https://gopay.com.pk/api/v1/gateway/pay-to-user

Automate payouts, affiliate commissions, instant prize disbursements, or customer refunds directly from your Merchant Balance into any user's GoPay wallet.

Closed-Loop Payout Exemption (Fully Withdrawable Funds)

Under GoPay's financial rails, normal user-to-user transfers are non-withdrawable. However, funds disbursed directly from a verified Merchant account are credited into the user's Main Balance and are fully withdrawable by the recipient via EasyPaisa, JazzCash, or Pakistani Bank Accounts.

Pay to User Parameters

Parameter Type Requirement Description
recipient string Required Customer's phone number (03001234567), email address, or username.
amount numeric Required Payout amount in PKR (minimum: 1.00).
reference_id string Optional Your internal payout reference ID (e.g. PAYOUT-REF-9921).
note string Optional Memo displayed on customer transaction ledger statement.
// cURL Command
curl -X POST https://gopay.com.pk/api/v1/gateway/pay-to-user \
  -H "Authorization: Bearer sk_live_YOUR_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "recipient": "03001234567",
    "amount": 2500.00,
    "reference_id": "PAYOUT-REF-9921",
    "note": "Affiliate Commission Settlement"
  }'
Example Response (HTTP 200 OK)
{
  "success": true,
  "trx_id": "MPAY_A9F32BC17DE4",
  "amount": 2500.00,
  "currency": "PKR",
  "recipient": {
    "name": "Hamza Ali",
    "username": "hamza_ali",
    "phone": "0300****567"
  },
  "merchant_remaining_balance": 7500.00,
  "status": "completed",
  "message": "Funds successfully paid to user. User can withdraw these funds."
}

Standard HTTP Status Codes

RFC 7231 Compliant
Code Status Meaning & Solution
200 / 201 OK / Created The request was successfully processed and the resource created.
401 Unauthorized Missing or invalid Secret Key header, or website application has not yet been approved.
403 Forbidden Insufficient operational scope — e.g. calling /payments with a Withdrawal-only key or calling /pay-to-user with a Deposit-only key.
404 Not Found Recipient customer or payment token could not be found in the network.
409 Conflict Order ID has already been finalized or paid (strict idempotency lock).
422 Unprocessable Entity Validation failure (missing required parameters or insufficient merchant balance).

Ready to integrate GoPay into your business?

Follow this 4-step checklist to go live with payment processing.

1
Register Merchant

Sign up in seconds with your store details and business email.

2
Add Website URL

Submit your domain in the portal for standard compliance verification.

3
Copy API Credentials

Retrieve your private Secret Key and Webhook Signing Secret.

4
Accept Payments

Deploy checkout and receive real-time settlements into your wallet.

Copied to clipboard