- Google Pay
- PhonePe
- Paytm
Prerequisites
- Sign up for a Razorpay account.
- Generate API Keys from the Dashboard.
Workflow
To enable UPI Intent on your customer’s iOS device:1
Step 1
6
Step 6
Step 1: Create an Order
Order is an important step in the payment process.- An order should be created for every payment.
- You can create an order using the Orders API. It is a server-side API call. Know how to authenticate Orders API.
- The
order_idreceived in the response should be passed to the checkout. This ties the order with the payment and secures the request from being tampered.
Handy TipsUnder the Authorization section in Postman, select Basic Auth and add the Key Id and secret as the Username and Password, respectively.
API Sample Code
Use this endpoint to create an order using the Orders API./ordersCurl
Success Response
Request Parameters
amount mandatory
: integer Payment amount in the smallest currency subunit. For example, if the amount to be charged is 299, then pass 29900 in this field. In the case of three decimal currencies, such as KWD, BHD and OMR, to accept a payment of 295.991, pass the value as 295990. And in the case of zero decimal currencies such as JPY, to accept a payment of 295, pass the value as 295.
Handy TipsRazorpay has added support for zero decimal currencies, such as JPY and three decimal currencies, such as KWD, BHD and OMR, allowing businesses to accept international payments in these currencies. Know more about Currency Conversion (May 2024).
receipt optional
: string Your receipt id for this order should be passed here. Maximum length is 40 characters.notes optional
: json object Key-value pair that can be used to store additional information about the entity. Maximum 15 key-value pairs, 256 characters (maximum) each. For example, "note_key": "Beam me up Scotty”.partial_payment optional
: boolean Indicates whether the customer can make a partial payment. Possible values:true: The customer can make partial payments.false(default): The customer cannot make partial payments.
first_payment_min_amount optional
: integer Minimum amount that must be paid by the customer as the first partial payment. For example, if an amount of 7000 is to be received from the customer in two installments of #1 - 5000, #2 - 2000 then you can set this value as 500000. This parameter should be passed only if partial_payment is true.Know more about Orders API.Response Parameters
Descriptions for the response parameters are present in the Orders Entity parameters table.Error Response Parameters
The error response parameters are available in the API Reference Guide.Step 2: Update your app’s info.plist file
Your iOS app must seek permission from the device to open the UPI PSP app that the customer selects on Checkout. For this, you must make the following changes in your iOS app’s info.plist file.info.plist
Step 3: Check Availability of PSP App on Customer Device
You must ensure that the UPI PSP app (Google Pay, PhonePe or Paytm) is available on the customer’s device. This can be done by checking the URI scheme. If an app is not available, it will not be displayed on the Checkout. For example, if you want to determine availability of PhonePe on customer’s device:Check PSP App Availability
Step 4: Initiate the Payment
/payments/create/upiRequest
Request Parameters
Following are the request parameters:amount mandatory
: integer Amount in paisa. The amount associated with the payment in smallest unit of the supported currency. For example, 2000 means ₹20.
currency mandatory
: string ISO code of the currency associated with the payment amount. In this case, it is INR.
order_id mandatory
: string Unique identifier of the order, obtained from the response of the previous step.
contact mandatory
: string Phone number of the customer.
email mandatory
: string Email address of the customer.
method mandatory
: string Method used to make the payment. Here, it is upi.
flow mandatory
: string Type of the UPI method. In this case, it is flow.
ip mandatory
: string Client’s browser IP address. For example, 117.217.74.98
referer mandatory
: string Value of thereferer header passed by the client’s browser. For example, https://example.com/
user_agent mandatory
: string Value of the user_agent header passed by client’s browser. For example, Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36
notes optional
: json object Key-value pair that can be used to store additional information about the entity. Maximum 15 key-value pairs, 256 characters (maximum) each. For example, "note_key": "Beam me up Scotty”.
description optional
: string Descriptive text of the payment.
callback_URL optional
: string URL where Razorpay will submit the final payment status.
Step 5: Deep link the URL by prefixing App Name
After the URL is generated in the response of the previous step, you should edit it and prefix the app name to the URL. For example, if you detect the presence of PhonePe on the customer’s device, you should add a prefix to the URL as shown below:Original URL | Edited URL
upi://pay?pa=upi@razopay&pn=Acme&tr=z5WHDd077OGFvPK&tn=razorpay&am=1&cu=INR&mc=5411 | phonepe://pay?pa=upi@razorpay&pn=Acme&tr=99fz4Q6LKearD1B&tn=razorpay&am=1&cu=INR&mc=5411 For Google Pay and Paytm, you should append the prefix to the URL as shown:App Name | Prefix-appended URL
Google Pay | tez://upi/pay?pa=upi@razorpay&pn=Acme&tr=99fz4Q6LKearD1B&tn=razorpay&am=1&cu=INR&mc=5411
Paytm | paytmmp://upi/pay?pa=upi@razorpay&pn=Acme&tr=99fz4Q6LKearD1B&tn=razorpay&am=1&cu=INR&mc=5411Step 6: Verify Payment Status
You can subscribe to theorder.paid, payment.authorized and payment.captured Webhook events to get notified once the customer completes the UPI payment. Know more aboutWebhooks.
You can also poll our APIs at regular intervals to track the status of the payments made for an order.
Payment Failure and Re-initiating Payments
If the order is not markedpaid within 2-3 minutes, you can re-initiate payment for the same order.