# Refund interface

# Refund

Refund need merchant login name,password, DES_KEY, DEX_VI, please contact IOTPay to get.

# Request URL

# Server address


# 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
currency y String(3) CAD
refundAmount y int 100 refund amount in cents,<= pay amount
clientIp y String(32) client ip
device n String(64) WEB
notifyUrl y String(200) http://xxx.com/notify.php need this value but not used for now
loginName y String(32) xxx merchant login name
password y String(64) xxx merchant password
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 = 'http://pay.4jicao.com/api/refund/create_order';
$order_amount = $_POST['orderamount'];
$order_sn = $_SERVER['REQUEST_TIME'];
$Utility = new Utility();
$ip = $Utility->real_ip();
$notifyUrl = 'https://develop.IOTPay.ca/demo/order/notify.php';
$loginname = $_POST['loginname'];
$DES_KEY = "xxxxxxx";  //ask IOTPay to get this value
$DES_VI = "xxxxxxx";   //ask IOTPay to get this value
$password = $Utility->encrypt($_POST['password'], $DES_KEY, $DES_VI);
$payorderid = $_POST['payorderid'];
$arr = array(
    'mchId' => $merchant_id,
    'mchRefundNo' => $order_sn,
    'loginName' => $loginname,
    'password' => $password,
    'currency' => 'CAD',
    'refundAmount' => intval($order_amount * 100),
    'clientIp' => $ip,
    'notifyUrl' => $notifyUrl,
    '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

# error code

more error code

# Demo


Last Updated: 11/20/2019, 2:59:46 PM