Api References
Generate QR Code
Generates a QR code for payment without creating a full order.
Endpoint
POST https://merchant.dv.vai247.pro/api/v1/payment-gateway/payment/generate-qr
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
amount | number | Yes | Payment amount |
currency | string | Yes | Currency code (USD, KHR) |
Code Examples
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"time"
)
type GenerateQRRequest struct {
Amount float64 `json:"amount"`
Currency string `json:"currency"`
}
type GenerateQRResponse struct {
QRCode string `json:"qr_code"`
QRData string `json:"qr_data"`
ExpiresAt string `json:"expires_at"`
}
func generateQRCode(amount float64, currency string) (*GenerateQRResponse, error) {
url := "https://merchant.dv.vai247.pro/api/v1/payment-gateway/payment/generate-qr"
payload := GenerateQRRequest{
Amount: amount,
Currency: currency,
}
jsonData, err := json.Marshal(payload)
if err != nil {
return nil, err
}
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
if err != nil {
return nil, err
}
// Add authentication headers
req.Header.Set("X-App-Id", "your-app-id")
req.Header.Set("X-Api-Key", "your-api-key")
req.Header.Set("X-Timestamp", fmt.Sprintf("%d", time.Now().Unix()))
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
var result GenerateQRResponse
if err := json.Unmarshal(body, &result); err != nil {
return nil, err
}
return &result, nil
}
func main() {
qr, err := generateQRCode(50.00, "USD")
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf("QR Code URL: %s\n", qr.QRCode)
fmt.Printf("QR Data: %s\n", qr.QRData)
fmt.Printf("Expires At: %s\n", qr.ExpiresAt)
}
const axios = require('axios');
async function generateQRCode(amount, currency) {
const url = 'https://merchant.dv.vai247.pro/api/v1/payment-gateway/payment/generate-qr';
const headers = {
'X-App-Id': 'your-app-id',
'X-Api-Key': 'your-api-key',
'X-Timestamp': Math.floor(Date.now() / 1000).toString(),
'Content-Type': 'application/json'
};
const payload = {
amount: amount,
currency: currency
};
try {
const response = await axios.post(url, payload, { headers });
return response.data;
} catch (error) {
console.error('Error generating QR code:', error.response?.data || error.message);
throw error;
}
}
// Usage
(async () => {
try {
const qr = await generateQRCode(50.00, 'USD');
console.log('QR Code URL:', qr.qr_code);
console.log('QR Data:', qr.qr_data);
console.log('Expires At:', qr.expires_at);
} catch (error) {
console.error('Failed to generate QR code');
}
})();
Response
{
"qr_code": "https://api.dvpay.com/qr/xyz789",
"qr_data": "dvpay://pay?amount=50.00¤cy=USD&ref=xyz789",
"expires_at": "2025-10-04T11:00:00Z"
}
Notes
- QR codes are typically valid for 30 minutes
- Use this endpoint for quick payment generation without order tracking