Exemplo n.º 1
0
        public ActionResult Index(InvoiceDelayViewModel Model)
        {
            //1. 設定觸發或延遲開立發票資訊
            InvoiceDelay invc = new InvoiceDelay();
            invc.MerchantID = Model.MerchantID;
            invc.DelayFlag = Model.DelayFlag;
            invc.RelateNumber = Model.RelateNumber;
            invc.CustomerID = Model.CustomerID;
            invc.CustomerIdentifier = Model.CustomerIdentifier;
            invc.CustomerAddr = Model.CustomerAddr;
            invc.CustomerName = Model.CustomerName;
            invc.CustomerPhone = Model.CustomerPhone;
            invc.CustomerEmail = Model.CustomerEmail;
            invc.ClearanceMark = Model.ClearanceMark;
            invc.TaxType = Model.TaxType;
            invc.SalesAmount = Model.SalesAmount;
            invc.carruerType = Model.CarruerType;
            invc.CarruerNum = Model.CarruerNum;
            invc.Donation = Model.Donation;
            invc.LoveCode = Model.LoveCode;
            invc.Print = Model.Print;
            invc.Items.Add(new Item()
            {
                ItemName = Model.ItemName,
                ItemPrice = Model.ItemPrice,
                ItemCount = Model.ItemCount,
                ItemWord = Model.ItemWord,
                ItemAmount = Model.ItemAmount
            });
            invc.InvoiceRemark = Model.InvoiceRemark;
            invc.DelayDay = Model.DelayDay;
            invc.ECBankID = Model.ECBankID;
            invc.Tsr = Model.Tsr;
            invc.PayType = Model.PayType;
            invc.NotifyURL = Model.NotifyURL;
            invc.invType = Model.InvType;

            //2. 初始化發票Service物件
            Invoice<InvoiceDelay> inv = new Invoice<InvoiceDelay>();

            //3. 指定測試環境, 上線時請記得改Prod
            inv.Environment = EInvoice.Integration.Enumeration.EnvironmentEnum.Stage;

            //4. 設定歐付寶提供的 Key 和 IV
            inv.HashIV = "q9jcZX8Ib9LM8wYk";
            inv.HashKey = "ejCk326UnaZWKisg";

            //5. 執行API的回傳結果(JSON)字串
            string json = inv.post(invc);

            //6. 解序列化,還原成物件使用
            //InvoiceDelayReturn obj = new InvoiceDelayReturn();
            //obj = JsonConvert.DeserializeObject<QueryAllowanceReturn>(json);
            //obj.XXX;
            // ...

            ViewBag.message = json;

            return View();
        }
