DEV Community

Azis Alvriyanto
Azis Alvriyanto

Posted on

πŸš€ Go-QRIS: Revolutionizing QRIS Transactions with Dynamic QR Codes πŸ’³

The way I handle payments is evolving rapidly, with digital solutions taking center stage in creating seamless transactions. In Indonesia, QRIS (Quick Response Code Indonesian Standard) has become the backbone of many payment systems, allowing businesses to accept payments through a standardized QR code format. While QRIS is incredibly convenient, the static nature of traditional QR codes can pose challenges in dynamic business environments.

This is where Go-QRIS steps in, an open-source project written in Go, designed to enhance the flexibility and adaptability of QRIS transactions by enabling dynamic QR codes. By addressing the limitations of static QRIS codes, Go-QRIS not only empowers businesses to better manage their payment systems but also ensures customers have a smoother and more efficient payment experience.

πŸ“œ Why Go-QRIS?

The static QRIS codes commonly used today are effective for straightforward transactions but lack the flexibility needed in scenarios where payment amounts, merchant details, or additional fees need to be customized. For example, imagine a merchant wanting to include dynamic charges such as service fees or discounts directly in their QR code. With static codes, this process is cumbersome and requires generating new QR codes each time.

Go-QRIS eliminates this hassle. By converting static QR codes into dynamic ones, it allows businesses to:

  • Adjust payment details in real-time.
  • Add or modify merchant information such as city, postal code, and terminal labels.
  • Automatically calculate and include fees (fixed or percentage-based).

This adaptability makes Go-QRIS an invaluable tool for modern businesses looking to stay agile and customer-focused.

πŸ› οΈ How Does Go-QRIS Work?

At its core, Go-QRIS is built with Go, a powerful programming language known for its efficiency and scalability. Its architecture is clean and modular, making it easy for developers to integrate into existing systems or build new solutions around it. The project provides an API-first approach, enabling seamless interaction with its functionalities through RESTful endpoints.

Key Functionalities:

  1. Dynamic QR Code Generation: Go-QRIS can convert static QRIS codes into dynamic versions, allowing for the inclusion of variables such as payment amounts, merchant city, postal codes, and more.
  2. Parsing and Validation: The tool provides robust QRIS parsing capabilities, ensuring the code's integrity and compliance with standards like CRC16-CCITT.
  3. Modification Tools: Beyond generating QR codes, Go-QRIS allows for modifying existing QRIS codes to adapt to changing business needs.
  4. Developer-Friendly SDK: For those building custom solutions, Go-QRIS offers a developer-friendly Go library with well-documented methods for parsing, validating, and generating QRIS codes.

πŸ’Œ Benefits for Businesses and Developers

For Businesses:

  • Increased Flexibility: Tailor QRIS codes to specific needs without creating new ones repeatedly.
  • Enhanced Customer Experience: Reduce friction in payments with precise, real-time QR code customization.
  • Cost Efficiency: Save resources by reusing dynamic QR codes instead of printing new static ones.

For Developers:

  • Ease of Integration: Go-QRIS API and library are designed for quick and smooth implementation.
  • Open Source Community: Collaborate and contribute to a growing community dedicated to improving the project.
  • Scalability: Built with Go, the tool handles large-scale operations effortlessly.

βš™οΈ How to Get Started

Getting started with Go-QRIS is simple:

  1. Clone the Repository
    Start by cloning the project from GitHub:

    git clone https://github.com/fyvri/go-qris.git && cd go-qris
    
  2. Set Up Your Environment
    Copy the .env.example file to .env and configure it according to your needs.

  3. Install Dependencies
    Run go mod tidy to ensure all dependencies are installed.

  4. Run the Application
    Launch the application locally:

    go run ./cmd/main.go
    

Or use Docker for an isolated setup. The repository provides a detailed Docker setup guide.

Implement into Your Awesome Project

Integrating Go-QRIS into your own application is straightforward. Here’s an example of how you can use Go-QRIS library to dynamically generate and manipulate QRIS codes:

