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.1 | 2023-06-01 | Initial release with basic payment function interface |
V2.0 | 2024-09-20 | Added 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 |
---|---|---|---|---|---|
version | String | M | M | API version, fixed value "1.1" | |
transType | String | M | M | The type code of Sale transaction, Fixed value 01 | |
appId | String | 18 | M | - | The payment app id registered in Codepay Gateway, Please refer to the Payment gateway integration guide |
transData | JSON | M | C | ||
result | String | - | M | Refer to appendix - Transaction result code | |
resultMsg | String | - | C | Failure message |
V2.0 Message
Key | Parameter type | Request | Response | Description |
---|---|---|---|---|
topic | string | M | M | Message topic identifier. Please refer to the topic Example: ecrhub.pay.order |
version | string | M | O | The API version. fixed value:2.0 |
app_id | string | M | O | The payment app id registered in Codepay Gateway, Please refer to the Payment gateway integration guide |
biz_data | JSONObject | O | O | Business Data. each transaction type has own business data |
response_code | string | - | O | The 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_msg | String | - | C | Failed 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();
}
}
}
```