Razorpay payments

For apps whose customers pay in India. Adds a payment table linked to one of your tables and its price field. People see what they owe on a Pay page and pay on Razorpay's hosted Payment Link page (UPI, cards, netbanking, wallets) for exactly that record's price, so the app needs no payment script. When Razorpay sends them back, a server function checks Razorpay's signature on the result before the page says the payment went through, and Razorpay's signed payment_link.paid webhook marks the payment paid only when it collected the right amount. Payers read only their own payments and rules stop anyone changing an amount or marking a payment paid. One-time payments only (no subscriptions).

Razorpay payments: the Pay page, added to Nook, on desktopRazorpay payments: the Pay page, added to Nook, on a phone

What it adds to your app

Table payment linked to your table. RazorpayPayList and RazorpayPayments components with their pages. Server functions: create a Payment Link and verify Razorpay's signed callback. A Razorpay-signed webhook that marks payments paid or not completed. A staff payments page.

Tables

  • payment record_id, payer_id, amount, currency, status, razorpay_link_id, razorpay_payment_id, paid_at

Pages

  • /pay Pay (‹payer_role›)
  • /my-payments My payments (‹payer_role›)
  • /payments-admin Payments (@staff)

Components

  • RazorpayPayList What the signed-in person can pay for, with a Pay button that opens a Razorpay Payment Link
  • RazorpayPayments The signed-in person's payments; checks Razorpay's signed result on the way back

Rules on every write

  • payment A payment starts as pending and matches the price.
  • payment Only Razorpay can change a payment.

How its workflows run

Each one is a server workflow in your project: it runs on its trigger, with retries, and its runs show in the builder's log.

  1. Create a Razorpay Payment Link for one ‹attach_to›

    When the app calls it: server function (‹payer_role›). Then: Look up ‹attach_to›, then Create payment, then Call api.razorpay.com, then Update payment.

  2. Check the signed result Razorpay sends people back with

    When the app calls it: server function (‹payer_role›). Then: Look up payment.

  3. Apply Razorpay's payment link events to payments

    When a webhook arrives: webhook razorpay-payment-events. Then: Look up payment, then Update payment.

  4. Thank the payer when a payment goes through

    When a row changes: payment updated, when status is paid. Then: Notify.

Set it up

It merges into the contract of an app you already have. Nothing is overwritten: a name you already use is refused until you pass a prefix.

  1. Pick the project

    Use the button above, or ask your coding agent with the Appbricx MCP server connected (quickstart).

  2. Point it at your tables and roles

    Leave out the ones with defaults; a wrong one is refused with the options your app has.

    ParamWhat it isExample
    attach_toThe table whose records people pay for (bookings, orders, invoices).booking
    price_fieldThe number field on that table holding what to charge. Optional.total
    payer_roleThe role whose people pay (their own table is the payer). Optional.customer
    payer_refOptional: the ref on that table naming the person who owes it, so people only see and pay their own. Optional.customer_id
    currencyThe three-letter currency code, upper case (Razorpay takes INR and other currencies your account enables). Optional.INR
  3. Connect what it calls

    add the RAZORPAY_KEY_ID secret (project settings); add the RAZORPAY_KEY_SECRET secret (project settings); add the RAZORPAY_WEBHOOK_SECRET secret (project settings). A table with a number price field. A Razorpay webhook (Dashboard, Settings, Webhooks) at the URL get_contract lists for razorpay-payment-events, for payment_link.paid, payment_link.expired and payment_link.cancelled, with its secret in RAZORPAY_WEBHOOK_SECRET.

  4. Preview, then apply to dev

    A dry run shows the diff and the check report; applying it changes your dev environment only.

  5. Deploy

    When dev looks right, deploy. Production gets a snapshot first, so you can roll back.

Use it with your coding agent

The agent reads the template, runs a dry run, shows you the diff and applies it.

Prompt
Add the Razorpay payments template (slug "razorpay-payments") to my Appbricx project. Read it with get_template, run use_template with dry_run first and show me the diff, then apply it. Ask me where it attaches if you can't tell from my contract (attach_to: what is paid for; price_field: price field; payer_role: who pays; payer_ref: whose record it is; currency: currency).
MCP call
{
  "tool": "use_template",
  "arguments": {
    "slug": "razorpay-payments",
    "project_id": "<your project id>",
    "params": {
      "attach_to": "booking",
      "price_field": "total",
      "payer_role": "customer",
      "payer_ref": "customer_id",
      "currency": "INR"
    },
    "dry_run": true
  }
}
CLI
appbricx templates use razorpay-payments --param attach_to=booking --param price_field=total --param payer_role=customer --param payer_ref=customer_id --param currency=INR --dry-run

Works with

The services this template calls. Each page lists every action and what connecting it takes.

Your agent adds it. Appbricx runs it.