0% found this document useful (0 votes)
24 views4 pages

Razorpay Subscription API Guide

The document outlines a sequence of API calls for creating a subscription, retrieving a session ID, processing a payment, and authenticating that payment using Razorpay's services. It includes the necessary headers, parameters, and JSON data for each step in the process. The responses for each API call are also provided as examples.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views4 pages

Razorpay Subscription API Guide

The document outlines a sequence of API calls for creating a subscription, retrieving a session ID, processing a payment, and authenticating that payment using Razorpay's services. It includes the necessary headers, parameters, and JSON data for each step in the process. The responses for each API call are also provided as examples.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

-----create-subscription-----

import requests

headers = {
'Accept': 'application/json, text/plain, */*',
'Accept-Language': 'en-US,en;q=0.9',
'Connection': 'keep-alive',
'Content-Type': 'application/json;charset=UTF-8',
'Origin': '[Link]
'Referer':
'[Link]
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-origin',
'Sec-Fetch-Storage-Access': 'none',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36
(KHTML, like Gecko) Chrome/[Link] Safari/537.36',
'sec-ch-ua': '"Google Chrome";v="141", "Not?A_Brand";v="8",
"Chromium";v="141"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
}

json_data = {
'payment_page_item_id': 'ppi_QGrJy8028PRqGk',
'notes': {
'email': 'sekol30908@[Link]',
'phone': '+9116045559876',
'name': 'Madara Uchiha',
},
}

response = [Link](
'[Link]
create_subscription',
headers=headers,
json=json_data,
)

responce like : {"subscription_id":"sub_RZeTlxaIpgb1K6"}

-------get session id----

import requests

headers = {
'Accept':
'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/
webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
'Accept-Language': 'en-US,en;q=0.9',
'Connection': 'keep-alive',
'Referer':
'[Link]
'Sec-Fetch-Dest': 'iframe',
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-Site': 'same-origin',
'Sec-Fetch-Storage-Access': 'none',
'Sec-Fetch-User': '?1',
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36
(KHTML, like Gecko) Chrome/[Link] Safari/537.36',
'sec-ch-ua': '"Google Chrome";v="141", "Not?A_Brand";v="8",
"Chromium";v="141"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
}

params = {
'traffic_env': 'production',
'build': 'aeb7bd4a67e4c99c507294a18eb6d43459f0f167',
'build_v1': '5e1b407408e37bbadb2b865fbb9347af96f2d8cd',
'checkout_v2': '1',
'new_session': '1',
'rzp_device_id':
'1.2cae2ff1de9de5b425e17c5d7375e93becb7d54f.1761820130330.43216666',
'unified_session_id': 'RZeTfcfARM9sYq',
}

response = [Link]('[Link]
params=params, headers=headers)

response like : window.session_token =


"DCFF9CB411C40220D04F04B132B0AC98DDF7D1CE4CA91E27A551831E49582D98FDF6AAC88D64D9837E
158604BFBB73ACA098C342DC6C8DDA5CDC732708EF35D18549ED7CAFD9917F4B7AC894D63D711ABC5FF
CE62A266AFA3D780418CFDACB5BA4B0CE4FC7E3B3B8";

--------------payment--------------

import requests

headers = {
'Accept': '*/*',
'Accept-Language': 'en-US,en;q=0.9',
'Connection': 'keep-alive',
'Content-type': 'application/x-www-form-urlencoded',
'Origin': '[Link]
'Referer': '[Link]
traffic_env=production&build=aeb7bd4a67e4c99c507294a18eb6d43459f0f167&build_v1=5e1b
407408e37bbadb2b865fbb9347af96f2d8cd&checkout_v2=1&new_session=1&rzp_device_id=1.2c
ae2ff1de9de5b425e17c5d7375e93becb7d54f.1761820130330.43216666&unified_session_id=RZ
eTfcfARM9sYq&session_token=DCFF9CB411C40220D04F04B132B0AC98DDF7D1CE4CA91E27A551831E
49582D98FDF6AAC88D64D9837E158604BFBB73ACA098C342DC6C8DDA5CDC732708EF35D18549ED7CAFD
9917F4B7AC894D63D711ABC5FFCE62A266AFA3D780418CFDACB5BA4B0CE4FC7E3B3B8',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-origin',
'Sec-Fetch-Storage-Access': 'none',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36
(KHTML, like Gecko) Chrome/[Link] Safari/537.36',
'sec-ch-ua': '"Google Chrome";v="141", "Not?A_Brand";v="8",
"Chromium";v="141"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
}

