---
title: "PayU"
space: "BWH Payments"
url: "https://docs.bwh.tech/bwh-payments/gateways/payu"
updated: "2026-11-07"
---

Take cards, UPI, netbanking and wallets in India through [PayU](https://payu.in) hosted checkout. The shopper pays on PayU's own page, and a hashed webhook reports when the payment is captured.

## Before you start

- A PayU India merchant account. Test mode is fine.
- A **Merchant Key** and **Salt** from the **Developers** section of the PayU Dashboard. Test and live have separate pairs.
- Payments in **INR**. PayU India takes other currencies only when it enables them for your account, and BWH Payments refuses them.

## Set up PayU

**1. Fill in PayU Gateway Settings**

| Field | Value |
|---|---|
| Merchant Key | The key from the PayU Dashboard |
| Merchant Salt | The **Salt v2 (256-bit)** shown with the key. PayU also signs its payment webhooks with it. |
| Test Mode | On for a test key: shoppers go to `test.payu.in`. Turn it off with live credentials. |
| Success URL | Your [confirmation page](/bwh-payments/get-started/return-pages). `?reference_id=…` is added to it. Required, unless every payment sets `redirect_to`. |
| Failure URL | Your [payment-failed page](/bwh-payments/get-started/return-pages). PayU sends failed **and** cancelled payments here. Required, unless every payment sets `redirect_to`. |
| Cancelled URL | PayU never redirects here. BWH Payments passes it back to your app, so you can send the shopper there yourself. |

**2. Create a Payment Gateway Profile** named `PayU`, set **Gateway Settings** to `PayU Gateway Settings`, and tick **Enabled**.

**3. Add the webhooks.** In the PayU Dashboard, go to **Developers → Webhooks → Create Webhook**. Some dashboards show it as **Settings → Webhook**. Create one webhook for each event:

- **URL:** `https://your.site/api/v2/method/bwh_payments.bwh_payments.webhook.handle?gateway=PayU`
- **Type:** Payment
- **Events:** Successful, Failed, and Refund

:::note
PayU sends refund webhooks only after it enables them for your account. If refunds raised outside your app never arrive, ask PayU Support to turn on the refund callback. Until then, `sync_refunds` finds them.
:::

## How checkout works

PayU has no checkout link to hand out. The shopper's browser must post a signed form to PayU, so BWH Payments serves that form itself:

1. `create_payment` makes no call to PayU. It generates a 20-character `txnid`, stores it as `order_ref`, and sets `order_url` to BWH Payments' own `start_checkout` page.
2. You redirect the shopper to `order_url`. The page posts the signed form to PayU at once. It has a **Continue to PayU** button for browsers that block the automatic post.
3. The shopper pays on PayU's page.
4. PayU posts the shopper back to BWH Payments, which redirects them to your Success URL or Failure URL. With `redirect_to`, both go to `return_from_gateway`, which confirms the payment with PayU first.

The shopper stays signed in. PayU's post comes from another site, so the browser sends none of your site's cookies with it. BWH Payments drops the guest cookies that Frappe would otherwise set, so the shopper's own session survives.

:::caution
`order_url` works for anyone who has it, as it does for every gateway. The page shows the shopper's name, email and phone number in the form, so share it only with the shopper. It's never cached, and it opens only while the payment is Pending and the PayU profile is enabled.
:::

## How it behaves

| PayU `unmappedstatus` | Payment status |
|---|---|
| `captured` | Paid |
| `userCancelled` | Cancelled |
| `autorefund` | Not Paid |
| `failed`, `bounced`, `dropped` | Pending |
| `auth`, `pending`, anything else | Pending |

A failed attempt stays **Pending** on purpose. PayU lets the shopper try again on the same `txnid`, and a request that has left Pending ignores a later capture. Your app can't release an open PayU checkout either: `release_if_unpaid()` returns `False`, because PayU can't cancel a transaction.

- **Amounts** are sent as a decimal string in rupees, for example `"149.00"`.
- **Shopper details:** PayU needs an email and a phone number. `create_payment` throws without them, so the shopper doesn't reach a PayU error page. The first name is `customer_forenames`, or `Customer` when it's empty.
- **Payment webhooks** are checked with PayU's reverse hash (SHA-512 over the posted fields and your salt). The hash uses your own Merchant Key, so a delivery meant for another merchant fails.
- **Refund webhooks** aren't signed. BWH Payments reads only the refund id from the body, then asks PayU for that refund. It ignores the delivery when the id belongs to a capture, not a refund.
- **Refunds** go against the payment's PayU ID (`mihpayid`), which is stored as `gateway_transaction_ref`. Partial refunds are supported. PayU queues every refund, so it starts `Pending` and settles from a refund webhook or from `sync_refunds`.
- **Refunds raised on the PayU Dashboard** are recorded by the refund webhook, or by the next `sync_refunds`.

## Test mode

Use PayU's [test cards and UPI ids](https://docs.payu.in/docs/test-cards-upi-id-and-wallets), for example Mastercard `5123 4567 8901 2346`, expiry `05/30`, CVV `123`, OTP `123456`.

PayU's test environment can take a long time to settle a refund, so a test refund can stay `Pending` for hours.

A webhook only reaches a public URL. To test on your own machine, expose your site through a tunnel, for example `cloudflared tunnel --url http://127.0.0.1:8000 --http-host-header your.site`, and use the tunnel's URL in step 3.

## Next steps

- [Return pages](/bwh-payments/get-started/return-pages): the confirmation and payment-failed pages
- [Webhooks and security](/bwh-payments/build/webhooks-and-security): debug a delivery that isn't arriving
