Skip to content

Payins

Merchants call this endpoint to request a payin. The portal forwards the request to the configured payin backend to generate the QR code or payment flow, then returns the backend’s response.

Endpoint

http
POST /api/v1/payins

All payin traffic flows through this unified endpoint. The application forwards every request to the remote server configured via PAYIN_SERVER_* environment variables, using the exact JSON payload supplied by the client.

Authentication

Requires API key authentication via the X-API-Key (or Api-Key) header.

Request Body

json
{
  "amount": 100.50,
  "currency": "USDT",
  "memo": "Payment for invoice #123",
  "out_trade_no": "MERCHANT-ORDER-001"
}
FieldTypeRequiredDescription
amountnumberYesAmount in USDT (min 0.01, up to 6 decimal places).
currencystringNoDefaults to USDT. Supported: USDT.
memostringNoOptional reference or note (max 255 characters).
out_trade_nostringYesMerchant order identifier (max 255 characters). Must be unique per merchant.

The payload is forwarded as-is to the configured payin server. Set PAYIN_SERVER_ENDPOINT and PAYIN_SERVER_API_KEY in your environment to enable forwarding.

Response

json
{
  "success": true,
  "code": 200,
  "data": {
    "invoice_reference": "PAYIN-202511A1B2C3D4E5F6G7H",
    "amount": 100.5,
    "currency": "USDT",
    "fee": 2.50,
    "qrcode": {
      "content": "00020101021229...",
      "image": "iVBORw0KGgoAAAANSUhEUgAAAyoAAANmCAIAAACaMeiHAADFN0lEQVR4nOzdd..."
    },
    "out_trade_no": "MERCHANT-ORDER-001"
  }
}
FieldDescription
invoice_referenceSystem-generated unique invoice reference (format: PAYIN-XXXXXXXXXXXXXXXXXX).
amountThe requested amount.
currencyCurrency code (defaults to USDT).
feeProcessing fee charged for this transaction (in same currency as amount).
qrcodeObject containing the QR code data.
qrcode.contentDecoded QR code data (e.g., payment URI for deep linking).
qrcode.imageBase64-encoded PNG image of the QR code.
out_trade_noMerchant's order identifier.

Example Request (cURL)

bash
#!/bin/bash

API_KEY="your_api_key"

curl -X POST "https://dev-crypto-portal.kesspay.io/api/v1/payins" \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: ${API_KEY}" \
  -d '{
    "amount": 100,
    "memo": "POS-INV-9231",
    "out_trade_no": "ORDER-2025-001"
  }'

How it works

  • Merchant calls /api/v1/payins with amount, out_trade_no, and optional memo.
  • Portal validates uniqueness of out_trade_no (must be unique per merchant).
  • Portal creates a TopUp record and forwards the JSON payload to your configured payin server.
  • The payin server generates the QR code/payment payload and returns JSON.
  • Portal returns the TopUp details, fee information, and QR code to the merchant.
  • When the payment is settled, the webhook callback includes the out_trade_no for merchant reconciliation.

Error Responses

StatusMessageWhen it occurs
422Validation errors for fields or duplicate out_trade_no.Missing/invalid fields or out_trade_no already exists for this merchant.
502Payin service is unavailable. Please try again later.The upstream payin server responded with a 4xx/5xx or could not be reached.
500Unable to process payin request. Please contact support.Unexpected exception while forwarding the request.

Query Payment Status

Query the status of a payment using your merchant order reference.

Endpoint

http
POST /api/v1/payins/status

Authentication

Requires API key authentication via the X-API-Key header.

Request Body

json
{
  "out_trade_no": "MERCHANT-ORDER-001"
}
FieldTypeRequiredDescription
out_trade_nostringYesYour merchant order identifier used when creating the payin.

Response

json
{
  "success": true,
  "code": 200,
  "data": {
    "trx_ref": "TRX-PROVIDER-123",
    "amount": 100.5,
    "fee": 2.5,
    "invoice_reference": "PAYIN-202511A1B2C3D4E5F6G7H",
    "out_trade_no": "MERCHANT-ORDER-001",
    "status": "success"
  }
}
FieldTypeDescription
trx_refstringProvider transaction reference.
amountnumberPayment amount (same as input).
feenumberFee amount.
invoice_referencestringSystem-generated invoice reference.
out_trade_nostringYour merchant order identifier.
statusstringCurrent payment status.

Status Values

StatusDescription
waitingPayment pending, awaiting user payment.
successPayment confirmed and wallet credited.
expiredPayment expired without completion.
closePayment closed/cancelled.

Example Request (cURL)

bash
#!/bin/bash

API_KEY="your_api_key"

curl -X POST "https://dev-crypto-portal.kesspay.io/api/v1/payins/status" \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: ${API_KEY}" \
  -d '{
    "out_trade_no": "MERCHANT-ORDER-001"
  }'

Error Responses

StatusMessageWhen it occurs
401UnauthorizedInvalid or missing API key.
404Top-up not found.No payment found for the given out_trade_no.
422Validation errorMissing out_trade_no field.

Implementation Notes

  • The request payload is never mutated. If you include optional fields, they are forwarded to the upstream server.
  • Payin server configuration lives in config/services.php (PAYIN_SERVER_ENDPOINT, PAYIN_SERVER_API_KEY, PAYIN_SERVER_TIMEOUT).
  • If PAYIN_SERVER_ENDPOINT is not set, payin requests will fail validation. Configure your own provider endpoint and API key before enabling payins.

Next Steps

  • Learn about Webhooks to receive payment notifications from the portal.
  • Review Rate Limiting to understand API throttling rules.