SEPA SDD XML Generator中的directDebitTransaction聚合

时间:2016-01-20 10:34:26

标签: php xml

我正在使用SEPA SDD XML Generator(https://github.com/dmitrirussu/php-sepa-xml-generator)为SEPA直接付款创建XML文件。

要添加" addDirectDebitTransaction",首先我创建了一个包含所有交易的对象:

$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));

}

之后,我创建了XML文件:

$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');

问题是:如何将$ xmlFile2(事务)添加到$ xmlFile(XML文件)中?

感谢。

1 个答案:

答案 0 :(得分:0)

$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');