Exemplo n.º 1
0
        static void UnifiedOrder()
        {
            var apps = File.ReadAllLines(@"D:\alipay\app.txt");

            Console.WriteLine("请输入订单号:");
            var tradeNo   = Console.ReadLine();
            var precreate = new Precreate()
            {
                AppID       = apps[0],
                Charset     = "utf-8",
                SignType    = "RSA",
                Timestamp   = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),// "2017-03-25 03:07:50",
                Version     = "1.0",
                OutTradeNo  = tradeNo,
                TotalAmount = 0.01m,
                NotifyUrl   = "http://a.b.com",
                Subject     = "test123"
            };
            var payHandle      = new AlipayPayCore.PayHandle();
            var backPreccreate = payHandle.Send(precreate) as PrecreateBack;

            if (backPreccreate.Code == "10000")
            {
                SavaQR(backPreccreate.QrCode);
            }
            else
            {
                Console.WriteLine($"Code:{backPreccreate.Code} Message:{backPreccreate.Message}");
            }
        }
Exemplo n.º 2
0
        static void Refund()
        {
            var apps = File.ReadAllLines(@"D:\alipay\app.txt");

            Console.WriteLine("请输入订单号:");
            var tradeNo = Console.ReadLine();
            var refund  = new Refund()
            {
                AppID        = apps[0],
                Charset      = "utf-8",
                SignType     = "RSA",
                Timestamp    = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                Version      = "1.0",
                OutTradeNo   = tradeNo,
                RefundAmount = 0.01m,
                RefundReason = "his收费失败"
            };
            var payHandle  = new AlipayPayCore.PayHandle();
            var backRefund = payHandle.Send(refund) as RefundBack;

            if (backRefund.Code == "10000")
            {
                Console.WriteLine($"code:{backRefund.Code} msg:{backRefund.Message}");
            }
            else
            {
                Console.WriteLine($"code:{backRefund.Code} msg:{backRefund.Message} SubCode:{backRefund.SubCode}  SubMessage:{backRefund.SubMessage}");
            }
        }