Handy TipsThis is an on-demand feature. Write to us at magic-checkout-support@razorpay.com to get this feature enabled on your account.
Use Cases
Here are some examples of how you can leverage RTO Intelligence.- Custom Checkout Experience
- Website or App
- Logistics Partners and Aggregators
Prerequisites
- Create a Razorpay account.
- Generate the API keys from the Dashboard. You can use the Test Mode keys for testing and later switch to Live Mode, generate the Live API keys and replace it with the test keys.
Integration Steps
Perform the following integration steps:Step 1: Create an Order
You can create an order using the following API and send the additional information required for Magic Checkout. Pass theorder_id received in response in the subsequent API calls as the identifier of the order.
/orders
Curl
Success Response
Request Parameters
amount mandatory
: integer The transaction amount expressed in the currency subunit, such as paise (in case of INR). For example, for an actual amount of ₹299.35, the value of this field should be 29935.
currency mandatory
: string The currency in which the customer makes the transaction. See the list of supported currencies. The default is INR, and the length must be 3 characters.
receipt mandatory
: string Your receipt id for this order should be passed here. Maximum length of 40 characters.
notes optional
: 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”.
rto_review mandatory
: boolean Identifier to mark the order eligible for RTO risk prediction. Possible values:
true: You can get RTO risk prediction using the orders/rto_review API.false(default): You can choose not to get RTO risk prediction for the order.
Response Parameters
amount
: integer The amount for which the order was created, in currency subunits. For example, for an amount of ₹295, enter 29500.
amount_due
: integer The amount pending against the order.
amount_paid
: string The amount paid by the customer.
attempts
: integer The number of payment attempts, successful and failed, that have been made against this order. For example, 1.
cod_fee
: integer COD fee charged on the line items in paise.
created_at
: string The Unix timestamp when the order was created.
currency
: string A 3 letter ISO code for the currency you want to accept the payment. For example, INR. Refer to the list of supported currencies.
customer_details
: object Details of the customer.
contact
: string The customer’s phone number. Maximum length of 15 characters, including the country code. For example, +919000090000.
email
: string The customer’s email address. Maximum length of 64 characters. For example, gaurav.kumar@example.com.
insights
: json object Additional customer details including past transaction data.
name
: string Customer’s name. Alphanumeric values with period (.), apostrophe (’) and parentheses are allowed. The name must be between 3-50 characters in length. For example, Gaurav Kumar.
shipping_address
: Details of the customer’s shipping address.
city
: string The name of the city. For example, Bengaluru.
contact
: string The customer’s email address. Maximum length of 64 characters. For example, gaurav.kumar@example.com.
country
: string ISO 3 country code of the shipping address. For example, IND.
landmark
: string Nearest landmark to the delivery address.
latitude
: float Latitude of the position expressed in decimal degrees (WSG 84), for example, 6.244203. A positive value denotes the northern hemisphere or the equator, and a negative value denotes the southern hemisphere. The number of digits represents the precision of the coordinate.
line1
: string The first line of the customer’s address.
line2
: string The second line of the customer’s address.
longitude
: float Longitude of the position expressed in decimal degrees (WSG 84), for example, -75.581211. A positive value denotes east longitude or the prime meridian, and a negative value denotes west longitude. The number of digits represents the precision of the coordinate.
name
: string The customer’s name.
state
: string The name of the state. For example, Karnataka.
tag
: string Address tags are additional short descriptors commonly used for filtering and searching. Maximum length of 40 characters. For example, Home, Office, and so on.
zipcode
: string The customer’s ZIP code.
billing_address
: Details of the customer’s billing address.
city
: string The name of the city. For example, Bengaluru.
contact
: string The customer’s email address. Maximum length of 64 characters. For example, gaurav.kumar@example.com.
country
: string ISO 3 country code of the billing address. For example, IND.
landmark
: string Nearest landmark to the delivery address.
latitude
: float Latitude of the position expressed in decimal degrees (WSG 84), for example, 6.244203. A positive value denotes the northern hemisphere or the equator, and a negative value denotes the southern hemisphere. The number of digits represents the precision of the coordinate.
line1
: string The first line of the customer’s address.
line2
: string The second line of the customer’s address.
longitude
: float Longitude of the position expressed in decimal degrees (WSG 84), for example, -75.581211. A positive value denotes east longitude or the prime meridian, and a negative value denotes west longitude. The number of digits represents the precision of the coordinate.
name
: string The customer’s name.
state
: string The name of the state. For example, Karnataka.
tag
: string Address tags are additional short descriptors commonly used for filtering and searching. Maximum length of 40 characters. For example, Home, Office, and so on.
zipcode
: string The customer’s ZIP code.
entity
: integer Indicates the type of entity. Here, it is order.
id
: string The unique identifier of the order.
line_items_total
: integer Sum of offer_price for all line items added in the cart in paise. For example, if a bag worth ₹8,000 and a shoe worth ₹10,000 are added to the cart, the line_item_total will be 180000. This is post-tax.
notes
: 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”.
offers
: array Offers enabled on your account.
promotions
: array Used to pass all offer or discount-related information, including coupon code discount, method discount and so on.
reference_id
: string Id of the Offer.
code
: string Coupon code used to avail discount.
type
: string Type of Offer. Possible values:
couponoffer
value mandatory
: decimal The offer value that is applied. In the case of fixed_amount, it is a flat discount. For example, ₹500. In the case of percentage, it is a percentage value. For example, 10%.
value_type mandatory
: string The type of value. Possible values:
fixed_amount: A fixed amount discount value in the currency of the order. For example, ₹500.percentage: A percentage discount value. For example, 10%.
description
: string Description of the promotion applied. For example, New Year Sale Offer.
receipt
: string Receipt number that corresponds to this order. The maximum length of 40 characters and has to be unique.
shipping_fee
: integer Shipping fee charged on the line items in paise.
status
: integer The status of the order. Possible values:
created: When you create an order, it is in the created state. It stays in this state till a payment is attempted on it.attempted: An order moves from created to attempted state when a payment is first attempted. It remains in this state till the payment associated with the order is captured.paid: After successfully capturing the payment, the order moves to the paid state. The order stays in the paid state even if the payment associated with the order is refunded.
Step 2: View RTO/Risk Reasons
You can use theorder_id obtained in the previous step to view the RTO risk and reasons why a particular order is risky. This information can be consumed to:
- Disable COD as a payment method for a customer.
- Take necessary action on the order, like calling up the customer post-order placement to verify if they are a genuine customer.
Path Parameter
order_id mandatory
: string The unique identifier of an order to access the rto_review information.
Response Parameters
risk_tier
: string Determines how risky the order is. Possible values:
highmediumlow
rto_reasons
: array Top 5 reasons for risky orders in descending order of importance. Refer to the list of possible reasons for risky orders.
reason
: string Id of the Offer.
description
: string A unique identifier for the RTO reason.
bucket
: string Categorises the reason into a specific group. For example, both reasons in the code are categorised under the address bucket.
Error Response Parameters
Given below is the list of errors for RTO review. INVALID_ARGUMENT- Error: input_validation_failed
- Description: The id provided does not exist.
- Error Status: 400
- Source: business
- Step: rto_review
- Next Steps: Try with the id shared back during order creation response (/v1/orders)
INVALID_ARGUMENT
- Error: input_validation_failed
- Description: order_id: the length must be exactly 14
- Error Status: 400
- Source: business
- Step: rto_review
- Next Steps: Invalid order_id cannot be mapped back to an existing order. Try with the id shared back during order creation response (v1/orders)
INVALID_ARGUMENT
- Error: input_validation_failed
- Description: Mandatory field shipping_address not present
- Error Status: 400
- Source: business
- Step: rto_review
- Next Steps: Shipping address was not shared in order_create API (/v1/orders). Please try creating an order again with all the mandatory details.
INTERNAL
- Error: NA
- Description: We are facing some trouble completing your request at the moment. Please try again shortly.
- Error Status: 500
- Source: business
- Step: rto_review
- Next Steps: Please try in a while.
Step 3: Update the Fulfillment Details
Use the code below to update the Fulfilment details of the order and payment method used.Path Parameter
order_id mandatory
: string The unique identifier of an order to access the fulfillment information.
Request Parameters
payment_method optional
: string Payment Method opted by the customer to complete the payment. Possible values:
upicardwalletnetbankingcodemicardless_emipaylaterrecurringother
Error Response Parameters
Given below is the the list of errors for fulfillment details. INVALID_ARGUMENT- Error: input_validation_failed
- Description: The id provided does not exist.
- Error Status: 400
- Source: business
- Step: fulfillment_updates
- Next Steps: Try with another id shared as a response to (/v1/orders)
INVALID_ARGUMENT
- Error: input_validation_failed
- Description: Mandatory fields are missing in payment object: [“order_id”]
- Error Status: 400
- Source: business
- Step: fulfillment_updates
- Next Steps: Please send order_id in the URL to get RTO reviews for that order.
INVALID_ARGUMENT
- Error: input_validation_failed
- Description: shipping_status: invalid shipping status entered, please pass a valid shipping status.
- Error Status: 400
- Source: business
- Step: fulfillment_updates
- Next Steps: Please pass a valid shipping status.
INTERNAL
- Error: NA
- Description: We are facing some trouble completing your request at the moment. Please try again shortly.
- Error Status: 500
- Source: business
- Step: NA
- Next Steps: Please try in a while.