退款接口

本接口只用于微信支付,支付宝支付和银联支付。

API 请求

端点

https://api.iotpaycloud.com/v1/refund_order

方法

POST

头部

Content-Type: application/x-www-form-urlencoded

! 提示

在收到访问凭证(商户 ID、登录名、商户密钥)之后, 您可以按照演示退款订单在新窗口打开进行测试。 这可能在阅读文档时对您有所帮助。

参数

字段名变量名必填类型示例值描述
商户IDmchIdString(30)20001222支付中心分配的商户号
商户退款订单号mchRefundNoString(30)20160427210604000490商户自己生成
退款金额refundAmountint100退款金额,单位分,不能大于订单金额
客户端IPclientIpString(32)210.73.10.148客户端IP地址
设备deviceString(64)WEB终端设备号(门店号或收银设备ID),
注意:PC网页或公众号内支付请传”WEB
用户名loginNameString(32)xxx用户名
支付订单号payOrderIdString(64)U00180918065500913991007022要与原支付订单号一致
签名signString(32)C380BEC2BFD727A4B6845133519F3AD6签名值,详见签名算法

提示

由于兼容性要求,我们要求参数被包装如下:

params={"channelId":"WX_MICROPAY","clientIp":"24.80.45.254","device":"","loginName":"vincent","mchId":"10000576","mchRefundNo":"1537224899791","payOrderId":"U00180918065500913991007022","refundAmount":"1","sign":"75BB98BD083B7F2F7FDEFF5852F3D526"}

返回结果

字段名变量名必填类型示例值描述
返回状态码retCodeString(16)SUCCESSSUCCESS/FAIL此字段是通信标识,非交易标识,交易是否成功需要查看resCode来判断
返回信息retMsgString(128)签名失败返回信息,如非空,为错误原因 签名失败 参数格式校验错误

代码示例

require_once('Utility.php');
$merchant_id = $_POST['merchantid'];
$merchant_key = $_POST['merchantKey'];
$url = 'https://api.iotpaycloud.com/v1/refund_order';
$order_amount = $_POST['orderamount'];
$order_sn = $_SERVER['REQUEST_TIME'];
$Utility = new Utility();
$ip = $Utility->real_ip();

$loginname = $_POST['loginname'];
$payorderid = $_POST['payorderid'];
$arr = array(
    'mchId' => $merchant_id,
    'mchRefundNo' => $order_sn,
    'loginName' => $loginname,
    'currency' => 'CAD',
    'refundAmount' => intval($order_amount * 100),
    'clientIp' => $ip,
    'payOrderId' => $payorderid,
);
$sort_array = $Utility->arg_sort($arr);
$arr['sign'] = $Utility->build_mysign($sort_array, $merchant_key, "MD5");//Generate signature parameter sign
$param = 'params=' . json_encode($arr);
$resBody = $Utility->request($url, $param);//Submit to the gateway
$res = json_decode($resBody, true);
if ($res['retCode'] == 'SUCCESS' AND $res['resCode'] == 'SUCCESS') {
    echo "Refund successfully";
} else {
    echo 'Order payment failed!' . $res['retMsg'] . $res['errCodeDes'];
}


上次更新: