# Refund interface

This interface is for WechatPay, Alipay and UnionPay only.

# Request URL

# Server address

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

# Request method

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

# Parameters

name required type sample description
mchId y String(30) 20001222 merchant id assigned by IOTPay
mchRefundNo y String(30) 20160427210604000490 generated by merchant
refundAmount y int 100 refund amount in cents,<= pay amount
clientIp y String(32) client ip
device n String(64) WEB
loginName y String(32) xxx merchant login name
payOrderId y String(64) U00180918065500913991007022 order id must be the same with original order id
sign y String(32) C380BEC2BFD727A4B6845133519F3AD6 signature

# parameters sample


# sample code

$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' OR $res['resCode'] == 'SUCCESS') {
    echo "Refund successfully";
} else {
    echo 'Order payment failed!' . $res['retMsg'] . $res['errCodeDes'];

# return result

field required type sample description
retCode y String(16) SUCCESS SUCCESS/FAIL,retCode indicate communication status,
still need to check resCode to judge transaction status
retMsg n String(128) signature error error message

# Demo

Demo Download

Last Updated: 1/26/2021, 4:10:48 PM