Skip to main content

Difference between version V1 and version V2 of same-terminal application integration

1. Introduction

There are two versions of the same terminal integration method, version 1.1 is the first version, and version 2.0 is based on version 1.1, and unifies the fields of the same terminal integration and cross-terminal integration.

Version Release time Description
V1.12023-06-01Initial release with basic payment function interface
V2.02024-09-20Added Batch Close and Tip Adjustment, and implemented and cross-terminal integration field field unification

2. Detailed description of changes

V1.1 Message

Name Type Length Request Response Description
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

V2.0 Message

Key Parameter type Request Response Description
topicstringMMMessage topic identifier. Please refer to the topic Example: ecrhub.pay.order
versionstringMOThe API version. fixed value:2.0
app_idstringMOThe payment app id registered in Codepay Gateway, Please refer to the Payment gateway integration guide
biz_dataJSONObjectOOBusiness Data. each transaction type has own business data
response_codestring-OThe order payment status code returned by CodePay Register, 000 means the transaction was successful, other means the transaction failed.Please refer to Response code

response_msgString-CFailed transaction error message returned by CodePay Register

The version field is unchanged, the V2 version removes the transData field and adds a new biz_data field, and removes the transType field and puts the transType field inside the biz_data, the V2 version adds a new topic field, and replaces the V1 version's result and resultMsg with the response_code and response_msg.

3.Sample Code Comparison

 V1.1 Sale Code

```java
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();
}
}
}
```
V2.0 Sale Code

```java
Intent intent = new Intent();
intent.setAction("com.codepay.transaction.call");
intent.putExtra("version", "2.0");
intent.putExtra("topic", "ecrhub.pay.order");
intent.putExtra("app_id", "{YOUR_APP_ID}");
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("trans_type", "1"); // Sale transaction
jsonObject.put("merchant_order_no","202202222222");
jsonObject.put("pay_scenario","SWIPE_CARD"); //Card payment
jsonObject.put("card_type", "1") //Debit
jsonObject.put("order_amount","2.15");
intent.putExtra("biz_data", jsonObject.toString());
} catch (JSONException e) {
e.printStackTrace();
}
startActivityForResult(intent, 1);

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
String responseCode = data.getStringExtra("response_code");
String responseMsg = data.getStringExtra("response_msg");
String bizData = data.getStringExtra("biz_data");
if (responseCode.equals("000")){
try {
JSONObject jsonObject = new JSONObject(bizData);
String amount = jsonObject.getString("order_amount");
}catch(JSONException e){
e.printStackTrace();
}
}
}
```