Api References
Refund Order
Processes a refund for an existing order.
Endpoint
POST https://merchant.dv.vai247.pro/api/v1/payment-gateway/order/refund
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
order_id | string | Yes | Order identifier to refund |
amount | number | Yes | Refund amount (must be ≤ original amount) |
reason | string | No | Refund reason |
Code Examples
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"time"
)
type RefundRequest struct {
OrderID string `json:"order_id"`
Amount float64 `json:"amount"`
Reason string `json:"reason,omitempty"`
}
type RefundResponse struct {
RefundID string `json:"refund_id"`
OrderID string `json:"order_id"`
Amount float64 `json:"amount"`
Status string `json:"status"`
CreatedAt string `json:"created_at"`
}
func refundOrder(orderID string, amount float64, reason string) (*RefundResponse, error) {
url := "https://merchant.dv.vai247.pro/api/v1/payment-gateway/order/refund"
payload := RefundRequest{
OrderID: orderID,
Amount: amount,
Reason: reason,
}
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 RefundResponse
if err := json.Unmarshal(body, &result); err != nil {
return nil, err
}
return &result, nil
}
func main() {
refund, err := refundOrder("ord_abc123xyz", 50.00, "Customer request")
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf("Refund ID: %s\n", refund.RefundID)
fmt.Printf("Status: %s\n", refund.Status)
}
const axios = require('axios');
async function refundOrder(orderId, amount, reason = '') {
const url = 'https://merchant.dv.vai247.pro/api/v1/payment-gateway/order/refund';
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 = {
order_id: orderId,
amount: amount,
...(reason && { reason })
};
try {
const response = await axios.post(url, payload, { headers });
return response.data;
} catch (error) {
console.error('Error processing refund:', error.response?.data || error.message);
throw error;
}
}
// Usage
(async () => {
try {
const refund = await refundOrder('ord_abc123xyz', 50.00, 'Customer request');
console.log('Refund ID:', refund.refund_id);
console.log('Status:', refund.status);
} catch (error) {
console.error('Failed to process refund');
}
})();
Response
{
"refund_id": "ref_xyz789",
"order_id": "ord_abc123xyz",
"amount": 50.00,
"status": "processing",
"created_at": "2025-10-04T11:00:00Z"
}
Notes
- Refund amount cannot exceed the original order amount
- Partial refunds are supported
- Refunds may take 3-5 business days to process