M O N I T R I
M I R A I

Loading ...


logo-img
  • Home
  • Services
    • Web Development
    • Android Development
    • SEO
    • Digital Marketing
    • Email Marketing
    • Payment
  • About Us
  • Blog
  • Contact Us
Get Started
img
img

Service Details

  • Home
  • Service Details
monitri-mirai-razorpay-integration
By Monitri Mirai Team
March 26, 2024
Payment Gateway
Razorpay Integration

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:

PHP

                                            
        

                                            $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:

HTML + JavaScript

                                            
                                                

  • Replace the your-key in the JavaScript variable key and save the file with .html extension.
  • Note: For live mode, change the setting in Razorpay dashboard top navigation bar and copy the LIVE KEY-ID.
  • 🎉 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:

    Tags:

    Razorpay Recurring Payments Subscriptions Payment Gateway PHP API Integration
    Tags: Razorpay Payment Integration
    Share:
    img
    img

    Stay Connected With
    Cutting Edge IT

    talk TO A SPECIALIST

    Monitri Mirai

    Phasellus ultricies aliquam volutpat ullamcorper laoreet neque, a lacinia curabitur lacinia mollis

    Quick Links

    • Monitri Mirai About
    • Our Services
    • Our Blogs
    • FAQ’S
    • Contact Us

    Recent Posts

    post-img
    • 20 Feb, 2024
    Top 5 Most Famous
    Technology Trend In 2024
    post-img
    • 15 Dec, 2024
    The Surfing Man Will Blow
    Your Mind

    Contact Us

    • [email protected]

    © All Copyright 2024 by Monitri Mirai

    • Terms & Condition
    • Privacy Policy