Credit Card API V2(不建议使用,请对接V3版本)

  • 仅支持加元交易.

  • 有两种应用流程:
    简单购买流程
    重复购买流程

生成签名和签名验证

Sign algorithm

Request和response参数格式

均为JSON格式

发送请求范例

$arr = array(
    'customerId' => '0000000123',
    'mchOrderNo' => 'm12345',
    'mchId' => 'your merchant id',
  	'currency' => 'CAD',
    'amount' => 100,   // in cents
    'jobNo' => 'jack', //your login name
    'notifyUrl' => 'http://yourdomain.com/notifyme.php',
    'returnUrl' => 'http://yourdomain.com/returnhere.php',
    'subject' => "ipad pro",
    'body' => '64G,wifi,white'
);
$Utility = new Utility();
$sort_array = $Utility->arg_sort($arr);   //sort the parameters
$arr['sign'] = $Utility->build_mysign($sort_array, $merchantKey, "MD5");   //generate sign and put it into the array
$param = json_encode($arr);    //generate json string to send
$resBody = $Utility->request($url, $param);//Submit to the gateway

$res = json_decode($resBody, true);
if ($res['retCode'] == 'SUCCESS') {
    header('Location: ' . $res['payUrl']);//Redirect to payment page
} else {
    echo $res['msg'];
}

简单购买流程

用户每次购买都需要输入信用卡信息.

Sequence

1, 调用 cc_purchase 然后重定向到 payUrl,用户在这里输入信用卡信息;
2, 购买结束后, 会重定向到 returnUrl;
3, 如果交易成功, IOTPay会发送notify message到 notifyUrl;

Request URL for simple purchase

Endpoint: https://api.iotpaycloud.com/v2/cc_purchase

Request method:

  • POST
  • Content-Type: application/json;charset=UTF-8

Parameters

namerequiredtypesampledescription
mchIdyString(30)10000701assigned by IOTPay
mchOrderNoyString(30)1234567890abcassigned by merchant
customerIdyString(30)abc123@gmail.com or 16647865678assigned by merchant
amountyInt1500in cents
currencyyString(3)CADfor now only CAD supported
jobNoyString(12)jack123merchant's login name
subjectnString(64)
bodynString(250)
notifyUrlyString(200)get notify when success
returnUrlyString(200)redirect to this url after payment
signyString(32)C380BEC2BFD727A4B6845133519F3AD6Sign algorithm

Response

namerequiredtypesampledescription
retCodeyStringSUCCESS or FAIL
retMsgyString
payUrlyStringif retCode=SUCCESS, merchant redirect to this url

NotifyUrl message

namerequiredtypesampledescription
payOrderIdyStringIOTPay transaction number
mchIdyStringmerchant Id
mchOrderNoyStringmerchant transaction number
transIdyStringbank transaction number
currencyyString
amountyInt2000in cents
statusyInt2success: 2 or 3
paySuccTimeyString
cardTypeyStringVpossible value: A/M/I/V/O, blank for unknown type
cardNumyString450116XXXXXX7214
expirationDateyString0725
signyStringSign algorithm

ReturnUrl parameters

namerequiredtypesampledescription
retCodeyStringSUCCESS or FAIL
payOrderIdyStringIOTPay transaction number
mchOrderNoyStringmerchant transaction number
transIdyStringbank transaction number
paySuccTimeyString
statusyInt2success: 2 or 3
signyStringSign algorithm

Recurring purchase

绑定用户和信用卡信息,方便后续重复购买,避免每次购买都要输入信用卡信息。

Sequence

1, 调用 cc_adduser 并且重定向到 payUrl,用户在这里输入信用卡信息;
2, 用户输入卡信息后,会重定向到returnUrl:
如果成功: retCode=SUCCESS&customerId=xxx&cardNumber=450116XXXXXX7214&expirationDate=0725&cardType=V&sign=xxxx
如果失败: retCode=FAIL&customerId=xxxx&sign=xxxx
3, 如果绑定用户成功, 调用 cc_purchasewithtoken 发起真实支付

Request URL for adduser

Endpoint: https://api.iotpaycloud.com/v2/cc_adduser

Request method:

  • POST
  • Content-Type: application/json;charset=UTF-8

Parameters

namerequiredtypesampledescription
mchIdyString(30)10000701assigned by IOTPay
customerIdyString(30)604567999商户分配的客户ID,必须唯一
currencyyString(3)CADfor now only CAD supported
jobNoyString(12)jack123merchant's login name
returnUrlyString(200)redirect to this url after payment
signyString(32)C380BEC2BFD727A4B6845133519F3AD6Sign algorithm

每个 customerId 只能绑定一张信用卡, 如果同一个用户需要绑定多张信用卡, 需要使用不同的 customerId

Response

namerequiredtypesampledescription
retCodeyStringSUCCESS or FAIL
retMsgyString
payUrlyStringif retCode=SUCCESS, merchant redirect to this url

ReturnUrl parameters

namerequiredtypesampledescription
retCodeyStringSUCCESS or FAIL
customerIdyString00987654321
cardNumberyString450116XXXXXX7214card number
expirationDateyString0725card expire date
cardTypeyStringVV: Visa, M: Mastercard
signyStringSign algorithm

Request URL for purchasewithtoken

Endpoint: https://api.iotpaycloud.com/v2/cc_purchasewithtoken

Request method:

  • POST
  • Content-Type: application/json;charset=UTF-8

Parameters

namerequiredtypesampledescription
mchIdyString(30)10000701assigned by IOTPay
mchOrderNoyString(30)1234567890abcassigned by merchant
customerIdyString(30)604567999assigned by merchant
amountyInt1500in cents
currencyyString(3)CADfor now only CAD supported
jobNoyString(12)jack123merchant's login name
subjectnString(64)
bodynString(250)
signyString(32)C380BEC2BFD727A4B6845133519F3AD6Sign algorithm

Response

namerequiredtypesampledescription
retCodeyStringSUCCESS or FAIL
retMsgyString
ordernJSONif retCode=SUCCESS, order detailed info returned

Basic parameters in order

namerequiredtypesampledescription
payOrderIdyStringSUCCESS or FAILtransaction number assigned by IOTPay
mchOrderNoyStringtransaction number assigned by merchant
transidyStringtransaction number of bank
statusyInttransaction status: 2 or 3 means success
paySuccTimeyStringtransaction success time
originalOrderIdyStringoriginal pay order id if payType=refund
payTypeyStringpay or refundtransaction type

Refund a transaction

Endpoint: https://api.iotpaycloud.com/v2/cc_refund

Request method:

  • POST
  • Content-Type: application/json;charset=UTF-8

Parameters

namerequiredtypesampledescription
mchIdyString(30)10000701assigned by IOTPay
mchRefundNoyString(30)R1234567890abcassigned by merchant
loginNameyString(12)jack_chenassigned by merchant,equals to jobNo
currencyyString(3)CADfor now only CAD supported
refundAmountyInt100in cents
payOrderIdyString(30)100
signyString(32)C380BEC2BFD727A4B6845133519F3AD6Sign algorithm

Response

namerequiredtypesampledescription
retCodeyStringSUCCESS or FAIL
retMsgyString
ordernJSONif retCode=SUCCESS, order detailed info returned

Void a transaction

Endpoint: https://api.iotpaycloud.com/v2/cc_void

Request method:

  • POST
  • Content-Type: application/json;charset=UTF-8

Parameters

namerequiredtypesampledescription
mchIdyString(30)10000701assigned by IOTPay
mchRefundNoyString(30)R1234567890abcassigned by merchant
loginNameyString(12)jack_chenassigned by merchant,equals to jobNo
currencyyString(3)CADfor now only CAD supported
payOrderIdyString(30)100
signyString(32)C380BEC2BFD727A4B6845133519F3AD6Sign algorithm

Response

namerequiredtypesampledescription
retCodeyStringSUCCESS or FAIL
retMsgyString
ordernJSONif retCode=SUCCESS, order detailed info returned

Query order

Endpoint: https://api.iotpaycloud.com/v2/cc_query

Request method:

  • POST
  • Content-Type: application/json;charset=UTF-8

Parameters

namerequiredtypesampledescription
mchIdyString(30)10000701assigned by IOTPay
mchOrderNoyString(30)1234567890abcassigned by Merchant
payOrderIdyString(30)1000008assigned by IOTPay
signyString(32)C380BEC2BFD727A4B6845133519F3AD6Sign algorithm

** payOrderId 或者 mchOrderNo, 传递其中一个就可以**

Response

namerequiredtypesampledescription
retCodeyStringSUCCESS or FAIL
retMsgyString
ordernJSONif retCode=SUCCESS, order detailed info returned

Query user binding status

Endpoint: https://api.iotpaycloud.com/v2/cc_isbinding

Request method:

  • POST
  • Content-Type: application/json;charset=UTF-8

Parameters

namerequiredtypesampledescription
mchIdyString(30)10000701assigned by IOTPay
customerIdyString(30)R1234567890abcassigned by merchant
signyString(32)C380BEC2BFD727A4B6845133519F3AD6Sign algorithm

Response

namerequiredtypesampledescription
retCodeyStringSUCCESS or FAILif SUCCESS, merchant can use customerId to call cc_purchasewithtoken
retMsgyString

Demo and source code

Simple purchase: demo在新窗口打开 Recurring purchase: demo在新窗口打开 source code download在新窗口打开

上次更新: