PHP code example of dmitrirussu / php-sepa-xml-generator

1. Go to this page and download the library: Download dmitrirussu/php-sepa-xml-generator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dmitrirussu / php-sepa-xml-generator example snippets


		//When you start to generate a SEPA Xml File, need to choose PAIN
		$directDebitTransaction = \SEPA\XMLGenerator::PAIN_008_001_02; // For Direct Debit transactions is By Defaut
		$creditTransfer = \SEPA\XMLGenerator::PAIN_001_001_02; //For Credit Transfer

		SEPA\Factory\XMLGeneratorFactory::createXmlGeneratorObject($directDebitTransaction)->addXmlMessage(
        	SEPA\Factory\XMLGeneratorFactory::createXMLMessage()
        		->setMessageGroupHeader(
        			SEPA\Factory\XMLGeneratorFactory::createXMLGroupHeader()
        				->setMessageIdentification(1)
        				->setInitiatingPartyName('Amazing SRL ???? ыаывпавпва '))
        		->addMessagePaymentInfo(
        			SEPA\Factory\XMLGeneratorFactory::createXMLPaymentInfo()
        				->setPaymentInformationIdentification(6222)
        				->setSequenceType('FRST')
        				->setCreditorAccountIBAN('MD24 AG00 0225 1000 1310 4168')
        				->setCreditorAccountBIC('AABAFI42')->setCreditorName('Amazing SRL')
        				->setCreditorSchemeIdentification('FR07ZZZ519993')
        				->setRequestedCollectionDate('2013-08-06')
						->setAggregatePerMandate(true) //Default Transaction aggregation option = true
        				->addDirectDebitTransaction( //First transaction
        					SEPA\Factory\XmlGeneratorFactory::createXMLDirectDebitTransaction()
        						->setInstructionIdentification(3)
        						->setEndToEndIdentification(3)
        						->setInstructedAmount(100.5)
        						->setDebtorName('Roy SRL')
        						->setDebitIBAN('FR14 2004 1010 0505 0001 3M02 606')
        						->setDebitBIC('AABAFI22') //Optional
        						->setMandateIdentification('SDD000000016PFX0713') //unique Identifier
        						->setDateOfSignature('2013-08-03')
        //						->setCurrency('EUR')
        						->setDirectDebitInvoice(122)
        				)->addDirectDebitTransaction( //Second transaction are the same client transaction
        					SEPA\Factory\XmlGeneratorFactory::createXMLDirectDebitTransaction()
        						->setInstructionIdentification(4)
        						->setEndToEndIdentification(4)
        						->setInstructedAmount(100.5)
        						->setDebtorName('Roy SRL')
        						->setDebitIBAN('FR14 2004 1010 0505 0001 3M02 606')
        						->setDebitBIC('AABAFI22') //Optional
        						->setMandateIdentification('SDD000000016PFX0713') //unique Identifier
        						->setDateOfSignature('2013-08-03')
        //						->setCurrency('EUR')
        						->setDirectDebitInvoice(122))
        				->addDirectDebitTransaction( //An other client Transaction
        					SEPA\Factory\XmlGeneratorFactory::createXMLDirectDebitTransaction()
        						->setInstructionIdentification(6)
        						->setEndToEndIdentification(6)
        						->setInstructedAmount(100.5)
        						->setDebtorName('ND SRL')
        						->setDebitIBAN('FR14 2004 1010 0505 0001 3M02 606')
        						->setDebitBIC('AABAFI22') //Optional
        						->setMandateIdentification('SDD000000016PFX0714') //unique Identifier
        						->setDateOfSignature('2013-08-03')
        //						->setCurrency('EUR')
        						->setDirectDebitInvoice(122))
        		)

        )->view()->save(realpath(__DIR__) . '/xml_files/sepa_test.xml');


	$xmlFile = SEPA\Factory\XMLGeneratorFactory::createXmlGeneratorObject(\SEPA\XMLGenerator::PAIN_001_001_02)->addXmlMessage(
			SEPA\Factory\XMLGeneratorFactory::createXMLMessage()->setMessageGroupHeader(
				SEPA\Factory\XMLGeneratorFactory::createXMLGroupHeader()
					->setMessageIdentification(1)
					->setInitiatingPartyName('Amazing SRL ???? ыаывпавпва'))
				->addMessagePaymentInfo(
					SEPA\Factory\XMLGeneratorFactory::createXMLPaymentInfo()
						->setAggregatePerMandate(false)
						->setPaymentInformationIdentification(6222)
						->setSequenceType('FRST')
						->setDebitorAccountIBAN('MD24 AG00 0225 1000 1310 4168')
						->setDebitorAccountBIC('AABAFI42')
						->setDebitorName('Amazing SRL')
						->setRequestedCollectionDate('2013-08-06')
						->addCreditTransferTransaction(
							SEPA\Factory\XmlGeneratorFactory::createXMLCreditTransferTransaction()
								->setInstructionIdentification(3)
								->setCreditInvoice(1223)
								->setInstructedAmount(100.5)
								->setBIC('AABAFI42')
								->setCreditorName('1222')
								->setIBAN('MD24 AG000225100013104168')
						)
						->addCreditTransferTransaction(
							SEPA\Factory\XmlGeneratorFactory::createXMLCreditTransferTransaction()
								->setInstructionIdentification(4)
								->setCreditInvoice(1223)
								->setInstructedAmount(50.5)
								->setBIC('AABAFI42')
								->setCreditorName('1222')
								->setIBAN('MD24 AG000225100013104168')
						)
						->addCreditTransferTransaction(
							SEPA\Factory\XmlGeneratorFactory::createXMLCreditTransferTransaction()
								->setInstructionIdentification(4)
								->setCreditInvoice(1223)
								->setInstructedAmount(25.5)
								->setBIC('AABAFI42')
								->setCreditorName('1222')
								->setIBAN('MD24 AG000225100013104168')
						)
			)
		)->save($fileExist = realpath(__DIR__) . '/xml_files/sepa_test.xml');

		$this->assertTrue(file_exists($fileExist));