简体   繁体   中英

directDebitTransaction aggregation in SEPA SDD XML Generator

I'm creating a XML file for SEPA Direct Debit with SEPA SDD XML Generator ( https://github.com/dmitrirussu/php-sepa-xml-generator ).

To add "addDirectDebitTransaction", at first I created one object with all the transactions:

$a = 1;
$xmlFile2 = SEPA\Factory\XMLGeneratorFactory::createXMLPaymentInfo();
foreach($transactions as $t)
{
    $xmlFile2->addDirectDebitTransaction(
                    SEPA\Factory\XmlGeneratorFactory::createXMLDirectDebitTransaction()
                        ->setInstructionIdentification(++$a)
                        ->setEndToEndIdentification(++$a)
                        ->setInstructedAmount(100.5)
                        ->setDebtorName('DVORAK')
                        ->setDebitIBAN('FR14 2004 1010 0505 0001 3M02 606')
                        ->setDebitBIC('AABAFI22')
                        ->setMandateIdentification('SDD000000016PFX071'.$a) 
                        ->setDateOfSignature('2013-08-03')
                        ->setDirectDebitInvoice(++$a));

}

After, I created the XML file:

$xmlFile = SEPA\Factory\XMLGeneratorFactory::createXmlGeneratorObject(\SEPA\XMLGenerator::PAIN_008_001_02)->addXmlMessage(
            SEPA\Factory\XMLGeneratorFactory::createXMLMessage()->setMessageGroupHeader(
                SEPA\Factory\XMLGeneratorFactory::createXMLGroupHeader()
                    ->setMessageIdentification($identificacionFichero)
                    ->setInitiatingPartyName($datos['nombreCliente'])
                    ->setPrivateIdentification($identificador))
                ->addMessagePaymentInfo(
                    SEPA\Factory\XMLGeneratorFactory::createXMLPaymentInfo()
                        ->setPaymentInformationIdentification(6222)
                        ->setSequenceType('RCUR')
                        ->setCreditorAccountIBAN('MD24 AG00 0225 1000 1310 4168')
                        ->setCreditorAccountBIC('AABAFI42')->setCreditorName('Amazing SRL')
                        ->setCreditorSchemeIdentification('FR07ZZZ519993')
                        ->setRequestedCollectionDate('2013-08-06'))->save($fileExist = 'sepa_test.xml');

The question is: how can I add $xmlFile2 (the transactions) into $xmlFile (the XML file)?

Thanks.

$paymentInfo = SEPA\Factory\XMLGeneratorFactory::createXMLPaymentInfo();

    $transactions = array(1, 2, 3, 4, 5);
    $a = 0;
    //add payment info transactions
    foreach($transactions as $t)
    {
        $paymentInfo->addDirectDebitTransaction(
            SEPA\Factory\XmlGeneratorFactory::createXMLDirectDebitTransaction()
                ->setInstructionIdentification(++$a)
                ->setEndToEndIdentification(++$a)
                ->setInstructedAmount(100.5)
                ->setDebtorName('DVORAK')
                ->setDebitIBAN('FR14 2004 1010 0505 0001 3M02 606')
                ->setDebitBIC('AABAFI22')
                ->setMandateIdentification('SDD000000016PFX071'.$a)
                ->setDateOfSignature('2013-08-03')
                ->setDirectDebitInvoice(++$a));

    }

    //set The payment info
    $paymentInfo->setPaymentInformationIdentification(6222)
        ->setSequenceType('RCUR')
        ->setCreditorAccountIBAN('MD24 AG00 0225 1000 1310 4168')
        ->setCreditorAccountBIC('AABAFI42')->setCreditorName('Amazing SRL')
        ->setCreditorSchemeIdentification('FR07ZZZ519993')
        ->setRequestedCollectionDate('2013-08-06');

  //create SEPA file
  \SEPA\Factory\XMLGeneratorFactory::createXmlGeneratorObject(\SEPA\XMLGenerator::PAIN_008_001_02)
      ->addXmlMessage(
      SEPA\Factory\XMLGeneratorFactory::createXMLMessage()->setMessageGroupHeader(

          SEPA\Factory\XMLGeneratorFactory::createXMLGroupHeader()
              ->setMessageIdentification($identificacionFichero = 1)
              ->setInitiatingPartyName($datos['nombreCliente'] = 'test')
              ->setPrivateIdentification($identificador=123)
      )->addMessagePaymentInfo($paymentInfo)

    )->save($fileExist = realpath(__DIR__) . '/xml_files/sepa_demo.xml');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM