๐Ÿ’ณ PayRails Merchant PayIn Integration Guide

Live API console — authenticate, test, and explore the PayRails PayIn API in real time.

EnvironmentLive Demo
Base URLhttps://api.payrails.in/api/v1
Authenticationx-api-key
Payment MethodUPI (Unified Payments Interface)
CurrencyINR (hardcoded by platform)
๐Ÿ” Authentication
Every request must include your merchant API key in the x-api-key header. No OAuth, no login session required.
Base URLhttps://api.payrails.in/api/v1
Auth methodx-api-key request header
Content typeapplication/json
ProtocolHTTPS only
Headers on every request
Content-Type: application/json
Accept: application/json
x-api-key: YOUR_API_KEY
โšก Quick Start

Everything you need to accept your first UPI payment in under 5 minutes.

๐Ÿ”
Step 1 — Get API Key
Obtain your x-api-key from PayRails. Include it on every request.
๐Ÿ“ค
Step 2 — Create Transaction
POST /transactions
Supply amount, merchantTxnId, paymentMethod.
๐Ÿ“ฅ
Step 3 — Receive Intent URL
Extract upi_intent_url from response. Redirect the customer.
๐Ÿ“ฑ
Step 4 — Customer Pays
Customer completes payment in their UPI app (GPay, PhonePe, Paytm, etc.).
๐Ÿ””
Step 5 — Receive Webhook
PayRails POSTs to your callback URL with the final status.
โœ…
Step 6 — Update Order
SUCCESS — fulfil the order.
FAILED — prompt retry.
Return HTTP 200 to webhook.
๐Ÿ”„ Integration Flow

Follow this sequence for every PayIn transaction.

๐Ÿ“ค POST /transactions
Send merchantTxnId, amount, paymentMethod, customer
๐Ÿ“ฅ Receive upi_intent_url
transaction_id = PENDING  •  upi_intent_url in response
๐Ÿ“ฑ Redirect Customer
Open UPI intent on mobile  •  Show QR on desktop
โณ Customer Pays in UPI App
GPay  •  PhonePe  •  Paytm  •  BHIM and others
๐Ÿ”” Webhook Received
PayRails POSTs to your callback URL  •  Return HTTP 200
โœ… Terminal State
SUCCESS  •  FAILED  •  CANCELLED  •  EXPIRED
๐Ÿ“ค Create Transaction API

Initiates a UPI payment session. Returns a upi_intent_url that the merchant redirects the customer to.

Endpoint
POST /transactions
Auth
x-api-key
Success response
HTTP 201 Created
Initial status
PENDING
Currency
INR (hardcoded by platform)
Rate limit
Per merchant tier
Request Body
FieldRequiredTypeNotes
merchantTxnIdRequiredstringYour unique transaction reference. Must be unique per merchant.
amountRequirednumberTransaction amount in INR. Positive number.
paymentMethodRequiredstringMust be UPI for the merchant API.
customer.nameRequiredstringCustomer's name for logging and provider handoff.
customer.emailRequiredstringCustomer's email address.
customer.mobileRequiredstringCustomer's mobile number.
s2s_client_ipRecommendedstringCustomer's actual IP address. Used for fraud detection. Falls back to request IP if omitted.
s2s_device_infoRecommendedstringCustomer's browser User-Agent. Falls back to request header if omitted.
Not allowed: provider_id, provider_code, upi_vpa, routing_rule_id, routing_strategy โ€” these fields are rejected with HTTP 400.
Silently ignored: callbackUrl / callback_url โ€” configure your webhook URL in the PayRails merchant settings instead.

The live form below creates a real transaction using this exact endpoint.

๐Ÿš€ Live Demo

Enter an amount below and click Create UPI Transaction to execute a real API call. All debug panels below will populate with live data.

Transaction Amount (INR)
๐Ÿ“ฑ UPI Intent URL

The upi_intent_url field in the response is a deep link that opens the customer's UPI app directly. It follows the standard upi://pay?... URI scheme.

Format
upi://pay?pa=...&pn=...&am=...&tr=...&tn=...
Supported apps
  • Google Pay (GPay)
  • PhonePe
  • Paytm
  • BHIM
  • Amazon Pay
  • Any UPI-enabled bank app
