Exemplo n.º 1
0
        /// <summary>
        /// Generate the Transaction XML part
        /// </summary>
        /// <param name="pmtInf">The root nodes for a transaction</param>
        /// <param name="transfer">The transaction to generate</param>
        private static void GenerateTransaction(XmlElement pmtInf, SepaCreditTransferTransaction transfer)
        {
            var cdtTrfTxInf = pmtInf.NewElement("CdtTrfTxInf");
            var pmtId       = cdtTrfTxInf.NewElement("PmtId");

            if (transfer.Id != null)
            {
                pmtId.NewElement("InstrId", transfer.Id);
            }
            pmtId.NewElement("EndToEndId", transfer.EndToEndId);
            cdtTrfTxInf.NewElement("Amt")
            .NewElement("InstdAmt", StringUtils.FormatAmount(transfer.Amount))
            .SetAttribute("Ccy", transfer.Currency);
            cdtTrfTxInf.NewElement("CdtrAgt").NewElement("FinInstnId").NewElement("BIC", transfer.Creditor.Bic);
            cdtTrfTxInf.NewElement("Cdtr").NewElement("Nm", transfer.Creditor.Name);
            cdtTrfTxInf.NewElement("CdtrAcct").NewElement("Id").NewElement("IBAN", transfer.Creditor.Iban);
            cdtTrfTxInf.NewElement("RmtInf").NewElement("Ustrd", transfer.RemittanceInformation);
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Add an existing credit transfer transaction
        /// </summary>
        /// <param name="transfer"></param>
        /// <exception cref="ArgumentNullException">If transfert is null.</exception>
        public void AddCreditTransfer(SepaCreditTransferTransaction transfer)
        {
            if (transfer == null)
            {
                throw new ArgumentNullException("transfer");
            }

            transfer = (SepaCreditTransferTransaction)transfer.Clone();
            if (transfer.EndToEndId == null)
            {
                transfer.EndToEndId = (PaymentInfoId ?? MessageIdentification) + "/" + (numberOfTransactions + 1);
            }
            CheckTransactionIdUnicity(transfer.Id, transfer.EndToEndId);
            transactions.Add(transfer);
            numberOfTransactions++;
            headerControlSum  += transfer.Amount;
            paymentControlSum += transfer.Amount;
        }