/// <summary> /// Generates the payload for a Girocode (QR-Code with credit transfer information). /// Attention: When using Girocode payload, QR code must be generated with ECC level M! /// </summary> /// <param name="iban">Account number of the Beneficiary. Only IBAN is allowed.</param> /// <param name="bic">BIC of the Beneficiary Bank.</param> /// <param name="name">Name of the Beneficiary.</param> /// <param name="amount">Amount of the Credit Transfer in Euro. /// (Amount must be more than 0.01 and less than 999999999.99)</param> /// <param name="remittanceInformation">Remittance Information (Purpose-/reference text). (optional)</param> /// <param name="typeOfRemittance">Type of remittance information. Either structured (e.g. ISO 11649 RF Creditor Reference) and max. 35 chars or unstructured and max. 140 chars.</param> /// <param name="purposeOfCreditTransfer">Purpose of the Credit Transfer (optional)</param> /// <param name="messageToGirocodeUser">Beneficiary to originator information. (optional)</param> /// <param name="version">Girocode version. Either 001 or 002. Default: 001.</param> /// <param name="encoding">Encoding of the Girocode payload. Default: ISO-8859-1</param> public Girocode(string iban, string bic, string name, decimal amount, string remittanceInformation = "", TypeOfRemittance typeOfRemittance = TypeOfRemittance.Unstructured, string purposeOfCreditTransfer = "", string messageToGirocodeUser = "", GirocodeVersion version = GirocodeVersion.Version1, GirocodeEncoding encoding = GirocodeEncoding.ISO_8859_1) { this.version = version; this.encoding = encoding; if (!IsValidIban(iban)) { throw new GirocodeException("The IBAN entered isn't valid."); } this.iban = iban.Replace(" ", "").ToUpper(); if (!IsValidBic(bic)) { throw new GirocodeException("The BIC entered isn't valid."); } this.bic = bic.Replace(" ", "").ToUpper(); if (name.Length > 70) { throw new GirocodeException("(Payee-)Name must be shorter than 71 chars."); } this.name = name; if (amount.ToString().Replace(",", ".").Contains(".") && amount.ToString().Replace(",", ".").Split('.')[1].TrimEnd('0').Length > 2) { throw new GirocodeException("Amount must have less than 3 digits after decimal point."); } if (amount < 0.01m || amount > 999999999.99m) { throw new GirocodeException("Amount has to at least 0.01 and must be smaller or equal to 999999999.99."); } this.amount = amount; if (purposeOfCreditTransfer.Length > 4) { throw new GirocodeException("Purpose of credit transfer can only have 4 chars at maximum."); } this.purposeOfCreditTransfer = purposeOfCreditTransfer; if (typeOfRemittance == TypeOfRemittance.Unstructured && remittanceInformation.Length > 140) { throw new GirocodeException("Unstructured reference texts have to shorter than 141 chars."); } if (typeOfRemittance == TypeOfRemittance.Structured && remittanceInformation.Length > 35) { throw new GirocodeException("Structured reference texts have to shorter than 36 chars."); } this.typeOfRemittance = typeOfRemittance; this.remittanceInformation = remittanceInformation; if (messageToGirocodeUser.Length > 70) { throw new GirocodeException("Message to the Girocode-User reader texts have to shorter than 71 chars."); } this.messageToGirocodeUser = messageToGirocodeUser; }
public EPCQRCode(string iban , string nameOfBeneficiary , decimal amount , string bic = "" , string remittanceInformation = "" , TypeOfRemittance typeOfRemittance = TypeOfRemittance.Unstructured , string purposeOfCreditTransfer = "" , string messageToBeneficiary = "") { this.nameBeneficiary = nameOfBeneficiary; this.amount = amount; this.bicBeneficiary = bic; this.accountNumberBeneficiary = iban; this.remittanceInformation = remittanceInformation; this.typeOfRemittance = typeOfRemittance; this.purposeOfCreditTransfer = purposeOfCreditTransfer; this.beneficiaryToOriginatorInformation = messageToBeneficiary; }