How to Write a UPI Link

Introduction to Writing UPI Links

Unified Payments Interface (UPI) is a popular instant payment system. By writing a UPI link to an NFC tag, you can create a 'tap-to-pay' experience where users can quickly initiate a payment to you from their smartphone.

You can use our Free UPI QR & Link Generator to create the correct URL format.

Code Example

A UPI payment link is just a specific type of URL. You can write it to a tag using the same method as a standard URL record.

async function writeUpiLink(upiUrl) {
  if (!('NDEFReader' in window)) {
    console.log('Web NFC is not supported by this browser.');
    return;
  }
  try {
    const writer = new NDEFReader();
    await writer.write({
      records: [{ recordType: 'url', data: upiUrl }]
    });
    console.log('UPI link written successfully!');
  } catch (error) {
    console.error('Error writing UPI link:', error);
  }
}

// Example usage:
// const upiLink = 'upi://pay?pa=your-upi-id@okhdfcbank&pn=Your%20Name&am=10.00&cu=INR';
// writeUpiLink(upiLink);

Use Cases

  • Accepting contactless payments at a physical store.
  • Collecting donations at an event.
  • Allowing friends to easily pay you back.
✏️ Edit this page on GitHub