示例#1
0
        /// <summary>
        /// 支付宝App支付
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string BuildAlipayAppRequest(HttpContext context)
        {
            string orderId      = context.Request["order_id"];
            string appId        = context.Request["app_id"];
            string websiteOwner = bllPay.WebsiteOwner;

            if (string.IsNullOrEmpty(orderId))
            {
                resp.errcode = 1;
                resp.errmsg  = "order_id 必传";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
            }
            var orderInfo = bllMall.GetOrderInfo(orderId);

            if (orderInfo == null)
            {
                resp.errcode = 1;
                resp.errmsg  = "订单号不存在";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
            }
            if (orderInfo.OrderUserID != currentUserInfo.UserID)
            {
                resp.errcode = 1;
                resp.errmsg  = "订单号无效";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
            }
            if (orderInfo.PaymentStatus == 1)
            {
                resp.errcode = 1;
                resp.errmsg  = "订单已经支付,不需重复支付";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
            }

            BLLJIMP.Model.AppManage app = bllApp.GetApp(websiteOwner, appId);
            if (!bllApp.IsAppAlipay(app))
            {
                resp.errcode = 1;
                resp.errmsg  = "未配置App支付宝支付";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
            }
            //更改支付方式
            //bllMall.Update(orderInfo, " PaymentType=1 ", string.Format(" (OrderID = '{0}' Or ParentOrderId='{0}') ", orderInfo.OrderID));

            string notifyUrl = baseUrl + "/Alipay/MallAppNotifyUrlV2.aspx";
            var    payForm   = bllPay.GetAliPayRequestApp(orderInfo.OrderID, (double)orderInfo.TotalAmount, app.AlipayAppId,
                                                          app.AlipayPrivatekey, app.AlipayPublickey, app.AlipaySignType, notifyUrl);

            return(ZentCloud.Common.JSONHelper.ObjectToJson(new
            {
                errcode = 0,
                pay_req = payForm
            }));
        }