Ejemplo n.º 1
0
        /// <summary>
        /// 获取预交易二维码
        /// </summary>
        /// <param name="info"></param>
        public string GetPayQrCode(PayInfo info)
        {
            IAopClient client = new DefaultAopClient("https://openapi.alipay.com/gateway.do", Com.Alipay.Config.APP_ID, Com.Alipay.Config.Private_key);

            AlipayAcquirePrecreateRequest request = new AlipayAcquirePrecreateRequest();

            request.SellerId = info.AlipayId;
            request.SetNotifyUrl("https://www.gotopsports.com/service/NotifyAlipay.aspx");
            request.OutTradeNo = info.BillId;

            string subject;
            string body;

            PayHelper.GetSubjectAndBody(info, out subject, out body);

            request.Subject  = subject;
            request.Body     = body;
            request.TotalFee = info.PayAmount.ToString();

            request.ItBPay = "1d";
            var response = client.Execute <AlipayAcquirePrecreateResponse>(request);

            //调用成功,则处理业务逻辑
            if (response.IsSuccess == "T")
            {
                return(response.QrCode);
            }

            return(null);
        }
Ejemplo n.º 2
0
        private string GetOrderInfo(PayInfo info)
        {
            string subject;
            string body;

            PayHelper.GetSubjectAndBody(info, out subject, out body);

            Dictionary <string, string> payinfo = new Dictionary <string, string>();

            payinfo.Add("partner", "\"" + Com.Alipay.Config.Partner + "\"");
            payinfo.Add("seller_id", "\"" + info.AlipayId + "\"");
            payinfo.Add("out_trade_no", "\"" + info.BillId + "\"");
            payinfo.Add("subject", "\"" + subject + "\"");
            payinfo.Add("body", "\"" + body + "\"");
            payinfo.Add("total_fee", "\"" + info.PayAmount + "\"");
            payinfo.Add("service", "\"mobile.securitypay.pay\"");
            payinfo.Add("notify_url", ALIPAY_NOTIFY_URL);
            payinfo.Add("payment_type", "\"1\"");
            payinfo.Add("_input_charset", "\"UTF-8\"");
            payinfo.Add("it_b_pay", "\"30m\"");

            return(Com.Alipay.Core.CreateLinkString(payinfo));
        }
Ejemplo n.º 3
0
        /**
         * 调用统一下单,获得下单结果
         * @return 统一下单结果
         * @失败时抛异常WxPayException
         */
        private string GetUnifiedOrderResult(PayInfo info)
        {
            string subject;
            string body;

            PayHelper.GetSubjectAndBody(info, out subject, out body);

            //统一下单
            WxPayData data = new WxPayData();

            data.SetValue("body", subject);
            data.SetValue("out_trade_no", info.BillId);
            //金额单位分
            data.SetValue("total_fee", (int)info.PayAmount * 100);
            data.SetValue("time_start", DateTime.Now.ToString("yyyyMMddHHmmss"));
            data.SetValue("time_expire", DateTime.Now.AddMinutes(10).ToString("yyyyMMddHHmmss"));
            data.SetValue("trade_type", "APP");

            WxPayData result = WxPayApi.UnifiedOrder(data);

            if (!result.IsSet("appid") || !result.IsSet("prepay_id") || result.GetValue("prepay_id").ToString() == "")
            {
                throw new WxPayException("UnifiedOrder response error!");
            }

            //客户端调起支付接口需要参数
            WeixinPayReq req = new WeixinPayReq();

            req.Appid     = result.GetValue("appid").ToString();
            req.Partnerid = result.GetValue("mch_id").ToString();
            req.Prepayid  = result.GetValue("prepay_id").ToString();
            req.Noncestr  = WxPayAPI.WxPayApi.GenerateNonceStr();
            req.Timestamp = WxPayAPI.WxPayApi.GenerateTimeStamp();
            req.Sign      = MakeSecondSign(req);

            return(JsonConvert.SerializeObject(req));
        }