|
|
|
@ -9,12 +9,18 @@ import com.cst.im30.common.Constants;
|
|
|
|
|
import com.cst.im30.model.CancelRequest; |
|
|
|
|
import com.cst.im30.model.CancelResponse; |
|
|
|
|
import com.cst.im30.model.EventLogDetailed; |
|
|
|
|
import com.cst.im30.model.InquiryRequest; |
|
|
|
|
import com.cst.im30.model.InquiryResponse; |
|
|
|
|
import com.cst.im30.model.PreAuthRequest; |
|
|
|
|
import com.cst.im30.model.PreAuthResponse; |
|
|
|
|
import com.cst.im30.model.SaleCompletionRequest; |
|
|
|
|
import com.cst.im30.model.SaleCompletionResponse; |
|
|
|
|
import com.cst.im30.model.SaleRequest; |
|
|
|
|
import com.cst.im30.model.SaleResponse; |
|
|
|
|
import com.cst.im30.model.SetDateTimeRequest; |
|
|
|
|
import com.cst.im30.model.SetDateTimeResponse; |
|
|
|
|
import com.cst.im30.model.SettlementRequest; |
|
|
|
|
import com.cst.im30.model.SettlementResponse; |
|
|
|
|
import com.cst.im30.model.VoidRequest; |
|
|
|
|
import com.cst.im30.model.VoidResponse; |
|
|
|
|
import com.cst.im30.utility.Logger; |
|
|
|
@ -50,6 +56,17 @@ public class PaymentHandler {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void handlePayFunctionInquiry(EventLogDetailed eventLogDetailed) { |
|
|
|
|
InquiryRequest request = PaymentUtils.createInquiryRequest(eventLogDetailed); |
|
|
|
|
if (PaymentUtils.validateInquiryRequest(request)) { |
|
|
|
|
MainApplication.getInstance().logPayment("[INQUIRY]" + " Confirmation Number:" + eventLogDetailed.getConfirmationNumber() + " Reference Number:" + eventLogDetailed.getReferenceNumber() + " Amount:" + eventLogDetailed.getPayableAmount() + " Remark:" + eventLogDetailed.getRemark()); |
|
|
|
|
initInquiry(request); |
|
|
|
|
} else { |
|
|
|
|
Toast.makeText(context, "Invalid Inquiry Request", Toast.LENGTH_SHORT).show(); |
|
|
|
|
Logger.logW("Invalid Inquiry Request: " + request.toString()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void handlePayFunctionCancel() { |
|
|
|
|
CancelRequest request = new CancelRequest(); |
|
|
|
|
initCancel(request); |
|
|
|
@ -77,6 +94,28 @@ public class PaymentHandler {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void handlePayFunctionSettlement(EventLogDetailed eventLogDetailed) { |
|
|
|
|
SettlementRequest request = PaymentUtils.createSettlementRequest(eventLogDetailed); |
|
|
|
|
if (PaymentUtils.validateSettlementRequest(request)) { |
|
|
|
|
MainApplication.getInstance().logPayment("[SETTLEMENT]" + " Confirmation Number:" + eventLogDetailed.getConfirmationNumber() + " Reference Number:" + eventLogDetailed.getReferenceNumber() + " Amount:" + eventLogDetailed.getPayableAmount() + " Remark:" + eventLogDetailed.getRemark()); |
|
|
|
|
initSettlement(request); |
|
|
|
|
} else { |
|
|
|
|
Toast.makeText(context, "Invalid Settlement Request", Toast.LENGTH_SHORT).show(); |
|
|
|
|
Logger.logW("Invalid Settlement Request: " + request.toString()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void handlePayFunctionSetDateTime(EventLogDetailed eventLogDetailed) { |
|
|
|
|
SetDateTimeRequest request = PaymentUtils.createSetDateTimeRequest(eventLogDetailed); |
|
|
|
|
if (PaymentUtils.validateSetDateTimeRequest(request)) { |
|
|
|
|
MainApplication.getInstance().logPayment("[SET DATE TIME]" + " Confirmation Number:" + eventLogDetailed.getConfirmationNumber() + " Reference Number:" + eventLogDetailed.getReferenceNumber() + " Amount:" + eventLogDetailed.getPayableAmount() + " Remark:" + eventLogDetailed.getRemark()); |
|
|
|
|
initSetDateTime(request); |
|
|
|
|
} else { |
|
|
|
|
Toast.makeText(context, "Invalid Set Date Time Request", Toast.LENGTH_SHORT).show(); |
|
|
|
|
Logger.logW("Invalid Set Date Time Request: " + request.toString()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void initSalePayment(SaleRequest request) { |
|
|
|
|
Logger.logD("Direct Payment: " + request.toString()); |
|
|
|
|
MainApplication.getInstance().logPayment(request.toString()); |
|
|
|
@ -137,6 +176,22 @@ public class PaymentHandler {
|
|
|
|
|
app2app(extra); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void initInquiry(InquiryRequest request) { |
|
|
|
|
Logger.logD(request.toString()); |
|
|
|
|
MainApplication.getInstance().logPayment(request.toString()); |
|
|
|
|
|
|
|
|
|
Bundle extra = new Bundle(); |
|
|
|
|
extra.putString("pay_function", request.getPayFunction()); |
|
|
|
|
extra.putString("pay_amount", request.getPayAmount()); |
|
|
|
|
extra.putString("pay_print_receipt_id", request.getPayPrintReceiptId()); |
|
|
|
|
extra.putString("pay_trace_no", request.getPayTraceNo()); |
|
|
|
|
extra.putString("pay_invoice_no", request.getPayInvoiceNo()); |
|
|
|
|
|
|
|
|
|
MainApplication.currentInquiryRequest = request; |
|
|
|
|
|
|
|
|
|
app2app(extra); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void initPreAuth(PreAuthRequest request) { |
|
|
|
|
Logger.logD(request.toString()); |
|
|
|
|
MainApplication.getInstance().logPayment(request.toString()); |
|
|
|
@ -180,6 +235,39 @@ public class PaymentHandler {
|
|
|
|
|
app2app(extra); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void initSettlement(SettlementRequest request) { |
|
|
|
|
Logger.logD(request.toString()); |
|
|
|
|
MainApplication.getInstance().logPayment(request.toString()); |
|
|
|
|
|
|
|
|
|
Bundle extra = new Bundle(); |
|
|
|
|
extra.putString("pay_function", request.getPayFunction()); |
|
|
|
|
|
|
|
|
|
String payPosTxnId = request.getPayPosTxnId(); |
|
|
|
|
if (payPosTxnId != null && !payPosTxnId.isEmpty()) { |
|
|
|
|
extra.putString("pay_pos_txn_id", payPosTxnId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
extra.putString("pay_print_receipt_id", request.getPayPrintReceiptId()); |
|
|
|
|
|
|
|
|
|
MainApplication.currentSettlementRequest = request; |
|
|
|
|
|
|
|
|
|
app2app(extra); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void initSetDateTime(SetDateTimeRequest request) { |
|
|
|
|
Logger.logD(request.toString()); |
|
|
|
|
MainApplication.getInstance().logPayment(request.toString()); |
|
|
|
|
|
|
|
|
|
Bundle extra = new Bundle(); |
|
|
|
|
extra.putString("pay_function", request.getPayFunction()); |
|
|
|
|
extra.putString("pay_pos_txn_date", request.getPayPosTxnDate()); |
|
|
|
|
extra.putString("pay_pos_txn_time", request.getPayPosTxnTime()); |
|
|
|
|
|
|
|
|
|
MainApplication.currentSetDateTimeRequest = request; |
|
|
|
|
|
|
|
|
|
app2app(extra); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void app2app(Bundle bundle) { |
|
|
|
|
Intent intent = new Intent(Constants.APP_2_APP); |
|
|
|
|
intent.putExtras(bundle); |
|
|
|
@ -271,6 +359,37 @@ public class PaymentHandler {
|
|
|
|
|
MainApplication.status = response.getPayRespErrorDesc(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void handlePayFunctionInquiryResponse(Bundle extra) { |
|
|
|
|
InquiryResponse response = new InquiryResponse(); |
|
|
|
|
|
|
|
|
|
response.setPayAmount(extra.getString("pay_amount")); |
|
|
|
|
response.setPayFunction(extra.getString("pay_function")); |
|
|
|
|
response.setPayPrintReceiptId(extra.getString("pay_print_receipt_id")); |
|
|
|
|
response.setPayRespTxnDate(extra.getString("pay_resp_txn_date")); |
|
|
|
|
response.setPayRespTxnTime(extra.getString("pay_resp_txn_time")); |
|
|
|
|
response.setPayRespInvoiceNo(extra.getString("pay_resp_invoice_no")); |
|
|
|
|
response.setPayRespTraceNo(extra.getString("pay_resp_trace_no")); |
|
|
|
|
response.setPayRespBatchNo(extra.getString("pay_resp_batch_no")); |
|
|
|
|
response.setPayRespScheme(extra.getString("pay_resp_scheme")); |
|
|
|
|
response.setPayRespTid(extra.getString("pay_resp_tid")); |
|
|
|
|
response.setPayRespMid(extra.getString("pay_resp_mid")); |
|
|
|
|
response.setPayRespQrTxnId(extra.getString("pay_resp_qr_txn_id")); |
|
|
|
|
response.setPayRespQrWalletId(extra.getString("pay_resp_qr_wallet_id")); |
|
|
|
|
response.setPayRespCustomerId(extra.getString("pay_resp_customer_id")); |
|
|
|
|
response.setPayRespCode(extra.getString("pay_resp_code")); |
|
|
|
|
response.setPayRespErrorDesc(extra.getString("pay_resp_error_desc")); |
|
|
|
|
response.setPayRespMerchInfo(extra.getString("pay_resp_merch_info")); |
|
|
|
|
response.setPayRespIssuerId(extra.getString("pay_resp_issuer_id")); |
|
|
|
|
|
|
|
|
|
Logger.logD(response.toString()); |
|
|
|
|
MainApplication.getInstance().logPayment(response.toString()); |
|
|
|
|
|
|
|
|
|
MainApplication.currentInquiryResponse = response; |
|
|
|
|
|
|
|
|
|
MainApplication.code = response.getPayRespCode(); |
|
|
|
|
MainApplication.status = response.getPayRespErrorDesc(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void handlePayFunctionCancelResponse(Bundle extra) { |
|
|
|
|
CancelResponse response = new CancelResponse(); |
|
|
|
|
|
|
|
|
@ -360,4 +479,44 @@ public class PaymentHandler {
|
|
|
|
|
MainApplication.currentSaleCompletionResponse = response; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void handlePayFunctionSettlementResponse(Bundle extra) { |
|
|
|
|
SettlementResponse response = new SettlementResponse(); |
|
|
|
|
|
|
|
|
|
response.setPayFunction(extra.getString("pay_function")); |
|
|
|
|
response.setPayPrintReceiptId(extra.getString("pay_print_receipt_id")); |
|
|
|
|
response.setPayRespTxnDate(extra.getString("pay_resp_txn_date")); |
|
|
|
|
response.setPayRespTxnTime(extra.getString("pay_resp_txn_time")); |
|
|
|
|
response.setPayRespBatchNo(extra.getString("pay_resp_batch_no")); |
|
|
|
|
response.setPayRespTid(extra.getString("pay_resp_tid")); |
|
|
|
|
response.setPayRespMid(extra.getString("pay_resp_mid")); |
|
|
|
|
response.setPayRespCode(extra.getString("pay_resp_code")); |
|
|
|
|
response.setPayRespErrorDesc(extra.getString("pay_resp_error_desc")); |
|
|
|
|
response.setPayRespMerchInfo(extra.getString("pay_resp_merch_info")); |
|
|
|
|
|
|
|
|
|
Logger.logD(response.toString()); |
|
|
|
|
MainApplication.getInstance().logPayment(response.toString()); |
|
|
|
|
|
|
|
|
|
MainApplication.currentSettlementResponse = response; |
|
|
|
|
|
|
|
|
|
MainApplication.code = response.getPayRespCode(); |
|
|
|
|
MainApplication.status = response.getPayRespErrorDesc(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void handlePayFunctionSetDateTimeResponse(Bundle extra) { |
|
|
|
|
SetDateTimeResponse response = new SetDateTimeResponse(); |
|
|
|
|
|
|
|
|
|
response.setPayFunction(extra.getString("pay_function")); |
|
|
|
|
response.setPayRespTxnDate(extra.getString("pay_resp_txn_date")); |
|
|
|
|
response.setPayRespTxnTime(extra.getString("pay_resp_txn_time")); |
|
|
|
|
response.setPayRespCode(extra.getString("pay_resp_code")); |
|
|
|
|
response.setPayRespErrorDesc(extra.getString("pay_resp_error_desc")); |
|
|
|
|
|
|
|
|
|
Logger.logD(response.toString()); |
|
|
|
|
MainApplication.getInstance().logPayment(response.toString()); |
|
|
|
|
|
|
|
|
|
MainApplication.currentSetDateTimeResponse = response; |
|
|
|
|
|
|
|
|
|
MainApplication.code = response.getPayRespCode(); |
|
|
|
|
MainApplication.status = response.getPayRespErrorDesc(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|