Exemplo n.º 1
0
        public async Task <WapPayOutput> WapPay(WapPayInput input, AlipayOptions options = null)
        {
            await Task.Yield();

            // 设置产品代码
            if (input.Data.ProductCode.IsNullOrWhiteSpace())
            {
                input.Data.ProductCode = YoYoAlipayConsts.ProductCode_QUICK_WAP_WAY;
            }
            // 设置支付中途退出返回商户网站地址
            if (input.Data.QuitUrl.IsNullOrWhiteSpace())
            {
                input.Data.QuitUrl = input.QuitUrl;
            }

            var request = new AlipayTradeWapPayRequest();

            // 设置同步回调地址
            request.SetReturnUrl(input.SynchronizationCallbackUrl);
            // 设置异步通知接收地址
            request.SetNotifyUrl(input.AsyncNotifyUrl);
            // 将业务model载入到request
            request.SetBizModel(input.Data);

            // 发起支付
            var response = await this._alipayService.PageExecuteAsync(request);

            return(new WapPayOutput()
            {
                Response = response,
                Body = response.Body
            });
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Wap支付
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public Task <WapPayOutput> WapPay(WapPayInput input)
        {
            var client = GetClient();

            var request = new AlipayTradeWapPayRequest();
            var model   = new AlipayTradeWapPayModel
            {
                Body = input.Body,
                DisablePayChannels = input.DisablePayChannels,
                EnablePayChannels  = input.EnablePayChannels,
                //ExtendParams = input.ex
                GoodsType      = input.GoodsType,
                OutTradeNo     = input.TradeNo ?? Guid.NewGuid().ToString("N"),
                PassbackParams = WebUtility.UrlEncode(input.PassbackParams),
                ProductCode    = "QUICK_WAP_WAY",
                PromoParams    = input.PromoParams,
                //SpecifiedChannel
                StoreId        = input.StoreId,
                Subject        = input.Subject,
                TimeoutExpress = input.TimeoutExpress,
                TotalAmount    = input.TotalAmount.ToString(CultureInfo.InvariantCulture),
                QuitUrl        = input.QuitUrl
            };

            request.SetBizModel(model);
            request.SetNotifyUrl(input.NotifyUrl ?? alipaySettings.Notify);
            var response = client.pageExecute(request);

            if (response.IsError)
            {
                LoggerAction?.Invoke("Error", "支付宝支付请求参数错误:" + JsonConvert.SerializeObject(model));
                throw new AlipayExcetion("支付宝支付请求参数错误,请检查!");
            }

            return(Task.FromResult(new WapPayOutput
            {
                Body = response.Body
            }));
        }