Skip to main content

Overview

This guide will walk you through creating your first Dynamic QR Ph payment in under 10 minutes. By the end, you’ll have generated a QR code that customers can scan to make a payment.
This quickstart uses Node.js, but the same principles apply to any language. Check the API Reference for examples in other languages.

Prerequisites

1

Get Your Credentials

Contact Modulus Labs to receive:
  • Secret Key (starts with sk_)
  • Encryption Key
  • Activation Code (format: XXXX-XXXX-XXXX-XXXX)
2

Install Node.js

Ensure you have Node.js 14+ installed
3

Create a New Project

Step 1: Install Dependencies

Install the required packages:
Package Purposes:
  • axios - HTTP client for API requests
  • jose - JWE token encryption/decryption
  • dotenv - Manage environment variables securely

Step 2: Set Up Environment Variables

Create a .env file in your project root:
.env
Never commit your .env file to version control! Add it to .gitignore immediately:
Note: The MODULUS_ENCRYPTION_KEY must be a Base64-encoded key that decodes to 32 bytes to match the A256KW encryption key-length requirement. Any leading/trailing whitespace will cause encryption to fail.

Step 3: Create Your First QR Code

Create create-qr.js:
create-qr.js
Run it:
Expected output:

Step 4: View Your QR Code

Open the generated PNG file:
You should see a QR code image that customers can scan to make a payment.

Step 5: Test Payment (Optional)

To test the complete flow, follow the Testing Guide to simulate a payment and receive a webhook notification.

Quick Test Summary:

1

Decode QR Code

Upload your QR image to zxing.org/w/decode.jspx to get the raw QR value
2

Simulate Payment

Use the raw QR value with the Simulate Webhook API to trigger a payment event
3

Receive Webhook

Your registered webhook endpoint receives the transaction status

Complete Example with Error Handling

Here’s a production-ready example with proper error handling:
production-example.js

What’s Next?

Now that you’ve created your first QR code, here are some next steps:

Set Up Webhooks

Receive real-time payment notifications

Test Payments

Simulate payments in sandbox environment

Error Handling

Learn how to handle errors gracefully

Go to Production

Deploy your integration to production

Common Issues

Solution:
  • Check your .env file has the correct MODULUS_SECRET_KEY
  • Ensure no extra spaces or quotes around the key
  • Verify you’re using sandbox credentials for sandbox URL
Solution:
  • Verify your MODULUS_ENCRYPTION_KEY is correct
  • Ensure the key hasn’t been modified (no spaces, newlines)
  • Check you’re Base64-decoding the key
Solution:
  • Ensure amount is between 1.00 and 99999.99
  • Pass amount as a string with 2 decimal places: "500.00"
  • Use .toFixed(2) to format numbers correctly
Solution:
  • Ensure you’re decoding the full Base64 string
  • Check the file was written in binary mode
  • Verify no encoding issues during Base64 decode

Need Help?

API Reference

Complete API documentation

Code Examples

Examples in multiple languages

Contact Support

Get help from our team

Join Community

Connect with other developers
You’re all set! You’ve successfully created your first Dynamic QR Ph payment. The QR code is ready to be scanned by customers using their banking apps.