private async void btnVerifySignedInv_Click(object sender, EventArgs e) { string RespJson = File.ReadAllText(WorkingFilesPath + @"\RespPlGenIRN.txt"); VerifyRespPl verifyRespPl = new VerifyRespPl(); RespPlGenIRN respPlGenIRN = new RespPlGenIRN(); respPlGenIRN = JsonConvert.DeserializeObject <RespPlGenIRN>(RespJson); TxnRespWithObj <VerifyRespPl> txnRespWithObj = await eInvoiceAPI.VerifySignedInvoice(eInvSession, respPlGenIRN); if (txnRespWithObj.IsSuccess) { verifyRespPl.IsVerified = txnRespWithObj.RespObj.IsVerified; verifyRespPl.JwtIssuerIRP = txnRespWithObj.RespObj.JwtIssuerIRP; verifyRespPl.VerifiedWithCertificateEffectiveFrom = txnRespWithObj.RespObj.VerifiedWithCertificateEffectiveFrom; verifyRespPl.CertificateName = txnRespWithObj.RespObj.CertificateName; verifyRespPl.CertStartDate = txnRespWithObj.RespObj.CertStartDate; verifyRespPl.CertExpiryDate = txnRespWithObj.RespObj.CertExpiryDate; } else { verifyRespPl = txnRespWithObj.RespObj; } }
private async void btnGenIRN_Click(object sender, EventArgs e) { ReqPlGenIRN reqPlGenIRN = new ReqPlGenIRN(); //reqPlGenIRN.Version = "1.01"; //reqPlGenIRN.TranDtls = new ReqPlGenIRN.TranDetails(); //reqPlGenIRN.TranDtls.TaxSch = "GST"; //reqPlGenIRN.TranDtls.SupTyp = "B2B"; //reqPlGenIRN.DocDtls = new ReqPlGenIRN.DocSetails(); //reqPlGenIRN.DocDtls.Typ = "INV"; //reqPlGenIRN.DocDtls.No = "DOC-NO/64"; //reqPlGenIRN.DocDtls.Dt = "11/03/2020"; //reqPlGenIRN.SellerDtls = new ReqPlGenIRN.SellerDetails(); //reqPlGenIRN.SellerDtls.Gstin = "************"; //reqPlGenIRN.SellerDtls.LglNm = "ABC company pvt ltd"; //reqPlGenIRN.SellerDtls.TrdNm = null; //reqPlGenIRN.SellerDtls.Addr1 = "5th block, kuvempu layout"; //reqPlGenIRN.SellerDtls.Addr2 = null; //reqPlGenIRN.SellerDtls.Loc = "GANDHINAGAR"; //reqPlGenIRN.SellerDtls.Pin = "560002"; //reqPlGenIRN.SellerDtls.State = "KARNATAKA"; //reqPlGenIRN.SellerDtls.Ph = null; //reqPlGenIRN.SellerDtls.Em = null; //reqPlGenIRN.BuyerDtls = new ReqPlGenIRN.BuyerDetails(); //reqPlGenIRN.BuyerDtls.Gstin = "37BZNPM9430M1kl"; //reqPlGenIRN.BuyerDtls.LglNm = "XYZ company pvt ltd"; //reqPlGenIRN.BuyerDtls.TrdNm = null; //reqPlGenIRN.BuyerDtls.Pos = "37"; //reqPlGenIRN.BuyerDtls.Addr1 = "7th block, kuvempu layout"; //reqPlGenIRN.BuyerDtls.Addr2 = null; //reqPlGenIRN.BuyerDtls.Loc = "GANDHINAGAR"; //reqPlGenIRN.BuyerDtls.Pin = null; //reqPlGenIRN.BuyerDtls.State = null; //reqPlGenIRN.BuyerDtls.Ph = null; //reqPlGenIRN.BuyerDtls.Em = null; //reqPlGenIRN.DispDtls = new ReqPlGenIRN.DispatchedDetails(); //reqPlGenIRN.DispDtls.Nm = "ABC company pvt ltd"; //reqPlGenIRN.DispDtls.Addr1 = "7th block, kuvempu layout"; //reqPlGenIRN.DispDtls.Addr2 = null; //reqPlGenIRN.DispDtls.Loc = "Banagalore"; //reqPlGenIRN.DispDtls.Pin = "560043"; //reqPlGenIRN.DispDtls.Stcd = "29"; //reqPlGenIRN.ShipDtls = new ReqPlGenIRN.ShippedDetails(); //reqPlGenIRN.ShipDtls.Gstin = null; //reqPlGenIRN.ShipDtls.LglNm = "CBE company pvt ltd"; //reqPlGenIRN.ShipDtls.TrdNm = null; //reqPlGenIRN.ShipDtls.Addr1 = "7th block, kuvempu layout"; //reqPlGenIRN.ShipDtls.Addr2 = null; //reqPlGenIRN.ShipDtls.Loc = "Banagalore"; //reqPlGenIRN.ShipDtls.Pin = "560043"; //reqPlGenIRN.ShipDtls.Stcd = "29"; //reqPlGenIRN.ItemList = new List<ReqPlGenIRN.ItmList>(); //ReqPlGenIRN.ItmList itm = new ReqPlGenIRN.ItmList(); //itm.SlNo = "1"; //itm.IsServc = "N"; //itm.PrdDesc = null; //itm.HsnCd = "1001"; //itm.BchDtls = null; //itm.Qty = null; //itm.Unit = null; //itm.UnitPrice = 10.00; //itm.TotAmt = 10.00; //itm.Discount = 0.0; //itm.AssAmt = 10.00; //itm.GstRt = 10.00; //itm.SgstAmt = 0.0; //itm.IgstAmt = 0.0; //itm.CgstAmt = 0.0; //itm.CesRt = 0.0; //itm.CesAmt = 0.0; //itm.CesNonAdvlAmt = 0.0; //itm.StateCesRt = 0.0; //itm.StateCesAmt = 0.0; //itm.StateCesNonAdvlAmt = 0.0; //itm.OthChrg = 0.0; //itm.TotItemVal = 10.00; //itm.AttribDtls = null; //reqPlGenIRN.ItemList.Add(itm); //reqPlGenIRN.PayDtls = null; //reqPlGenIRN.RefDtls = null; //reqPlGenIRN.AddlDocDtls = null; //reqPlGenIRN.ExpDtls = null; //reqPlGenIRN.EwbDtls = null; //reqPlGenIRN.ValDtls = new ReqPlGenIRN.ValDetails(); //reqPlGenIRN.ValDtls.AssVal = 0.0; //reqPlGenIRN.ValDtls.CgstVal = 0.0; //reqPlGenIRN.ValDtls.SgstVal = 0.0; //reqPlGenIRN.ValDtls.IgstVal = 0.0; //reqPlGenIRN.ValDtls.CesVal = 0.0; //reqPlGenIRN.ValDtls.StCesVal = 0.0; //reqPlGenIRN.ValDtls.RndOffAmt = 0.0; //reqPlGenIRN.ValDtls.TotInvVal = 0.0; //TxnRespWithObj<RespPlGenIRN> txnRespWithObj = await eInvoiceAPI.GenIRNAsync(eInvSession, reqPlGenIRN); //PayLoad in Json Format reading file Json. //string ReqJson = File.ReadAllText(WorkingFilesPath + @"\ProductionSampleJsonGenIRN.txt"); //TxnRespWithObj<RespPlGenIRN> txnRespWithObj = await eInvoiceAPI.GenIRNAsync(eInvSession, ReqJson, 250); string ReqJson = File.ReadAllText(txtResponceHdr.Text); TxnRespWithObj <RespPlGenIRN> txnRespWithObj = await eInvoiceAPI.GenIRNAsync(eInvSession, rtbResponce.Text, 250); RespPlGenIRN respPlGenIRN = txnRespWithObj.RespObj; string ErrorCodes = ""; string ErrorDesc = ""; rtbResponce.Text = ""; if (txnRespWithObj.IsSuccess) { //Process the Response here //For DEMO, just showing the searilized Response Object in text box rtbResponce.Text = JsonConvert.SerializeObject(respPlGenIRN); //respPlGenIRN.QrCodeImage.Save(@"C:\Users\Desktop\qr1.png"); //Store respPlGenIRN (manditory - AckDate and SignedInvoice) to verify signed invoice //below code is to show how to verify signed invoice respPlGenIRN.QrCodeImage = null; TxnRespWithObj <VerifyRespPl> txnRespWithObj1 = await eInvoiceAPI.VerifySignedInvoice(eInvSession, respPlGenIRN); VerifyRespPl verifyRespPl = new VerifyRespPl(); if (txnRespWithObj.IsSuccess) { verifyRespPl.IsVerified = txnRespWithObj1.RespObj.IsVerified; verifyRespPl.JwtIssuerIRP = txnRespWithObj1.RespObj.JwtIssuerIRP; verifyRespPl.VerifiedWithCertificateEffectiveFrom = txnRespWithObj1.RespObj.VerifiedWithCertificateEffectiveFrom; verifyRespPl.CertificateName = txnRespWithObj1.RespObj.CertificateName; verifyRespPl.CertStartDate = txnRespWithObj1.RespObj.CertStartDate; verifyRespPl.CertExpiryDate = txnRespWithObj1.RespObj.CertExpiryDate; } } else { //Error has occured //Display TxnOutCome in text box - process or show msg to user //Process error codes if (txnRespWithObj.ErrorDetails != null) { foreach (RespErrDetailsPl errPl in txnRespWithObj.ErrorDetails) { //Process errPl item here ErrorCodes += errPl.ErrorCode + ","; ErrorDesc += errPl.ErrorCode + ": " + errPl.ErrorMessage + Environment.NewLine; rtbResponce.Text = ErrorDesc; } } //Process InfoDetails here RespInfoDtlsPl respInfoDtlsPl = new RespInfoDtlsPl(); //Serialize Desc object from InfoDtls as per InfCd if (txnRespWithObj.InfoDetails != null) { foreach (RespInfoDtlsPl infoPl in txnRespWithObj.InfoDetails) { var strDupIrnPl = JsonConvert.SerializeObject(infoPl.Desc); //Convert object type to json string switch (infoPl.InfCd) { case "DUPIRN": DupIrnPl dupIrnPl = JsonConvert.DeserializeObject <DupIrnPl>(strDupIrnPl); break; case "EWBERR": List <EwbErrPl> ewbErrPl = JsonConvert.DeserializeObject <List <EwbErrPl> >(strDupIrnPl); break; case "ADDNLNFO": //Deserialize infoPl.Desc as string type and then if this string contains json object, it may be desirilized again as per future releases string strDesc = (string)infoPl.Desc; break; } } } } txtResponceHdr.Text = "Generate IRN Responce..."; }