Razorpay Recurring Subscriptions
Master the art of collecting recurring payments from your customers with seamless automation and powerful features.
Using Razorpay Subscriptions you can automatically charge customers based on a billing cycle that you control. You can easily create and manage recurring payments and get instant alerts on payment activity as well as the status of subscriptions. Razorpay handles all the complexities of managing recurring payments on your behalf.
Step 1: Define a Plan
The first step to creating a subscription is to create a plan. A plan contains product details along with the amount and frequency of the billing cycles. Depending upon your business, you can create multiple plans with different billing cycles and pricing. To create a plan from the Dashboard:
- Create an Razorpay Account.
- Go to Subscriptions, click on getting started( if you are coming for first time) and choose plans tab.
- Click New Plan Button.
- Enter the Plan Name,Plan Description, Billing Frequency, Billing Amount and Internal Notes details(optional) as shown below.
Step 2: Creating a Subscription
The next step is creating a subscription using the plan you created in Step 1. You have to define the following details when creating a subscription:
- Copy and paste the code in your website to create automatic subscription.
PHP Implementation Example
Here's how to create a subscription programmatically:
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://user-key-id:[email protected]/v1/subscriptions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "plan_id=monitrimirai_user_plan_id&total_count=12&customer_notify=1",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"content-type: application/x-www-form-urlencoded",
"postman-token: 67d92778-3ca8-ffb4-9680-c384d115f95a"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
- Now replace the user-key-id, user-key-secret and plan-id.
- Note: You can get key and secret from here and plan id from step-1.
- You will get response as shown below when you run the above code.
Step 3: Creating Payment Button
- Pass the response you got in step-2 to Subscriber_Response Variable.
- Below code helps to store the subscription id.
- Note: Subscription id is stored in GetSubscriberId_Basic Variable.
Frontend Integration
Add this HTML and JavaScript to create the payment button:
🎉 Congratulations!
You have successfully integrated Razorpay Recurring Payments!
If you encounter any issues during implementation, feel free to reach out to our team for support.
📹 Video Tutorial
Watch our step-by-step video guide for visual learners: