# 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

Reqeust method:

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

# Parameters

name required type sample description
mchId y String(30) 10000701 assigned by IOTPay
mchOrderNo y String(30) 1234567890abc assigned by merchant
customerId y String(30) abc123@gmail.com or 16647865678 assigned by merchant
amount y Int 1500 in cents
currency y String(3) CAD for now only CAD supported
jobNo y String(12) jack123 merchant's login name
subject n String(64)
body n String(250)
notifyUrl y String(200) get notify when success
returnUrl y String(200) redirect to this url after payment
sign y String(32) C380BEC2BFD727A4B6845133519F3AD6 Sign algorithm

# Response

name required type sample description
retCode y String SUCCESS or FAIL
retMsg y String
payUrl y String if retCode=SUCCESS, merchant redirect to this url

# NotifyUrl message

name required type sample description
payOrderId y String IOTPay transaction number
mchId y String merchant Id
mchOrderNo y String merchant transaction number
transId y String bank transaction number
currency y String
amount y Int 2000 in cents
status y Int 2 success: 2 or 3
paySuccTime y String
cardType y String V possible value: A/M/I/V/O, blank for unknown type
cardNum y String 450116XXXXXX7214
expirationDate y String 0725
sign y String Sign algorithm

# ReturnUrl parameters

name required type sample description
retCode y String SUCCESS or FAIL
payOrderId y String IOTPay transaction number
mchOrderNo y String merchant transaction number
transId y String bank transaction number
paySuccTime y String
status y Int 2 success: 2 or 3
sign y String Sign 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

Reqeust method:

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

# Parameters

name required type sample description
mchId y String(30) 10000701 assigned by IOTPay
customerId y String(30) 604567999 商户分配的客户ID,必须唯一
currency y String(3) CAD for now only CAD supported
jobNo y String(12) jack123 merchant's login name
returnUrl y String(200) redirect to this url after payment
sign y String(32) C380BEC2BFD727A4B6845133519F3AD6 Sign algorithm

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

# Response

name required type sample description
retCode y String SUCCESS or FAIL
retMsg y String
payUrl y String if retCode=SUCCESS, merchant redirect to this url

# ReturnUrl parameters

name required type sample description
retCode y String SUCCESS or FAIL
customerId y String 00987654321
cardNumber y String 450116XXXXXX7214 card number
expirationDate y String 0725 card expire date
cardType y String V V: Visa, M: Mastercard
sign y String Sign algorithm

# Request URL for purchasewithtoken

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

Reqeust method:

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

# Parameters

name required type sample description
mchId y String(30) 10000701 assigned by IOTPay
mchOrderNo y String(30) 1234567890abc assigned by merchant
customerId y String(30) 604567999 assigned by merchant
amount y Int 1500 in cents
currency y String(3) CAD for now only CAD supported
jobNo y String(12) jack123 merchant's login name
subject n String(64)
body n String(250)
sign y String(32) C380BEC2BFD727A4B6845133519F3AD6 Sign algorithm

# Response

name required type sample description
retCode y String SUCCESS or FAIL
retMsg y String
order n JSON if retCode=SUCCESS, order detailed info returned

# Basic parameters in order

name required type sample description
payOrderId y String SUCCESS or FAIL transaction number assigned by IOTPay
mchOrderNo y String transaction number assigned by merchant
transid y String transaction number of bank
status y Int transaction status: 2 or 3 means success
paySuccTime y String transaction success time
originalOrderId y String original pay order id if payType=refund
payType y String pay or refund transaction type

# Refund a transaction

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

Reqeust method:

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

# Parameters

name required type sample description
mchId y String(30) 10000701 assigned by IOTPay
mchRefundNo y String(30) R1234567890abc assigned by merchant
loginName y String(12) jack_chen assigned by merchant,equals to jobNo
currency y String(3) CAD for now only CAD supported
refundAmount y Int 100 in cents
payOrderId y String(30) 100
sign y String(32) C380BEC2BFD727A4B6845133519F3AD6 Sign algorithm

# Response

name required type sample description
retCode y String SUCCESS or FAIL
retMsg y String
order n JSON if retCode=SUCCESS, order detailed info returned

# Void a transaction

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

Reqeust method:

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

# Parameters

name required type sample description
mchId y String(30) 10000701 assigned by IOTPay
mchRefundNo y String(30) R1234567890abc assigned by merchant
loginName y String(12) jack_chen assigned by merchant,equals to jobNo
currency y String(3) CAD for now only CAD supported
payOrderId y String(30) 100
sign y String(32) C380BEC2BFD727A4B6845133519F3AD6 Sign algorithm

# Response

name required type sample description
retCode y String SUCCESS or FAIL
retMsg y String
order n JSON if retCode=SUCCESS, order detailed info returned

# Query order

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

Reqeust method:

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

# Parameters

name required type sample description
mchId y String(30) 10000701 assigned by IOTPay
mchOrderNo y String(30) 1234567890abc assigned by Merchant
payOrderId y String(30) 1000008 assigned by IOTPay
sign y String(32) C380BEC2BFD727A4B6845133519F3AD6 Sign algorithm

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

# Response

name required type sample description
retCode y String SUCCESS or FAIL
retMsg y String
order n JSON if retCode=SUCCESS, order detailed info returned

# Query user binding status

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

Reqeust method:

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

# Parameters

name required type sample description
mchId y String(30) 10000701 assigned by IOTPay
customerId y String(30) R1234567890abc assigned by merchant
sign y String(32) C380BEC2BFD727A4B6845133519F3AD6 Sign algorithm

# Response

name required type sample description
retCode y String SUCCESS or FAIL if SUCCESS, merchant can use customerId to call cc_purchasewithtoken
retMsg y String

# Demo and source code

Simple purchase: demo Recurring purchase: demo source code download

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