跳到主要内容

同一终端内应用集成(V1)

1. 交易API

本文根据以下约定每个参数字段的必要性。

  • M:必要参数
  • C:在满足某些条件时,是必要参数
  • O:可选参数
  • -:不存在

1.1 消费(Sale)

销售交易指持卡人从商户处购买商品或服务时进行的支付操作。交易金额从持卡人账户中扣除,转入到商户账户。

1.1.1 报文参数

参数名 类型 长度 请求 响应 说明
versionStringMMAPI version, fixed value "1.1".
transTypeStringMMThe type code of Sale transaction, Fixed value 01.
appIdString18M-The payment app id registered in Codepay Gateway, Please refer to the Payment gateway integration guide.
transDataJSONMC
resultString-MRefer to appendix - Transaction result code.
resultMsgString-CFailure message

transData 字段

参数名 类型 长度 请求 响应 说明
businessOrderNoStringMMThe order number of the merchant's point of sale application or business system, it must be unique in its system.
paymentScenarioStringMM1 - card payment
2 - cash payment
3 - QR code payment, merchant present code and customers scan it
4 - QR code payment, customers present code and merchant scan it.
paymentMethodStringCMSpecify a Payment method. This field is mandatory only when "paymentScenario" is set to "3" or "4".
Please refer to Payment method.
cardTypeStringC-When "paymentScenario" field is set to "1", this field is mandatory.
1 - DEBIT_CARD
2 - CREDIT_CARD
3 - EBT_CARD
4 - GIFT_CARD.
amtString12MMOrder amount.
tipString12OOTip amount.
transDateString8-MTransaction date, format: YYYYMMDD.
transTimeString6-MTransaction time, format: HHMMSS.
operatorString4-Ooperator's work number.
authCodeString6-CAuthentication code. This field returns value when card payment transaction.
refNoString12-CRetrieval Reference Number .This field returns value when card payment transaction.
cardNoString19-CCard PAN number, It has been masked according to PCI specification. example: 430277****5723. This field returns value when card payment transaction.
entryModeString2-OThis field returns value when card payment transaction:
1 - Swipe magnetic stripe card
2 - Contact chip card
3 - Contactless chip card
4 - Manual entry input.
transactionIDString32-MThe transaction id of CodePay Gateway.
noteString128O-The order note information.
merchantIdString32-CThe merchant no.
payChannelMerchantIDString32-CMerchant id of the payment channel,channel example: TSYS,ELAVON.
payChannelTerminalIDString32-CTerminal id of the payment channel,channel example: TSYS,ELAVON.
merchantNameString128-CThe merchant name.
onScreenTipBoolean10-true: On-screen tip is required. false: On-screen tip is not required.
onScreenSignatureBoolean10-true: On-screen signature is required. false: On-screen signature is not required.
receiptPrintModeInteger1O-Receipt printing mode.0: No printing, default value;1: Print merchant copy;2: Print customer copy;3: Print merchant copy + customer.

1.1.2 示例代码

Intent intent = new Intent();
intent.setAction("com.codepay.transaction.call");
intent.putExtra("version", "1.0");
intent.putExtra("appId", "{YOUR_APP_ID}");
intent.putExtra("transType", "01"); // Sale transaction
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("businessOrderNo","202202222222");
jsonObject.put("paymentScenario","1"); //Card payment
jsonObject.put("cardType", "1") //Debit
jsonObject.put("amt","2.15");
intent.putExtra("transData", jsonObject.toString());
} catch (JSONException e) {
e.printStackTrace();
}
startActivityForResult(intent, 1);

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
String result = data.getStringExtra("result");
String resultMsg = data.getStringExtra("resultMsg");
String transData = data.getStringExtra("transData");
if (result.equals("00")){
try {
JSONObject jsonObject = new JSONObject(transData);
String amount = jsonObject.getString("amt");
}catch(JSONException e){
e.printStackTrace();
}
}
}

1.2 撤销(Void)

撤销交易通常是指在交易完成后的短时间内,商家因某种原因(例如商家错误、顾客改变主意等)需要取消交易。

  • 撤销通常必须在交易当日且在批结算之前进行。
  • 成功撤销后,原交易金额将退还给持卡人的账户,就像交易从未发生过一样。
  • 撤销通常需要原始交易凭证或相关信息才能进行操作。

1.2.1 Message

参数名 类型 长度 请求 响应 说明
versionStringMMAPI version, fixed value "1.1".
transTypeStringMMThe type code of Void transaction, Fixed value 02.
appIdString18M-The payment app id registered in Codepay Gateway, Please refer to the Payment gateway integration guide.
transDataJSONMC
resultString-MRefer to appendix - Transaction result code.
resultMsgString-CFailure message.

transData field

参数名 类型 长度 请求 响应 说明
originBusinessOrderNoStringMMThe order number of the original purchase transaction.
businessOrderNoStringMMThe order number of the merchant's point of sale application or business system, it must be unique in its system.
paymentMethodString-MPlease refer to Payment method.
amtString12-MOrder amount.
tipString12-OTip amount.
transDateString8-MTransaction date, format: YYYYMMDD.
transTimeString6-MTransaction time, format: HHMMSS.
operatorString4-Ooperator's work number.
authCodeString6-MAuthentication code. This field returns value when card payment transaction.
refNoString12-MRetrieval Reference Number .This field returns value when card payment transaction.
cardNoString19-MCard PAN number, It has been masked according to PCI specification. example: 430277****5723. This field returns value when card payment transaction.
entryModeString2-OThis field returns value when card payment transasction:
1 - Swipe magnetic stripe card
2 - Contact chip card
3 - Contactless chip card
4 - Manual entry input.
transactionIDString32-MThe transaction id of CodePay Gateway.
merchantIdString32-CThe merchant no.
payChannelMerchantIDString32-CMerchant id of the payment channel,channel example: TSYS,ELAVON.
payChannelTerminalIDString32-CTerminal id of the payment channel,channel example: TSYS,ELAVON.
merchantNameString128-CThe merchant name.
receiptPrintModeInteger1O-Receipt printing mode.0: No printing, default value;1: Print merchant copy;2: Print customer copy;3: Print merchant copy + customer.

1.2.2 示例代码

Intent intent = new Intent();
intent.setAction("com.codepay.transaction.call");
intent.putExtra("version", "1.0");
intent.putExtra("appId", "{YOUR_APP_ID}");
intent.putExtra("transType", "02"); // Void transaction
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("originBusinessOrderNo","202202222222");
jsonObject.put("businessOrderNo","202202222233");
intent.putExtra("transData", jsonObject.toString());
} catch (JSONException e) {
e.printStackTrace();
}
startActivityForResult(intent, 1);

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
String result = data.getStringExtra("result");
String resultMsg = data.getStringExtra("resultMsg");
String transData = data.getStringExtra("transData");
if (result.equals("00")){
try {
JSONObject jsonObject = new JSONObject(transData);
String amount = jsonObject.getString("amt");
}catch(JSONException e){
e.printStackTrace();
}
}
}

1.3 退款(Refund)

退款交易是指持卡人因某种原因(例如物品有问题、对服务不满意等)需要退回物品或取消服务,在交易清算后要求将支付的金额退回到信用卡账户的过程。

  • 退款可能发生在交易当天,也可能在几天或更久之后。
  • 退款通常需要持卡人提供购买凭证和退款原因,商家审核后退款将适当金额退回到持卡人的信用卡账户。

1.3.1 报文参数

参数名 类型 长度 请求 响应 说明
versionStringMMAPI version, fixed value "1.1" .
transTypeStringMMThe type code of Refund transaction, Fixed value 03.
appIdString18M-The payment app id registered in Codepay Gateway, Please refer to the Payment gateway integration guide.
transDataJSONMC
resultString-MRefer to appendix - Transaction result code.
resultMsgString-CFailure message.

transData 字段

