# 退款接口

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

# 请求URL

# 服务地址

服务地址: https://api.iotpaycloud.com/v1/refund_order

# 请求方式

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

# 参数

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

# 参数示例

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

# 代码示例

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'];
}


# 返回结果

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

# Demo

Demo 下载

上次更新: 7/27/2021, 3:02:32 PM