@@ -7,132 +7,132 @@ |
||
| 7 | 7 | use SKien\Sepa\SepaPmtInf; |
| 8 | 8 | use SKien\Sepa\SepaTxInf; |
| 9 | 9 | |
| 10 | - // some valid transactions |
|
| 11 | - $aValidTransactions = array( |
|
| 12 | - array( |
|
| 13 | - 'dblValue' => 104.45, |
|
| 14 | - 'strDescription' => 'Test Betreff 1', |
|
| 15 | - 'strName' => 'Mustermann, Max', |
|
| 16 | - 'strIBAN' => 'DE11682900000009215808', |
|
| 17 | - 'strBIC' => 'GENODE61LAH', |
|
| 18 | - 'strMandateId' => 'ID-0815', |
|
| 19 | - 'strDateOfSignature' => '2018-04-03' |
|
| 20 | - ), |
|
| 21 | - array( |
|
| 22 | - 'dblValue' => 205.67, |
|
| 23 | - 'strDescription' => 'Test Betreff 2', |
|
| 24 | - 'strName' => 'Musterfrau, Karin', |
|
| 25 | - 'strIBAN' => 'DE71664500500070143559', |
|
| 26 | - 'strBIC' => 'SOLADES1OFG', |
|
| 27 | - 'strMandateId' => 'ID-0816', |
|
| 28 | - 'strDateOfSignature' => '2019-06-09' |
|
| 29 | - ) |
|
| 30 | - ); |
|
| 10 | + // some valid transactions |
|
| 11 | + $aValidTransactions = array( |
|
| 12 | + array( |
|
| 13 | + 'dblValue' => 104.45, |
|
| 14 | + 'strDescription' => 'Test Betreff 1', |
|
| 15 | + 'strName' => 'Mustermann, Max', |
|
| 16 | + 'strIBAN' => 'DE11682900000009215808', |
|
| 17 | + 'strBIC' => 'GENODE61LAH', |
|
| 18 | + 'strMandateId' => 'ID-0815', |
|
| 19 | + 'strDateOfSignature' => '2018-04-03' |
|
| 20 | + ), |
|
| 21 | + array( |
|
| 22 | + 'dblValue' => 205.67, |
|
| 23 | + 'strDescription' => 'Test Betreff 2', |
|
| 24 | + 'strName' => 'Musterfrau, Karin', |
|
| 25 | + 'strIBAN' => 'DE71664500500070143559', |
|
| 26 | + 'strBIC' => 'SOLADES1OFG', |
|
| 27 | + 'strMandateId' => 'ID-0816', |
|
| 28 | + 'strDateOfSignature' => '2019-06-09' |
|
| 29 | + ) |
|
| 30 | + ); |
|
| 31 | 31 | |
| 32 | - // some invalid transactions to test validation |
|
| 33 | - $aInvalidTransactions = array( |
|
| 34 | - array( |
|
| 35 | - 'dblValue' => 104.45, |
|
| 36 | - 'strDescription' => 'Ein Eidgenosse...', |
|
| 37 | - 'strName' => '', // missing Name |
|
| 38 | - 'strIBAN' => 'CH18 0483 5029 8829 8100 0', |
|
| 39 | - 'strBIC' => 'CRESCHZZ80A', |
|
| 40 | - 'strMandateId' => 'ID-0815', |
|
| 41 | - 'strDateOfSignature' => '18-04-03' // Wrong Date |
|
| 42 | - ), |
|
| 43 | - array( |
|
| 44 | - // 'dblValue' => 104.45, // no value |
|
| 45 | - 'strDescription' => '', // missing descr |
|
| 46 | - 'strName' => 'Mustermann, Max', |
|
| 47 | - 'strIBAN' => 'FR14 2004 1010 0505 0001 3M02 606', |
|
| 48 | - 'strBIC' => 'GENODE61LAH', |
|
| 49 | - // 'strMandateId' => 'ID-0815', // missing |
|
| 50 | - // 'strDateOfSignature' => '18-04-03' // missing |
|
| 51 | - ), |
|
| 52 | - array( |
|
| 53 | - 'dblValue' => 205.67, |
|
| 54 | - 'strDescription' => 'Test Betreff 2 - enthält Umlaute, Sonderzeichen {} _@ und ungültige Zeichen [&%]',
|
|
| 55 | - 'strName' => 'Musterfrau, Karin', |
|
| 56 | - 'strIBAN' => 'DE71664600500070143559', // Wrong checksum |
|
| 57 | - 'strBIC' => 'SOLADES1OG', // missing sign |
|
| 58 | - 'strMandateId' => 'ID-0816', |
|
| 59 | - 'strDateOfSignature' => '2019-06-09' |
|
| 60 | - ) |
|
| 61 | - ); |
|
| 32 | + // some invalid transactions to test validation |
|
| 33 | + $aInvalidTransactions = array( |
|
| 34 | + array( |
|
| 35 | + 'dblValue' => 104.45, |
|
| 36 | + 'strDescription' => 'Ein Eidgenosse...', |
|
| 37 | + 'strName' => '', // missing Name |
|
| 38 | + 'strIBAN' => 'CH18 0483 5029 8829 8100 0', |
|
| 39 | + 'strBIC' => 'CRESCHZZ80A', |
|
| 40 | + 'strMandateId' => 'ID-0815', |
|
| 41 | + 'strDateOfSignature' => '18-04-03' // Wrong Date |
|
| 42 | + ), |
|
| 43 | + array( |
|
| 44 | + // 'dblValue' => 104.45, // no value |
|
| 45 | + 'strDescription' => '', // missing descr |
|
| 46 | + 'strName' => 'Mustermann, Max', |
|
| 47 | + 'strIBAN' => 'FR14 2004 1010 0505 0001 3M02 606', |
|
| 48 | + 'strBIC' => 'GENODE61LAH', |
|
| 49 | + // 'strMandateId' => 'ID-0815', // missing |
|
| 50 | + // 'strDateOfSignature' => '18-04-03' // missing |
|
| 51 | + ), |
|
| 52 | + array( |
|
| 53 | + 'dblValue' => 205.67, |
|
| 54 | + 'strDescription' => 'Test Betreff 2 - enthält Umlaute, Sonderzeichen {} _@ und ungültige Zeichen [&%]',
|
|
| 55 | + 'strName' => 'Musterfrau, Karin', |
|
| 56 | + 'strIBAN' => 'DE71664600500070143559', // Wrong checksum |
|
| 57 | + 'strBIC' => 'SOLADES1OG', // missing sign |
|
| 58 | + 'strMandateId' => 'ID-0816', |
|
| 59 | + 'strDateOfSignature' => '2019-06-09' |
|
| 60 | + ) |
|
| 61 | + ); |
|
| 62 | 62 | |
| 63 | - $bValidTest = isset($_GET['valid']) && $_GET['valid'] == 1; |
|
| 63 | + $bValidTest = isset($_GET['valid']) && $_GET['valid'] == 1; |
|
| 64 | 64 | |
| 65 | - // initialize package |
|
| 66 | - // - init() have to be called first before any use of the package! |
|
| 67 | - // - full validation is by default activated |
|
| 68 | - // - switch to german error messages |
|
| 69 | - Sepa::init(); |
|
| 70 | - Sepa::setValidationLevel(Sepa::V_FULL_VALIDATION); |
|
| 71 | - Sepa::loadErrorMsg('sepa_errormsg_de.json');
|
|
| 65 | + // initialize package |
|
| 66 | + // - init() have to be called first before any use of the package! |
|
| 67 | + // - full validation is by default activated |
|
| 68 | + // - switch to german error messages |
|
| 69 | + Sepa::init(); |
|
| 70 | + Sepa::setValidationLevel(Sepa::V_FULL_VALIDATION); |
|
| 71 | + Sepa::loadErrorMsg('sepa_errormsg_de.json');
|
|
| 72 | 72 | |
| 73 | - // test for dirct debit transdaction |
|
| 74 | - $type = Sepa::CDD; |
|
| 73 | + // test for dirct debit transdaction |
|
| 74 | + $type = Sepa::CDD; |
|
| 75 | 75 | |
| 76 | - // create new SEPA document with header |
|
| 77 | - $oSepaDoc = new SepaDoc($type); |
|
| 78 | - $oSepaDoc->createGroupHeader('Test company 4711');
|
|
| 76 | + // create new SEPA document with header |
|
| 77 | + $oSepaDoc = new SepaDoc($type); |
|
| 78 | + $oSepaDoc->createGroupHeader('Test company 4711');
|
|
| 79 | 79 | |
| 80 | - // create payment info instruction (PII) and set all needet creditor information |
|
| 81 | - $oPPI = new SepaPmtInf($oSepaDoc); |
|
| 82 | - $oPPI->setName('Testfirma');
|
|
| 83 | - $oPPI->setCI('CH51 ZZZ 12345678901');
|
|
| 84 | - $oPPI->setIBAN('DE71664500500070143559');
|
|
| 85 | - $oPPI->setBIC('GENODE61LAH');
|
|
| 86 | - $oPPI->setSeqType(Sepa::SEQ_RECURRENT); |
|
| 80 | + // create payment info instruction (PII) and set all needet creditor information |
|
| 81 | + $oPPI = new SepaPmtInf($oSepaDoc); |
|
| 82 | + $oPPI->setName('Testfirma');
|
|
| 83 | + $oPPI->setCI('CH51 ZZZ 12345678901');
|
|
| 84 | + $oPPI->setIBAN('DE71664500500070143559');
|
|
| 85 | + $oPPI->setBIC('GENODE61LAH');
|
|
| 86 | + $oPPI->setSeqType(Sepa::SEQ_RECURRENT); |
|
| 87 | 87 | |
| 88 | - // add the PII to the document. |
|
| 89 | - // NOTE: dont' add any transaction to the PII bofore added to the doc! |
|
| 90 | - if (($iErr = $oSepaDoc->addPaymentInstructionInfo($oPPI)) == Sepa::OK) {
|
|
| 91 | - // test for transactions through SepaTxInf::fromArray() |
|
| 92 | - $aTransactions = $bValidTest ? $aValidTransactions : $aInvalidTransactions; |
|
| 93 | - foreach ($aTransactions as $aTrans) {
|
|
| 94 | - $oTxInf = new SepaTxInf($type); |
|
| 95 | - $oTxInf->fromArray($aTrans); |
|
| 96 | - $iErr = $oPPI->addTransaction($oTxInf); |
|
| 97 | - if ($iErr != Sepa::OK) {
|
|
| 98 | - echo '<h2>' . $oTxInf->getName() . ' (' . $oTxInf->getDescription() . ')</h2>';
|
|
| 99 | - echo $oTxInf->errorMsg($iErr, '<br />'); |
|
| 100 | - } else {
|
|
| 101 | - // ... may write back generated id to database |
|
| 102 | - // $strPaymentId = $oTxInf->getPaymentId(); |
|
| 103 | - } |
|
| 104 | - } |
|
| 88 | + // add the PII to the document. |
|
| 89 | + // NOTE: dont' add any transaction to the PII bofore added to the doc! |
|
| 90 | + if (($iErr = $oSepaDoc->addPaymentInstructionInfo($oPPI)) == Sepa::OK) {
|
|
| 91 | + // test for transactions through SepaTxInf::fromArray() |
|
| 92 | + $aTransactions = $bValidTest ? $aValidTransactions : $aInvalidTransactions; |
|
| 93 | + foreach ($aTransactions as $aTrans) {
|
|
| 94 | + $oTxInf = new SepaTxInf($type); |
|
| 95 | + $oTxInf->fromArray($aTrans); |
|
| 96 | + $iErr = $oPPI->addTransaction($oTxInf); |
|
| 97 | + if ($iErr != Sepa::OK) {
|
|
| 98 | + echo '<h2>' . $oTxInf->getName() . ' (' . $oTxInf->getDescription() . ')</h2>';
|
|
| 99 | + echo $oTxInf->errorMsg($iErr, '<br />'); |
|
| 100 | + } else {
|
|
| 101 | + // ... may write back generated id to database |
|
| 102 | + // $strPaymentId = $oTxInf->getPaymentId(); |
|
| 103 | + } |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - // test for direct call of SepaTxInf::setXXX Methods |
|
| 107 | - $oTxInf = new SepaTxInf($type); |
|
| 106 | + // test for direct call of SepaTxInf::setXXX Methods |
|
| 107 | + $oTxInf = new SepaTxInf($type); |
|
| 108 | 108 | |
| 109 | - $oTxInf->setValue( 168.24 ); |
|
| 110 | - $oTxInf->setDescription('Test Betreff 3');
|
|
| 111 | - $oTxInf->setName('Doe, John');
|
|
| 112 | - $oTxInf->setIBAN('DE71664500500070143559');
|
|
| 113 | - $oTxInf->setBIC('SOLADES1OFG');
|
|
| 114 | - $oTxInf->setMandateId('ID-4711');
|
|
| 115 | - $oTxInf->setDateOfSignature(new DateTime('22.12.2017'));
|
|
| 109 | + $oTxInf->setValue( 168.24 ); |
|
| 110 | + $oTxInf->setDescription('Test Betreff 3');
|
|
| 111 | + $oTxInf->setName('Doe, John');
|
|
| 112 | + $oTxInf->setIBAN('DE71664500500070143559');
|
|
| 113 | + $oTxInf->setBIC('SOLADES1OFG');
|
|
| 114 | + $oTxInf->setMandateId('ID-4711');
|
|
| 115 | + $oTxInf->setDateOfSignature(new DateTime('22.12.2017'));
|
|
| 116 | 116 | |
| 117 | - $iErr = $oTxInf->validate(); |
|
| 118 | - if ($iErr == Sepa::OK) {
|
|
| 119 | - $oPPI->addTransaction($oTxInf); |
|
| 120 | - } else {
|
|
| 121 | - echo $oTxInf->getName() . ' (' . $oTxInf->getDescription() . ')<br />';
|
|
| 122 | - echo $oTxInf->errorMsg($iErr, '<br />'); |
|
| 123 | - } |
|
| 117 | + $iErr = $oTxInf->validate(); |
|
| 118 | + if ($iErr == Sepa::OK) {
|
|
| 119 | + $oPPI->addTransaction($oTxInf); |
|
| 120 | + } else {
|
|
| 121 | + echo $oTxInf->getName() . ' (' . $oTxInf->getDescription() . ')<br />';
|
|
| 122 | + echo $oTxInf->errorMsg($iErr, '<br />'); |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - if ($oSepaDoc->getInvalidCount() == 0) {
|
|
| 126 | - // ... may cretae some loging etc. |
|
| 127 | - /* |
|
| 125 | + if ($oSepaDoc->getInvalidCount() == 0) {
|
|
| 126 | + // ... may cretae some loging etc. |
|
| 127 | + /* |
|
| 128 | 128 | $strLog = date('Y-m-d H:i') . ': SEPA Direct Debit Transactions erzeugt (';
|
| 129 | 129 | $strLog .= $oSepaDoc->getTxCount() . 'Transaktionen / '; |
| 130 | 130 | $strLog .= sprintf("%01.2f", $oSepaDoc->getCtrlSum()) . ' €)';
|
| 131 | 131 | */ |
| 132 | - $oSepaDoc->output('test.xml');
|
|
| 133 | - } |
|
| 134 | - } else {
|
|
| 135 | - echo '<h2>' . $oPPI->getName() . '</h2>'; |
|
| 136 | - echo $oPPI->errorMsg($iErr, '<br />'); |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | 132 | \ No newline at end of file |
| 133 | + $oSepaDoc->output('test.xml');
|
|
| 134 | + } |
|
| 135 | + } else {
|
|
| 136 | + echo '<h2>' . $oPPI->getName() . '</h2>'; |
|
| 137 | + echo $oPPI->errorMsg($iErr, '<br />'); |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | 140 | \ No newline at end of file |
@@ -169,19 +169,19 @@ |
||
| 169 | 169 | self::addValidation('IT', 'SKien\Sepa\CntryValidation\SepaCntryValidationIT');
|
| 170 | 170 | |
| 171 | 171 | self::$aIBANError = array( |
| 172 | - Sepa::ERR_IBAN_INVALID_CNTRY => 'The country code of the IBAN is not supported!' |
|
| 172 | + Sepa::ERR_IBAN_INVALID_CNTRY => 'The country code of the IBAN is not supported!' |
|
| 173 | 173 | ,Sepa::ERR_IBAN_INVALID_LENGTH => 'Invalid length of the IBAN!' |
| 174 | 174 | ,Sepa::ERR_IBAN_INVALID_SIGN => 'The IBAN contains invalid characters!' |
| 175 | 175 | ,Sepa::ERR_IBAN_CHECKSUM => 'Invalid IBAN checksum!' |
| 176 | 176 | ); |
| 177 | 177 | |
| 178 | 178 | self::$aBICError = array( |
| 179 | - Sepa::ERR_BIC_INVALID => 'Invalid BIC!' |
|
| 179 | + Sepa::ERR_BIC_INVALID => 'Invalid BIC!' |
|
| 180 | 180 | ,Sepa::ERR_BIC_INVALID_CNTRY => 'The country code of the BIC is not supported!' |
| 181 | 181 | ); |
| 182 | 182 | |
| 183 | 183 | self::$aCIError = array( |
| 184 | - Sepa::ERR_IBAN_INVALID_CNTRY => 'The country code of the CI is not supported!' |
|
| 184 | + Sepa::ERR_IBAN_INVALID_CNTRY => 'The country code of the CI is not supported!' |
|
| 185 | 185 | ,Sepa::ERR_IBAN_INVALID_LENGTH => 'Invalid length of the CI!' |
| 186 | 186 | ,Sepa::ERR_IBAN_INVALID_SIGN => 'The CI contains invalid characters!' |
| 187 | 187 | ,Sepa::ERR_IBAN_CHECKSUM => 'Invalid CI checksum!' |
@@ -183,7 +183,7 @@ |
||
| 183 | 183 | return $this->strLastCheckSum; |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - /** |
|
| 186 | + /** |
|
| 187 | 187 | * calculate modulo 97 checksum for bankcode and accountnumber |
| 188 | 188 | * MOD 97-10 (see ISO 7064) |
| 189 | 189 | * @param string $strCheck |
@@ -202,7 +202,7 @@ |
||
| 202 | 202 | |
| 203 | 203 | // New Year Good Day Easter Monday 1'stMay 1.Christmas 2.Christmas |
| 204 | 204 | $aTarget2 = array( |
| 205 | - '2019-01-01', '2019-04-18', '2019-04-21', '2019-05-01', '2019-12-25', '2019-12-26' |
|
| 205 | + '2019-01-01', '2019-04-18', '2019-04-21', '2019-05-01', '2019-12-25', '2019-12-26' |
|
| 206 | 206 | ,'2020-01-01', '2020-04-10', '2020-04-13', '2020-05-01', '2020-12-25', '2020-12-26' |
| 207 | 207 | ,'2021-01-01', '2021-04-02', '2021-04-05', '2021-05-01', '2021-12-25', '2021-12-26' |
| 208 | 208 | ,'2022-01-01', '2022-04-15', '2022-04-18', '2022-05-01', '2022-12-25', '2022-12-26' |