Exemplo n.º 1
0
        public AliPayRequest JsApiPay(AliPayModel payModel)
        {
            payModel.SetProductCode("QUICK_WAP_WAY");

            var common = new AliPayCommonModel();

            common.SetMethod("alipay.trade.wap.pay");
            common.SetBizContent(payModel);

            var parameters = common.GetType().GetProperties().OrderBy(o => o.Name).ToDictionary(item => item.Name, item => item.GetValue(common).ToString());
            var str        = BuildData.BuildParamStr(parameters);

            var sign = GenerateRsaAssist.RasSign(str, AliPayConfig.PrivateKey, SignType.Rsa2);

            parameters.Add("sign", sign);

            try
            {
                var from = BuildData.BuildHtmlRequest(parameters, "post", "post");
                return(new AliPayRequest {
                    IsSuccess = true, PreSign = str, Sign = sign, Result = from
                });
            }
            catch (Exception e)
            {
                return(new AliPayRequest {
                    IsSuccess = false, PreSign = str, Sign = sign, Result = e.Message
                });
            }
        }
Exemplo n.º 2
0
        public async Task <AliRefundQueryResponse> AliRefundQuery(AliRefundQueryModel refundQueryModel)
        {
            var common = new AliPayCommonModel();

            common.SetMethod("alipay.trade.fastpay.refund.query");
            common.SetBizContent(refundQueryModel);
            var parameters = common.GetType().GetProperties().OrderBy(o => o.Name).ToDictionary(item => item.Name, item => item.GetValue(common).ToString());
            var str        = BuildData.BuildParamStr(parameters);
            var sign       = GenerateRsaAssist.RasSign(str, AliPayConfig.PrivateKey, SignType.Rsa2);

            parameters.Add("sign", sign);
            var response = await HttpUtil.CreatePostHttpResponse(AliPayConfig.Gateway, parameters);

            var result = await response.Content.ReadAsStringAsync();

            var jsonResult = JsonConvert.DeserializeObject <AliRefundQueryResponse>(result);

            return(jsonResult);
        }