Skip to content

Commit a5e71d5

Browse files
committed
Added razor pay
1 parent 3888c32 commit a5e71d5

11 files changed

+249
-2
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.
254 KB
Loading
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 247 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,247 @@
1+
---
2+
slug: /integrations/payments/razorpay
3+
title: Razorpay
4+
description: Learn how to integrate Razorpay in your FlutterFlow app.
5+
tags: [FlutterFlow, Razorpay, Payments, Integration]
6+
sidebar_position: 1
7+
keywords: [FlutterFlow, Razorpay, Payments, Integration]
8+
---
9+
# RazorPay
10+
11+
[Razorpay](https://razorpay.com/) is a leading online payment gateway widely used by businesses in India to accept and process digital payments securely.
12+
13+
It provides a platform for merchants and businesses to integrate payment solutions into their websites and mobile apps. It allows customers to make online payments using various payment methods such as credit cards, debit cards, net banking, UPI (Unified Payments Interface), and digital wallets.
14+
15+
:::warning
16+
Currently, publishing to the web with Razorpay enabled is restricted due to some regulations.
17+
:::
18+
19+
<div style={{
20+
position: 'relative',
21+
paddingBottom: 'calc(56.67989417989418% + 41px)', // Keeps the aspect ratio and additional padding
22+
height: 0,
23+
width: '100%'}}>
24+
<iframe
25+
src="https://www.loom.com/embed/02447248672c41c29abc5d7477296aa3?sid=10f5f200-c4d0-4160-a81c-356485c60914"
26+
title=""
27+
style={{
28+
position: 'absolute',
29+
top: 0,
30+
left: 0,
31+
width: '100%',
32+
height: '100%',
33+
colorScheme: 'light'
34+
}}
35+
frameborder="0"
36+
loading="lazy"
37+
webkitAllowFullScreen
38+
mozAllowFullScreen
39+
allowFullScreen
40+
allow="clipboard-write">
41+
</iframe>
42+
</div>
43+
<p></p>
44+
45+
:::info[Prerequisites]
46+
47+
Before starting to set up payments, make sure you have,
48+
49+
1. Complete [**Firebase Setup**](../../ff-integrations/firebase/connect-to-firebase-setup.md) for your project.
50+
2. Enabled [**Firebase Authentication**](../authentication/firebase-auth/auth-initial-setup.md) for your project.
51+
3. Upgraded your Firebase project to [**Blaze Plan**](https://firebase.google.com/pricing). We use [**Firebase Cloud Functions**](https://firebase.google.com/docs/functions) to process a transaction.
52+
:::
53+
54+
## Razorpay Integration
55+
56+
Integrating Razorpay in your app comprises the following steps:
57+
58+
1. [Setup Razorpay](#1-setup-razorpay)
59+
2. [Trigger Razorpay payment](#2-trigger-razorpay-payment-action)
60+
3. [Testing](#3-testing)
61+
4. [Releasing to production](#4-releasing-to-production)
62+
63+
### 1. Setup Razorpay
64+
65+
Setting up the Razorpay payments includes creating an account, enabling test mode, acquiring the keys from your Razorpay account, and adding them to your project.
66+
67+
:::warning
68+
You should always try out payments in a test mode before releasing them to your production application. Hence, the instructions below will guide you on how to get the test keys.
69+
:::
70+
71+
Here are the steps:
72+
73+
1. Create a new Razorpay account from [here](https://dashboard.razorpay.com/signup). If you already have an account, [log in](https://dashboard.razorpay.com/signin).
74+
2. Once you are logged in, turn on the **Test Mode**. Test mode helps you simulate the payments without involving real money transactions.
75+
![Enabling test mode](imgs/enable-test-mode.avif)
76+
3. From the left side menu, select **Account & Settings** > Under **Website and app settings** section, select **API keys**.
77+
4. If you're asked to add a website link but your app isn't published yet, you can temporarily publish it to a subdomain using our [web publishing](../../testing-deployment-publishing/publishing/web-publishing.md) feature. Later, you can update this to your actual domain in both FlutterFlow and Razorpay.
78+
![add-website-link](imgs/add-website-link.avif)
79+
5. Click **Generate Test Key** and copy the **Key Id** and **Key Secret**. To regenerate, click on **Regenerate Test Key** and choose how you want to deactivate the old key.
80+
![Generate Test Key](imgs/generate-test-key.webp)
81+
82+
<div style={{
83+
position: 'relative',
84+
paddingBottom: 'calc(56.67989417989418% + 41px)', // Keeps the aspect ratio and additional padding
85+
height: 0,
86+
width: '100%'}}>
87+
<iframe
88+
src="https://www.loom.com/embed/6ccda9493cae46198027b357afcda521?sid=91f61c5c-50dc-4c77-a5a6-11d613507eb4"
89+
title=""
90+
style={{
91+
position: 'absolute',
92+
top: 0,
93+
left: 0,
94+
width: '100%',
95+
height: '100%',
96+
colorScheme: 'light'
97+
}}
98+
frameborder="0"
99+
loading="lazy"
100+
webkitAllowFullScreen
101+
mozAllowFullScreen
102+
allowFullScreen
103+
allow="clipboard-write">
104+
</iframe>
105+
</div>
106+
<p></p>
107+
108+
6. Return to the FlutterFlow project, navigate to **Settings and Integrations** > **In App Purchases & Subscriptions** > **Razorpay**. Use the toggle to **Enable Razorpay Payments**.
109+
7. Under **Test Credentials**, paste the **Key ID** and **Key Secret** obtained in the previous step.
110+
8. Set your **Business Name**.
111+
9. Click the **Deploy** button.
112+
![deploy](imgs/deploy.png)
113+
114+
### 2. Trigger Razorpay payment [Action]
115+
116+
To initiate a payment using Razorpay, you must use the **Razorpay Payment** action. This action lets users process a payment inside your app using credit cards, debit cards, net banking, UPI (Unified Payments Interface), and digital wallets via Razorpay.
117+
118+
Follow the steps below to add this action:
119+
120+
1. Select the widget (e.g., checkout button) on which you want to add the action.
121+
2. Select **Actions** from the Properties panel (the right menu), and click Open. This will open an **Action Flow Editor** in a new popup window. Click on the **+ Add Action**.
122+
3. Search and select the **Razorpay Payment** (under *Integrations*) action.
123+
4. Enter or use a variable for specifying the total amount under the **Amount** section. **Note** that the value should be specified in the currency's smallest unit.
124+
- For example, *$24.99* should be passed as *2499* (as a round-off integer; otherwise, it would be automatically rounded); similarly, for an amount of ₹120.00, 12000 should be passed.
125+
- Most probably, you'll specify this value from a variable. If you do so, you might need this [code expression](../../resources/control-flow/functions/utility-functions.md#code-expressions) to convert the total amount in the required format: `amount.toStringAsFixed(2).replaceAll(".", "");`
126+
5. Enter the **Currency Code** to be used for the amount, for example, *INR*, *USD*, *EUR*, or *BRL*. Make sure you enter a valid currency code; otherwise, the transaction won't go through. Download the complete [list of supported currencies](https://razorpay.com/docs/build/browser/assets/images/international-currency-list.xlsx).
127+
![Specifying amount and country code manually](imgs/specify-amount-and-code-manually.avif)
128+
129+
<div style={{
130+
position: 'relative',
131+
paddingBottom: 'calc(56.67989417989418% + 41px)', // Keeps the aspect ratio and additional padding
132+
height: 0,
133+
width: '100%'}}>
134+
<iframe
135+
src="https://www.loom.com/embed/1405bb45c9734f4abba2ba123949fb0c?sid=0215e670-70b5-49ed-adae-a86d65b261e7"
136+
title=""
137+
style={{
138+
position: 'absolute',
139+
top: 0,
140+
left: 0,
141+
width: '100%',
142+
height: '100%',
143+
colorScheme: 'light'
144+
}}
145+
frameborder="0"
146+
loading="lazy"
147+
webkitAllowFullScreen
148+
mozAllowFullScreen
149+
allowFullScreen
150+
allow="clipboard-write">
151+
</iframe>
152+
</div>
153+
<p></p>
154+
155+
6. With this action, you can also add some optional fields, such as **Receipt Number**, **Description**, **User Name**, **User Email**, **User Contact**, and **Timeout** (time for which the checkout dialog should remain active. By default, it is 180 seconds).
156+
157+
<div style={{
158+
position: 'relative',
159+
paddingBottom: 'calc(56.67989417989418% + 41px)', // Keeps the aspect ratio and additional padding
160+
height: 0,
161+
width: '100%'}}>
162+
<iframe
163+
src="https://www.loom.com/embed/291c0d50a2d54c3a8af8eddbaa2e9058?sid=2cf88f42-0716-4e86-80cd-9074aa3cf64f"
164+
title=""
165+
style={{
166+
position: 'absolute',
167+
top: 0,
168+
left: 0,
169+
width: '100%',
170+
height: '100%',
171+
colorScheme: 'light'
172+
}}
173+
frameborder="0"
174+
loading="lazy"
175+
webkitAllowFullScreen
176+
mozAllowFullScreen
177+
allowFullScreen
178+
allow="clipboard-write">
179+
</iframe>
180+
</div>
181+
<p></p>
182+
183+
7. You can also customize the color scheme for the payment sheet using properties such as **Dialog Color, Barrier Color,** **Text Color**, **Processing Color**, **Success Color**, **Error Color,** and more.
184+
![Customizing Razorpay payment sheet](imgs/customize-payment-sheet.avif)
185+
8. Enter an **Action** **Output Variable Name** where the payment ID would be stored on a successful transaction.
186+
9. Now you must check if the payment was successful. You can do so by adding the [conditional action](../../resources/control-flow/functions/conditional-logic.md#conditional-actions). To do so, click the "**+**" button below the previous action tile and select **Add Conditional**.
187+
10. On the right side (**Set Condition for Action**),
188+
1. Select **UNSET** > **Condition** > **Single Condition**.
189+
2. **First Value** > **Action** **Output Variable Name**.
190+
3. Set the operator to **Is Set and Not Empty**.
191+
11. Under the **TRUE** section, add an action that will be triggered if the payment is successful.
192+
12. Under the **FALSE** section, add an action that will be triggered if payment is failed.
193+
194+
<div style={{
195+
position: 'relative',
196+
paddingBottom: 'calc(56.67989417989418% + 41px)', // Keeps the aspect ratio and additional padding
197+
height: 0,
198+
width: '100%'}}>
199+
<iframe
200+
src="https://www.loom.com/embed/9f9aea02e2db4c4fa3ea14f480567650?sid=d780d458-5970-4bbb-b10a-08ff6e4dab1b"
201+
title=""
202+
style={{
203+
position: 'absolute',
204+
top: 0,
205+
left: 0,
206+
width: '100%',
207+
height: '100%',
208+
colorScheme: 'light'
209+
}}
210+
frameborder="0"
211+
loading="lazy"
212+
webkitAllowFullScreen
213+
mozAllowFullScreen
214+
allowFullScreen
215+
allow="clipboard-write">
216+
</iframe>
217+
</div>
218+
<p></p>
219+
220+
:::warning
221+
Ensure the user is authenticated before triggering this action; otherwise, it will result in an error. You can follow the steps on [this page](../authentication/firebase-auth/auth-initial-setup.md) to set up Firebase Authentication.
222+
:::
223+
224+
### 3. Testing
225+
226+
You can test Razorpay payments on Run mode, Test mode, an emulator/Simulator, or a physical device.
227+
228+
To test payments in Test or Run mode:
229+
230+
1. In your FlutterFlow project, navigate to **Settings and Integrations** > **In App Purchases & Subscriptions** > **Razorpay**.
231+
2. Make sure the **Is Production** is disabled.
232+
3. Make sure you have entered the correct **Test Credentials**.
233+
4. Run your app in [Test mode](../../testing-deployment-publishing/running-your-app/run-your-app.md#test-mode).
234+
5. To test the purchase, you can try any method from [here](https://razorpay.com/docs/payments/payments/test-card-upi-details/#test-card-for-international-payments).
235+
236+
### 4. Releasing to production
237+
238+
Once you are done testing your Razorpay integration and you are ready to go **live**, follow the steps below:
239+
240+
1. Complete **KYC** (or the [Activation Form](https://dashboard.razorpay.com/app/activation?ref=blog.flutterflow.io)) to access the Razorpay Live API.
241+
2. Log into the [Razorpay Dashboard](https://dashboard.razorpay.com/?ref=blog.flutterflow.io#/access/signin) and switch to **Live Mode** on the menu.
242+
3. From the left side menu, select **Account & Settings** > Under **Website and app settings** section, select **API keys**.
243+
4. Click **Generate Live Key** and copy the **Key Id** and **Key Secret**. To regenerate, click on **Regenerate Live Key** and choose how you want to deactivate the old key.
244+
5. Return to the FlutterFlow project, navigate to **Settings and Integrations** > **In App Purchases & Subscriptions** > **Razorpay**. Turn on the **Is Production**.
245+
6. Under **Production Credentials**, paste the **Key ID** and **Key Secret** obtained in the previous step.
246+
7. Click the **Deploy** button.
247+
8. [Test](../../testing-deployment-publishing/running-your-app/run-your-app.md#test-mode) your app.

0 commit comments

Comments
 (0)