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:axios- HTTP client for API requestsjose- JWE token encryption/decryptiondotenv- Manage environment variables securely
Step 2: Set Up Environment Variables
Create a.env file in your project root:
.env
Step 3: Create Your First QR Code
Createcreate-qr.js:
create-qr.js
Step 4: View Your QR Code
Open the generated PNG file: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
Error: Invalid API Key
Error: Invalid API Key
Solution:
- Check your
.envfile has the correctMODULUS_SECRET_KEY - Ensure no extra spaces or quotes around the key
- Verify you’re using sandbox credentials for sandbox URL
Error: Cannot decrypt token
Error: Cannot decrypt token
Solution:
- Verify your
MODULUS_ENCRYPTION_KEYis correct - Ensure the key hasn’t been modified (no spaces, newlines)
- Check you’re Base64-decoding the key
Error: Amount validation failed
Error: Amount validation failed
Solution:
- Ensure amount is between 1 and 9,999,999
- Pass amount as a number (
500.00); a numeric string like"500.00"is also accepted
QR code file is corrupted
QR code file is corrupted
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
Contact Support
Get help from our team