- By Monitri Mirai
- 26, March, 2024
- Technology
- 20 Feb, 2024
Loading ...
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.
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:
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:
$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=techhawa_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;
}