Beispiel #1
0
        /// <summary>
        /// 收银宝订单支付成功后续处理
        /// </summary>
        /// <param name="posOrderQueryResponse"></param>
        /// <param name="orderPaid"></param>
        public void VspOrderHandle(POSOrderQueryResponse posOrderQueryResponse, OrderPaid orderPaid)
        {
            var iPingAnOrderPaidService = DIFactory.GetContainer().Resolve <IPingAnOrderPaidService>();

            if (orderPaid.Merchant.AccountBank == AccountBankOption.PingAn.ToInt())
            {
                if (orderPaid.Status == OrderPaidStatusOption.Default.ToInt())
                {
                    orderPaid.Status = OrderPaidStatusOption.PaySuccess.ToInt();

                    orderPaid.PingAnOrderPaid.POSBaoSerialNumber = posOrderQueryResponse.trxid;

                    iPingAnOrderPaidService.Save(orderPaid.PingAnOrderPaid);
                    Save(orderPaid);

                    Commit();
                }

                //订单支付成功---调代付(代付成功,代付失败,代付中),当代付成功将信息记录到代付表,并更新主订单金额
                PingAnTltSingleOntimePay(orderPaid);
            }
            else if (orderPaid.Merchant.AccountBank == AccountBankOption.GuangDa.ToInt())
            {
                if (orderPaid.Status == OrderPaidStatusOption.Default.ToInt())
                {
                    orderPaid.Status = OrderPaidStatusOption.PaySuccess.ToInt();

                    Save(orderPaid);

                    Commit();
                }

                RechargeAndFreeze(orderPaid);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 订单支付通知
        /// </summary>
        public void POSOrderPaidNotify()
        {
            try
            {
                Dictionary <string, string> param = HttpUtility.UrlDecode(content).ToDictionary(true);

                if (!param.ContainsKey("bizseq"))
                {
                    throw new Exception("bizseq不能为空");
                }

                string bizseq = param["bizseq"];

                var orderPaid = iOrderPaidService.Get(t => t.OrderNumber == bizseq);

                if (orderPaid == null)
                {
                    throw new Exception("订单不存在:" + bizseq);
                }

                //获取支付参数
                var preferences = iPreferencesService.Get(t => t.MerchantID == orderPaid.MerchantID);
                this.vspExec = new VSPExec(preferences.POSBaoMerchant, preferences.POSBaoKey, preferences.APPID);

                if (vspExec.IsVerify(param))//验签成功
                {
                    POSOrderQueryResponse posOrderQueryResponse = JsonHelper.Deserialize <POSOrderQueryResponse>(JsonHelper.Serialize(param));
                    byte[] bytes = Encoding.GetEncoding("gbk").GetBytes(posOrderQueryResponse.trxreserve ?? ""); //将字符串转成gbk编码的字节数组
                    posOrderQueryResponse.trxreserve = Encoding.GetEncoding("utf-8").GetString(bytes);           //将字节数组转回为字符串

                    if (posOrderQueryResponse.trxcode == "VSP001" && posOrderQueryResponse.trxstatus == "0000")
                    {
                        //订单支付成功后的平安和光大订单的后续处理
                        iOrderPaidService.VspOrderHandle(posOrderQueryResponse, orderPaid);

                        Response.Write("success");
                    }
                }
                else
                {
                    throw new Exception("通知验签失败");
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                Response.Write("error");
            }
        }