# KiliCow Pay Payment Gateway - API Documentation

Integrate KiliCow Pay with your platform using our simple API. All payment processing is handled by KiliCow Pay — you only need to interact with our secure endpoints.

## 1. Create Payment Request

Endpoint: `POST https://rdnslvhost.in.net/payinr/payin`

Content-Type: `application/x-www-form-urlencoded`

##### Required Parameters:

- `merchant_key` – Your unique KiliCow Pay merchant key
- `amount` – Payment amount (e.g., 500.00)
- `currency` – Currency code (e.g., INR)
- `txn_id` – Unique transaction/order ID

Sample Request

    merchant_key=abc123xyz
    amount=500.00
    currency=inr
    txn_id=ORD98765

Sample Success Response

    {
      "status": "redirect",
      "message": "Redirect to payment",
      "payment_url": "https://secure.rdnslvhost.in.net/pay/redirect-url"
    }

Sample Error Response

    {
      "status": "error",
      "message": "Invalid merchant key"
    }

## 2. Callback Webhook (Payment Status)

After payment, KiliCow Pay will send a POST request to your configured callback URL.

Content-Type: `application/json`

##### Example Payload:

    {
      "appNo": "HMP01",
      "merchantCode": "ORD98765",
      "orderCode": "GATEWAY123456",
      "status": "1",
      "amount": "500.00",
      "realAmount": "500.00",
      "sign": "a1b2c3d4e5..."
    }

##### Signature Verification (Backend):

    unset($data['sign']);
    ksort($data);
    $str = "";
    foreach ($data as $k => $v) {
        $str .= "$k=$v&";
    }
    $str .= "key=YOUR_SECRET_KEY";
    $verify_sign = md5($str);

If the signature matches and `status == "1"`, mark the payment as successful.

Required Response (to KiliCow Pay)

    { "message": "success" }

## 3. Optional: Webhook to Your System

If you've set a webhook URL in your merchant panel, KiliCow Pay will notify you on every successful transaction.

##### Payload Sent to Your Webhook:

    {
      "txn_id": "ORD98765",
      "status": "success",
      "amount": "500.00",
      "order_sn": "ORD98765",
      "sign": "ABCDEF123456..."
    }

##### Webhook Signature Logic:

    ksort($data);
    $str = "";
    foreach ($data as $k => $v) {
        $str .= "$k=$v&";
    }
    $str .= "key=MERCHANT_SECRET_KEY";
    $sign = strtoupper(md5($str));

Return `200 OK` from your webhook to confirm receipt.

## Support

If you need assistance with integration:

- Telegram: @kilicowpay