Пример #1
0
        /// <summary>
        /// 查询退款
        /// 提交退款申请后,通过该接口查询退款状态。退款有一定延时
        /// 用零钱支付的退款20分钟内到账,银行卡支付的退款3个工作日后重新查询退款状态。
        /// </summary>
        /// <param name="request">out_refund_no、out_trade_no、transaction_id、refund_id四个参数必填一个</param>
        /// <param name="config"></param>
        /// <param name="timeOut">接口超时时间</param>
        /// <returns>成功时返回,其他抛异常</returns>
        public static async Task <WechatRefundQueryResponse> RefundQueryAsync(WechatRefundQueryRequest request, WechatpayConfig config, int timeOut = 6)
        {
            //检测必填参数
            if (string.IsNullOrEmpty(request.OutRefundNo) && string.IsNullOrEmpty(request.OutTradeNo) &&
                string.IsNullOrEmpty(request.RefundId) && string.IsNullOrEmpty(request.TransactionId))
            {
                throw new Exception("退款查询接口中,out_refund_no、out_trade_no、transaction_id、refund_id四个参数必填一个!");
            }

            var result = await HttpService.ExecuteAsync(request, config, WechatConstants.RefundOrderQueryUrl);

            if (result.ReturnCode != WechatConstants.SUCCESS && result.ResultCode != WechatConstants.SUCCESS)
            {
                throw new Exception(result.ReturnMsg);
            }
            return(result);
        }
Пример #2
0
        public void WechatNativePayRefundTest()
        {
            //1.生成订单
            string orderId = "xxsss1111111";
            //var WechatPayNativePayService = serviceProvider.GetService<IWechatPayNativePayService>();
            //var WechatPayNativePayRequest = new WechatPayNativePayRequest()
            //{
            //    Body = "sssss",
            //    OutTradeNo = orderId,
            //    TotalFee = 0.01m,
            //    Attach = "dadadaaaa",
            //    FeeType = FeeType.CNY,
            //    Detail = new WechatPayPayRequestBase.GoodsDetail()
            //    {
            //        GoodsId = "GoodsId",
            //        WxpayGoodsId = "WxpayGoodsId",
            //        GoodsName = "GoodsName",
            //        Quantity = 2,
            //        Price = 1

            //    },
            //    Receipt = "Y",
            //    LimitPay = "no_credit",

            //    ProductId = "ProductId",
            //    GoodsTag = "GoodsTag",
            //    TimeExpire = DateTime.Now.AddHours(2),
            //    TimeStart = DateTime.Now,
            //    SceneInfo = new WechatPayPayRequestBase.StoreSceneInfo
            //    {

            //        store_info = new WechatPayPayRequestBase.StoreSceneInfoObj()
            //        {
            //            id = "Id",
            //            address = "Address",
            //            area_code = "AreaCode",
            //            name = "Name"
            //        },
            //    }.ToJson(),

            //    //OpenId = "98980989080980"

            //};
            //var result = WechatPayNativePayService.PayAsync(WechatPayNativePayRequest).GetAwaiter().GetResult();
            //string url = result?.Data?.CodeUrl;
            //去支付

            //2。查询订单
            var wechatOrderQueryService = serviceProvider.GetService <IWechatOrderQueryService>();
            var result2 = wechatOrderQueryService.QueryAsync(new WechatOrderQueryRequest()
            {
                OutTradeNo = orderId
            }).GetAwaiter().GetResult();

            //3.1退款订单
            var wechatRefundOrderService = serviceProvider.GetService <IWechatRefundOrderService>();
            var wechatRefundOrderRequest = new WechatRefundOrderRequest()
            {
                OutRefundNo = orderId,
                OutTradeNo  = orderId,
                TotalFee    = 0.01m,
                RefundFee   = 0.01m,
                //NotifyUrl= "https://weixin.qq.com/notify/"
            };
            var result31 = wechatRefundOrderService.RefundAsync(wechatRefundOrderRequest).GetAwaiter().GetResult();



            //3.2退款查询
            var wechatRefundQueryService = serviceProvider.GetService <IWechatRefundQueryService>();
            var wechatRefundQueryRequest = new WechatRefundQueryRequest()
            {
                OutTradeNo = orderId
            };
            var result32 = wechatRefundQueryService.RefundQuery(wechatRefundQueryRequest).GetAwaiter().GetResult();

            //4.查询订单
            var result4 = wechatOrderQueryService.QueryAsync(new WechatOrderQueryRequest()
            {
                OutTradeNo = orderId
            }).GetAwaiter().GetResult();
        }
