private CreditcardFeeQueryTradeRequestEntity packUp( CupsTrmnl cupsTrmnl, UlinkplusKeyManage ulinkplusKeyManage, UlinkplusRequestInfo request) throws TransferFailedException { // 消费报文打包 // {2,3,4,11,22,25,41,42,48,49,64} CreditcardFeeQueryTradeRequestEntity requestEntity = new CreditcardFeeQueryTradeRequestEntity(); requestEntity.setCardNo(request.getCardNo()); // 2 requestEntity.setProcessCode("310000"); // 3 requestEntity.setTransAmt(StringUtils.amtToBCD(request.getAmount())); // 4 requestEntity.setTrmnlFlowNo(cupsTrmnl.getTrmnlFlowNo()); // 11 requestEntity.setPosEntryMode("012"); // 22 requestEntity.setServiceCode("92"); // 25 requestEntity.setTrmnlNo(cupsTrmnl.getTrmnlNo()); requestEntity.setTrmnlMrchNo(cupsTrmnl.getMrchNo()); // 位置 长度 格式 内容 说明 // 0 2 n2 用法标志 “PA” // 2 2 n2 帐单号码类型 08 // 4 19 Ans19 信用卡卡码 左对齐,右补空格 // 23 11 N11 手机号码 // 34 1 ans1 结束标志 # // PA086222040000000001 # requestEntity.setSelfDefined48( ("PA08" + StringUtils.rightPad(request.getCreditcardNo(), 19, " ") + "#").getBytes()); requestEntity.setCurrency(Currency.CNY.getCodeN()); requestEntity.setMacCode(new byte[8]); cupsTrmnlService.updateCupsTrmnlFlowNo(cupsTrmnl); return requestEntity; }
private IcScriptUploadTradeRequestEntity packUp( CupsTrmnl cupsTrmnl, CupsKeyManage cupsKeyManage, PepsiColaRequestInfo request) throws TransferFailedException { if (request.getIcScript() == null) { throw new TransferFailedException( AppExCode.ILLEGAL_PARAMS, "isScript upload failed! IcScript objet is null"); } PayCups originalPayCups = payCupsService.findPayCups(request.getOriginalPayNo()); // 脚本上送打包 IcScriptUploadTradeRequestEntity entity = new IcScriptUploadTradeRequestEntity(); entity.setCardNo(originalPayCups.getCardNo()); // 2 卡号 entity.setProcessCode(originalPayCups.getProcessCode()); // 3 未选卡种 String amount = null; if (originalPayCups.getTransAmt() != null || BigDecimal.ZERO.compareTo(originalPayCups.getTransAmt()) != 0) { amount = com.newland.base.util.StringUtils.amtToBCD(originalPayCups.getTransAmt()); } entity.setTransAmt(amount); // 4 交易金额 entity.setTrmnlFlowNo(cupsTrmnl.getTrmnlFlowNo()); // 11 终端流水号 entity.setPosEntryMode(originalPayCups.getPosEntryMode()); // 22 卡输入方式 if (StringUtils.isBlank(originalPayCups.getIcData())) { // 磁条卡 entity.setSelfDefined60( Const.SD60_1_MSGTYPE_CONTROL + cupsTrmnl.getTrmnlBatchNo()); // 60 自定义域 22(交易类型码)+000001(批次号)+000(网络管理信息码) } else { // IC卡 entity.setCardSeqNum(originalPayCups.getCardSeqNum()); // IC卡必须上送该域 byte[] icData = getIcData(originalPayCups.getIcData(), request.getIcScript()); entity.setIcData(icData); // 55 IC卡数据 String selfDefined60 = Const.SD60_1_MSGTYPE_CONTROL + cupsTrmnl.getTrmnlBatchNo() + Const.SD60_3_IC_CRIPT_UPLOAD + Const.SD60_4_TERMINAL_READING_ABILITY_CONTACT_ICCARD + Const.SD60_5_IC_SERVICE_CODE_NORMAL; entity.setSelfDefined60(selfDefined60); } entity.setTrmnlRefferNo(originalPayCups.getTrmnlReferNo()); // 37 entity.setTrmnlNo(originalPayCups.getTrmnlNo()); // 41 终端号 entity.setTrmnlMrchNo(originalPayCups.getTrmnlMrchNo()); // 42 终端商户号 entity.setCurrency(originalPayCups.getCurrency()); // 49 货币代码 entity.setOriginalMessage( originalPayCups.getTrmnlBatchNo() + originalPayCups.getTrmnlFlowNo() + originalPayCups.getTransDate()); // 61 原批次号+原流水号 entity.setMacCode(new byte[8]); // 64 mac return entity; }