/** * @param int $version Use SephpaCreditTransfer::SEPA_PAIN_001_* constants * @param bool $addBIC * @param bool $addOptionalData * @param bool $checkAndSanitize * @return DOMDocument */ private function getCreditTransferFile($version, $addBIC, $addOptionalData, $checkAndSanitize) { $creditTransferFile = new SephpaCreditTransfer('Initiator Name', 'MessageID-1234', $version, $checkAndSanitize); $collectionData = array('pmtInfId' => 'PaymentID-1234', 'dbtr' => 'Name of Debtor2', 'iban' => 'DE21500500001234567897'); if ($addBIC) { $collectionData['bic'] = 'BELADEBEXXX'; } if ($addOptionalData) { $collectionData['ccy'] = 'EUR'; // Currency. Default is 'EUR' $collectionData['btchBookg'] = 'true'; // BatchBooking, only 'true' or 'false' $collectionData['reqdExctnDt'] = '2013-11-25'; // Date: YYYY-MM-DD $collectionData['ultmtDebtr'] = 'Ultimate Debtor Name'; // just an information, this do not affect the payment (max 70 characters) } $paymentData = array('pmtId' => 'TransferID-1234-1', 'instdAmt' => 1.14, 'iban' => 'DE21500500009876543210', 'cdtr' => 'Name of Creditor'); if ($addBIC) { $paymentData['bic'] = 'SPUEDE2UXXX'; } if ($addOptionalData) { $paymentData['ultmtCdrt'] = 'Ultimate Creditor Name'; // just an information, this do not affect the payment (max 70 characters) $paymentData['rmtInf'] = 'Remittance Information'; // unstructured information about the remittance (max 140 characters) } $creditTransferCollection = $creditTransferFile->addCollection($collectionData); $creditTransferCollection->addPayment($paymentData); $domDoc = new DOMDocument(); $domDoc->loadXML($creditTransferFile->generateXml('2014-10-19T00:38:44')); return $domDoc; }
public function testCreditTransfer00100303() { $creditTransferFile = new SephpaCreditTransfer('Initiator Name', 'MessageID-1234', SephpaCreditTransfer::SEPA_PAIN_001_003_03); // at least one in every SEPA file $creditTransferCollection = $creditTransferFile->addCollection(array('pmtInfId' => 'PaymentID-1234', 'dbtr' => 'Name of Debtor2', 'iban' => 'DE21500500001234567897', 'bic' => 'BELADEBEXXX', 'ccy' => 'EUR', 'btchBookg' => 'true', 'reqdExctnDt' => '2013-11-25', 'ultmtDebtr' => 'Ultimate Debtor Name')); // at least one in every CreditTransferCollection $creditTransferCollection->addPayment(array('pmtId' => 'TransferID-1234-1', 'instdAmt' => 1.14, 'iban' => 'DE21500500009876543210', 'bic' => 'SPUEDE2UXXX', 'cdtr' => 'Name of Creditor', 'ultmtCdrt' => 'Ultimate Creditor Name', 'rmtInf' => 'Remittance Information')); $this->assertXmlStringEqualsXmlFile(__DIR__ . '/creditTransferValid00100303.xsd', $creditTransferFile->generateXml('2014-10-19T00:38:44')); }
<?php /* * This is just an example. Please read the documentation * of the SEPA file format to learn more about using SEPA files. */ use AbcAeffchen\Sephpa\SephpaCreditTransfer; use AbcAeffchen\SepaUtilities\SepaUtilities; use AbcAeffchen\Sephpa\SephpaDirectDebit; require_once '../src/Sephpa.php'; // generate a SepaCreditTransfer object (pain.001.002.03). $creditTransferFile = new SephpaCreditTransfer('Initiator Name', 'MessageID-1234', SephpaCreditTransfer::SEPA_PAIN_001_003_03); // at least one in every SEPA file $creditTransferCollection = $creditTransferFile->addCollection(array('pmtInfId' => 'PaymentID-1234', 'dbtr' => 'Name of Debtor2', 'iban' => 'DE21500500001234567897', 'bic' => 'BELADEBEXXX', 'ccy' => 'EUR', 'btchBookg' => 'true', 'reqdExctnDt' => '2013-11-25', 'ultmtDebtr' => 'Ultimate Debtor Name')); // at least one in every CreditTransferCollection $creditTransferCollection->addPayment(array('pmtId' => 'TransferID-1234-1', 'instdAmt' => 1.14, 'iban' => 'DE21500500009876543210', 'bic' => 'SPUEDE2UXXX', 'cdtr' => 'Name of Creditor', 'ultmtCdrt' => 'Ultimate Creditor Name', 'rmtInf' => 'Remittance Information')); $creditTransferFile->storeSepaFile(); // generate a SepaDirectDebit object (pain.008.002.02). $directDebitFile = new SephpaDirectDebit('Initiator Name', 'MessageID-1235', SephpaDirectDebit::SEPA_PAIN_008_003_02); // at least one in every SEPA file. No limit. $directDebitCollection = $directDebitFile->addCollection(array('pmtInfId' => 'PaymentID-1235', 'lclInstrm' => SepaUtilities::LOCAL_INSTRUMENT_CORE_DIRECT_DEBIT, 'seqTp' => SepaUtilities::SEQUENCE_TYPE_RECURRING, 'cdtr' => 'Name of Creditor', 'iban' => 'DE87200500001234567890', 'bic' => 'BELADEBEXXX', 'ci' => 'DE98ZZZ09999999999', 'ccy' => 'EUR', 'btchBookg' => 'true', 'ultmtCdtr' => 'Ultimate Creditor Name', 'reqdColltnDt' => '2013-11-25')); // at least one in every DirectDebitCollection. No limit. $directDebitCollection->addPayment(array('pmtId' => 'TransferID-1235-1', 'instdAmt' => 2.34, 'mndtId' => 'Mandate-Id', 'dtOfSgntr' => '2010-04-12', 'bic' => 'BELADEBEXXX', 'dbtr' => 'Name of Debtor', 'iban' => 'DE87200500001234567890', 'amdmntInd' => 'false', 'ultmtDbtr' => 'Ultimate Debtor Name', 'rmtInf' => 'Remittance Information', 'orgnlMndtId' => 'Original-Mandat-ID', 'orgnlCdtrSchmeId_nm' => 'Creditor-Identifier Name', 'orgnlCdtrSchmeId_id' => 'DE98AAA09999999999', 'orgnlDbtrAcct_iban' => 'DE87200500001234567890', 'orgnlDbtrAgt' => 'SMNDA')); $directDebitFile->storeSepaFile();