Upgraded docs version is here ✨

Your documentation experience is getting an upgrade. Check it out now!

Go To Beta

Docs upgrade is here. Check it out!

Go To Beta
API ReferenceIntegrationsKnowledge Base

Razorpay Subscriptions Plugin for WooCommerce

You can now accept recurring payments on your WooCommerce-enabled WordPress site using the Razorpay Subscriptions for WooCommerce plugin. This plugin is built on the Razorpay Subscriptions product and offers seamless integration, allowing you to create and sell subscription services on your website.

Advantages🔗

  • There is no need to create Plans or Subscriptions using the Razorpay Dashboard or Razorpay APIs. All this can be done easily from your WooCommerce Dashboard.
  • Customers are not redirected from your website to make payments.

Video Tutorial🔗

Watch this video to learn how to integrate Razorpay Payment Gateway with your WooCommerce Subscriptions website using our plugin.

Prerequisites🔗

  • Sign up for a Razorpay Account.
  • Generate API Keys from the Razorpay Dashboard. Watch the short animation below for more information.

  • Navigate to Razorpay Dashboard → Subscriptions and click Next and Get Started.
  • Razorpay Subscriptions is based on the existing Razorpay payment flow process. If you are new to Razorpay, we recommend you to understand this flow before you read further.

Integration Steps🔗

To start accepting subscription payments using the plugin:

On Your WordPress Site:

  1. Install the Razorpay Subscriptions for WooCommerce Plugin.
  2. Configure WooCommerce Settings.
  3. Create a Subscriptions product using WooCommerce.
  4. Test it out - Sign up for a subscription.

On Razorpay Dashboard:

  1. Enable Webhooks.

Install the Razorpay Subscriptions for WooCommerce Plugin🔗

There are two methods to install the Razorpay Subscription for WooCommerce plugin:

  • Install via WordPress Plugin Directory
  • Manual Installation

Install via WordPress Plugin Directory🔗

You can search for the plugin on the WordPress Admin Dashboard and add it.

  1. In the WordPress Admin Dashboard, navigate to Plugins → Add New.
  2. Search for Razorpay Subscriptions for WooCommerce and click Install Now.
  1. Click Activate.

Manual Installation🔗

  1. Download a ZIP file of the Razorpay WooCommerce Subscriptions Plugin from the repository on Github.
  2. Unzip this file and upload the contents in wp-content → Plugins.
  1. The plugin now appears in your WordPress Dashboard → Plugins folder.
  2. Click Activate.

Configure WooCommerce Settings🔗

On your WordPress Dashboard, navigate to WooCommerce → Settings → Payments tab.

Settings for Razorpay Payment Gateway🔗

  1. In the Payments tab, go to Razorpay → Allow customers to securely pay via Razorpay and click Manage.




    Field

    Description

    Enable/Disable

    Ensure that the Enable this module? option is selected.

    Title

    Add the title that is visible to the customer during checkout of a product with type - Simple Product.

    Description

    Enter a short description that is visible to the customer during checkout.

    Key ID

    Enter the Key ID generated from the Razorpay Dashboard.

    Key Secret

    Enter the API Key Secret generated from the Razorpay Dashboard.

    Payment Action

    To automatically capture successful payments, select Authorize and Capture option in the dropdown. Select Authorize if you want to capture payments manually from the Razorpay Dashboard or using API.

    Order Completion Message

    Enter the message that must be displayed after an order is successfully placed.

    Enable Webhook

    Ensure that Enable Razorpay Webhook option is selected. Complete the webhook enablement process on Razorpay Dashboard.

    Webhook Secret

    Enter the webhook secret here. Webhook secret is used for webhook signature verification. This must match with the one added in the Razorpay Dashboard.




