Razorpay Payment Links in Google Sheets: No Code Guide

Introduction
In today’s global marketplace, businesses need a fast, reliable way to request payments from customers anywhere in the world. Combining Razorpay’s powerful payment‑link API with the flexibility of Google Sheets gives you a low‑cost, no‑code solution that scales from a single freelancer to a growing enterprise. This article walks you through every step required to generate Razorpay payment links directly from a spreadsheet, automate notifications, and keep your financial records tidy—all without writing complex backend code. By the end, you’ll be able to turn a simple Google Sheet into a live invoicing hub that instantly creates secure, trackable payment URLs for your clients.

Setting Up Razorpay API Access

Before any link can be generated, you must obtain API credentials from Razorpay. Follow these steps:

  • Log in to your Razorpay dashboard and navigate to Settings > API Keys.
  • Click Generate Key and note the Key ID and Key Secret. Treat the secret like a password.
  • Enable Payment Links under the Products tab if it isn’t already active.
  • Optionally, create a separate “Google Sheets Integration” user with limited permissions to improve security.

These credentials will be used in the Google Apps Script to authenticate each request to Razorpay’s REST endpoint.

Preparing Your Google Sheet

The spreadsheet acts as both a data source and a dashboard. Design it with the following columns:

  • Invoice ID – unique reference for each transaction.
  • Customer Name – for personalization.
  • Email – where the payment link will be sent.
  • Amount (INR) – numeric value; Razorpay expects the amount in paise, so multiply by 100 in the script.
  • Description – brief note that appears on the payment page.
  • Payment Link – will be auto‑filled after the API call.
  • Status – “Pending”, “Link Created”, “Paid”, etc.

Freeze the header row, protect the Payment Link and Status columns to prevent accidental edits, and set data validation for the Email column to ensure proper formatting.

Creating the Payment Link Script

Google Apps Script bridges the sheet and Razorpay. Open Extensions > Apps Script and paste the following core function:

function createRazorpayLink(row) {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  const data = sheet.getRange(row, 1, 1, 7).getValues()[0];
  const [invoiceId, name, email, amount, desc] = data;
  const payload = {
    amount: amount * 100,               // convert to paise
    currency: "INR",
    description: desc,
    receipt: invoiceId,
    customer: { name: name, email: email },
    notify: { sms: false, email: true },
    callback_url: "https://yourdomain.com/razorpay/callback",
    expire_by: Math.floor(Date.now() / 1000) + 7 * 24 * 60 * 60   // 7 days
  };
  const options = {
    method: "post",
    contentType: "application/json",
    payload: JSON.stringify(payload),
    headers: {
      "Authorization": "Basic " + Utilities.base64Encode(":")
    },
    muteHttpExceptions: true
  };
  const response = UrlFetchApp.fetch("https://api.razorpay.com/v1/payment_links", options);
  const result = JSON.parse(response.getContentText());
  if (response.getResponseCode() === 200) {
    sheet.getRange(row, 6).setValue(result.short_url);
    sheet.getRange(row, 7).setValue("Link Created");
  } else {
    sheet.getRange(row, 7).setValue("Error: " + result.error.description);
  }
}

Replace <YOUR_KEY_ID> and <YOUR_KEY_SECRET> with the credentials from the first chapter. This function reads a single row, builds the JSON payload, calls Razorpay, and writes back the generated link and status.

Automating Link Generation & Notification

To make the process seamless, add a trigger that runs whenever a new row is added or the Amount column is edited:

  • In Apps Script, click Triggers > Add Trigger.
  • Select createRazorpayLink as the function.
  • Choose “From spreadsheet” → “On edit”.
  • Set the condition to fire only when column D (Amount) is edited and column F (Payment Link) is empty.

Next, send an email to the customer with the link:

function sendPaymentEmail(row) {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  const [_, name, email, amount, desc, link] = sheet.getRange(row, 1, 1, 6).getValues()[0];
  const subject = `Payment Request – Invoice ${row-1}`;
  const body = `Hi ${name},\n\nPlease complete your payment of ₹${amount} for "${desc}" using the link below:\n${link}\n\nThank you!`;
  MailApp.sendEmail(email, subject, body);
  sheet.getRange(row, 7).setValue("Email Sent");
}

Chain this function at the end of createRazorpayLink so the email is dispatched automatically once the link is generated.

Best Practices & Troubleshooting

Implementing this workflow is straightforward, but a few safeguards keep it reliable:

  • Secure your keys: Store them in the script’s Properties Service instead of hard‑coding.
  • Rate limits: Razorpay allows 30 requests per second; batch large invoices with a short pause (Utilities.sleep(500)) to avoid throttling.
  • Error handling: Log failed responses to a hidden “Logs” sheet for later review.
  • Data integrity: Use onFormSubmit triggers if the sheet is populated via Google Forms, ensuring every submission receives a link.
  • Compliance: Keep the callback_url active to receive payment status updates and reconcile them automatically.

Regularly audit the Status column; any “Pending” or “Error” rows should be investigated promptly to maintain a smooth cash‑flow experience for your customers.

Conclusion
By integrating Razorpay’s payment‑link API with Google Sheets, you gain a powerful, low‑maintenance invoicing engine that works entirely in the cloud. The process starts with secure API setup, moves through a well‑structured spreadsheet, leverages Apps Script to create links, and finishes with automated email notifications and robust error handling. This workflow eliminates manual link generation, reduces human error, and provides real‑time visibility into payment status—all while keeping costs minimal. Implement the steps outlined above, adapt them to your specific business rules, and you’ll be equipped to request payments from customers worldwide with confidence and efficiency.

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Digital Malayali