Skip to main content

Same-terminal application integration(V2)

Constraints

Different aspects of each field are defined in this document according to the following conventions.

  • M: Required parameters
  • C: Required parameters when some conditions are met
  • O: Optional parameters
  • -: Not Present The common parameters is as follows:
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

Each transaction type has a message topic:

Key Name
ecrhub.pay.orderSubmit transaction
ecrhub.pay.queryQuery transaction
ecrhub.pay.reprintRe-print transaction
ecrhub.pay.batch.closeBatch close
ecrhub.pay.tip.adjustmentTip adjustment

API List

1. Submit transaction

Message Topic

ecrhub.pay.order

Parameter list

Name Type Request Response Description
trans_typeStringMMTransaction type. Please refer to Transaction type.
merchant_order_noStringMMMerchant order number.This field is the refund request order number (distinct from the original transaction order number). No more than 32 alphanumeric characters.
orig_merchant_order_noStringCCOriginal merchant order number. Required if trans_type is Void, Refund, or Completion (2, 3, 6).
price_currencyStringOOPrice Currency, compliant with ISO-4217 standard, described with a three-character code.
order_amountStringMMOrder amount. Order amount in base currency units (e.g., 1.00 USD = one dollar).
tip_amountStringOOTip amount. This field represents the transaction tip amount. For example, 1 USD stands for one dollar, not one cent.
on_screen_tipbooleanOOWhether or not to enter tips on the CodePay Register page, default is false, when "trans_type=1, 3, 4", this parameter can be set.
cashback_amountStringOOCashback amount. Expressed in the quoted currency, for example, One USD stands for one dollar, not one cent.
pay_method_idStringOOPayment method id. Please Refer to Payment method

If the trans_type is 3, this parameter will not required.
pay_scenarioStringOOPayment scene, please refer to PayScenario .
card_network_typeStringOOBank card network, when this parameter is not required, the bank card transaction selects the network based on the type of card being read,please refer to Card Network Type.
attachStringO-Additional data.Allows merchants to submit additional data, which will be returned as is.
descriptionStringOODescription of ordered goods or services.A brief description of the goods or services purchased by the customer.
notify_urlStringO-Callback address for payment notification.Receive payment notifications from the CodePay gateway to call back the server address, and only when the transaction goes through the CodePay payment gateway will there be a callback.
expiresStringO-Order expires time, after the expires time is not allowed to be paid, unit: seconds.
confirm_on_terminalbooleanO-Do you need terminal confirmation before proceeding with payment operations? The default is false. When set to true, you need to confirm the order first, otherwise you will directly enter the card reading interface.
receipt_print_modeIntegerO-Receipt printing mode.0: No printing, default value;1: Print merchant copy;2: Print customer copy;3: Print merchant copy + customer.
required_terminal_authenticationbooleanO-When refund or void a transaction, does the store manager role need to authorize this operation on the terminal? default value: false.
on_screen_signaturebooleanO-This parameter controls the display logic of electronic signatures:
  • true: Display the electronic signature page and print the signature information on the purchase order
  • false: The electronic signature page will not be displayed, but the signature area needs to be printed on the purchase order
But even if this parameter is set, CodePay Register still processes electronic signatures according to the following logic in the following situations:
  • Credit card network, APP does not display signature page, fixed on receipt to print signature column

  • Pin debit transactions do not require a signature, the APP does not display a signature page, and the receipt is not printed either
.
trans_noString-MTransaction number of CodePay. which uniquely identifies a transaction.
trans_statusString-MTransaction status, please refer to Transaction status.
trans_end_timestring-MTransaction completed time. If trans_status is 2, the returned data will include this parameters. Timezone: Local time zone, the time zone set by the payment terminal, Format: YYYY-MM-DD HH:mm:ss.
cashierstringO-The cashier's id number or name, the transaction will record this field for easy tip counting.
auth_codestring-CAuthentication code. Returned for card transactions.
ref_nostring-CRetrieval Reference Number .Returned for card transactions.
card_nostring-CCard PAN number, It has been masked according to PCI specification. example: 430277****5723. Returned for card transactions.
entry_modestring-CReturned for card transactions:1: Magnetic stripe swipe, 2: Contact chip, 3: Contactless, 4: Manual entry.
merchant_nostring-CThe merchant no.
merchant_namestring-CThe merchant name.
pay_channel_merchant_idstring-CMerchant id of the payment channel,channel example: TSYS,ELAVON.
pay_channel_terminal_idstring-CTerminal id of the payment channel,channel example: TSYS,ELAVON.