Usage by platform
PlatformRecommended Approach
AndroidUse <a href="upi://pay?..."> or trigger via JavaScript. Opens UPI app selector automatically.
iOSSame deep link works on iOS. Not all UPI apps support iOS — GPay and PhonePe have iOS apps.
DesktopGenerate and display a QR code from the intent URL. Customer scans with phone.
Mobile webRedirect directly. Device opens UPI app selector.
Important: Never rely on the UPI app redirect alone to confirm payment. Always wait for the PayRails webhook before marking an order as paid. The customer may close the app, experience a network issue, or the payment may be delayed.
โ™ป๏ธ Transaction Status Lifecycle

A PayIn transaction transitions through these states after creation.

Standard flow
PENDING
Transaction created, awaiting payment
SUCCESS
Customer completed UPI payment
Failure paths
PENDING → FAILED
Payment declined or error
PENDING → CANCELLED
Cancelled or EXPIRED (mapped to CANCELLED in webhook)

All statuses
PENDING SUCCESS FAILED CANCELLED EXPIRED
EXPIRED: The payment window elapsed without a definitive outcome from the provider. In webhook callbacks, EXPIRED is mapped to CANCELLED for simplicity. FAILED and SUCCESS are terminal states. Never trust a browser redirect for final status — always wait for the webhook.
๐Ÿ”” Webhook

PayRails sends a webhook to your configured callback URL when a transaction reaches a terminal state (SUCCESS, FAILED, CANCELLED/EXPIRED). Configure your callback URL in the PayRails merchant settings.

HTTP Method
POST
Payload format
application/json
Expected response
HTTP 200 (any 2xx)
Retry behaviour
Up to 3 attempts with exponential backoff
Webhook Payload
{
  "transaction_id":  "internal-uuid",
  "merchant_txn_id": "YOUR-REF-001",
  "status":          "SUCCESS",
  "amount":          "100",
  "currency":        "INR",
  "provider":        "razorpay",
  "provider_txn_id": "pay_xxxxx",
  "bank_reference":  "HDFC123456",
  "failure_code":    null,
  "failure_reason":  null,
  "completed_at":    "2026-07-08T..."
}
FieldTypeDescription
transaction_idstringPayRails internal UUID. Same as returned by Create Transaction.
merchant_txn_idstringYour original reference from the Create Transaction request.
statusstringSUCCESS ยท FAILED ยท CANCELLED
amountstringTransaction amount as stored (may be string).
currencystringAlways INR.
providerstringPayment provider that processed the transaction.
provider_txn_idstring|nullProvider's own transaction reference. Null if payment never reached the provider.
bank_referencestring|nullBank reference number (UTR). Available on SUCCESS for reconciliation.
failure_codestring|nullProvider-specific failure code. Null on SUCCESS.
failure_reasonstring|nullHuman-readable failure description. Null on SUCCESS.
completed_atstringISO-8601 UTC timestamp of webhook dispatch.
Your webhook handler must return HTTP 200 (any 2xx) within the timeout window. If it does not, PayRails retries up to 3 times. Implement idempotency in your handler using transaction_id to prevent double-fulfilment on retries.
โš ๏ธ Error Reference

All errors from the PayIn backend. Every entry is verified from the actual implementation.

HTTPError / ConditionCauseResolution
400merchantTxnId is requiredmerchantTxnId missing from body.Always include a unique merchantTxnId.
400amount is requiredamount missing or zero.Send a positive numeric amount.
400paymentMethod is requiredpaymentMethod field absent.Send "paymentMethod": "UPI".
400provider_id/provider_code not allowedMerchant sent provider routing hints.Remove provider_id / provider_code from body.
400upi_vpa is not allowedMerchant sent a VPA in the request.Remove upi_vpa field.
400routing hints not allowedrouting_rule_id or routing_strategy present.Remove routing hint fields.
401UnauthorizedMissing or invalid x-api-key header.Include a valid API key.
409Duplicate merchantTxnIdA transaction with this merchantTxnId already exists for your merchant.Use a new unique reference.
503No provider availableNo payment provider is currently eligible for routing.Retry with backoff. Contact support if persistent.
๐Ÿ’ป cURL Reference Example

Copy-paste ready. Replace YOUR_API_KEY with your actual key.

Create UPI Transaction
curl -X POST \
  'https://api.payrails.in/api/v1/transactions' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'x-api-key: YOUR_API_KEY' \
  -d '{
    "merchantTxnId": "ORDER-20260708140658",
    "amount": 100,
    "paymentMethod": "UPI",
    "customer": {
      "name": "Customer Name",
      "email": "customer@example.com",
      "mobile": "9876543210"
    },
    "s2s_client_ip": "1.2.3.4",
    "s2s_device_info": "Mozilla/5.0 ..."
  }'
โœ… Production Checklist

Verify each item before going live with PayRails PayIn API.