参数名 类型 长度 请求 响应 说明
originBusinessOrderNoStringCCThe order number of the original Sale or Completion transaction.
businessOrderNoStringMMThe order number of the merchant's point of sale application or business system, it must be unique in its system.
paymentScenarioStringMM1 - card payment
2 - cash payment
3 - QR code payment, merchant present code and customers scan it
4 - QR code payment, customers present code and merchant scan it.
paymentMethodString-MPlease refer to Payment method.
cardTypeStringC-When "paymentScenario" field is set to "1" and originBusinessOrderNo is empty, this field is mandatory.
1 - DEBIT_CARD
2 - CREDIT_CARD
3 - EBT_CARD
4 - GIFT_CARD.
amtString12MMRefund amount.
tipString12OOTip amount.
transDateString8-MTransaction date, format: YYYYMMDD.
transTimeString6-MTransaction time, format: HHMMSS.
operatorString4-Ooperator's work number.
authCodeString6-CAuthentication code. This field returns value when card payment transaction.
refNoString12-CRetrieval Reference Number .This field returns value when card payment transaction.
cardNoString19-CCard PAN number, It has been masked according to PCI specification. example: 430277****5723. This field returns value when card payment transaction.
entryModeString2-OThis field returns value when card payment transaction:
1 - Swipe magnetic stripe card
2 - Contact chip card
3 - Contactless chip card
4 - Manual entry input.
transactionIDString32-MThe transaction id of CodePay Gateway.
merchantIdString32-CThe merchant no.
payChannelMerchantIDString32-CMerchant id of the payment channel,channel example: TSYS,ELAVON.
payChannelTerminalIDString32-CTerminal id of the payment channel,channel example: TSYS,ELAVON.
merchantNameString128-CThe merchant name.
receiptPrintModeInteger1O-Receipt printing mode.0: No printing, default value;1: Print merchant copy;2: Print customer copy;3: Print merchant copy + customer.

1.3.2 示例代码

Intent intent = new Intent();
intent.setAction("com.codepay.transaction.call");
intent.putExtra("version", "1.0");
intent.putExtra("appId", "{YOUR_APP_ID}");
intent.putExtra("transType", "03"); // Refund transaction
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("originBusinessOrderNo","202202222222");
jsonObject.put("businessOrderNo","202202222233");
jsonObject.put("paymentScenario","1");//Card payment
jsonObject.put("amt","1.2");
intent.putExtra("transData", jsonObject.toString());
} catch (JSONException e) {
e.printStackTrace();
}
startActivityForResult(intent, 1);

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
String result = data.getStringExtra("result");
String resultMsg = data.getStringExtra("resultMsg");
String transData = data.getStringExtra("transData");
if (result.equals("00")){
try {
JSONObject jsonObject = new JSONObject(transData);
String amount = jsonObject.getString("amt");
}catch(JSONException e){
e.printStackTrace();
}
}
}

1.4 授权(Authorization)

授权交易是一种卡片交易授权类型,商家可以通过该授权确保交易金额在客户账户中冻结或保留,直到交易完成。 在授权阶段,商家向客户的银行请求特定金额的授权,如果客户的账户中有足够的可用余额或信用额度,则会暂时冻结该金额。这意味着该金额尚未实际扣除,但客户在此期间不能将资金用于其他购买。 授权通常用于最终交易金额不确定的情况,例如住宿服务、租赁服务、无人值守自助服务等。

1.4.1 报文参数

参数名 类型 长度 请求 响应 说明
versionStringMMAPI version, fixed value "1.1".
transTypeStringMMThe type code of Authorizaion transaction, Fixed value 04.
appIdString18M-The payment app id registered in Codepay Gateway, Please refer to the Payment gateway integration guide.
transDataJSONMC
resultString-MRefer to appendix - Transaction result code.
resultMsgString-CFailure message.

transData 字段

参数名 类型 长度 请求 响应 说明
businessOrderNoStringMMThe order number of the merchant's point of sale application or business system, it must be unique in its system.
paymentMethodString-MPlease refer to Payment method.
cardTypeStringM-1 -- DEBIT_CARD
2 -- CREDIT_CARD
3 -- EBT_CARD
4 -- GIFT_CARD.
amtString12MMOrder amount.
transDateString8-MTransaction date, format: YYYYMMDD.
transTimeString6-MTransaction time, format: HHMMSS.
operatorString4-Ooperator's work number
authCodeString6-MAuthentication code. This field returns value when card payment transaction.
refNoString12-MRetrieval Reference Number .This field returns value when card payment transaction.
cardNoString19-MCard PAN number, It has been masked according to PCI specification. example: 430277****5723. This field returns value when card payment transaction.
entryModeString2-OThis field returns value when card payment transaction:
1 - Swipe magnetic stripe card
2 - Contact chip card
3 - Contactless chip card
4 - Manual entry input.
transactionIDString32-MThe transaction id of CodePay Gateway.
merchantIdString32-CThe merchant no.
payChannelMerchantIDString32-CMerchant id of the payment channel,channel example: TSYS,ELAVON.
payChannelTerminalIDString32-CTerminal id of the payment channel,channel example: TSYS,ELAVON.
merchantNameString128-CThe merchant name.
onScreenSignatureBoolean10-true: On-screen signature is required. false: On-screen signature is not required.
receiptPrintModeInteger1O-Receipt printing mode.0: No printing, default value;1: Print merchant copy;2: Print customer copy;3: Print merchant copy + customer.