Sample code

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();
}
}
}

2. Query transaction

Message Topic

ecrhub.pay.query

Parameter list

Name Type Request Response Description
merchant_order_noStringMMMerchant order number of the original transaction
trans_typeString-MTransaction type. Please refer to Transaction type.
price_currencyString-MPrice Currency, compliant with ISO-4217 standard, described with a three-character code.
order_amountString-MOrder amount. This field represents the transaction ordered amount, For example, one USD stands for one dollar, not one cent.
tip_amountString-OTip amount. This field represents the transaction tip amount. For example, 1 USD stands for one dollar, not one cent.
cashback_amountString-OCashback amount. Expressed in the quoted currency, for example, One USD stands for one dollar, not one cent.
attachString-OAdditional data.Allows merchants to submit additional data, which will be returned as is.
pay_scenarioString-OPayment scene, If trans_status is 2, the returned data will include the following parameters, please refer to Please Refer to PayScenario .
pay_method_idString-OPayment method id. If trans_status is 2, the returned data will include the following parameters. Please Refer to Payment method

If the trans_type is 3, this parameter will not required.
card_network_typeString-OBank card network, when this parameter is not required, the bank card transaction selects the network based on the type of card being read,please refer to Card Network Type.
trans_noString-MTransaction number of CodePay. which uniquely identifies a transaction.
trans_statusString-MTransaction status, please refer to Transaction status.
trans_end_timestring-MTransaction completed time. If trans_status is 2, the returned data will include this parameters. Timezone: Local time zone, the time zone set by the payment terminal, Format: YYYY-MM-DD HH:mm:ss.
cashierstring--The cashier's id number or name, the transaction will record this field for easy tip counting.
auth_codestring-CAuthentication code. Returned for card transactions.
ref_nostring-CRetrieval Reference Number .Returned for card transactions.
card_nostring-CCard PAN number, Masked per PCI DSS (e.g., 430277****5723). Returned for card transactions.
entry_modestring-CReturned for card transactions:1 - Swipe magnetic stripe card;2 - Contact chip card; 3 - Contactless chip card;4 - Manual entry input.
merchant_nostring-CThe merchant no
merchant_namestring-CThe merchant name
pay_channel_merchant_idstring-CMerchant id of the payment channel,channel example: TSYS,ELAVON
pay_channel_terminal_idstring-CTerminal id of the payment channel,channel example: TSYS,ELAVON

Sample code

Intent intent = new Intent();
intent.setAction("com.CodePay.transaction.call");
intent.putExtra("version", "2.0");
intent.putExtra("topic", "ecrhub.pay.query");
intent.putExtra("app_id", "{YOUR_APP_ID}");
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("merchant_order_no","202202222222");
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();
}
}
}

3. Re-print transaction

Message Topic

ecrhub.pay.reprint

Parameter list

Name Type Request Response Description
merchant_order_noStringM-Merchant order number of the original transaction.

Sample code

Intent intent = new Intent();
intent.setAction("com.CodePay.transaction.call");
intent.putExtra("version", "2.0");
intent.putExtra("topic", "ecrhub.pay.reprint");
intent.putExtra("app_id", "{YOUR_APP_ID}");
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("trans_type", "22");
jsonObject.put("merchant_order_no","202202222222");
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");
}

4. Batch Close

Message Topic

ecrhub.pay.batch.close

Sample code

Intent intent = new Intent();
intent.setAction("com.CodePay.transaction.call");
intent.putExtra("version", "2.0");
intent.putExtra("topic", "ecrhub.pay.batch.close");
intent.putExtra("app_id", "{YOUR_APP_ID}");
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");
}

5. Tip Adjustment

Message Topic

ecrhub.pay.tip.adjustment

Parameter list

Name Type Request Response Description
merchant_order_noStringM-Merchant order number requiring tip adjustment transaction
tip_adjustment_amountStringM-Tip adjustment amount. For example, 1 USD stands for one dollar, not one cent.

Sample code

Intent intent = new Intent();
intent.setAction("com.CodePay.transaction.call");
intent.putExtra("version", "2.0");
intent.putExtra("topic", "ecrhub.pay.tip.adjustment");
intent.putExtra("app_id", "{YOUR_APP_ID}");
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("merchant_order_no", "202202222222");
jsonObject.put("tip_adjustment_amount", "10.00");
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");
}

Integration Demo

Get started with our example projects