Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            MobileBarcode qinv = new MobileBarcode();

            qinv.MerchantID = "2000132";                      //廠商編號。
            qinv.BarCode    = "/6G+X3LQ";
            qinv.BarCode    = qinv.BarCode.Replace('+', ' '); //依API說明,把+號換成空白
            Invoice <MobileBarcode> inv = new Invoice <MobileBarcode>();

            inv.Environment = Ecpay.EInvoice.Integration.Enumeration.EnvironmentEnum.Stage;
            inv.HashIV      = "q9jcZX8Ib9LM8wYk";
            inv.HashKey     = "ejCk326UnaZWKisg";

            string json = inv.post(qinv);

            Dictionary <string, string> values = JsonConvert.DeserializeObject <Dictionary <string, string> >(json);


            string temp = string.Empty;

            temp = string.Format("結果<br> Data={0} ", values["IsExist"].ToString());
            Response.Write(temp);
            temp = string.Format("結果<br> RtnCode={0} ", values["RtnCode"].ToString());
            Response.Write(temp);
        }
        public void TestCheckMobileBarCode()
        {
            //1. 產生條碼物件
            var mobileBarcode = new MobileBarcode
            {
                //廠商編號。
                MerchantID = "2000132",

                //依API說明,把+號換成空白
                BarCode = "/6G+X3LQ".Replace('+', ' ')
            };

            //2. 執行API的回傳結果
            var response = Client.Post <MobileBarcodeReturn, MobileBarcode>(mobileBarcode);

            //表示成功
            Assert.AreEqual("1", response.RtnCode);

            //表示存在
            Assert.AreEqual("Y", response.IsExist);

            //表示存在
            Assert.AreEqual("B12E2D8EBEAEC0EA37173BB65B77150F", response.CheckMacValue);
        }