Exemplo n.º 2
0
        public void TestDelayIssue()
        {
            //1. 設定觸發或延遲開立發票資訊
            var invoiceDelay = new InvoiceDelay
            {
                //廠商編號
                MerchantID = "2000132",
                //延遲註記
                DelayFlag = DelayFlagEnum.NormalDelay,
                //商家自訂訂單編號
                RelateNumber = "ecPaytest" + new Random().Next(0, 99999),
                //客戶代號
                CustomerID = "",
                //統一編號
                CustomerIdentifier = "",
                //客戶名稱
                CustomerName = "",
                //客戶地址
                CustomerAddr = "",
                //客戶手機號碼
                CustomerPhone = "0912345678",
                //客戶電子信箱
                CustomerEmail = "*****@*****.**",
                //通關方式
                //ClearanceMark = CustomsClearanceMarkEnum.None,
                //列印註記
                Print = PrintEnum.No,
                //捐贈註記
                Donation = DonationEnum.No,
                //愛心碼
                LoveCode = "930",
                //載具類別
                carruerType = CarruerTypeEnum.PhoneBarcode,
                //載具編號
                //依API說明,把+號換成空白
                CarruerNum = "/6G+X3LQ".Replace('+', ' '),
                //課稅類別
                TaxType = TaxTypeEnum.DutyFree,
                //發票金額。含稅總金額
                SalesAmount = "200",
                //備註
                InvoiceRemark = "",
                //延遲天數
                DelayDay = "5",
                //ECBank 代號
                //ECBankID = "",
                //交易單號
                Tsr = "ecPaytest" + new Random().Next(0, 99999),
                //交易類別
                PayType = PayTypeEnum.ECPAY,
                //開立完成時通知廠商的網址
                //NotifyURL = "",
                //發票字軌類別
                //invType = TheWordTypeEnum.Normal,
                //商品單價是否含稅
                //vat = VatEnum.No
            };

            //2. 商品資訊(Item)的集合類別。
            invoiceDelay.Items.Add(new Item
            {
                ItemName   = "1111111", //商品名稱
                ItemPrice  = "100",     //商品單價
                ItemCount  = "1",       //商品數量
                ItemWord   = "個",       //單位
                ItemAmount = "100",     //總金額
                //ItemTaxType  =TaxTypeEnum.DutyFree//商品課稅別
            });
            invoiceDelay.Items.Add(new Item
            {
                ItemName   = "1111111", //商品名稱
                ItemPrice  = "100",     //商品單價
                ItemCount  = "1",       //商品數量
                ItemWord   = "個",       //單位
                ItemAmount = "100",     //總金額
                //ItemTaxType  =TaxTypeEnum.DutyFree//商品課稅別
            });

            //3. 執行API的回傳結果
            var response = Client.Post <InvoiceDelayReturn, InvoiceDelay>(invoiceDelay);

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

            //交易單號要一樣
            Assert.AreEqual(invoiceDelay.Tsr, response.OrderNumber);
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //1. 設定觸發或延遲開立發票資訊
            InvoiceDelay invc = new InvoiceDelay();

            invc.MerchantID         = "2000132";                                            //廠商編號
            invc.DelayFlag          = DelayFlagEnum.NormalDelay;                            //延遲註記
            invc.RelateNumber       = "ecPaytest" + new Random().Next(0, 99999).ToString(); //商家自訂訂單編號
            invc.CustomerID         = "";                                                   //客戶代號
            invc.CustomerIdentifier = "";                                                   //統一編號
            invc.CustomerName       = "";                                                   //客戶名稱
            invc.CustomerAddr       = "";                                                   //客戶地址
            invc.CustomerPhone      = "0912345678";                                         //客戶手機號碼
            invc.CustomerEmail      = "*****@*****.**";                                 //客戶電子信箱
            //invc.ClearanceMark = CustomsClearanceMarkEnum.None;//通關方式
            invc.Print    = PrintEnum.No;                                                   //列印註記
            invc.Donation = DonationEnum.No;                                                //捐贈註記
            //invc.LoveCode = "930";//愛心碼
            invc.carruerType   = CarruerTypeEnum.PhoneBarcode;                              //載具類別
            invc.CarruerNum    = "/6G+X3LQ";                                                //載具編號
            invc.CarruerNum    = invc.CarruerNum.Replace('+', ' ');                         //依API說明,把+號換成空白
            invc.TaxType       = TaxTypeEnum.DutyFree;                                      //課稅類別
            invc.SalesAmount   = "200";                                                     //發票金額。含稅總金額
            invc.InvoiceRemark = "";                                                        //備註
            invc.DelayDay      = "0";                                                       //延遲天數
            //invc.ECBankID = "";//ECBank 代號
            invc.Tsr     = "ecPaytest" + new Random().Next(0, 99999).ToString();            //交易單號
            invc.PayType = PayTypeEnum.ECPAY;                                               //交易類別
            //invc.NotifyURL = "";//開立完成時通知廠商的網址
            //invc.invType = TheWordTypeEnum.Normal;//發票字軌類別
            //invc.vat = VatEnum.No;//商品單價是否含稅

            //商品資訊(Item)的集合類別。
            invc.Items.Add(new Item()
            {
                ItemName   = "1111111", //商品名稱
                ItemPrice  = "100",     //商品單價
                ItemCount  = "1",       //商品數量
                ItemWord   = "個",       //單位
                ItemAmount = "100",     //總金額
                //ItemTaxType  =TaxTypeEnum.DutyFree//商品課稅別
            });
            invc.Items.Add(new Item()
            {
                ItemName   = "1111111", //商品名稱
                ItemPrice  = "100",     //商品單價
                ItemCount  = "1",       //商品數量
                ItemWord   = "個",       //單位
                ItemAmount = "100",     //總金額
                //ItemTaxType  =TaxTypeEnum.DutyFree//商品課稅別
            });

            //2. 初始化發票Service物件
            Invoice <InvoiceDelay> inv = new Invoice <InvoiceDelay>();

            //3. 指定測試環境, 上線時請記得改Prod
            inv.Environment = Ecpay.EInvoice.Integration.Enumeration.EnvironmentEnum.Stage;
            //4. 設定歐付寶提供的 Key 和 IV
            inv.HashIV  = "q9jcZX8Ib9LM8wYk";
            inv.HashKey = "ejCk326UnaZWKisg";
            //5. 執行API的回傳結果(JSON)字串
            string json = inv.post(invc);


            bool check = isJSON2(json);

            string temp = string.Empty;



            if (check)   //判斷是不是json格式
            {
                //6. 解序列化,還原成物件使用
                InvoiceCreateReturn obj = new InvoiceCreateReturn();

                obj = JsonConvert.DeserializeObject <InvoiceCreateReturn>(json);

                temp = string.Format("開立發票結果<br> InvoiceDate={0}<br> InvoiceNumber={1}<br> RandomNumber={2}<br> RtnCode={3} <br> RtnCode={4} ", obj.InvoiceDate, obj.InvoiceNumber, obj.RandomNumber, obj.RtnCode, obj.RtnMsg);
            }
            else
            {
                temp = json;
            }
            Response.Write(temp);
        }
