转账凭证下载接口

更新时间:2026-08-05

接口说明

转账凭证下载接口,支持通过平台订单号transactionNo)或商户订单号orderNo)获取转账电子回执单的下载链接。

适用对象
间连商户
请求 URL
https://openapi.shuhuipay.com/v1/order/voucher
请求方法
POST
ℹ️ 公共参数说明详见「通用规则 - API公共参数」部分
⚠️
使用前提:
  • 仅支持查询转账订单(代付接口创建的订单),支付订单不支持
  • 订单状态必须为转账成功(状态码 2),其他状态无法获取凭证
  • 电子回执单由支付渠道异步生成,转账成功后可能需要等待一段时间才能获取

请求参数(bizContent)

ℹ️ transactionNoorderNo 二者必须提供其中一个。推荐使用 transactionNo(平台订单号)进行查询,效率更高。
参数名 类型 必填 参数说明
transactionNo String 二选一 平台订单号,与 orderNo 二选一
orderNo String 二选一 商户订单号,与 transactionNo 二选一

请求示例

通过 transactionNo 查询(推荐)

JSON
{
  "appId": "you_system_appid",
  "subMerchantNo": "your_user_id",
  "bizContent": "{\"transactionNo\":\"SHTRANS202608042051264580514\"}",
  "version": "1.0",
  "nonce": "49d55020fa3adf6ed67b253c583ccdaa",
  "contentHash": "95772c8a0c74e52b707e2ace5963e0eae956e8b1ae26e86a6cde5469247d0382",
  "timestamp": "2026-08-05 10:30:00",
  "sign": "your_sign"
}

通过 orderNo 查询

JSON
{
  "appId": "you_system_appid",
  "subMerchantNo": "your_user_id",
  "bizContent": "{\"orderNo\":\"ORDER202608013137111100000000007\"}",
  "version": "1.0",
  "nonce": "49d55020fa3adf6ed67b253c583ccdaa",
  "contentHash": "95772c8a0c74e52b707e2ace5963e0eae956e8b1ae26e86a6cde5469247d0382",
  "timestamp": "2026-08-05 10:30:00",
  "sign": "your_sign"
}

响应参数

公共返回参数

参数 类型 必须 参数说明
code String Y 响应状态码,成功 0000
message String Y 响应描述
timestamp String Y 响应时间戳,UTC 时间,ISO 8601 格式
data Object Y 业务数据,无数据时返回空对象 {}

响应附加参数(data)

参数名 类型 必填 参数说明
transactionNo String Y 平台订单号
orderNo String Y 商户订单号
downloadUrl String Y 转账凭证下载链接,有效期有限,建议及时下载保存
status String N 回执单状态,SUCCESS 表示生成成功
channel String N 支付渠道名称,如 Alipay

响应示例

成功响应:

JSON
{
  "code": "0000",
  "message": "Success",
  "timestamp": "2026-08-05T10:30:05.000Z",
  "data": {
    "transactionNo": "SHTRANS202608042051264580514",
    "orderNo": "ORDER202608013137111100000000007",
    "downloadUrl": "https://openapi.alipay.com/xxx/ereceipt/download?file_id=xxx",
    "status": "SUCCESS",
    "channel": "Alipay"
  }
}

失败响应:

JSON
// 订单不存在
{
  "code": "4004",
  "message": "订单号 ORDER202608010001 不存在或不属于当前商户",
  "timestamp": "2026-08-05T10:30:05.000Z",
  "data": {}
}

// 凭证生成中(异步生成,需稍后重试)
{
  "code": "5000",
  "message": "获取转账回执单凭证file_id失败",
  "timestamp": "2026-08-05T10:30:05.000Z",
  "data": {}
}

// 参数缺失
{
  "code": "4001",
  "message": "transactionNo 和 orderNo 不能同时为空",
  "timestamp": "2026-08-05T10:30:05.000Z",
  "data": {}
}

代码示例

Java
import java.util.HashMap;
import java.util.Map;
import com.alibaba.fastjson.JSON;

public class VoucherDownloadExample {
    public static void main(String[] args) {
        // 方式一:通过平台订单号查询
        Map<String, String> queryByTransactionNo = new HashMap<>();
        queryByTransactionNo.put("transactionNo", "SHTRANS202608042051264580514");
        String result1 = getVoucher(queryByTransactionNo);
        System.out.println("查询结果:" + result1);

        // 方式二:通过商户订单号查询
        Map<String, String> queryByOrderNo = new HashMap<>();
        queryByOrderNo.put("orderNo", "ORDER202608013137111100000000007");
        String result2 = getVoucher(queryByOrderNo);
        System.out.println("查询结果:" + result2);
    }

    public static String getVoucher(Map<String, String> queryParams) {
        String appId = "your_app_id";
        String subMerchantNo = "your_user_id";
        String signKey = "your_sign_key";
        String apiUrl = "https://openapi.shuhuipay.com/v1/order/voucher";

        Map<String, String> requestData = new HashMap<>();
        requestData.put("appId", appId);
        requestData.put("subMerchantNo", subMerchantNo);
        requestData.put("bizContent", JSON.toJSONString(queryParams));
        requestData.put("version", "1.0");
        requestData.put("nonce", "49d55020fa3adf6ed67b253c583ccdaa");
        requestData.put("contentHash", "95772c8a0c74e52b707e2ace5963e0eae956e8b1ae26e86a6cde5469247d0382");
        requestData.put("timestamp", "2026-08-05 10:30:00");

        String sign = SignUtil.generateSign(requestData, signKey);
        requestData.put("sign", sign);

        String response = HttpUtil.post(apiUrl, requestData);
        return response;
    }
}
Python
import requests
import json
import hashlib