1.4.2 示例代码

Intent intent = new Intent();
intent.setAction("com.codepay.transaction.call");
intent.putExtra("version", "1.0");
intent.putExtra("appId", "{YOUR_APP_ID}");
intent.putExtra("transType", "04"); // Authorization transaction
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("businessOrderNo","202202222222");
jsonObject.put("cardType","1");//DEBIT_CARD
jsonObject.put("amt","1.2");
intent.putExtra("transData", jsonObject.toString());
} catch (JSONException e) {
e.printStackTrace();
}
startActivityForResult(intent, 1);

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
String result = data.getStringExtra("result");
String resultMsg = data.getStringExtra("resultMsg");
String transData = data.getStringExtra("transData");
if (result.equals("00")){
try {
JSONObject jsonObject = new JSONObject(transData);
String amount = jsonObject.getString("amt");
}catch(JSONException e){
e.printStackTrace();
}
}
}

1.5 完成(Completion)

完成交易是指在授权后,当服务或商品的实际消费完成并最终确定金额时,请求商家正式从客户的账户中扣除先前授权的金额的过程。这一步是对授权的后续行动,确保商家收到付款。 例如,当顾客在住宿结束时结账离开酒店时,酒店将比较先前授权的金额与实际花费的金额;如果实际花费的金额较高,酒店将请求额外授权以弥补差额;如果实际花费的金额较低,则只会扣除实际花费的金额,授权金额的余额将退回到客户的账户中。

1.5.1 报文参数

参数名 类型 长度 请求 响应 说明
versionStringMMAPI version, fixed value "1.1".
transTypeStringMMThe type code of Authorizaion Compleation transaction, Fixed value 06.
appIdString18M-The payment app id registered in Codepay Gateway, Please refer to the Payment gateway integration guide.
transDataJSONMC
resultString-MRefer to appendix - Transaction result code.
resultMsgString-CFailure message.

transData 字段

参数名 类型 长度 请求 响应 说明
originBusinessOrderNoString12M-The order number of the original purchase transaction.
businessOrderNoStringMMThe order number of the merchant's point of sale application or business system, it must be unique in its system.
paymentMethodString-MPlease refer to Payment method.
amtString12MMAuthorization confirmation amount, final payment amount, and any excess amount during authorization will be refunded to the customer's account.
transDateString8-MTransaction date, format: YYYYMMDD.
transTimeString6-MTransaction time, format: HHMMSS.
operatorString4-Ooperator's work number.
authCodeString6-MAuthentication code. This field returns value when card payment transaction.
refNoString12-MRetrieval Reference Number .This field returns value when card payment transaction.
cardNoString19-MCard PAN number, It has been masked according to PCI specification. example: 430277****5723. This field returns value when card payment transaction.
entryModeString2-OThis field returns value when card payment transaction:
1 - Swipe magnetic stripe card
2 - Contact chip card
3 - Contactless chip card
4 - Manual entry input.
transactionIDString32-MThe transaction id of CodePay Gateway.
merchantIdString32-CThe merchant no.
payChannelMerchantIDString32-CMerchant id of the payment channel,channel example: TSYS,ELAVON.
payChannelTerminalIDString32-CTerminal id of the payment channel,channel example: TSYS,ELAVON.
merchantNameString128-CThe merchant name.
receiptPrintModeInteger1O-Receipt printing mode.0: No printing, default value;1: Print merchant copy;2: Print customer copy;3: Print merchant copy + customer.

1.5.2 示例代码

