public override string ToString() { //Header "logical" element var SwissQrCodePayload = "SPC" + br; //QRType SwissQrCodePayload += "0100" + br; //Version SwissQrCodePayload += "1" + br; //Coding //CdtrInf "logical" element SwissQrCodePayload += iban.ToString() + br; //IBAN //Cdtr "logical" element SwissQrCodePayload += creditor.ToString(); //UltmtCdtr "logical" element if (ultimateCreditor != null) { SwissQrCodePayload += ultimateCreditor.ToString(); } else { SwissQrCodePayload += string.Concat(Enumerable.Repeat(br, 6).ToArray()); } //CcyAmtDate "logical" element SwissQrCodePayload += (amount != null ? $"{amount:0.00}" : string.Empty) + br; //Amt SwissQrCodePayload += currency + br; //Ccy SwissQrCodePayload += (requestedDateOfPayment != null ? ((DateTime)requestedDateOfPayment).ToString("yyyy-MM-dd") : string.Empty) + br; //ReqdExctnDt //UltmtDbtr "logical" element if (debitor != null) { SwissQrCodePayload += debitor.ToString(); } else { SwissQrCodePayload += string.Concat(Enumerable.Repeat(br, 6).ToArray()); } //RmtInf "logical" element SwissQrCodePayload += reference.RefType.ToString() + br; //Tp SwissQrCodePayload += (!string.IsNullOrEmpty(reference.ReferenceText) ? reference.ReferenceText : string.Empty) + br; //Ref SwissQrCodePayload += (!string.IsNullOrEmpty(reference.UnstructureMessage) ? reference.UnstructureMessage : string.Empty) + br; //Ustrd //AltPmtInf "logical" element if (!string.IsNullOrEmpty(alternativeProcedure1)) { SwissQrCodePayload += alternativeProcedure1.Replace("\n", "") + br; //AltPmt } if (!string.IsNullOrEmpty(alternativeProcedure2)) { SwissQrCodePayload += alternativeProcedure2.Replace("\n", "") + br; //AltPmt } return(SwissQrCodePayload); }
public void Constructor_Empty() { var iban = new Iban(); Assert.IsNull(iban.Country); Assert.IsNotNullOrEmpty(iban.NationalCheckDigits); Assert.AreEqual(NationalCheckDigits, iban.NationalCheckDigits); Assert.IsNull(iban.Bban); Assert.IsNullOrEmpty(iban.Value()); Assert.IsNotNullOrEmpty(iban.ToString()); }
static void Main(string[] args) { string defaultBankAccount = "5620092134961"; //string userInput2 = "159030-776"; // 159030-776, 101710-122 Console.WriteLine("Enter your bank number, ty. (e.g. 562009-2134961, 159030-776)"); string userInput = Console.ReadLine(); if (String.IsNullOrEmpty(userInput)) { userInput = defaultBankAccount; } Bban bban = new Bban(userInput); Console.WriteLine("BBAN is: {0}", bban.ToString()); Iban iban = new Iban(userInput); Console.WriteLine("IBAN is: {0}", iban.ToString()); string newIban = "FI2056200920134961"; if (Iban.Validate(newIban)) { Console.WriteLine($"{newIban} is valid."); } else { Console.WriteLine($"{newIban} is invalid."); } Console.WriteLine(Iban.GetBicCode(iban.ToString())); // END Console.WriteLine("\nPress any key to continue...."); Console.ReadKey(); }
public IActionResult Save([FromBody] InputModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Iban iban = _parser.Parse(model.BankAccountNumber); // Do something with model... model.BankAccountNumber = iban.ToString(Iban.Formats.Partitioned); return(Ok(model)); }
public IActionResult OnPostAsync(RazorPageModel model) { if (!ModelState.IsValid) { return(Page()); } Iban iban = Iban.Parse(model.BankAccountNumber); // Do something with model... BankAccountNumber = iban.ToString(Iban.Formats.Partitioned); return(Page()); }
public IActionResult OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } Iban iban = _parser.Parse(Model.BankAccountNumber); // Do something with model... Model.BankAccountNumber = iban.ToString(IbanFormat.Print); return(Page()); }
public IActionResult Save(InputModel model) { if (!ModelState.IsValid) { return(View("Index")); } Iban iban = _parser.Parse(model.BankAccountNumber); // Do something with model... ModelState.Clear(); model.BankAccountNumber = iban.ToString(Iban.Formats.Partitioned); return(View("Index", model)); }
public void IbanConstructionWithSupportedCountryShouldReturnIban() { Iban iban = Iban.CreateInstance("CZ6508000000192000145399"); Assert.AreEqual("CZ6508000000192000145399", iban.ToString()); }
public void ToString4() { var iban = new Iban("de", 88, "200800000970375710"); Assert.AreEqual("DE88 2008 0000 0970 3757 10", iban.ToString()); }
public void ToString2() { var iban = new Iban("de", 68, "210501700012345678"); Assert.AreEqual("DE68 2105 0170 0012 3456 78", iban.ToString()); }
public override string Pack() { string SwissQrCodePayload = "SPC" + br; //QRType SwissQrCodePayload += "0200" + br; //Version SwissQrCodePayload += "1" + br; //Coding //CdtrInf "logical" element SwissQrCodePayload += iban.ToString() + br; //IBAN //Cdtr "logical" element SwissQrCodePayload += creditor.ToString(); //UltmtCdtr "logical" element //Since version 2.0 ultimate creditor was marked as "for future use" and has to be delivered empty in any case! //SwissQrCodePayload += string.Concat(Enumerable.Repeat(br, 7).ToArray()); for (int i = 0; i < 7; i++) { SwissQrCodePayload += br; } //CcyAmtDate "logical" element //Amoutn has to use . as decimal seperator in any case. See https://www.paymentstandards.ch/dam/downloads/ig-qr-bill-en.pdf page 27. //SwissQrCodePayload += (amount != null ? amount.ToString().Replace(",", ".") : string.Empty) + br; //Amt if (amount != null) { string strAmount = amount.ToString(); if (!strAmount.Contains(".")) { strAmount = amount.ToString().Replace(",", "."); } else { strAmount += ".00"; } SwissQrCodePayload += strAmount; } else { SwissQrCodePayload += string.Empty; } SwissQrCodePayload += br; SwissQrCodePayload += currency + br; //Ccy //UltmtDbtr "logical" element if (debitor != null) { SwissQrCodePayload += debitor.ToString(); } else { for (int i = 0; i < 7; i++) { SwissQrCodePayload += br; } } //RmtInf "logical" element SwissQrCodePayload += reference.RefType.ToString() + br; //Tp SwissQrCodePayload += (!string.IsNullOrEmpty(reference.ReferenceText) ? reference.ReferenceText : string.Empty) + br; //Ref //AddInf "logical" element SwissQrCodePayload += (!string.IsNullOrEmpty(additionalInformation.UnstructureMessage) ? additionalInformation.UnstructureMessage : string.Empty) + br; //Ustrd SwissQrCodePayload += additionalInformation.Trailer + br; //Trailer SwissQrCodePayload += (!string.IsNullOrEmpty(additionalInformation.BillInformation) ? additionalInformation.BillInformation : string.Empty) + br; //StrdBkgInf //AltPmtInf "logical" element if (!string.IsNullOrEmpty(alternativeProcedure1)) { SwissQrCodePayload += alternativeProcedure1.Replace("\n", "") + br; //AltPmt } if (!string.IsNullOrEmpty(alternativeProcedure2)) { SwissQrCodePayload += alternativeProcedure2.Replace("\n", "") + br; //AltPmt } //S-QR specification 2.0, chapter 4.2.3 if (SwissQrCodePayload.EndsWith(br)) { SwissQrCodePayload = SwissQrCodePayload.Remove(SwissQrCodePayload.Length - br.Length); } return(SwissQrCodePayload); }
public void Empty_Iban_ToString_Returns_String_Empty() { var sut = new Iban(); sut.ToString().Should().Be(string.Empty); }