package main

import (
    "fmt"

    "github.com/fyvri/go-qris/pkg/services"
)

func main() {
    qrisString := "000201010211y0ur4w3soMEQr15STriN6"
    merchantCity := "Kota Yogyakarta"                    // optional
    merchantPostalCode := "55000"                        // optional
    paymentAmount := 1337                                // mandatory
    paymentFeeCategory := "FIXED"                        // optional, value: FIXED or PERCENT
    paymentFee := 666                                    // optional, based on paymentFeeCategory value
    terminalLabel := "Made with love by Alvriyanto Azis" // optional, it works if terminal label exists in qrisString

    qrisService := services.NewQRIS()
    qrisString, err, errs := qrisService.Convert(qrisString, merchantCity, merchantPostalCode, paymentAmount, paymentFeeCategory, paymentFee, terminalLabel)
    if err != nil {
        fmt.Println("[ FAILURE ]", err)
        if errs != nil {
            for _, err := range *errs {
                fmt.Println("            -", err)
            }
        }
        return
    }
    fmt.Println("[ SUCCESS ]", qrisString)
}
Enter fullscreen mode Exit fullscreen mode

You can also use the library's additional functionalities such as parsing, validating, modifying, and converting QRIS codes back to string form. Here’s a quick summary:

  • Parse QRIS: Extract QRIS details.

    qris, err, errs := qrisService.Parse(qrisString)
    
  • Validate QRIS: Check if the QRIS is valid.

    isValid := qrisService.IsValid(qris)
    
  • Modify QRIS: Dynamically update QRIS fields:

    qris, err, errs = qrisService.Modify(qris, merchantCity, merchantPostalCode, paymentAmount, paymentFeeCategory, paymentFee, terminalLabel)
    
  • Convert to String: Generate a QRIS string from a QRIS object.

    qrisString = qrisService.ToString(qris)
    

A Glimpse of API

You can experience Go-QRIS in action through its live API endpoint: http://api.qris.membasuh.com. This live service provides access to the same powerful QRIS conversion, validation, and parsing functionalities described above, allowing you to integrate it into your applications or test its capabilities. Go-QRIS offers endpoints such as:

  • POST /parse: Extract and interpret QRIS data for validation or customization.

    {
        "qr_string": "000201010211y0ur4w3soMEQr15STriN6"
    }
    
  • POST /convert: Convert static QR codes to dynamic ones.

    {
        "qr_string": "000201010211y0ur4w3soMEQr15STriN6",
        "merchant_city": "Kota Yogyakarta",
        "merchant_postal_code": "55000",
        "payment_amount": 1337,
        "payment_fee_category": "FIXED",
        "payment_fee": 666,
        "terminal_label": "Made with love by Alvriyanto Azis"
    }
    
  • POST /is-valid: Verify the validity of a QRIS code against standard protocols.

    {
        "qr_string": "000201010211y0ur4w3soMEQr15STriN6"
    }
    

The API documentation, hosted on Postman, provides detailed examples and usage instructions, making integration straightforward even for those new to Go-QRIS.

πŸ€ Real-World Applications of Go-QRIS

The versatility of Go-QRIS makes it ideal for a wide range of use cases:

  • E-Commerce Platforms: Generate dynamic QR codes for varying order amounts.
  • Physical Stores: Include location-specific details in QR codes for better tracking and customer convenience.
  • Service Industries: Automatically include service charges or tips in payment QR codes.
  • Event Ticketing: Use dynamic QR codes to handle variable ticket prices or promotions.

πŸ‘₯ Join Go-QRIS Community

Go-QRIS is not just a tool; it's a step toward more flexible, efficient, and scalable payment solutions. Whether you're a developer exploring new technologies or a business looking to enhance your payment systems, Go-QRIS has something for you.
Dive into the GitHub repository, explore the Postman API documentation, and start transforming your payment processes today. Together, let's push the boundaries of QRIS innovation!

πŸ”— Related Links

Top comments (0)