Exemplo n.º 4
0
        public ActionResult Index(InvoiceDelayViewModel Model)
        {
            //1. 設定觸發或延遲開立發票資訊
            InvoiceDelay invc = new InvoiceDelay();

            invc.MerchantID         = Model.MerchantID;
            invc.DelayFlag          = Model.DelayFlag;
            invc.RelateNumber       = Model.RelateNumber;
            invc.CustomerID         = Model.CustomerID;
            invc.CustomerIdentifier = Model.CustomerIdentifier;
            invc.CustomerAddr       = Model.CustomerAddr;
            invc.CustomerName       = Model.CustomerName;
            invc.CustomerPhone      = Model.CustomerPhone;
            invc.CustomerEmail      = Model.CustomerEmail;
            invc.ClearanceMark      = Model.ClearanceMark;
            invc.TaxType            = Model.TaxType;
            invc.SalesAmount        = Model.SalesAmount;
            invc.carruerType        = Model.CarruerType;
            invc.CarruerNum         = Model.CarruerNum;
            invc.Donation           = Model.Donation;
            invc.LoveCode           = Model.LoveCode;
            invc.Print = Model.Print;
            invc.Items.Add(new Item()
            {
                ItemName   = Model.ItemName,
                ItemPrice  = Model.ItemPrice,
                ItemCount  = Model.ItemCount,
                ItemWord   = Model.ItemWord,
                ItemAmount = Model.ItemAmount
            });
            invc.InvoiceRemark = Model.InvoiceRemark;
            invc.DelayDay      = Model.DelayDay;
            invc.ECBankID      = Model.ECBankID;
            invc.Tsr           = Model.Tsr;
            invc.PayType       = Model.PayType;
            invc.NotifyURL     = Model.NotifyURL;
            invc.invType       = Model.InvType;

            //2. 初始化發票Service物件
            Invoice <InvoiceDelay> inv = new Invoice <InvoiceDelay>();

            //3. 指定測試環境, 上線時請記得改Prod
            inv.Environment = EInvoice.Integration.Enumeration.EnvironmentEnum.Stage;

            //4. 設定歐付寶提供的 Key 和 IV
            inv.HashIV  = "q9jcZX8Ib9LM8wYk";
            inv.HashKey = "ejCk326UnaZWKisg";

            //5. 執行API的回傳結果(JSON)字串
            string json = inv.post(invc);

            //6. 解序列化,還原成物件使用
            //InvoiceDelayReturn obj = new InvoiceDelayReturn();
            //obj = JsonConvert.DeserializeObject<QueryAllowanceReturn>(json);
            //obj.XXX;
            // ...

            ViewBag.message = json;

            return(View());
        }