private void PayProcess() { int nTryConfirm = 3; CPowerPayUserBeingPay beingPay = new CPowerPayUserBeingPay(); TransResult retPay = SyncTransaction(beingPay); CReverse_PowerPay rev = new CReverse_PowerPay(beingPay); //Test //retPay = TransResult.E_RECV_FAIL; //beingPay.ReturnCode = "55"; if (retPay == TransResult.E_SUCC) { if (bisICCard) { int state = emv.EMVTransEnd(m_entity.RecvField55, m_entity.RecvField38); if (state != 0) { rev.Reason = "06"; SyncTransaction(rev); ShowMessageAndGotoMain("IC确认错误,交易失败,请重试"); return; } } rev.ClearReverseFile();//缴费成功之后进入销账流程,不在发冲正报文,清除冲正文件 CONFIRM: //缴费成功,发起确认销账 CPowerPayUserBillConfirm billConfirm = new CPowerPayUserBillConfirm(); TransResult retConfirm = SyncTransaction(billConfirm); //Test //retConfirm = TransResult.E_RECV_FAIL; if (retConfirm != TransResult.E_SUCC) { //超时无响应循环发送确认报文 if (nTryConfirm != 0 && (retConfirm == TransResult.E_RECV_FAIL)) { nTryConfirm--; goto CONFIRM; } //销账失败 //缴费确认未成功,48小时内系统会自动处理,请耐心等待,不要重复缴费 string temp0 = "银行卡扣款成功,但销账失败,由系统自行处理电表编号={0},凭证号={1},系统参考号={2},缴费流水号={3}"; string temp = string.Format(temp0, m_entity.DBNo, m_entity.PayTraceNo, m_entity.PayReferenceNo, m_entity.PayFlowNo); Log.Warn(temp); StartActivity("电力支付用户销账失败"); } else { string temp = string.Format("销账成功,电表编号:{0},销账流水:{1},缴纳金额:{2}", m_entity.DBNo, m_entity.ConfirmTraceNo, CommonData.Amount.ToString("#######0.00")); Log.Info(temp); if (ReceiptPrinter.ExistError()) { StartActivity("电力支付交易完成"); } else { StartActivity("电力支付交易成功是否打印"); } } } else if (retPay == TransResult.E_HOST_FAIL) { if (beingPay.ReturnCode == "51") { ShowMessageAndGotoMain("温馨提示:抱歉!交易失败!" + "\n" + "您卡内余额不足!"); } else if (beingPay.ReturnCode == "55") { StartActivity("电力支付密码错误"); } else { ShowMessageAndGotoMain(beingPay.ReturnCode + "-" + beingPay.ReturnMessage); } } else if (retPay == TransResult.E_RECV_FAIL) { rev.Reason = "98"; SyncTransaction(rev); ShowMessageAndGotoMain("交易超时,请重试"); return; } else if (retPay == TransResult.E_UNPACKET_FAIL) { rev.Reason = "96"; SyncTransaction(rev); ShowMessageAndGotoMain("系统异常,请稍后再试"); return; } else { ShowMessageAndGotoMain("交易失败,请重试"); } rev.ClearReverseFile();//在不发冲正文件的情况下,才清除冲正文件 }
private void PayProcess() { //int nTryConfirm = 3; CPowerPayBeingPay beingPay = new CPowerPayBeingPay(); TransResult retPay = SyncTransaction(beingPay); CReverse_PowerPay rev = new CReverse_PowerPay(beingPay); //Test //retPay = TransResult.E_HOST_FAIL; //beingPay.ReturnCode = "55"; //rev.Reason = "98"; //retPay = SyncTransaction(rev); if (retPay == TransResult.E_SUCC) { if (bisICCard) { int state = emv.EMVTransEnd(m_entity.RecvField55, m_entity.RecvField38); if (state != 0) { rev.Reason = "06"; SyncTransaction(rev); ShowMessageAndGotoMain("IC确认错误,交易失败,请重试"); return; } } rev.ClearReverseFile();//缴费成功之后进入销账流程,不在发冲正报文,清除冲正文件 StartActivity("电力支付退出银行卡"); } else if (retPay == TransResult.E_HOST_FAIL) { if (beingPay.ReturnCode == "51") { ShowMessageAndGotoMain("温馨提示:抱歉!交易失败!" + "\n" + "您卡内余额不足!"); } else if (beingPay.ReturnCode == "55") { StartActivity("电力支付密码错误"); } else { ShowMessageAndGotoMain(beingPay.ReturnCode + "-" + beingPay.ReturnMessage); } } else if (retPay == TransResult.E_RECV_FAIL) { rev.Reason = "98"; SyncTransaction(rev); ShowMessageAndGotoMain("交易超时,请重试"); return; } else if (retPay == TransResult.E_UNPACKET_FAIL) { rev.Reason = "96"; SyncTransaction(rev); ShowMessageAndGotoMain("系统异常,请稍后再试"); return; } else { ShowMessageAndGotoMain("交易失败,请重试"); } rev.ClearReverseFile();//在不发冲正文件的情况下,才清除冲正文件 }
private void PayProcess() { int nTryConfirm = 3; CPowerPayBeingPay beingPay = new CPowerPayBeingPay(); TransResult retPay = SyncTransaction(beingPay); CReverse_PowerPay rev = new CReverse_PowerPay(beingPay); //Test //retPay = TransResult.E_HOST_FAIL; //beingPay.ReturnCode = "55"; if (retPay == TransResult.E_SUCC) { if (bisICCard) { int state = emv.EMVTransEnd(m_entity.RecvField55, m_entity.RecvField38); if (state != 0) { rev.Reason = "06"; SyncTransaction(rev); ShowMessageAndGotoMain("IC确认错误,交易失败,请重试"); return; } } rev.ClearReverseFile();//缴费成功之后进入销账流程,不在发冲正报文,清除冲正文件 CONFIRM: //缴费成功,发起确认销账 retConfirm = TransResult.E_RECV_FAIL; PostSync(ConfirmTrans); //Test //retConfirm = TransResult.E_RECV_FAIL; if (retConfirm != TransResult.E_SUCC) { //超时无响应循环发送确认报文 if (nTryConfirm != 0 && (retConfirm == TransResult.E_RECV_FAIL)) { nTryConfirm--; goto CONFIRM; } //销账失败 //缴费确认未成功,48小时内系统会自动处理,请耐心等待,不要重复缴费 string temp0 = "银行卡扣款成功,但销账失败,由系统自行处理CardNo={0},凭证号={1},系统参考号={2},缴费流水号={3}"; string temp = string.Format(temp0, CommonData.BankCardNum, m_entity.PayTraceNo, m_entity.PayReferenceNo, m_entity.PayFlowNo); Log.Warn(temp); StartActivity("电力支付销账失败"); } else { StartActivity("电力支付退出银行卡"); } } else if (retPay == TransResult.E_HOST_FAIL) { if (beingPay.ReturnCode == "51") { ShowMessageAndGotoMain("温馨提示:抱歉!交易失败!" + "\n" + "您卡内余额不足!"); } else if (beingPay.ReturnCode == "55") { StartActivity("电力支付密码错误"); } else { ShowMessageAndGotoMain(beingPay.ReturnCode + "-" + beingPay.ReturnMessage); } } else if (retPay == TransResult.E_RECV_FAIL) { rev.Reason = "98"; SyncTransaction(rev); ShowMessageAndGotoMain("交易超时,请重试"); return; } else if (retPay == TransResult.E_UNPACKET_FAIL) { rev.Reason = "96"; SyncTransaction(rev); ShowMessageAndGotoMain("系统异常,请稍后再试"); return; } else { ShowMessageAndGotoMain("交易失败,请重试"); } rev.ClearReverseFile();//在不发冲正文件的情况下,才清除冲正文件 }
protected override void Packet() { bool bIsIC = false; if (CommonData.UserCardType == UserBankCardType.ICCard || CommonData.UserCardType == UserBankCardType.IcMagCard) { bIsIC = true; } SendPackage.SetString(0, "0200"); if (!string.IsNullOrEmpty(CommonData.BankCardNum) && CommonData.BankCardNum.Length != 0) { SendPackage.SetString(2, CommonData.BankCardNum); } SendPackage.SetString(3, "190000"); SendPackage.SetString(4, Utility.AmountToString(CommonData.Amount.ToString())); PayEntity.PayTraceNo = GetTraceNo(); SendPackage.SetString(11, PayEntity.PayTraceNo); if (!string.IsNullOrEmpty(CommonData.BankCardExpDate) && CommonData.BankCardExpDate.Length != 0)//卡有效期 { SendPackage.SetString(14, CommonData.BankCardExpDate); } if (bIsIC)//22 { SendPackage.SetString(22, "051"); } else { SendPackage.SetString(22, "021"); } if (!string.IsNullOrEmpty(CommonData.BankCardSeqNum) && CommonData.BankCardSeqNum.Length != 0)//卡序列号 { SendPackage.SetString(23, CommonData.BankCardSeqNum); } SendPackage.SetString(25, "81"); //服务点条件代码 SendPackage.SetString(26, "06"); if (!string.IsNullOrEmpty(CommonData.Track2) && CommonData.Track2.Length != 0) { SendPackage.SetString(35, CommonData.Track2.Replace('=', 'D')); } if (!string.IsNullOrEmpty(CommonData.Track3) && CommonData.Track3.Length != 0) { SendPackage.SetString(36, CommonData.Track3.Replace('=', 'D')); } SendPackage.SetArrayData(48, PacketField48()); SendPackage.SetString(49, "156"); SendPackage.SetArrayData(52, Utility.str2Bcd(CommonData.BankPassWord)); switch (DType) { case DesType.Des: SendPackage.SetString(53, "2000000000000000"); break; case DesType.TripleDes: SendPackage.SetString(53, "2600000000000000"); break; } //55 if (bIsIC && PayEntity.SendField55 != null && PayEntity.SendField55.Length != 0) { SendPackage.SetArrayData(55, PayEntity.SendField55); } if (PayEntity.UseICCard) { SendPackage.SetString(60, "22" + GetBatchNo() + "00050"); } else { SendPackage.SetString(60, "22" + GetBatchNo() + "000"); } //创建冲正文件 98 96 06 CReverse_PowerPay cr = new CReverse_PowerPay(this); cr.CreateReverseFile("98"); }