Esempio n. 1
0
        /// <summary>
        /// 扫码统一下单
        /// </summary>
        static string UnifiedOrder()
        {
            var apps         = File.ReadAllLines(@"D:\cert.txt");
            var payHandle    = new PayHandle();
            var unifiedOrder = new UnifiedOrder()
            {
                AppID          = apps[0],
                MchID          = apps[1],
                Key            = apps[3],
                Body           = "test",
                OutTradeNo     = DateTime.Now.ToString("yyMMddhhmmss"),
                ToalFee        = 1,
                SpbillCreateIP = "8.8.8.8",
                NotifyURL      = "http://www.abcd.com",
                TradeType      = "NATIVE",
                ProductID      = "123456"
            };
            var unifiedOrderBack = payHandle.Send(unifiedOrder) as UnifiedOrderBack;

            if (unifiedOrderBack.ResultCode == "SUCCESS")
            {
                SavaQR(unifiedOrderBack.CodeURL);
            }
            return(unifiedOrderBack.CodeURL);
        }
Esempio n. 2
0
        static CloseOrderBack CloseOrder(string str)
        {
            var apps       = File.ReadAllLines(@"D:\cert.txt");
            var payHandle  = new PayHandle();
            var closeOrder = new CloseOrder
            {
                AppID      = apps[0],
                MchID      = apps[1],
                Key        = apps[3],
                OutTradeNO = str
            };
            var closeOrderBack = payHandle.Send(closeOrder) as CloseOrderBack;

            return(closeOrderBack);
        }
Esempio n. 3
0
        /// <summary>
        /// 查询退单
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        static RefundQueryBack QueryRefundBack(string str)
        {
            var apps        = File.ReadAllLines(@"D:\cert.txt");
            var payHandle   = new PayHandle();
            var refundQuery = new RefundQuery()
            {
                AppID      = apps[0],
                MchID      = apps[1],
                Key        = apps[3],
                OutTradeNo = str
            };
            var refundQueryBack = payHandle.Send(refundQuery) as RefundQueryBack;

            return(refundQueryBack);
        }
Esempio n. 4
0
        static ShortURLBack GetShortUrl(string url)
        {
            var apps      = File.ReadAllLines(@"D:\cert.txt");
            var payHandle = new PayHandle();
            var shortUrl  = new ShortURL()
            {
                AppID   = apps[0],
                MchID   = apps[1],
                Key     = apps[3],
                LongURL = url
            };
            var shortUrlBack = payHandle.Send(shortUrl) as ShortURLBack;

            SavaQR(shortUrlBack.ShortURL);
            return(shortUrlBack);
        }
Esempio n. 5
0
        /// <summary>
        /// 下载对账单
        /// </summary>
        /// <returns></returns>
        static DownLoadBillBack DownLoadBill()
        {
            var apps         = File.ReadAllLines(@"D:\cert.txt");
            var payHandle    = new PayHandle();
            var downLoadBill = new DownLoadBill
            {
                AppID    = apps[0],
                MchID    = apps[1],
                Key      = apps[3],
                BillDate = "20170509",
                BillType = "SUCCESS"
            };
            var downLoadBillBack = payHandle.Send(downLoadBill) as DownLoadBillBack;

            return(downLoadBillBack);
        }
Esempio n. 6
0
        static ReportBack Report()
        {
            var apps      = File.ReadAllLines(@"D:\cert.txt");
            var payHandle = new PayHandle();
            var report    = new Report()
            {
                AppID        = apps[0],
                MchID        = apps[1],
                Key          = apps[3],
                InterfaceURL = "https://api.mch.weixin.qq.com/pay/unifiedorder",
                ExcuteTime   = 23000,
                ReturnCode   = "SUCCESS",
                ResultCode   = "SUCCESSS",
                UserIP       = "172.16.30.78"
            };
            var reportBack = payHandle.Send(report) as ReportBack;

            return(reportBack);
        }
Esempio n. 7
0
        /// <summary>
        /// 查询订单
        /// </summary>
        /// <param name="str">订单号</param>
        /// <returns></returns>
        static OrderQueryBack OrderQuery(string str)
        {
            var apps       = File.ReadAllLines(@"D:\cert.txt");
            var payHandle  = new PayHandle();
            var orderQuery = new OrderQuery
            {
                AppID = apps[0],
                MchID = apps[1],
                Key   = apps[3],

                //// NotifyURL = "http://www.abcd.com",

                OutTradeNo = str,
                //TODO 此处有问题
                TransactionID = "123456"
            };
            var orderQueryBack = payHandle.Send(orderQuery) as OrderQueryBack;

            return(orderQueryBack);
        }
Esempio n. 8
0
        /// <summary>
        /// 退单
        /// </summary>
        /// <param name="str">商户单号</param>
        static void Refund(string str)
        {
            var payHandle = new PayHandle();
            var apps      = File.ReadAllLines(@"D:\cert.txt");
            var refund    = new Refund()
            {
                CertificatePath = @"D:\apiclient_cert.p12",
                OutTradeNo      = str,
                AppID           = apps[0],
                MchID           = apps[1],
                Key             = apps[3],
                OutRefundNo     = "123456789",
                TotalFee        = 1,
                RefundFee       = 1,
                OpUserID        = "大连医卫信息"
            };

            var refundBack = payHandle.Send(refund) as RefundBack;

            if (refundBack.ResultCode == "SUCCESS")
            {
                Console.WriteLine("退费成功 ");
            }
        }