예제 #1
0
        /// <summary>
        /// 该方法帮助开发者在订单生成之后掉用微信支付接口生成预支付订单,如果当前下单场景为公众号支付则返回一段用于发起支付的js代码,如果当前场景为PC端则返回一个用于发起支付的二维码图片URL
        /// </summary>
        /// <param name="order">设置需要支付的订单信息</param>
        /// <param name="notifyURL">设置发起支付之后微信服务端返回支付结果的回调地址</param>
        /// <param name="tradeType">设置支付类型,请参考Jumpcity.API.WeiXin.Pay.PayTradeType枚举类</param>
        /// <returns>如果当前下单场景为公众号支付则返回一段用于发起支付的js代码,如果当前场景为PC端则返回一个用于发起支付的二维码图片URL</returns>
        public static string UnifiedOrderPay(WMOrders order, string notifyURL, string tradeType)
        {
            string text = string.Empty;

            if (order != null && !General.IsNullable(notifyURL))
            {
                List<WMOrderGoods> goodList = WMOrderGoods.GetList(order.Id);
                UnifiedOrder.SubmitParameters submit = new UnifiedOrder.SubmitParameters(WxConfig.GetSystemPayParameters());

                if (!General.IsNullable(goodList))
                {
                    foreach (WMOrderGoods good in goodList)
                        submit.Detail += string.Format("{0} X {1}\n\r", good.GoodName, good.Count);
                }
                submit.Body = "添依网 - 购物清单";
                submit.OutTradeId = order.Id;
                submit.TotalPrice = (int)(order.OrderTotalPrice * 100);
                submit.NotifyURL = notifyURL;
                if (tradeType == PayTradeType.JSAPI && !General.IsNullable(order.OpenId))
                    submit.OpenId = order.OpenId;
                else
                    submit.ProductId = order.Id;

                UnifiedOrder un_order = new UnifiedOrder(submit);

                if (tradeType == PayTradeType.JSAPI)
                    text = un_order.PublicPlaceOrder();
                else
                    text = un_order.ScanCodePlaceOrder();
            }

            return text;
        }
예제 #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            UnifiedOrder.SubmitParameters submit = new UnifiedOrder.SubmitParameters(WxConfig.GetSystemPayParameters());

            submit.Body = "添依网 - 购物清单";
            submit.OutTradeId = Guid.NewGuid().ToUniqueString();
            submit.TotalPrice = 1;
            submit.NotifyURL = Request.Url.ToString();
            submit.OpenId = Request.GetString("openId");

            UnifiedOrder un_order = new UnifiedOrder(submit);

            wxJsApiParam = un_order.PublicPlaceOrder();
            //Response.Write(js);
            //Helper.ExecScript(js);
        }
    }