Intent intent = new Intent();
intent.setAction("com.codepay.transaction.call");
intent.putExtra("version", "1.0");
intent.putExtra("appId", "{YOUR_APP_ID}");
intent.putExtra("transType", "06"); // Authorization Completion transaction
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("originBusinessOrderNo","202202222233");
jsonObject.put("businessOrderNo","202202222222");
jsonObject.put("amt","1.2");
intent.putExtra("transData", jsonObject.toString());
} catch (JSONException e) {
e.printStackTrace();
}
startActivityForResult(intent, 1);

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
String result = data.getStringExtra("result");
String resultMsg = data.getStringExtra("resultMsg");
String transData = data.getStringExtra("transData");
if (result.equals("00")){
try {
JSONObject jsonObject = new JSONObject(transData);
String amount = jsonObject.getString("amt");
}catch(JSONException e){
e.printStackTrace();
}
}
}

1.6 返现(Sale with Cashback)

“消费返现”通常用于银行卡交易,指的是客户在使用借记卡支付购买商品或服务的费用时,除了商品或服务的成本外,还可以从银行账户中请求额外的现金。这项服务通常可以在零售店或超市的收银台找到,客户可以在结账时选择此选项,从而避免去银行或自动取款机提取现金的麻烦。

例如,如果你在杂货店花费 50 美元并想要 20 美元现金,你可以请求进行 70 美元的交易,其中 50 美元支付给超市,剩下的 20 美元以现金形式退还给你。此交易可能会在你的银行账户记录中显示为“消费返现”,总额为 70 美元。

1.6.1 报文参数

参数名 类型 长度 请求 响应 说明
versionStringMMAPI version, fixed value "1.1".
transTypeStringMMThe type code of Cashback transaction, Fixed value 11.
appIdString18M-The payment app id registered in Codepay Gateway, Please refer to the Payment gateway integration guide.
transDataJSONMC
resultString-MRefer to appendix - Transaction result code.
resultMsgString-CFailure message.

transData 字段

参数名 类型 长度 请求 响应 说明
businessOrderNoStringMMThe order number of the merchant's point of sale application or business system, it must be unique in its system.
paymentMethodString-MPlease refer to Payment method.
cardTypeStringM-1 -- DEBIT_CARD
2 -- CREDIT_CARD
3 -- EBT_CARD
4 -- GIFT_CARD.
amtString12MMOrder amount.
cashAmountString12MMCashback amount.
tipString12OOTip amount.
transDateString8-MTransaction date, format: YYYYMMDD.
transTimeString6-MTransaction time, format: HHMMSS.
operatorString4-Ooperator's work number.
authCodeString6-MAuthentication code. This field returns value when card payment transaction.
refNoString12-MRetrieval Reference Number .This field returns value when card payment transaction.
cardNoString19-MCard PAN number, It has been masked according to PCI specification. example: 430277****5723. This field returns value when card payment transasction.
entryModeString2-OThis field returns value when card payment transaction:
1 - Swipe magnetic stripe card
2 - Contact chip card
3 - Contactless chip card
4 - Manual entry input
transactionIDString32-MThe transaction id of CodePay Gateway.
merchantIdString32-CThe merchant no.
payChannelMerchantIDString32-CMerchant id of the payment channel,channel example: TSYS,ELAVON.
payChannelTerminalIDString32-CTerminal id of the payment channel,channel example: TSYS,ELAVON.
merchantNameString128-CThe merchant name.
onScreenTipBoolean10-true: On-screen tip is required. false: On-screen tip is not required.
onScreenSignatureBoolean10-true: On-screen signature is required. false: On-screen signature is not required.
receiptPrintModeInteger1O-Receipt printing mode.0: No printing, default value;1: Print merchant copy;2: Print customer copy;3: Print merchant copy + customer.

1.6.2 示例代码

Intent intent = new Intent();
intent.setAction("com.codepay.transaction.call");
intent.putExtra("version", "1.0");
intent.putExtra("appId", "{YOUR_APP_ID}");
intent.putExtra("transType", "11"); // Cashback transaction
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("businessOrderNo","202202222222");
jsonObject.put("cardType","1");//Debit
jsonObject.put("amt","10.2");
jsonObject.put("cashAmount","1.2");
intent.putExtra("transData", jsonObject.toString());
} catch (JSONException e) {
e.printStackTrace();
}
startActivityForResult(intent, 1);

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
String result = data.getStringExtra("result");
String resultMsg = data.getStringExtra("resultMsg");
String transData = data.getStringExtra("transData");
if (result.equals("00")){
try {
JSONObject jsonObject = new JSONObject(transData);
String amount = jsonObject.getString("amt");
}catch(JSONException e){
e.printStackTrace();
}
}
}

1.7 查询(Query)

查询指定交易的详情

1.7.1 报文参数

参数名 类型 长度 请求 响应 说明
versionStringMMAPI version, fixed value "1.1".
transTypeStringMMThe type code of Query transaction, Fixed value 21.
appIdString18M-The payment app id registered in Codepay Gateway, Please refer to the Payment gateway integration guide.
transDataJSONMC
resultString-MRefer to appendix - Transaction result code.
resultMsgString-CFailure message.

transData 字段

参数名 类型 长度 请求 响应 说明
businessOrderNoStringMMMerchant order number of the original transaction.
paymentScenarioString-M1 - card payment
2 - cash payment
3 - QR code payment, merchant present code and customers scan it
4 - QR code payment, customers present code and merchant scan it.
paymentMethodString-MSpecify a Payment method. This field is mandatory only when "paymentScenario" is set to "3" or "4".
Please refer to Payment method.
amtString12-MOrder amount.
cashAmountString12-OCashback amount.
tipString12-OTip amount.
transDateString8-MTransaction date, format: YYYYMMDD.
transTimeString6-MTransaction time, format: HHMMSS.
operatorString4-Ooperator's work number.
authCodeString6-CAuthentication code. This field returns value when card payment transaction.
transTypeString2-MType of transaction queried
refNoString12-CRetrieval Reference Number .This field returns value when card payment transaction.
cardNoString19-CCard PAN number, It has been masked according to PCI specification. example: 430277****5723. This field returns value when card payment transaction.
entryModeString2-OThis field returns value when card payment transaction:
1 - Swipe magnetic stripe card
2 - Contact chip card
3 - Contactless chip card
4 - Manual entry input.
transactionIDString32-MThe transaction id of CodePay Gateway.
merchantIdString32-CThe merchant no.
payChannelMerchantIDString32-CMerchant id of the payment channel,channel example: TSYS,ELAVON.
payChannelTerminalIDString32-CTerminal id of the payment channel,channel example: TSYS,ELAVON.
merchantNameString128-CThe merchant name.

1.7.2 示例代码

Intent intent = new Intent();
intent.setAction("com.codepay.transaction.call");
intent.putExtra("version", "1.0");
intent.putExtra("appId", "{YOUR_APP_ID}");
intent.putExtra("transType", "21");
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("businessOrderNo","202202222222");
intent.putExtra("transData", jsonObject.toString());
} catch (JSONException e) {
e.printStackTrace();
}
startActivityForResult(intent, 1);

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
String result = data.getStringExtra("result");
String resultMsg = data.getStringExtra("resultMsg");
String transData = data.getStringExtra("transData");
if (result.equals("00")){
try {
JSONObject jsonObject = new JSONObject(transData);
String amount = jsonObject.getString("amt");
}catch(JSONException e){
e.printStackTrace();
}
}
}

1.8 重打印(Reprint)

重打印指定交易的收据。收据上会标记为“重打印”。

1.8.1 报文参数

参数名 类型 长度 请求 响应 说明
versionStringMMAPI version, fixed value "1.1".
transTypeStringMMThe type code of Reprint transaction, Fixed value 22.
appIdString18M-The payment app id registered in Codepay Gateway, Please refer to the Payment gateway integration guide.
transDataJSONMC
resultString-MRefer to appendix - Transaction result code.
resultMsgString-CFailure message.

transData 字段

参数名 类型 长度 请求 响应 说明
businessOrderNoStringM-Merchant order number of the original transaction.

1.8.2 示例代码

