### Install OrderKuota Package Source: https://context7.com/autoftbot/orderkuota-go/llms.txt Use Go modules to install the package dependency. ```bash go get github.com/AutoFTbot/OrderKuota-go ``` -------------------------------- ### QRIS Generation and Payment Status Check Example Source: https://github.com/autoftbot/orderkuota-go/blob/main/README.md Example code demonstrating how to initialize the QRIS client, generate a QR code, and check payment status. ```APIDOC ## Example: QRIS Integration ### Description This example demonstrates the complete workflow of generating a QR code for payment and then continuously checking its status until it is paid. ### Initialization ```go config := qris.QRISConfig{ MerchantID: "#", APIKey: "#", BaseQrString: "#", } qrisInstance, err := qris.NewQRIS(config) if err != nil { panic(err) } ``` ### Generate QR Code ```go data := qris.QRISData{ Amount: 1000, TransactionID: "TRX123", } qrCode, err := qrisInstance.GenerateQRCode(data) if err != nil { log.Fatalf("Error generating QR code: %v", err) } err = qrCode.WriteFile(256, "qris.png") if err != nil { log.Fatalf("Error saving QR code: %v", err) } ``` ### Check Payment Status ```go for { status, err := qrisInstance.CheckPaymentStatus("TRX123", 1000) if err != nil { log.Printf("Error checking payment status: %v", err) time.Sleep(5 * time.Second) continue } fmt.Printf("Status Pembayaran: %s\n", status.Status) fmt.Printf("Amount yang diharapkan: %d\n", 1000) fmt.Printf("Amount yang diterima: %d\n", status.Amount) fmt.Printf("Reference: %s\n", status.Reference) if status.Status == "PAID" { fmt.Printf("Pembayaran berhasil!\n") fmt.Printf("Date: %s\n", status.Date) fmt.Printf("Brand: %s\n", status.BrandName) fmt.Printf("Buyer Ref: %s\n", status.BuyerRef) break } else { fmt.Println("Menunggu pembayaran...") } time.Sleep(5 * time.Second) } ``` ``` -------------------------------- ### Initialize QRIS Instance Source: https://context7.com/autoftbot/orderkuota-go/llms.txt Create a new QRIS instance by providing the necessary configuration, including the base QR string and authentication credentials. ```go package main import ( "fmt" "log" "github.com/AutoFTbot/OrderKuota-go/qris" ) func main() { config := qris.QRISConfig{ BaseQrString: "00020101021126670016COM.NOBUBANK.WWW01189360050300000898240215NOBU1234567890030303UMI51440014ID.CO.QRIS.WWW0215ID12345678901230303UMI5802ID5913Merchant Name6013Jakarta Pusat61051034062070703A01630400", AuthToken: "your-auth-token", AuthUsername: "your-auth-username", } qrisInstance, err := qris.NewQRIS(config) if err != nil { log.Fatalf("Failed to create QRIS instance: %v", err) } fmt.Println("QRIS instance created successfully") } ``` -------------------------------- ### Implement Complete Payment Flow in Go Source: https://context7.com/autoftbot/orderkuota-go/llms.txt Demonstrates the full workflow from initializing the QRIS client to generating a QR code and polling for payment confirmation. ```go package main import ( "fmt" "log" "time" "github.com/AutoFTbot/OrderKuota-go/qris" ) func main() { // Step 1: Initialize QRIS with configuration config := qris.QRISConfig{ BaseQrString: "00020101021126670016COM.NOBUBANK.WWW01189360050300000898240215NOBU1234567890030303UMI51440014ID.CO.QRIS.WWW0215ID12345678901230303UMI5802ID5913Merchant Name6013Jakarta Pusat61051034062070703A01630400", AuthToken: "your-auth-token", AuthUsername: "your-auth-username", } qrisInstance, err := qris.NewQRIS(config) if err != nil { log.Fatalf("Initialization failed: %v", err) } // Step 2: Create payment data paymentData := qris.QRISData{ Amount: 150000, TransactionID: fmt.Sprintf("ORDER-%d", time.Now().Unix()), } // Step 3: Generate QR code for customer qrCode, err := qrisInstance.GenerateQRCode(paymentData) if err != nil { log.Fatalf("QR generation failed: %v", err) } filename := fmt.Sprintf("payment-%s.png", paymentData.TransactionID) if err := qrCode.WriteFile(512, filename); err != nil { log.Fatalf("Failed to save QR: %v", err) } fmt.Printf("QR code saved: %s\n", filename) fmt.Println("Please scan and complete payment...") // Step 4: Poll for payment confirmation timeout := time.After(5 * time.Minute) ticker := time.NewTicker(5 * time.Second) defer ticker.Stop() for { select { case <-timeout: fmt.Println("Payment timeout - transaction expired") return case <-ticker.C: status, err := qrisInstance.CheckPaymentStatus( paymentData.TransactionID, paymentData.Amount, ) if err != nil { log.Printf("Status check error: %v", err) continue } if status.Status == "PAID" { fmt.Println("\n=== PAYMENT CONFIRMED ===") fmt.Printf("Amount: Rp %d\n", status.Amount) fmt.Printf("Date: %s\n", status.Date) fmt.Printf("Payment Method: %s\n", status.BrandName) fmt.Printf("Reference: %s\n", status.Reference) return } fmt.Print(".") } } } ``` -------------------------------- ### Generate QRIS and check payment status Source: https://github.com/autoftbot/orderkuota-go/blob/main/README.md Demonstrates initializing the QRIS client, generating a QR code image, and polling the API to check for payment completion. ```go package main import ( "fmt" "log" "time" "github.com/autoftbot/orderkuota-go/qris" ) func main() { // Inisialisasi QRIS dengan konfigurasi config := qris.QRISConfig{ MerchantID: "#", APIKey: "#", BaseQrString: "#", } // Buat instance QRIS qrisInstance, err := qris.NewQRIS(config) if err != nil { panic(err) } // Generate QR Code data := qris.QRISData{ Amount: 1000, TransactionID: "TRX123", } qrCode, err := qrisInstance.GenerateQRCode(data) if err != nil { log.Fatalf("Error generating QR code: %v", err) } // Simpan QR code ke file err = qrCode.WriteFile(256, "qris.png") if err != nil { log.Fatalf("Error saving QR code: %v", err) } fmt.Println("QR Code berhasil dibuat dan disimpan sebagai qris.png") fmt.Println("Silahkan scan QR code untuk melakukan pembayaran...") // Cek status pembayaran secara berulang for { fmt.Println("\nMengecek status pembayaran...") status, err := qrisInstance.CheckPaymentStatus("TRX123", 1000) if err != nil { log.Printf("Error checking payment status: %v", err) time.Sleep(5 * time.Second) continue } // Tampilkan detail status fmt.Printf("Status Pembayaran: %s\n", status.Status) fmt.Printf("Amount yang diharapkan: %d\n", 1000) fmt.Printf("Amount yang diterima: %d\n", status.Amount) fmt.Printf("Reference: %s\n", status.Reference) if status.Status == "PAID" { fmt.Printf("Pembayaran berhasil!\n") fmt.Printf("Date: %s\n", status.Date) fmt.Printf("Brand: %s\n", status.BrandName) fmt.Printf("Buyer Ref: %s\n", status.BuyerRef) break } else { fmt.Println("Menunggu pembayaran...") } // Tunggu 5 detik sebelum cek lagi time.Sleep(5 * time.Second) } } ``` -------------------------------- ### Best Practices Source: https://github.com/autoftbot/orderkuota-go/blob/main/README.md Recommended practices for using the QRIS integration library effectively and securely. ```APIDOC ## Best Practices 1. Always check for errors during QRIS initialization. 2. Use unique transaction IDs for each transaction. 3. Validate QRIS string before use. 4. Implement proper error handling for all operations. 5. Save QR code in PNG format for optimal quality. ``` -------------------------------- ### NewQRIS - Create QRIS Instance Source: https://context7.com/autoftbot/orderkuota-go/llms.txt Initializes a new QRIS instance by validating configuration parameters including the base QR string and authentication credentials. ```APIDOC ## NewQRIS - Create QRIS Instance ### Description Creates a new QRIS instance with the provided configuration. Validates that all required configuration fields are present and that the base QRIS string contains a valid Indonesian country code marker. ### Request Body - **BaseQrString** (string) - Required - The base QRIS string for the merchant. - **AuthToken** (string) - Required - Authentication token for the gateway. - **AuthUsername** (string) - Required - Authentication username for the gateway. ``` -------------------------------- ### Contributing and License Source: https://github.com/autoftbot/orderkuota-go/blob/main/README.md Information on how to contribute to the project and the licensing details. ```APIDOC ## Contributing Contributions are welcome. Please submit pull requests. For significant changes, open an issue first to discuss the proposed modifications. ## License This project is licensed under the [AutoFtBot License](https://github.com/AutoFTbot/OrderKuota-go/blob/main/LICENSE). ``` -------------------------------- ### Generate Payment QR Code Source: https://context7.com/autoftbot/orderkuota-go/llms.txt Generate a QR code image for a specific amount and transaction ID, then save it as a PNG file. ```go package main import ( "fmt" "log" "github.com/AutoFTbot/OrderKuota-go/qris" ) func main() { config := qris.QRISConfig{ BaseQrString: "00020101021126670016COM.NOBUBANK.WWW01189360050300000898240215NOBU1234567890030303UMI51440014ID.CO.QRIS.WWW0215ID12345678901230303UMI5802ID5913Merchant Name6013Jakarta Pusat61051034062070703A01630400", AuthToken: "your-auth-token", AuthUsername: "your-auth-username", } qrisInstance, err := qris.NewQRIS(config) if err != nil { log.Fatalf("Failed to create QRIS instance: %v", err) } data := qris.QRISData{ Amount: 100000, // Payment amount in IDR TransactionID: "TRX-2024-001", } qrCode, err := qrisInstance.GenerateQRCode(data) if err != nil { log.Fatalf("Error generating QR code: %v", err) } // Save QR code to file with 256x256 pixel dimensions err = qrCode.WriteFile(256, "payment-qris.png") if err != nil { log.Fatalf("Error saving QR code: %v", err) } fmt.Println("QR code saved to payment-qris.png") // Output: QR code saved to payment-qris.png } ``` -------------------------------- ### Define QRIS Data Structures Source: https://context7.com/autoftbot/orderkuota-go/llms.txt Reference for the configuration and data models required for QRIS operations and payment verification. ```go // QRISConfig - Configuration for QRIS operations type QRISConfig struct { BaseQrString string // Base QRIS string from merchant (must contain "5802ID") AuthToken string // Authentication token for API calls AuthUsername string // Authentication username for API calls } // QRISData - Payment data for QR code generation type QRISData struct { Amount int64 // Payment amount in IDR (must be > 0) TransactionID string // Unique transaction identifier } // PaymentStatus - Payment verification result type PaymentStatus struct { Status string // "PAID" or "UNPAID" Amount int64 // Confirmed payment amount Reference string // Payment reference number Date string // Payment timestamp (format: "2006-01-02 15:04:05") BrandName string // Payment provider (e.g., "OVO", "GoPay", "Dana") BuyerRef string // Buyer's reference identifier } ``` -------------------------------- ### Generate Raw QRIS String Source: https://context7.com/autoftbot/orderkuota-go/llms.txt Retrieve the raw QRIS string for a transaction without generating an image, useful for custom implementations or logging. ```go package main import ( "fmt" "log" "github.com/AutoFTbot/OrderKuota-go/qris" ) func main() { config := qris.QRISConfig{ BaseQrString: "00020101021126670016COM.NOBUBANK.WWW01189360050300000898240215NOBU1234567890030303UMI51440014ID.CO.QRIS.WWW0215ID12345678901230303UMI5802ID5913Merchant Name6013Jakarta Pusat61051034062070703A01630400", AuthToken: "your-auth-token", AuthUsername: "your-auth-username", } qrisInstance, err := qris.NewQRIS(config) if err != nil { log.Fatalf("Failed to create QRIS instance: %v", err) } data := qris.QRISData{ Amount: 50000, TransactionID: "TRX-2024-002", } qrString, err := qrisInstance.GetQRISString(data) if err != nil { log.Fatalf("Error generating QRIS string: %v", err) } fmt.Printf("Generated QRIS string: %s\n", qrString) // Output: Generated QRIS string: 00020101021226670016COM.NOBUBANK.WWW...5405500005802ID...6304XXXX } ``` -------------------------------- ### GenerateQRCode - Generate Payment QR Code Source: https://context7.com/autoftbot/orderkuota-go/llms.txt Generates a PNG QR code image for a specific transaction amount and ID. ```APIDOC ## GenerateQRCode - Generate Payment QR Code ### Description Generates a QR code image for QRIS payment with the specified amount and transaction ID. Returns a QRCode object that can be saved to a file. ### Request Body - **Amount** (float64) - Required - Payment amount in IDR. - **TransactionID** (string) - Required - Unique identifier for the transaction. ### Response #### Success Response (200) - **QRCode** (object) - Returns a QRCode object with methods to save to file. ``` -------------------------------- ### GetQRISString - Generate QRIS String Source: https://context7.com/autoftbot/orderkuota-go/llms.txt Generates the raw QRIS string for a payment without creating a visual QR code image. ```APIDOC ## GetQRISString - Generate QRIS String ### Description Generates the raw QRIS string for a payment without creating the QR code image. Useful for custom QR generation or logging. ### Request Body - **Amount** (float64) - Required - Payment amount in IDR. - **TransactionID** (string) - Required - Unique identifier for the transaction. ### Response #### Success Response (200) - **QRISString** (string) - The generated raw QRIS string. ``` -------------------------------- ### Define PaymentStatus struct Source: https://github.com/autoftbot/orderkuota-go/blob/main/README.md Represents the structure of a payment status response, including fields for status, amount, and transaction references. ```go type PaymentStatus struct { Status string // Payment status (PAID/UNPAID) / Status pembayaran (PAID/UNPAID) Amount int64 // Payment amount / Nominal pembayaran Reference string // Payment reference / Referensi pembayaran Date string // Payment date (if PAID) / Tanggal pembayaran (jika PAID) BrandName string // Payer brand name (if PAID) / Nama brand pembayar (jika PAID) BuyerRef string // Buyer reference (if PAID) / Referensi pembeli (jika PAID) } ``` -------------------------------- ### Error Handling Source: https://github.com/autoftbot/orderkuota-go/blob/main/README.md Details on the error handling mechanisms provided by the library. ```APIDOC ## Error Handling The package provides robust error handling for various stages of QRIS integration: - Input validation during initialization. - QRIS format validation. - Checksum validation. - QR code generation errors. - Payment status checking errors. ``` -------------------------------- ### Validate QRIS String Format Source: https://context7.com/autoftbot/orderkuota-go/llms.txt Validates a QRIS string by checking its length, country ID marker, amount format, and CRC16 checksum. ```go package main import ( "fmt" "log" "github.com/AutoFTbot/OrderKuota-go/qris" ) func main() { config := qris.QRISConfig{ BaseQrString: "00020101021126670016COM.NOBUBANK.WWW01189360050300000898240215NOBU1234567890030303UMI51440014ID.CO.QRIS.WWW0215ID12345678901230303UMI5802ID5913Merchant Name6013Jakarta Pusat61051034062070703A01630400", AuthToken: "your-auth-token", AuthUsername: "your-auth-username", } qrisInstance, err := qris.NewQRIS(config) if err != nil { log.Fatalf("Failed to create QRIS instance: %v", err) } // Generate a QRIS string first data := qris.QRISData{ Amount: 75000, TransactionID: "TRX-2024-003", } qrString, err := qrisInstance.GetQRISString(data) if err != nil { log.Fatalf("Error generating QRIS string: %v", err) } // Validate the generated string err = qrisInstance.ValidateQRISString(qrString) if err != nil { log.Fatalf("Invalid QRIS string: %v", err) } fmt.Println("QRIS string is valid") // Output: QRIS string is valid } ``` -------------------------------- ### QRIS Payment Status Structure Source: https://github.com/autoftbot/orderkuota-go/blob/main/README.md Defines the structure for payment status information returned by the QRIS system. ```APIDOC ## Struct: PaymentStatus ### Description Represents the status of a payment transaction. ### Fields - **Status** (string) - Payment status (PAID/UNPAID). - **Amount** (int64) - Payment amount. - **Reference** (string) - Payment reference. - **Date** (string) - Payment date (if PAID). - **BrandName** (string) - Payer brand name (if PAID). - **BuyerRef** (string) - Buyer reference (if PAID). ``` -------------------------------- ### Check Real-time Payment Status Source: https://context7.com/autoftbot/orderkuota-go/llms.txt Polls the payment gateway API to retrieve the status of a transaction. Requires a valid transaction reference and amount. ```go package main import ( "fmt" "log" "time" "github.com/AutoFTbot/OrderKuota-go/qris" ) func main() { config := qris.QRISConfig{ BaseQrString: "00020101021126670016COM.NOBUBANK.WWW01189360050300000898240215NOBU1234567890030303UMI51440014ID.CO.QRIS.WWW0215ID12345678901230303UMI5802ID5913Merchant Name6013Jakarta Pusat61051034062070703A01630400", AuthToken: "your-auth-token", AuthUsername: "your-auth-username", } qrisInstance, err := qris.NewQRIS(config) if err != nil { log.Fatalf("Failed to create QRIS instance: %v", err) } transactionID := "TRX-2024-004" amount := int64(100000) // Poll for payment status for i := 0; i < 12; i++ { // Check for 1 minute (12 x 5 seconds) fmt.Printf("Checking payment status (attempt %d)...\n", i+1) status, err := qrisInstance.CheckPaymentStatus(transactionID, amount) if err != nil { log.Printf("Error checking status: %v", err) time.Sleep(5 * time.Second) continue } fmt.Printf("Status: %s\n", status.Status) fmt.Printf("Amount: %d\n", status.Amount) fmt.Printf("Reference: %s\n", status.Reference) if status.Status == "PAID" { fmt.Printf("Payment successful!\n") fmt.Printf("Date: %s\n", status.Date) fmt.Printf("Brand: %s\n", status.BrandName) fmt.Printf("Buyer Ref: %s\n", status.BuyerRef) break } fmt.Println("Waiting for payment...") time.Sleep(5 * time.Second) } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.