コード例 #1
0
        public async void Test5()
        {
            var refundModel = new AliRefundQueryModel()
            {
                out_trade_no   = "20171010165857",
                out_request_no = "20171010165857"
            };
            AliPayService a = new AliPayService();
            var           s = await a.AliRefundQuery(refundModel);

            Assert.NotNull(s);
        }
コード例 #2
0
        public async void Test4()
        {
            var refundModel = new AliRefundModel()
            {
                out_trade_no  = "10005",
                trade_no      = "2017102321001004720230769658",
                refund_amount = 0.01M
            };
            AliPayService a = new AliPayService();
            var           s = await a.AliRefund(refundModel);

            Assert.NotNull(s);
        }
コード例 #3
0
        public async void Test2()
        {
            var payModel = new AliPayModel
            {
                out_trade_no = $"{DateTime.Now:yyyyMMddHHmmss}",
                subject      = $"Ö§¸¶²âÊÔ{DateTime.Now:yyyyMMddHHmmss}",
                total_amount = "0.01"
            };
            AliPayService a = new AliPayService();
            var           s = a.AppPay("ssss");

            Assert.NotNull(s);
        }
コード例 #4
0
        public async void Test3()
        {
            var payModel = new AliPayModel
            {
                out_trade_no = $"{DateTime.Now:yyyyMMddHHmmss}",
                subject      = $"JSAPI Test Pay",
                total_amount = "0.01",
            };
            AliPayService a = new AliPayService();
            var           s = a.JsApiPay(payModel);

            Assert.NotNull(s);
        }
コード例 #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                var result = string.Empty;

                using (var receiveStream = context.Request.InputStream)
                {
                    using (var readStream = new StreamReader(receiveStream, Encoding.UTF8))
                    {
                        result = readStream.ReadToEnd();
                    }
                }

                //result = "gmt_create=2018-08-08 17:59:57&charset=UTF-8&[email protected]&subject=测试&sign=ik411t/2Sy0FP5tNAba903lPkah0f3800kRb5TYtSP+YE2Yilz5YUjkyX+npMF5/16me1qlgV8SDW6HUQqth0TTm4LMp70ciZn52bYMvKqfVrRzRY66RCGrXEMskeHDguzTo5+AJy84SuRok2hJBZ7bt0c/F/cpaW8mmzHpqrMyalV/z773klDFLOxOxtf4fRMxpqI7CdZjw0shLxAXUwarspw4UOyWafjzSnDM0fH+6Tts72byyfXkRNKOnnBYASF24kpYhb04TzdiUe2QBxehSSPT5hYrEqFqz731aX+/huZ8W/PcHwRPjy1B63AUetbxDgT2aZy2OBQTyYWdV+g==&buyer_id=2088112203351006&invoice_amount=0.01&notify_id=2018080800222175957027000567184747&fund_bill_list=[{\"amount\":\"0.01\",\"fundChannel\":\"ALIPAYACCOUNT\"}]&notify_type=trade_status_sync&trade_status=TRADE_SUCCESS&receipt_amount=0.01&buyer_pay_amount=0.01&app_id=2018080360986076&sign_type=RSA2&seller_id=2088231214853139&gmt_payment=2018-08-08 17:59:57&notify_time=2018-08-08 17:59:58&version=1.0&out_trade_no=201888175948366&total_amount=0.01&trade_no=2018080821001004000571974470&auth_app_id=2018080360986076&buyer_logon_id=188****0611&point_amount=0.00";
                //gmt_create=2018-11-27+18%3A21%3A21&charset=UTF-8&seller_email=924325672%40qq.com&subject=%E7%AE%97%E5%91%BD%E5%8F%96%E5%90%8D%E5%A4%A7%E5%B8%AB-%E5%AE%9D%E5%AE%9D%E5%8F%96%E5%90%8D&sign=JowHuITk%2BVbOvf63JC87S5NaDpHXHGB22ju3o7RWHMAadJjbVVyidzO9DmYVqmKHiMF5HCcfkImV4h%2FOjt4Wkme%2FTmAHDIJ%2F9%2FA6r64sp8OqZvDBu0nedrKMUXtuQ8W6CCJmK6AqRibplUT8iyNOpKNbf%2FpQaHVc%2FJvDjsq%2FusQL%2F85nsRmM12HXTYLusRxzQnN6IRfHDN%2BUdT9Q8Vf9weJZk2oNPzrT0NgogLJ9qh5LwC%2B73V8u%2FhFUvVudOotYcfBPGHr0vBT8PEMPJAffXatTSazcc1ug1FArbNuyIy0KZEQOQ%2FdUplD5uSoz7oUUExE6U5dRSVb9dnFivKTOjw%3D%3D&body=%E6%94%AF%E4%BB%98%E8%AE%A2%E5%8D%95&buyer_id=2088212481754967&invoice_amount=0.02&notify_id=2018112700222182121054961033235779&fund_bill_list=%5B%7B%22amount%22%3A%220.02%22%2C%22fundChannel%22%3A%22ALIPAYACCOUNT%22%7D%5D&notify_type=trade_status_sync&trade_status=TRADE_SUCCESS&receipt_amount=0.02&buyer_pay_amount=0.02&app_id=2018080360986076&sign_type=RSA2&seller_id=2088231214853139&gmt_payment=2018-11-27+18%3A21%3A21&notify_time=2018-11-27+18%3A21%3A22&version=1.0&out_trade_no=19e939e7-842d-461b-954b-0699b75c334b&total_amount=0.02&trade_no=2018112722001454961011900401&auth_app_id=2018080360986076&buyer_logon_id=188****4025&point_amount=0.00

                var myUri       = new Uri("http://www.UnUsed.com?" + result);
                var tradeStatus = HttpUtility.ParseQueryString(myUri.Query).Get("trade_status")?.ToUpper();
                var orderId     = HttpUtility.ParseQueryString(myUri.Query).Get("out_trade_no")?.ToUpper();

                //支付成功
                if (tradeStatus == "TRADE_SUCCESS" || tradeStatus == "TRADE_FINISHED")
                {
                    var orderService  = new OrderService();
                    var aliPayService = new AliPayService();

                    var aliPayModel =
                        new Data.Domain.AliPay {
                        OrderId = orderId, PayStatus = tradeStatus, Remark = result
                    };

                    var orderInfo = orderService.GetByOrderId(orderId);
                    orderService.SetToPaid(orderInfo);
                    aliPayService.Insert(aliPayModel);
                }
                else
                {
                    //TODO LOG
                }
            }
            catch (Exception ex)
            {
                LogService.InsertLog(ex);
            }

            context.Response.Write("success");
            context.Response.End();
        }