Intent intent = new Intent();
intent.setAction("com.codepay.transaction.call");
intent.putExtra("version", "1.0");
intent.putExtra("appId", "{YOUR_APP_ID}");
intent.putExtra("transType", "22");
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("businessOrderNo","202202222222");
intent.putExtra("transData", jsonObject.toString());
} catch (JSONException e) {
e.printStackTrace();
}
startActivityForResult(intent, 1);

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
String result = data.getStringExtra("result");
String resultMsg = data.getStringExtra("resultMsg");
String transData = data.getStringExtra("transData");
if (result.equals("00")){
try {
JSONObject jsonObject = new JSONObject(transData);
String amount = jsonObject.getString("amt");
}catch(JSONException e){
e.printStackTrace();
}
}
}

1.9 批结算

终端调用批结算功能,做自动结算。

1.9.1 报文参数

参数名 类型 长度 请求 响应 说明
versionStringMMAPI 版本,固定值“1.1”
transTypeStringMM重打印交易的类型代码,固定值 22
appIdString18M-在 Codepay 网关注册的支付应用程序 ID,请参阅 支付网关集成指南
transDataJSONMC
resultString-M请参阅附录 - 交易结果代码
resultMsgString-C结果消息

1.9.2 示例代码

Intent intent = new Intent();
intent.setAction("com.codepay.transaction.call");
intent.putExtra("version", "1.0");
intent.putExtra("appId", "{YOUR_APP_ID}");
intent.putExtra("transType", "23");

startActivityForResult(intent, 1);

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
String result = data.getStringExtra("result");
String resultMsg = data.getStringExtra("resultMsg");
}

1.10 小费调整

指定交易的小费调整功能

1.10.1 报文参数

参数名 类型 长度 请求 响应 说明
versionStringMMAPI version, fixed value "1.1".
transTypeStringMMThe type code of Reprint transaction, Fixed value 24.
appIdString18M-The payment app id registered in Codepay Gateway, Please refer to the Payment gateway integration guide.
transDataJSONM-
resultString-MRefer to appendix - Transaction result code.
resultMsgString-CFailure message.

transData 字段

参数名 类型 长度 请求 响应 说明
businessOrderNoStringM-Merchant order number requiring tip adjustment.
tipAdjustmentAmountString12M-Tip adjustment amount.

1.10.2 示例代码

Intent intent = new Intent();
intent.setAction("com.codepay.transaction.call");
intent.putExtra("version", "1.0");
intent.putExtra("appId", "{YOUR_APP_ID}");
intent.putExtra("transType", "24");
try {
jsonObject.put("businessOrderNo","202202222222");
jsonObject.put("tipAdjustmentAmount","10.00");
intent.putExtra("transData", jsonObject.toString());
} catch (JSONException e) {
e.printStackTrace();
}

startActivityForResult(intent, 1);

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
String result = data.getStringExtra("result");
String resultMsg = data.getStringExtra("resultMsg");
}

2. 附录

2.1 交易结果码

类别 结果码 说明
成功00交易已批准
终端交易内核异常A003卡片中没有 EMV 应用程序
A008交易已被拒绝
A020IC 命令失败
A036二次GAC 失败
A040初始化SDK失败
卡片识别异常C000读卡异常
C001刷卡失败
C004读卡失败
C006卡片冲突
C008IC 卡不允许先刷卡
C009读卡超时
C011找不到跟踪键
C014磁条卡模式不支持非接触式交易
密码键盘异常G000PinPad 异常
G003输入取消
G004输入超时
G005输入失败
包处理异常H010Mac 错误
H011签名验证失败
网络异常J000网络异常
J002网络连接超时
J003网络连接失败
J004发送数据失败
J005读取数据失败
J006读取数据超时
交易异常K018必须使用与原始交易的卡
K019无待结算数据
K026操作员手动取消
K027交易超时
K029电池电量低!
三方APP调用过程异常M002参数错误
M003无效金额
M007此功能暂不支持
M008调用版本不正确
M009无效的应用程序调用
M010找不到原始交易
M011无法作废原始交易
M013无法退款原始交易
M014无法完成原始交易
服务端异常N002网关服务请求异常
N003收单服务请求异常
用户端异常P001账户或密码错误,请重试
P002账户已锁定,无法登录
初始化过程异常Q001系统时间错误,请连接网络获取自动时间!
Q002AID 未配置
Q003支付功能未配置。请联系技术支持。
其它异常Z000出现异常。请联系技术支持。