Exemplo n.º 1
0
        public ContentResult CapitalChargeNotify(string id)
        {
            id = DecodePaymentId(id);
            Log.Info("商家充值异步回调key:" + id);
            string str = string.Empty;

            try
            {
                var payment = Core.PluginsManagement.GetPlugin <IPaymentPlugin>(id);
                var payInfo = payment.Biz.ProcessReturn(HttpContext.Request);
                CashDepositDetailInfo model = new CashDepositDetailInfo();
                string payStateKey          = CacheKeyCollection.PaymentState(string.Join(",", payInfo.OrderIds)); //获取支付状态缓存键
                bool   result = Cache.Get <bool>(payStateKey);                                                     //记录缓存,不重复处理
                if (!result)
                {
                    long orderIds = payInfo.OrderIds.FirstOrDefault();
                    Log.Info("商家充值异步回调订单号:" + orderIds);
                    BillingApplication.ShopRecharge(orderIds, payInfo.TradNo, id);

                    str = payment.Biz.ConfirmPayResult();
                    //写入支付状态缓存
                    Cache.Insert(payStateKey, true);//标记为已支付
                }
            }
            catch (Exception ex)
            {
                Log.Error("商家充值异步回调错误:" + ex.Message);
            }
            return(Content(str));
        }
Exemplo n.º 2
0
        public ActionResult CapitalChargeReturn(string id)
        {
            id = DecodePaymentId(id);
            Log.Info("商家充值同步回调key:" + id);
            string error = string.Empty;

            try
            {
                var payment = Core.PluginsManagement.GetPlugin <IPaymentPlugin>(id);
                var payInfo = payment.Biz.ProcessReturn(HttpContext.Request);
                CashDepositDetailInfo model = new CashDepositDetailInfo();
                bool result = Cache.Get(CacheKeyCollection.PaymentState(string.Join(",", payInfo.OrderIds))) == null ? false : true;//记录缓存,不重复处理
                if (!result)
                {
                    long orderIds = payInfo.OrderIds.FirstOrDefault();
                    Log.Info("商家充值同步回调订单号:" + orderIds);
                    BillingApplication.ShopRecharge(orderIds, payInfo.TradNo, id);

                    //写入支付状态缓存
                    string payStateKey = CacheKeyCollection.PaymentState(string.Join(",", payInfo.OrderIds)); //获取支付状态缓存键
                    Cache.Insert(payStateKey, true);                                                          //标记为已支付
                }
            }
            catch (Exception ex)
            {
                Log.Error("商家充值同步回调错误:" + ex.Message);
                error = ex.Message;
            }
            ViewBag.Error = error;
            return(View());
        }