Payments
PayU
PayU India hashed form checkout, pre-authorize capture, refunds and settlement details.
Usage
import { payu, payuDate } from "@dapplelight/signet-payments/payu"
import { app } from "./app"
import { env } from "./env"
import { payments } from "./payments"
const pu = payu({ key: env.PAYU_KEY, salt: env.PAYU_SALT, sandbox: true })
// Returns a form to POST from the browser: form.action and form.fields (with the hash).
const checkout = await pu.createCheckout({
amount: 49_900,
currency: "INR",
idempotencyKey: "order-1042",
returnUrl: "https://shop.example/payu/return",
customer: { name: "Asha Rao", email: "[email protected]" },
})
// Webhook: no signature header, the payload's `hash` is checked
app.post("/webhooks/payu", (c) => payments.handleWebhook("payu", c.req.raw))// Render the form and submit it
const { action, fields } = checkout.form!API
| Export | What it does |
|---|---|
payu(config) | A PaymentGateway named payu |
payuDate(value) | Parse PayU's zone-less YYYY-MM-DD HH:mm:ss as IST (+05:30) |
PayUConfig | Config type |
payu(config)
| Option | Type | Default | |
|---|---|---|---|
key | string | Required | |
salt | string | Required | |
postserviceUrl | string | PayU postservice host | Override the server-call URL |
settlementUrl | string | PayU settlement range host | Override the Settlement Detail Range URL |
Plus the shared sandbox, baseUrl (overrides the /_payment URL), fetch, retries, retryDelayMs.
Capabilities
Methods: upi, card, netbanking, wallet, applepay. Currency: INR only. Features: capture, refunds, partial refunds, settlements, webhooks. No customers, subscriptions or payouts.
Quirks
- Checkout needs
returnUrl,customer.emailandcustomer.name.gatewayIdis yourtxnid(reference ?? idempotencyKey).capture: "manual"addspre_authorize=1. - Capture and refund go through the merchant postservice. Capture is queued: the payment flips to
capturedwhen PayU processes it. Refunds returnpending. rawaccepts onlyPOST /postservicewith{ command, vars }.- Webhook: no signature header. The payload
hashis verified with the reverse hash. Payloads with no hash (dispute notifications) and split payments (splitInfo) are rejected. - Settlements use the Settlement Detail Range API. Timestamps carry no zone and are read as IST.
- Subscriptions: PayU standing instructions are merchant-run
si_transactiondebits. Charge renewals throughrawwith thesi_transactioncommand. - Apple Pay shows on PayU Hosted Checkout but is not forced.