Rohan Deshmukh
3 min readJan 16, 2024

Simplifying Payments using Mulesoft: Generating Payment QR Codes for Seamless Transactions

Payment QR Code Integration

In the ever-evolving landscape of digital payments, this blog post will explore how to seamlessly generate QR codes for payments using MuleSoft, streamlining transactions for both businesses and consumers.

Understanding the Basics Before diving into the implementation, let’s grasp the basics.

QR codes, or Quick Response codes, are two-dimensional barcodes that store data in both the vertical and horizontal directions. They have become a popular method for making transactions due to their speed, accuracy, and ease of use.

MuleSoft Integration:

We will be using a third-party QR API Service. Please refer goqr api documentation.

QR code API: command “create-qr-code” (generate QR code, QR code generator) (goqr.me)

  1. Create a ‘QR Project’ in Studio and create the following flow: Configure the Listener port number 8081 and path as /qrCode
Flow

2. Create a variable que in Transform Message.

%dw 2.0
output application/java
---
{
"data" : "upi://pay?pa="++ payload.upiId ++ "&pn=" ++ payload.name ++"&mc=100&cu=INR&am=" ++ payload.amount as Number ++ "&ver01&mode=02&purpose=00"
}

3. Configure HTTP Requestor.

Protocol:- HTTP
Host:- api.qrserver.com
BasePath:- /v1
Method:-
Path:-/create-qr-code/

4. Add quryParams as below

output application/java
---
{
"data" : vars.que.data,
"size" : "100x200"
}

5. Add transform message to just captutre the payload. Payload content/type will be image/png.

6. Deploy and Test: Deploy your Mule application and test the QR code generation functionality. Use tools like Postman or curl to simulate requests and verify the generated QR codes.

curl --location --request GET 'http://localhost:8081/qrCode' \
--header 'Content-Type: application/json' \
--data-raw '{
"amount" : "502",
"upiId" : "98******42@ybl",
"name": "Rohan"
}'
Postman
PhonePe application QR Scanner

Conclusion:

By incorporating QR code generation into your MuleSoft project, you can contribute to a more efficient and user-friendly payment process.

Please show your support and leave a clap if you find this post interesting.

Stay tuned for more insights on MuleSoft and innovative integration solutions!