Your Gateway API Documentation

Simple payment gateway integration using KiliPay for merchants to collect payments securely.

1. Overview

Merchants use this API to initiate payments. Your Gateway handles communication with KiliPay and sends asynchronous payment status updates.

2. Authentication

Provide a valid merchant_key in your request to authenticate.

3. Payment Collection API (Payin)

Endpoint

POST https://yourgatewaydomain.com/api/payin.php

Request Headers

HeaderDescription
Content-Typeapplication/x-www-form-urlencoded

Request Parameters

ParameterRequiredTypeDescription
merchant_keyYesstringYour unique merchant key
amountYesfloatPayment amount in PKR (integer)
currencyYesstringCurrency code (usually "pkr")
txn_idYesstringUnique transaction/order ID

Sample Request

POST /api/payin.php HTTP/1.1
Content-Type: application/x-www-form-urlencoded

merchant_key=abc123&amount=1000&currency=pkr&txn_id=order20250410xyz
  

Response

FieldTypeDescription
statusstring"success" or "error"
messagestringDescription message
transaction_idstringMerchant's transaction ID
remarkstringAdditional remarks
gateway_statusstringStatus from KiliPay API
payment_urlstringURL to redirect user to payment

Sample Success Response

{
  "status": "success",
  "message": "Kili Fast initiated successfully",
  "transaction_id": "order20250410xyz",
  "remark": "Payment for TXN order20250410xyz",
  "gateway_status": "0015",
  "payment_url": "https://kilipay.com/payment/abc123"
}
  

Possible Errors

4. Asynchronous Callback Notification

After payment completion, your gateway calls your configured webhook URL with payment status.

Callback URL

https://yourgatewaydomain.com/api/kilipay_callback.php

Callback POST Payload

ParameterTypeDescription
txn_idstringOriginal transaction ID
statusstringTransaction status ("success" or "failed")
amountstringAmount paid
order_snstringOrder serial number (same as txn_id)
signstringSignature for verification

Important: Merchant must verify the signature and respond with OK to confirm receipt.

5. Integration Flow

  1. Merchant generates unique txn_id (order number).
  2. Merchant calls /payin.php API with merchant_key, amount, currency, txn_id.
  3. Your gateway returns payment URL or status.
  4. Merchant redirects user to payment URL to complete payment.
  5. KiliPay processes payment.
  6. Your gateway receives async callback from KiliPay.
  7. Your gateway updates transaction and calls merchant webhook.
  8. Merchant receives webhook and updates their system.

6. Support

If you face any issues integrating, contact: support@yourgatewaydomain.com