Пример #3
0
        public void Test1()
        {
            ServiceCollection serviceDescriptors = new ServiceCollection();

            serviceDescriptors.AddPay(a =>
            {
                a.GatewayUrl = "https://openapi.alipaydev.com/gateway.do";
                a.AppId      = "2017022705929269";
                a.PrivateKey = "MIIEowIBAAKCAQEA4/wh822ynz+AutSuBfVgK39y9kU/QjlSb7sAhiypOdomZT4p7fyaVmXLdg361E3BeykbTVVxaFNZjRZ2p7Mk5VPl6cFB+eU+yJ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rhoLtXeUrROYs/YyEgQPFGXIwQP8VR/BX0UNiyWD5Nqhs4aRVkCgYBr7r3ajFqtyMR2KtxWt5ZSjI49dV1zDj8Oq3pzTyb/RaIQx1IPi3lKFgGabmO7YuVwAuY6MeZ3uZVpASsidr9dtQ0g5sQghMJ0RaxZLp8D+wziT8xlVEpq2UHnFOMYavbthd9Z7eZNsTfGr+hlJFCndoBrJSKNKKys8LaHj9moYQKBgAk0H7IMMQgdaGQmczk9NenRI4uE5A2Mra8k8MeTJyXGkWG5Ew6eMr/pSTIrkN8iQkSswv8MGYkb0lyazvWlm5lLGF3x/Jmh+3XIsjmwHDSHiMJDBJVkpTbjGQ15KPouzCO3gDJZYYWOO0dDj9tTEvnN8ftjLGE2gSJdgKB5hyXa";
                a.PublicKey  = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnmjf+QpGqixBIgk2FYNigemzhiagH0T0qIAN4sHofOacqFYknNG3vZbsoFy5SfBuYBnqBLxF8rekoeKx3RnZn1KUS9KD7VOAlVVBRpopTM7AzvzQrylICF1atRSuSqvw14vCXbAnzvagJR1OLwSE/2uFAqrRAXCampMU30D3OiLgoyJoIMTzg28LGMYS0cnTs44OkgleQtlGWMBr0V1bpOvYTNveETeASbAUMp5J7ofy+JRpX1YwcjY95ecpQWv9dp72XzjKN5q6l1FlLUeIewRde+Ry70M5/P90ofzCVmcaq30pbp0fQh3KyI4SJ6+NdqlF/GzLwO61gbF9xwIZ0QIDAQAB";
            }, w =>
            {
                w.AppId      = "wx6e95a65ad4ee0135";
                w.MerchantId = "1517630381";
                w.PrivateKey = "XIAKEweixinpay2019shjGGYGHD54hlk";
                w.NotifyUrl  = "https://openapi.alipaydev.com/gateway.do";
            });

            //string orderId = "12313412424412441";
            string orderId = "1231341242441242241";
            var    wechatpayNativePayService = serviceDescriptors.BuildServiceProvider().GetService <IWechatpayNativePayService>();
            var    wechatpayNativePayRequest = new WechatpayNativePayRequest()
            {
                Subject = "订单标题",
                OrderId = orderId,
                Money   = 0.01m,
                Attach  = "附加参数",
            };
            var result1 = wechatpayNativePayService.PayAsync(wechatpayNativePayRequest).GetAwaiter().GetResult();

            //var wechatOrderQueryService = serviceDescriptors.BuildServiceProvider().GetService<IWechatOrderQueryService>();
            //var result2 = wechatOrderQueryService.QueryAsync(new  WechatOrderQueryRequest()
            //{
            //    OrderId = orderId
            //}).GetAwaiter().GetResult();

            //var wechatCloseOrderService = serviceDescriptors.BuildServiceProvider().GetService<IWechatCloseOrderService>();
            //var result3 = wechatCloseOrderService.CloseAsync(new  WechatCloseOrderRequest()
            //{
            //    OrderId = orderId
            //}).GetAwaiter().GetResult();


            //var result4 = wechatOrderQueryService.QueryAsync(new  WechatOrderQueryRequest()
            //{
            //    OrderId = orderId
            //}).GetAwaiter().GetResult();



            //var wechatRefundOrderService = serviceDescriptors.BuildServiceProvider().GetService<IWechatRefundOrderService>();
            //var wechatRefundOrderRequest = new WechatRefundOrderRequest()
            //{
            //    OutRefundNo = "123456789",
            //    OrderId = orderId,
            //    Money = 0.01m,
            //    RefundMoney=0.01m,

            //    //NotifyUrl= "https://weixin.qq.com/notify/"

            //};
            //var result22 = wechatRefundOrderService.RefundAsync(wechatRefundOrderRequest).GetAwaiter().GetResult();


            var wechatRefundQueryService = serviceDescriptors.BuildServiceProvider().GetService <IWechatRefundQueryService>();
            var wechatRefundQueryRequest = new WechatRefundQueryRequest()
            {
                //OutRefundNo = "123456789",
                OrderId = orderId,


                //NotifyUrl= "https://weixin.qq.com/notify/"
            };
            var result2231 = wechatRefundQueryService.RefundQuery(wechatRefundQueryRequest).GetAwaiter().GetResult();
        }