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

ParameterTypeRequiredDescription
order_idstringYesOrder identifier to refund
amountnumberYesRefund amount (must be ≤ original amount)
reasonstringNoRefund 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)
}

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