Пример #1
0
        /// <summary>
        /// 刷卡(条码)支付
        /// </summary>
        /// <param name="order">扫码支付对象</param>
        /// <returns>二维码字符串</returns>
        public LcswPayDate.OrderPayACK BarcodePay(LcswPayDate.TradePay order)
        {
            order.pay_ver       = LcswPayConfig.Ver;
            order.merchant_no   = LcswPayConfig.StoreID;
            order.terminal_id   = LcswPayConfig.DeviceID;
            order.terminal_time = DateTime.Now.ToString("yyyyMMddHHmmss");
            order.service_id    = "010";
            order.key_sign      = order.GetSign();

            JavaScriptSerializer jsonSerialize = new JavaScriptSerializer();
            string data = jsonSerialize.Serialize(order);

            string response = Post(data, LcswPayConfig.GatewayURL + "pay/100/barcodepay", false, 20);

            Console.WriteLine(response);

            LcswPayDate.OrderPayACK ack = jsonSerialize.Deserialize <LcswPayDate.OrderPayACK>(response);
            if (ack.CheckSign())
            {
                //验签成功
                if (ack.return_code == "01")
                {
                    //响应成功
                    if (ack.result_code == "01")
                    {
                        //qrCode = ack.qr_code;
                        //return true;
                        return(ack);
                    }
                }
            }

            return(null);
        }
Пример #2
0
        /// <summary>
        /// 请求扫码支付条码
        /// </summary>
        /// <param name="order">扫码支付对象</param>
        /// <returns>二维码字符串</returns>
        public bool OrderPay(LcswPayDate.OrderPay order, out string qrCode)
        {
            qrCode              = "";
            order.pay_ver       = LcswPayConfig.Ver;
            order.merchant_no   = LcswPayConfig.StoreID;
            order.terminal_id   = LcswPayConfig.DeviceID;
            order.terminal_time = DateTime.Now.ToString("yyyyMMddHHmmss");
            order.service_id    = "011";
            order.notify_url    = LcswPayConfig.NotifyURL;
            order.key_sign      = order.GetSign();

            JavaScriptSerializer jsonSerialize = new JavaScriptSerializer();
            string data = jsonSerialize.Serialize(order);

            string response = Post(data, LcswPayConfig.GatewayURL + "pay/100/prepay", false, 20);

            Console.WriteLine(response);

            LcswPayDate.OrderPayACK ack = jsonSerialize.Deserialize <LcswPayDate.OrderPayACK>(response);
            if (ack.CheckSign())
            {
                //验签成功
                if (ack.return_code == "01")
                {
                    //响应成功
                    if (ack.result_code == "01")
                    {
                        //条码请求成功
                        qrCode = ack.qr_code;
                        return(true);
                    }
                }
            }

            return(false);
        }