def get_voucher(query_params):
    """获取转账凭证下载链接"""
    sys_appid = "your_sys_appid"
    open_subMerchantNo = "your_open_subMerchantNo"
    sign_key = "your_sign_key"
    api_url = "https://openapi.shuhuipay.com/v1/order/voucher"

    request_data = {
        "appId": sys_appid,
        "subMerchantNo": open_subMerchantNo,
        "version": "1.0",
        "timestamp": "2026-08-05 10:30:00",
        "nonce": "49d55020fa3adf6ed67b253c583ccdaa",
        "bizContent": json.dumps(query_params),
        "contentHash": "95772c8a0c74e52b707e2ace5963e0eae956e8b1ae26e86a6cde5469247d0382",
    }

    sign = generate_sign(request_data, sign_key)
    request_data["sign"] = sign

    try:
        response = requests.post(api_url, json=request_data, timeout=30)
        return response.json()
    except Exception as e:
        print(f"查询失败: {e}")
        return None

def generate_sign(params, sign_key):
    sorted_params = sorted(params.items())
    sign_str = "&".join([f"{k}={v}" for k, v in sorted_params if v])
    sign_str += f"&key={sign_key}"
    return hashlib.md5(sign_str.encode()).hexdigest().upper()

# 方式一:通过平台订单号查询
result = get_voucher({"transactionNo": "SHTRANS202608042051264580514"})

# 处理返回结果
if result and result.get("code") == "0000":
    data = result.get("data", {})
    download_url = data.get("downloadUrl")
    if download_url:
        print(f"凭证下载链接: {download_url}")
        # 下载文件
        file_response = requests.get(download_url)
        with open("voucher.pdf", "wb") as f:
            f.write(file_response.content)
        print("凭证已保存为 voucher.pdf")
else:
    print(f"获取失败: {result.get('message')}")
PHP
<?php

class VoucherDownload {
    private $appId = 'your_app_id';
    private $subMerchantNo = 'your_user_id';
    private $signKey = 'your_sign_key';
    private $apiUrl = 'https://openapi.shuhuipay.com/v1/order/voucher';

    public function getVoucher($queryParams) {
        $requestData = [
            'appId'       => $this->appId,
            'subMerchantNo'      => $this->subMerchantNo,
            'bizContent'  => json_encode($queryParams),
            'version'     => '1.0',
            'nonce'       => '49d55020fa3adf6ed67b253c583ccdaa',
            'contentHash' => '95772c8a0c74e52b707e2ace5963e0eae956e8b1ae26e86a6cde5469247d0382',
            'timestamp'   => '2026-08-05 10:30:00',
        ];

        $requestData['sign'] = $this->generateSign($requestData);
        $response = $this->httpPost($this->apiUrl, $requestData);
        return json_decode($response, true);
    }

    private function generateSign($params) {
        ksort($params);
        $signStr = '';
        foreach ($params as $key => $value) {
            if ($value !== '') {
                $signStr .= "{$key}={$value}&";
            }
        }
        $signStr .= "key={$this->signKey}";
        return strtoupper(md5($signStr));
    }

    private function httpPost($url, $data) {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
        curl_setopt($ch, CURLOPT_TIMEOUT, 30);
        $response = curl_exec($ch);
        curl_close($ch);
        return $response;
    }
}

// 通过平台订单号获取凭证
$result = (new VoucherDownload())->getVoucher([
    'transactionNo' => 'SHTRANS202608042051264580514'
]);

// 处理返回结果
if ($result && $result['code'] === '0000') {
    $data = $result['data'] ?? [];
    $downloadUrl = $data['downloadUrl'] ?? '';
    if (!empty($downloadUrl)) {
        echo "凭证下载链接: " . $downloadUrl;
        // 下载文件
        $fileContent = file_get_contents($downloadUrl);
        file_put_contents('voucher.pdf', $fileContent);
        echo "凭证已保存为 voucher.pdf";
    }
} else {
    echo "获取失败: " . ($result['message'] ?? '未知错误');
}

注意事项

⚠️
生成时效:
  • 电子回执单由支付渠道异步生成,转账成功后不会立即可用
  • 建议转账成功后等待 30 秒再调用此接口
  • 如返回"获取转账回执单凭证file_id失败",请稍后重试
💡
链接有效期:
  • 返回的 downloadUrl有效期限制,建议获取后立即下载
  • 如链接过期,需重新调用接口获取新的下载链接
  • 下载的文件格式为 PDF,可直接保存或打印
最佳实践:
  • 转账成功后,建议延迟 30 秒再调用此接口获取凭证
  • 如首次获取失败,建议每隔 10 秒重试一次,最多重试 3 次
  • 获取到下载链接后,立即下载并保存到本地或对象存储
  • 妥善保存 transactionNo(平台订单号),便于后续查询
🚫
常见错误:
  • 订单不存在 — 订单号错误或不属于当前商户
  • 订单支付渠道信息缺失 — 订单数据异常,联系技术支持
  • 获取转账回执单凭证file_id失败 — 凭证尚未生成,稍后重试