Settings for Razorpay Subscriptions🔗

  1. In the Payments tab, go to Razorpay Subscriptions → Allow customers to securely pay via Razorpay and click Manage.

  2. In the Razorpay Subscriptions Payment Gateway screen, fill in the following field details and click Save:


    Field

    Description

    Enable/Disable

    Ensure that the Enable this module? option is selected.

    Title

    Add the title that is visible to the customer during checkout of the subscription product with type Simple Subscription.

    Description

    Enter a short description that is visible to the customer during checkout.






Create a Subscriptions Product🔗

Let's assume Acme Corp. provides a streaming service called GoFlicks. There are two plans, GoFlicks PremiumWatch and GoFlicks StandardWatch. The details are mentioned below:

Plan Name

Rate/Month (₹)

Free Trial (days)

GoFlicks PremiumWatch HD

999

15

GoFlicks StandardWatch

499

Let us create a Subscriptions product for GoFlicks PremiumWatch HD.

  1. In the WordPress Dashboard, navigate to Products → Add New.
  2. Enter the product name and add a brief description.
  3. In the Product data section, enter the following details and click Publish:
    1. Select Simple Subscription as the product type in the dropdown list.
    2. Select Virtual checkbox as GoFlicks is a streaming service.
    3. In the General tab, enter the following details:
      1. Subscription Price - Enter the price, select every as the interval and month as the duration.
      2. Expire after - Select the period after which the subscription will expire. This period is in addition to any free trial or time provided before a synchronized first renewal date. Do not select Never Expire as it is not supported by Razorpay.
      3. Sign-up fee - Add an amount to be charged at the outset of the subscription. This fee will be charged immediately, even if the product has a free trial.
      4. Free trial - Enter the period up to which the subscriber can use the product for free. The trial period cannot exceed 90 days, 52 weeks, 24 months or 5 years. A sign-up fee will still be charged from the outset of the subscription.
      5. Sale Price - Enter the discounted price at which you want to offer the product. For example, you may offer GoFlicks PremiumWatch HD at INR 899 per month for a limited period. You can schedule the special price, by clicking Schedule and selecting the required dates on the calendar.

Similarly, create another Subscriptions product for GoFlicks StandardWatch.

Your product has been successfully created. Ensure that the product is visible to the website users so that they can add it to their cart. You can do this by displaying the product on your website's Shop page.

Users on your site can visit this page and buy the product. For example, they can add GoFlicks PremiumWatch HD to their cart and complete the payment.

Learn how to make a test transaction to ensure that the integration is working properly.

Enable Webhooks🔗

You can set up a webhook from your Razorpay Dashboard and configure separate URLs for live mode and test mode. Note:
For details of available events and sample payloads, refer to the Webhook Events section.

Setup Webhooks🔗

Watch this video to see how to set up a webhook.

To set up webhooks:

  1. Log into the Razorpay Dashboard and navigate to Settings → Webhooks.

  2. Click the + Add New Webhook button.

  3. In the Webhook Setup pop-up page:

    1. Enter the URL where you want to receive the webhook payload when an event is triggered. We recommended using an HTTPS URL. Handy Tips
      You can set up to 5 URLs to receive Webhook notifications. Webhooks can only be delivered to public URLs. If you attempt to save a localhost endpoint as part of a webhook setup, you will notice an error. Know more about testing Webhooks on an application running on localhost.
    2. Enter a Secret for the webhook endpoint. The secret is used to validate that the webhook is from Razorpay. Do not expose the secret publicly. Know more about how to validate webhooks. Handy Tips
      • When setting up the webhook, you will be asked to specify a secret. Using this secret, you can validate that the webhook is from Razorpay. Entering the secret is optional but recommended. The secret should never be exposed publicly.
      • The webhoook secret does not need to be the merchant secret key provided by Razorpay.
    3. In the Alert Email field, enter the email address to which the notifications should be sent in case of webhook failure. You will receive webhook deactivation notifications to this email address.
    4. Select the required events from the list of Active Events.
  4. Click Create Webhook.

  5. After you set a webhook, it appears on the list of webhooks.

You can click Edit to make changes to the webhooks.


×