PaymentInstructionInformation4 GeneratePaymentInformation_PmtInf( Creditor creditor, CreditorAgent creditorAgent, DirectDebitInitiationContract directDebitInitiationContract, DirectDebitRemittance directDebitRemittance, List<DirectDebitTransactionInformation9> directDebitTransactionInfo_DrctDbtTxInfList) { string paymentInformationIdentificaction_PmtInfId = "201402101"; //Private unique ID for payment group DateTime reqCollectionDate_ReqdColltnDt = new DateTime(2014, 2, 01); ServiceLevel8Choice serviceLevel_SvcLvl = new ServiceLevel8Choice( "SEPA", ItemChoiceType.Cd); LocalInstrument2Choice localInstrument_LclInstrm = new LocalInstrument2Choice( "COR1", ItemChoiceType.Cd); CategoryPurpose1Choice categoryOfPurpose_CtgyPurp = new CategoryPurpose1Choice( "Mensualidad", ItemChoiceType.Prtry); PaymentTypeInformation20 paymentTypeInformation_PmtTpInf = new PaymentTypeInformation20( Priority2Code.NORM, //<InstrPrty> Not used in SEPA COR1, but can't be null false, //<InstrPrty> will not be serialized serviceLevel_SvcLvl, //<SvcLvl> localInstrument_LclInstrm, //<LclInstrm> SequenceType1Code.RCUR, //<SeqTp> true, //<SeqTP> wll be serialized categoryOfPurpose_CtgyPurp); //<CtgyPurp> PartyIdentification32 creditor_Cdtr = new PartyIdentification32( creditor.Name, null, null, null, null); AccountIdentification4Choice creditorAccount_Id = new AccountIdentification4Choice( directDebitInitiationContract.CreditorAcount.IBAN.IBAN); CashAccount16 creditorAccount_CdtrAcct = new CashAccount16( creditorAccount_Id, null, null, null); FinancialInstitutionIdentification7 financialInstitutuinIdentification_FinInstnID = new FinancialInstitutionIdentification7( creditorAgent.BankBIC, null, null, null, null); BranchAndFinancialInstitutionIdentification4 creditorAgent_CdtrAgt = new BranchAndFinancialInstitutionIdentification4( financialInstitutuinIdentification_FinInstnID, null); OrganisationIdentificationSchemeName1Choice orgIDSchemeNameChoice_schmeNm = new OrganisationIdentificationSchemeName1Choice( "SEPA", ItemChoiceType.Prtry); GenericOrganisationIdentification1 genericOrganisationIdentification_othr = new GenericOrganisationIdentification1( directDebitInitiationContract.CreditorID, orgIDSchemeNameChoice_schmeNm, null); OrganisationIdentification4 organisationIdentification_orgiD = new OrganisationIdentification4( null, new GenericOrganisationIdentification1[] { genericOrganisationIdentification_othr }); Party6Choice organisationOrPrivateIdentification_id = new Party6Choice(organisationIdentification_orgiD); PartyIdentification32 creditorSchemeIdentification_CdtrSchemeId = new PartyIdentification32( null, null, organisationOrPrivateIdentification_id, null, null); DirectDebitTransactionInformation9[] directDebitTransactionInfoCollection = directDebitTransactionInfo_DrctDbtTxInfList.ToArray(); PaymentInstructionInformation4 paymentInformation_PmtInf = new PaymentInstructionInformation4( paymentInformationIdentificaction_PmtInfId, //<PmtInfId> PaymentMethod2Code.DD, //<PmtMtd> true, //<BtchBookg> Only one account entry for all payments true, //<BtchBookg> Will be serialized "2", //<NbOfTxs> (decimal)237, //<CtrlSum> true, //<CtrlSum> will be specified paymentTypeInformation_PmtTpInf, //<PmtTpInf> reqCollectionDate_ReqdColltnDt, //<ReqdColltnDt> creditor_Cdtr, //<Cdtr> creditorAccount_CdtrAcct, //<CdtrAcc> creditorAgent_CdtrAgt, //<CdtrAgt> null, //<CdtrAgtAcct> null, //<UltmtCdtr> Not neccesary. Same than creditor ChargeBearerType1Code.SLEV, //<ChrgBr> true, //<ChrgBr> will be serialized null, //<ChrgsAcct> Not used in SEPA COR1 null, //<ChrgsAcctAgt> Not used in SEPA COR1 creditorSchemeIdentification_CdtrSchemeId, //<CdtrSchemeId> directDebitTransactionInfoCollection); //<DrctDbtTxInf> return paymentInformation_PmtInf; }
public void PaymentInformation_PmtInf_IsCorrectlyCreated() { string paymentInformationIdentificaction_PmtInfId = "201402101"; //Private unique ID for payment group DateTime reqCollectionDate_ReqdColltnDt = new DateTime(2014, 2, 01); ServiceLevel8Choice serviceLevel_SvcLvl = new ServiceLevel8Choice( "SEPA", ItemChoiceType.Cd); LocalInstrument2Choice localInstrument_LclInstrm = new LocalInstrument2Choice( "COR1", ItemChoiceType.Cd); CategoryPurpose1Choice categoryOfPurpose_CtgyPurp = new CategoryPurpose1Choice( "Mensualidad", ItemChoiceType.Prtry); PaymentTypeInformation20 paymentTypeInformation_PmtTpInf = new PaymentTypeInformation20( Priority2Code.NORM, //<InstrPrty> Not used in SEPA COR1, but can't be null false, //<InstrPrty> will not be serialized serviceLevel_SvcLvl, //<SvcLvl> localInstrument_LclInstrm, //<LclInstrm> SequenceType1Code.RCUR, //<SeqTp> true, //<SeqTP> wll be serialized categoryOfPurpose_CtgyPurp); //<CtgyPurp> PartyIdentification32 creditor_Cdtr = new PartyIdentification32( creditor.Name, null, null, null, null); AccountIdentification4Choice creditorAccount_Id = new AccountIdentification4Choice( creditor.IBAN); CashAccount16 creditorAccount_CdtrAcct = new CashAccount16( creditorAccount_Id, null, null, null); FinancialInstitutionIdentification7 financialInstitutuinIdentification_FinInstnID = new FinancialInstitutionIdentification7( creditorAgent.BIC, null, null, null, null); BranchAndFinancialInstitutionIdentification4 creditorAgent_CdtrAgt = new BranchAndFinancialInstitutionIdentification4( financialInstitutuinIdentification_FinInstnID, null); OrganisationIdentificationSchemeName1Choice orgIDSchemeNameChoice_schmeNm = new OrganisationIdentificationSchemeName1Choice( "SEPA", ItemChoiceType.Prtry); GenericOrganisationIdentification1 genericOrganisationIdentification_othr = new GenericOrganisationIdentification1( creditor.Identification, orgIDSchemeNameChoice_schmeNm, null); OrganisationIdentification4 organisationIdentification_orgiD = new OrganisationIdentification4( null, new GenericOrganisationIdentification1[] { genericOrganisationIdentification_othr }); Party6Choice organisationOrPrivateIdentification_id = new Party6Choice(organisationIdentification_orgiD); PartyIdentification32 creditorSchemeIdentification_CdtrSchemeId = new PartyIdentification32( null, null, organisationOrPrivateIdentification_id, null, null); DirectDebitTransactionInformation9 deserializedDirectDebitTransactionInfo1 = XMLSerializer.XMLDeserializeFromFile<DirectDebitTransactionInformation9>(@"XML Test Files\DirectDebitTransactionInfo.xml", "DrctDbtTxInf", xMLNamespace); DirectDebitTransactionInformation9 deserializedDirectDebitTransactionInfo2 = XMLSerializer.XMLDeserializeFromFile<DirectDebitTransactionInformation9>(@"XML Test Files\DirectDebitTransactionInfo2.xml", "DrctDbtTxInf", xMLNamespace); DirectDebitTransactionInformation9[] directDebitTransactionInfoCollection = new DirectDebitTransactionInformation9[] { deserializedDirectDebitTransactionInfo1, deserializedDirectDebitTransactionInfo2 }; PaymentInstructionInformation4 paymentInformation_PmtInf = new PaymentInstructionInformation4( paymentInformationIdentificaction_PmtInfId, //<PmtInfId> PaymentMethod2Code.DD, //<PmtMtd> true, //<BtchBookg> Only one account entry for all payments true, //<BtchBookg> Will be serialized "2", //<NbOfTxs> (decimal)237, //<CtrlSum> true, //<CtrlSum> will be specified paymentTypeInformation_PmtTpInf, //<PmtTpInf> reqCollectionDate_ReqdColltnDt, //<ReqdColltnDt> creditor_Cdtr, //<Cdtr> creditorAccount_CdtrAcct, //<CdtrAcc> creditorAgent_CdtrAgt, //<CdtrAgt> null, //<CdtrAgtAcct> null, //<UltmtCdtr> Not neccesary. Same than creditor ChargeBearerType1Code.SLEV, //<ChrgBr> true, //<ChrgBr> will be serialized null, //<ChrgsAcct> Not used in SEPA COR1 null, //<ChrgsAcctAgt> Not used in SEPA COR1 creditorSchemeIdentification_CdtrSchemeId, //<CdtrSchemeId> directDebitTransactionInfoCollection); //<DrctDbtTxInf> string xmlString = XMLSerializer.XMLSerializeToString<PaymentInstructionInformation4>(paymentInformation_PmtInf, "PmtInf", xMLNamespace); string validatingErrors = XMLValidator.ValidateXMLNodeThroughModifiedXSD( "PmtInf", "PaymentInstructionInformation4", xMLNamespace, xmlString, xSDFilePath); Assert.AreEqual("", validatingErrors); }