IOTPay DocumentationIOTPay Documentation
  • Introduction
  • Signing
  • General Order API
  • Customer Scan QR Code
  • Merchant Scan Barcode
  • Payment in WeChat Web Browser
  • WeChat Mini Program
  • Online Secure Payment
  • App integrate IOTPay
  • Order Query
  • Asynchronous Notify
  • Get Client IP
  • Refund interface
  • Query Refund
  • POS Semi-Integration
  • Wordpress WooCommerce plugin
  • V3

    • Introduction
    • Redirected Integration
    • Redirected Integration With 3DS and AVS
    • Embedded Integration
    • Direct Method
    • Query Card
    • Purchase With Token
    • Purchase with Wallet
    • Void Transaction
    • Refund Transaction
    • Query Transaction
    • UnionPay ExpressPay API
  • V2

    • Credit Card API V2(Deprecated)
  • Introduction
  • Contract Signing
  • Payment
  • Query Order API
  • Callback
  • English
  • 简体中文
  • Introduction
  • Signing
  • General Order API
  • Customer Scan QR Code
  • Merchant Scan Barcode
  • Payment in WeChat Web Browser
  • WeChat Mini Program
  • Online Secure Payment
  • App integrate IOTPay
  • Order Query
  • Asynchronous Notify
  • Get Client IP
  • Refund interface
  • Query Refund
  • POS Semi-Integration
  • Wordpress WooCommerce plugin
  • V3

    • Introduction
    • Redirected Integration
    • Redirected Integration With 3DS and AVS
    • Embedded Integration
    • Direct Method
    • Query Card
    • Purchase With Token
    • Purchase with Wallet
    • Void Transaction
    • Refund Transaction
    • Query Transaction
    • UnionPay ExpressPay API
  • V2

    • Credit Card API V2(Deprecated)
  • Introduction
  • Contract Signing
  • Payment
  • Query Order API
  • Callback
  • English
  • 简体中文
  • General Order

    • Introduction
    • Signing
    • General Order API
    • Customer Scan QR Code
    • Merchant Scan Barcode
    • Payment in WeChat Web Browser
    • WeChat Mini Program
    • Online Secure Payment
    • App integrate IOTPay
    • Order Query
    • Asynchronous Notify
    • Get Client IP
    • Refund interface
    • Query Refund
    • POS Semi-Integration
    • Wordpress WooCommerce plugin
  • CreditCard

    • V3

      • Introduction
      • Redirected Integration
      • Redirected Integration With 3DS and AVS
      • Embedded Integration
      • Direct Method
      • Query Card
      • Purchase With Token
      • Purchase with Wallet
      • Void Transaction
      • Refund Transaction
      • Query Transaction
      • UnionPay ExpressPay API
    • Credit Card API V2(Deprecated)
  • Autodebit

    • Introduction
    • Contract Signing
    • Payment
    • Query Order API
    • Callback

Refund interface

This interface is for WeChatPay, Alipay and UnionPay only.

API Request

Endpoint

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

Method

POST

Header

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

! Tip

After you receive access credentials (merchant id, login name, merchant key). You can step through the demo Refund Order to test out the workflow for this functionality. Which may help you when going through the documentation.

Parameters

NameRequiredTypeSampleDescription
mchIdyString(30)20001222merchant id assigned by IOTPay
mchRefundNoyString(30)20160427210604000490generated by merchant
refundAmountyint100refund amount in cents,<= pay amount
clientIpyString(32)210.73.10.148client ip
devicenString(64)WEB
loginNameyString(32)xxxmerchant login name
payOrderIdyString(64)U00180918065500913991007022order id must be the same with original order id
signyString(32)C380BEC2BFD727A4B6845133519F3AD6signature

Note

Due to backwards compatibility requirements, we require the parameters to be wrapped like the following:

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

return result

NameRequiredTypeSampleDescription
retCodeyString(16)SUCCESSSUCCESS/FAIL,retCode indicate communication status,
still need to check resCode to judge transaction status
retMsgnString(128)signature errorerror message

Sample Code

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'];
}
Last Updated: 4/1/24, 5:41 PM
Prev
Get Client IP
Next
Query Refund