params = {
'session_token':
'DCFF9CB411C40220D04F04B132B0AC98DDF7D1CE4CA91E27A551831E49582D98FDF6AAC88D64D9837E
158604BFBB73ACA098C342DC6C8DDA5CDC732708EF35D18549ED7CAFD9917F4B7AC894D63D711ABC5FF
CE62A266AFA3D780418CFDACB5BA4B0CE4FC7E3B3B8',
'x_entity_id': 'sub_RZeTlxaIpgb1K6',
'keyless_header':
'api_v1:/EMC7U7/OQNcnPan1eW/3sKuAhIK/4k+HyWy9ufjYjcJHA9wZlPejYI2uhyh2YRrKKY5JagO75L
QNTG46OPnsqeBgBR9JQ==',
}

data = {
'contact': '+918989898989',
'email': 'sekol30908@[Link]',
'method': 'card',
'card[number]': '5363500007073082',
'card[cvv]': '571',
'card[name]': 'john wed',
'amount': '1000',
'currency_request_id': 'RZeV4j5Lv6QeRW',
'dcc_currency': 'USD',
'currency': 'INR',
'subscription_id': 'sub_RZeTlxaIpgb1K6',
'_[integration]': 'payment_button',
'_[shield][fhash]': '2cae2ff1de9de5b425e17c5d7375e93becb7d54f',
'_[device_id]':
'1.2cae2ff1de9de5b425e17c5d7375e93becb7d54f.1761820130330.43216666',
'_[shield][tz]': '330',
'_[build]': '17433332986',
'notes[email]': 'sekol30908@[Link]',
'notes[phone]': '+9116045559876',
'notes[name]': 'Madara Uchiha',
'card[expiry_month]': '06',
'card[expiry_year]': '31',
'_[checkout_id]': 'RZeTnaUM3yh9vp',
'_[[Link]]':
'1.2cae2ff1de9de5b425e17c5d7375e93becb7d54f.1761820130330.43216666',
'_[env]': 'production',
'_[library]': 'checkoutjs',
'_[library_src]': '[Link]',
'_[current_script_src]': '[Link]',
'_[platform]': 'browser',
'_[referer]':
'[Link]
'_[request_index]': '0',
}

response = [Link](
'[Link]
params=params,
headers=headers,
data=data,
)

response like : {
"payment_id": "pay_RZeVdqK2vmhKIG",
"redirect": true,
"type": "redirect",
"request": {
"url":
"https:\/\/[Link]\/v1\/payments\/RZeVdqK2vmhKIG\/authenticate",
"method": "POST",
"task_id": "edbc86eb-947a-4848-b1df-8a3f82be80dd"
},
"version": 1
}

------------open url------------------

open url from url;

import requests

headers = {
'Accept':
'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/
webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
'Accept-Language': 'en-US,en;q=0.9',
'Cache-Control': 'max-age=0',
'Connection': 'keep-alive',
'Sec-Fetch-Dest': 'document',
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-Site': 'none',
'Sec-Fetch-User': '?1',
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36
(KHTML, like Gecko) Chrome/[Link] Safari/537.36',
'sec-ch-ua': '"Google Chrome";v="141", "Not?A_Brand";v="8",
"Chromium";v="141"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
# 'Cookie': 'onComplete={"error":{"code":"GATEWAY_ERROR","description":"Your
payment didn\'t go through due to a temporary issue. Any debited amount will be
refunded in 4-5 business
days.","source":"issuer_bank","step":"payment_authorization","reason":"bank_technic
al_error","metadata":
{"payment_id":"pay_RZeVdqK2vmhKIG","order_id":"order_RZeTmglskZVKqk"}},"http_status
_code":502}',
}

response = [Link](
'[Link]
headers=headers,
)

You might also like