Token Sharing for Partnership Auth Model
Token sharing eliminates the need for customers to re-enter card details when making purchases across different businesses under the same legal entity, creating a seamless payment experience. This feature allows tokens created under any merchant ID (MID) to be automatically shared across all MIDs within the same entity, significantly improving customer convenience and reducing checkout friction. Know more about token sharing for partnership auth model.Integration Steps
Given below are the integration steps.Handy Tips
- Add the basic auth with partner credentials (client_id and client_secret).
- Add the
account_idof the sub-merchant using X-Razorpay-Account in the header. For example,-H "X-Razorpay-Account: acc_KBrJAIEqre5ucn"
1. Create a Customer
Razorpay links recurring tokens to customers via a unique identifier. You can generate this identifier using the Customer API. You can create customers with basic information such as email and contact and use them for various Razorpay offerings. The following endpoint creates a customer. /customersRequest
Request Parameters
name mandatory
: string The name of the customer. For example, Gaurav Kumar.
email mandatory
: string The email id of the customer. For example, gaurav.kumar@example.com.
contact mandatory
: string The phone number of the customer. For example, 9876543210.
fail_existing optional
: string The request throws an exception by default if a customer with the exact details already exists. You can pass an additional parameter fail_existing to get the existing customer’s details in the response. Possible values:
1(default): If a customer with the same details already exists, throws an error.0: If a customer with the same details already exists, fetches details of the existing customer.
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_1”: November Rains”.
Response Parameters
id
: string The unique identifier of the customer. For example, cust_1Aa00000000001.
entity
: string The name of the entity. Here, it is customer.
name
: string The name of the customer. For example, Gaurav Kumar.
email
: string The email id of the customer. For example, gaurav.kumar@example.com.
contact
: string The phone number of the customer. For example, 9876543210.
notes
: 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, For example, “note_key_1”: November Rains”.
created_at
: integer A Unix timestamp, at which the customer was created.
2. Create a Registration Payment
You can create the registration payment using: Given below is the sample code for the Consolidated Orders and Payments API. /ordersRequest
Request Parameters
amount mandatory
: integer Amount in currency subunits. For cards, the amount should be 100 (₹1).
currency mandatory
: string The 3-letter ISO currency code for the payment. We support INR only.
customer_id mandatory
: string The unique identifier of the customer to be charged. For example, cust_D0cs04OIpPPU1F.
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.
token mandatory
: json object Details related to the authorisation such as max amount and bank account information.
max_amount optional
: integer The maximum amount in paise a customer can be charged in a transaction. The value can range from 500 to 100000000. The default value is 9999900 (₹99,999).
expire_at optional
: integer The Unix timestamp to indicate till when you can use the token (authorisation on the payment method) to charge the customer upcoming payments.
frequency mandatory
: string The frequency at which you can charge your customer. Currently supported frequencies are as_presented and monthly. The support for other frequencies is expected to be live soon.
payment mandatory
: json object Details related to the payment.
amount mandatory
: integer Payment amount in the smallest currency unit. For example, paise for INR.
email mandatory
: string Customer’s email address for payment notifications and receipts.
contact mandatory
: string Customer’s phone number.
method mandatory
: string Payment method used for the payment. Here, it is card.
notes optional
: json object Key-value pairs for storing custom metadata related to the payment.
customer_id optional
: string Unique identifier of the customer.
recurring optional
: integer Indicates whether the payment is of recurring nature. Possible values are:
1: Recurring payment.0: One-time payment.
card conditional
: json object Card details object (required when method is card).
name mandatory
: string Cardholder’s name as printed on the card.
number mandatory
: string The card number.
cvv mandatory
: string 3-digit number printed at the back of the card.
expiry_month mandatory
: string Card expiry month in MM format.
expiry_year mandatory
: string Card expiry year in YY format.
authentication optional
: json object Authentication parameters for enhanced security.
authentication_channel optional
: string Channel used for authentication. Possible values are browser and app.
browser mandatory
: json object Information regarding the customer’s browser. This parameter need not be passed when authentication_channel=app.
java_enabled
: boolean Indicates whether the customer’s browser supports Java. Obtained from the navigator HTML DOM object. Possible values:
true: Customer’s browser supports Java.false: Customer’s browser does not support Java.
javascript_enabled
: boolean Indicates whether the customer’s browser can execute JavaScript. Obtained from the navigator HTML DOM object. Possible values:
true: Customer’s browser can execute JavaScript.false: Customer’s browser cannot execute JavaScript.
timezone_offset
: integer Time difference between UTC time and the cardholder’s browser local time. Obtained from the getTimezoneOffset() method applied to the Date object.
screen_width
: integer Total width of the payer’s screen in pixels. Obtained from the screen.width HTML DOM property.
screen_height
: integer Obtained from the navigator HTML DOM object.
color_depth
: integer Obtained from the payer’s browser using the screen.colorDepth HTML DOM property.
ip mandatory
: string Client’s browser IP address. For example, 117.217.74.98.
referer mandatory
: string Value of referer header passed by the client’s browser. For example, https://example.com/.
Response Parameters
id
: string A unique identifier of the order created. For example order_1Aa00000000001.
entity
: string The entity that has been created. Here it is order.
attempts
: integer The number of payment attempts, successful and failed, that have been made against this order. For example, 1.
amount
: integer Amount in currency subunits. For cards, the amount should be 100 (₹1).
amount_paid
: integer The amount that has been paid.
amount_due
: integer The amount that is yet to be paid.
currency
: string The 3-letter ISO currency code for the payment. Currently, we only support INR.
receipt
: string A user-entered unique identifier of the order. For example, rcptid #1. You should map this parameter to the order_id sent by Razorpay.
status
: string The status of the order.
notes
: 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”.
created_at
: integer The Unix timestamp at which the order was created.
method
: string The authorisation method. Here, it is card.
customer_id
: string The unique identifier of the customer. For example, cust_4xbQrmEoA5WJ01.
offer_id
: string Unique identifier of the offer.
payment_workflow
: json object Details of the payment workflow.
razorpay_payment_id
: string Unique identifier of the payment. Present for all responses.
next
: array A list of action objects available to continue the payment process. Present when the payment requires further processing.
action
: string An indication of the next step available for payment processing. Possible values:
otp_generate: Use this URL to allow the customer to generate the OTP.redirect: Use this URL to redirect the customer to payment page to complete the payment.
url
: string URL to be used for the action indicated.
3. Fetch Recurring token
You can fetch the recurring token using the Fetch Payments API or by subscribing to thepayment.authorized and token.confirmed webhook events. Use this recurring token to initiate subsequent debits.
Fetch Payments API
Use this endpoint to fetch the payment details with thepayment_id generated in the response of the previous step.
/v1/payments/:id
Request
Path Parameter
id mandatory
: string Unique identifier of the payment to be retrieved.
Response Parameters
id
: string Unique identifier of the payment.
entity
: string Indicates the type of entity.
amount
: integer The payment amount in currency subunits. For example, for an amount of ₹1.00 enter 100.
currency
: string The currency in which the payment is made.
status
: string The status of the payment. Possible values:
createdauthorizedcapturedrefundedfailed
method
: string The payment method used for making the payment. Here, it is card.
order_id
: string Order id, if provided.
description
: string Description of the payment, if any.
international
: boolean Indicates whether the payment is done via an international card or a domestic one. Possible values:
true: Payment made using international card.false: Payment not made using international card.
refund_status
: string The refund status of the payment. Possible values:
nullpartialfull
amount_refunded
: integer The amount refunded in currency subunits. For example, if amount_refunded = 100, it is equal to ₹1.00.
captured
: boolean Indicates if the payment is captured. Possible values:
true: Payment has been captured.false: Payment has not been captured.
email
: string Customer email address used for the payment.
contact
: string Customer contact number used for the payment.
fee
: integer Fee (including GST) charged by Razorpay.
tax
: integer GST charged for the payment.
error_code
: string Error that occurred during payment. For example, BAD_REQUEST_ERROR.
error_description
: string Description of the error which occurred during payment. For example, Payment processing failed because of incorrect OTP.
error_source
: string The point of failure. For example, customer.
error_step
: string The stage where the transaction failure occurred. The stages can vary depending on the payment method used to complete the transaction. For example, payment_authentication.
error_reason
: string The exact error reason. For example, incorrect_otp.
notes
: json object Contains user-defined fields, stored for reference purposes.
created_at
: integer Timestamp, in UNIX format, at which the payment was created.
card_id
: string The unique identifier of the card used by the customer to make the payment.
customer_id
: string Unique identifier of the customer created in step 1.
token_id
: string Unique identifier of the token.
bank
: string The 4-character bank code which the customer’s account is associated with. For example, UTIB for Axis Bank.
vpa
: string The customer’s VPA (Virtual Payment Address) or UPI id used to make the payment. For example, gauravkumar@exampleupi.
wallet
: string The name of the wallet used by the customer to make the payment. For example, payzapp.
acquirer_data
: json object A dynamic array consisting of a unique reference numbers.
rrn
: string A unique bank reference number provided by the banking partner when a refund is processed. This reference number can be used by the customer to track the status of the refund with the bank.
auth_code
: string Authorisation code from the issuing bank indicating transaction approval or decline status. Used to verify that the transaction was authorised by the bank.
arn
: string A unique reference number provided by the banking partner.
Subscribe to payment.authorized Webhook Event
Thetoken_id is also present in the payment.authorized webhook event payload.
payment.authorized payload
Subscribe to token.confirmed Webhook Event
Check the token activation status from thetoken.confirmed webhook event payload.
token.confirmed payload
4. Retrieve Saved Card Token by Subscribing to Webhooks
Subscribe to thetoken.service_provider_token.activated webhook event to automatically retrieve saved card tokens. These tokens streamline the card addition process across sub-merchant accounts and reduce user friction. When triggered, this webhook notifies the parent account, which can then cascade the information to all associated child accounts.
- Partner has to retrieve the card network information to assess if it is a Visa, Mastercard or Rupay card.
- If the card is of Visa or Mastercard network, then partner can enable the composite API using the saved card token id received in this webhook,
- If the network is Rupay, the partner should follow the normal Composite Order API flow shared above in Step 2 as Rupay does not support mandate registration using saved card token.
token.service_provider_token.activated
5. Create a Registration Payment using Saved Card Token with Composite Order API
Use the Composite Order API to create a registration payment using saved card token.Request Parameters
amount mandatory
: integer Amount in currency subunits. For cards, the amount should be 100 (₹1).
currency mandatory
: string The 3-letter ISO currency code for the payment. We support INR only.
notes optional
: json object Key-value object used for passing tracking info. Refer to Notes for more details.
payment mandatory
: json object Details related to the payment.
amount mandatory
: integer Payment amount in the smallest currency unit. For example, paise for INR.
email mandatory
: string Customer’s email address for payment notifications and receipts.
contact mandatory
: string Customer’s phone number.
method mandatory
: string Payment method used for the payment. Here, it is card.
notes optional
: json object Key-value pairs for storing custom metadata related to the payment.
customer_id optional
: string Unique identifier of the customer.
recurring optional
: integer Indicates whether the payment is of recurring nature. Possible values are:
1: Recurring payment.0: One-time payment.
token_id mandatory
: string Unique identifier of the token.
save mandatory
: integer Determines whether to save the card details. Possible values:
1: Save the card details.0: Do not save the card details.
authentication optional
: json object Authentication parameters for enhanced security.
authentication_channel optional
: string Channel used for authentication. Possible values: browser, mobile_app, api.
browser mandatory
: json object Information regarding the customer’s browser. This parameter need not be passed when authentication_channel=app.
java_enabled
: boolean Indicates whether the customer’s browser supports Java. Obtained from the navigator HTML DOM object. Possible values:
true: Customer’s browser supports Java.false: Customer’s browser does not support Java.
javascript_enabled
: boolean Indicates whether the customer’s browser can execute JavaScript. Obtained from the navigator HTML DOM object. Possible values:
true: Customer’s browser can execute JavaScript.false: Customer’s browser cannot execute JavaScript.
timezone_offset
: integer Time difference between UTC time and the cardholder’s browser local time. Obtained from the getTimezoneOffset() method applied to the Date object.
screen_width
: integer Total width of the payer’s screen in pixels. Obtained from the screen.width HTML DOM property.
screen_height
: integer Obtained from the navigator HTML DOM object.
color_depth
: integer Obtained from the payer’s browser using the screen.colorDepth HTML DOM property.
ip mandatory
: string Client’s browser IP address. For example, 117.217.74.98.
referer mandatory
: string Value of referer header passed by the client’s browser. For example, https://example.com/.
Response Parameters
id
: string A unique identifier of the order created. For example order_1Aa00000000001.
entity
: string The entity that has been created. Here it is order.
amount
: integer Amount in currency subunits. For cards, the amount should be 100 (₹1).
amount_paid
: integer The amount that has been paid.
amount_due
: integer The amount that is yet to be paid.
currency
: string The 3-letter ISO currency code for the payment. We support INR only.
receipt
: string A user-entered unique identifier of the order. For example, rcptid #1. You must map this parameter to the order_id sent by Razorpay.
status
: string The status of the order.
notes
: 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”.
created_at
: integer The Unix timestamp at which the order was created.
method
: string The authorisation method. Here, it is card.
customer_id
: string The unique identifier of the customer. For example, cust_4xbQrmEoA5WJ01.
payment_workflow
: json object Details of the payment workflow.
razorpay_payment_id
: string Unique identifier of the payment. Present for all responses.
next
: array A list of action objects available to continue the payment process. Present when the payment requires further processing.
action
: string An indication of the next step available for payment processing. Possible values:
otp_generate: Use this URL to allow the customer to generate the OTP.redirect: Use this URL to redirect the customer to payment page to complete the payment.
url
: string URL to be used for the action indicated.
Error Response Parameters
error
: json object The error object.
code
: string The type of error. Here, it is BAD_REQUEST_ERROR.
description
: string Descriptive text about the error.
source
: string The point of failure in the specific operation (payment in this case).
step
: string The stage where the transaction failure occurred.
reason
: string The exact error reason.
metadata
: json object Contains additional information about the request.
Submit OTP/Complete Redirection Flow for Successful Payment
Ensure the payment is completed successfully via OTP submission or redirection to the bank’s OTP page. Razorpay supports both Native OTP (via Composite API response) and Non-Native OTP (bank’s OTP page).
6. Create a Subsequent Payment
To create subsequent payments, you need to- Create an Order using Orders API.
- Create a Payment using Recurring Payments API.
6.1 Create an Order
Create an Order using the Orders API. Pass thecustomer_id in the request body along with the other parameters.
/orders
Request
Request Parameters
amount mandatory
: integer Payment amount in the smallest currency sub-unit.
currency mandatory
: string ISO code for the currency in which you want to accept the payment.
receipt
: string Receipt number that corresponds to this order, set for your internal reference. Can have a maximum length of 40 characters and has to be unique.
notes
: 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”.
customer_id mandatory
: string Unique identifier of the customer created in step 1.
Response Parameters
id
: string The unique identifier of the order.
amount
: integer The amount for which the order was created, in currency subunits. For example, for an amount of ₹295.00, enter 29500.
entity
: string Name of the entity. Here, it is order.
amount_paid
: integer The amount paid against the order.
amount_due
: integer The amount pending against the order.
currency
: string The 3-digit ISO code for the currency in which you want to accept the payment.
receipt
: string Receipt number that corresponds to this order.
status
: string 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 on it. It remains in the attempted state till one payment associated with that order is captured.paid: After the successful capture of the payment, the order moves to the paid state. No further payment requests are permitted once the order moves to the paid state. The order stays in the paid state even if the payment associated with the order is refunded.
attempts
: integer The number of payment attempts, successful and failed, that have been made against this order.
notes
: 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.
created_at
: integer Indicates the Unix timestamp when this order was created.
6.2 Create a Payment
Create a Payment using the Recurring Payments API. Use the recurring token fetched in step 3. /payments/create/recurringRequest
Request Parameters
email mandatory
: string The customer’s email address.
contact mandatory
: string The customer’s phone number.
amount mandatory
: integer The payment amount in currency subunits.
currency mandatory
: string The 3-digit ISO code for the currency in which you want to accept the payment.
order_id mandatory
: string Unique identifier of the order created in the previous step.
customer_id mandatory
: string Unique identifier of the customer created in step 1.
token mandatory
: string Unique identifier of the token.
recurring optional
: boolean Indicates whether the payment is of recurring nature. Possible values are:
true: Recurring payment.false: One-time payment.
description
: string Description of the payment, if any.
notes
: 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.
Response Parameters
razorpay_payment_id
: string Unique identifier of the payment.
razorpay_order_id
: string Unique identifier of the order.
razorpay_signature
: string The signature generated for the payment.
6.3 Subscribe to Webhook Events to Verify Payment Status
Subscribe to thepayment.captured webhook event to confirm the payment. You may also subscribe to the token.rejected webhook to get notified in case the token is rejected.
payment.captured Webhook Event payload
Given below is the webhook payload for thepayment.captured event.
payment.captured
token.rejected Webhook Event payload
Given below is the webhook payload for thetoken.rejected event.
token.rejected