Unify Applications
Logo
Razorpay Action

Razorpay Action

Logo

4 mins READ

Overview

The controlRazorpay action (Control Razorpay in the action picker) opens the Razorpay SDK's payment screen in a mobile app for a pre-created Razorpay order. It handles the payment UI and writes the result — payment credentials on success, or an error on failure — to appsAndIntegrations.razorpay, where the action's follow-up actions can read it.

The action is available only in mobile apps. It is not offered in web apps, and in a web preview it opens no checkout and shows the warning "Razorpay checkout is supported only in the native runner."

Note: Server-side order creation is required. Razorpay requires that an Order ID be created on your server using the Razorpay Orders API before the checkout is opened. The controlRazorpay action does not create the order — call your order-creation API with a Trigger Data Source action first, then pass the returned order_id to this action.

Prerequisites

Complete these steps before using the action:

  1. Build the payment flow in a mobile app. The action is hidden in web apps.

  2. Go to Settings → Apps & Integrations → Razorpay, turn on Enable Razorpay and enter your Key ID. Until the integration is enabled, the action does not appear in the action picker. If the Key ID is blank, the action finishes as a success without opening checkout, so the On Success callbacks still run with empty payment fields.

  3. Create the order on your server with the Razorpay Orders API, and expose it to the app through a data source.

unify-applications-razorpay-action-01-razorpay-settings.png
unify-applications-razorpay-action-01-razorpay-settings.png

Parameters

Parameter

Type

Required

Default

Description

Operation

string

Optional

Checkout

The only operation. Opens the Razorpay checkout.

Order ID (order_id)

string

Required

—

The Razorpay order ID returned by your server-side order creation API. Typically bound to a data source response.

Amount (amount)

number

Required

—

Payment amount in the smallest currency unit (paise for INR, cents for USD). For example, to charge ₹500 enter 50000. Use the same amount as the Razorpay order you created.

Currency (currency)

string

Required (pre-set)

INR

The payment currency. Choose INR or USD. It starts as INR, so change it only for USD orders. Must match the currency of the Razorpay order.

The merchant key comes from the Key ID in the app's Razorpay settings, and the checkout screen is titled with your app's name. You can't change either per action.

Results

After checkout, the action writes the result to appsAndIntegrations.razorpay:

Field

Description

{{ appsAndIntegrations.razorpay.paymentId }}

The Razorpay payment ID, set on success.

{{ appsAndIntegrations.razorpay.orderId }}

The Razorpay order ID, set on success.

{{ appsAndIntegrations.razorpay.signature }}

The payment signature, set on success. Use it for server-side verification.

{{ appsAndIntegrations.razorpay.error }}

Set instead of the IDs when checkout fails or is dismissed: { code, description, reason }.

On success, the action's On Success callbacks run. On failure, the error is stored and the action's On Failure callbacks run.

Payment Flow Architecture

The recommended end-to-end flow:

  1. Create order server-side: Fire a Trigger Data Source action that calls your backend endpoint (POST /orders). Your server calls the Razorpay Orders API and returns the order ID.

  2. Open Razorpay checkout: In the On Success callbacks of the order creation step, fire the controlRazorpay action with the returned order ID.

  3. Verify payment server-side (On Success): Pass paymentId, orderId and signature from appsAndIntegrations.razorpay to another data source that calls your backend's verification endpoint. Before you treat the payment as done, check that appsAndIntegrations.razorpay.paymentId is set, because the action also finishes as a success when checkout didn't open. Only fulfil the order after server-side verification passes.

  4. Handle failure (On Failure): Show an error snackbar with {{ appsAndIntegrations.razorpay.error.description }}. Optionally offer a retry button that re-opens checkout with the same order ID (Razorpay orders support multiple payment attempts).

Examples

Open Razorpay checkout after order creation

{ "actionType": "controlRazorpay", "payload": { "operation": "checkout", "order_id": "{{ ds_createOrder['data']['id'] }}", "amount": 50000, "currency": "INR" } }

Add an On Success callback that triggers your verification data source with {{ appsAndIntegrations.razorpay.paymentId }}, {{ appsAndIntegrations.razorpay.orderId }} and {{ appsAndIntegrations.razorpay.signature }}, and an On Failure callback that shows a "Payment failed" snackbar.

Testing

  • Test in a build of the mobile app on a device. The web preview opens no checkout and shows a warning.

  • Use a Razorpay test-mode Key ID while you test. The settings panel has no test/live switch: the key you enter decides the mode. Swap in your live Key ID before you go live.

FAQs

How do I test Razorpay payments without real money?

Enter a test-mode Key ID (rzp_test_...) in Settings → Apps & Integrations → Razorpay. Test on the mobile app — the web preview doesn't open checkout. In the checkout screen, use Razorpay's test card number 4111 1111 1111 1111 (any future expiry, CVV 111). For UPI, use success@razorpay. Payments made with a test key are not real transactions and do not move money. Switch to a live-mode Key ID only when deploying to production.

Why must I verify the payment signature server-side?

The signature written to appsAndIntegrations.razorpay on success is a SHA-256 HMAC of the payment ID and order ID, signed with your Razorpay Key Secret. Client-side verification is impossible and insecure — an attacker could forge a success result without making a real payment. Always call your backend to verify the signature using your Key Secret before marking the order as paid.

Can the user retry a failed payment?

Yes. A Razorpay order remains active (in created state) after a failed payment attempt. You can reuse the same order_id in another controlRazorpay action — the user is taken back to checkout for the same order. Razorpay supports multiple payment attempts per order until the order either succeeds or expires.