@@ -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 |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | array( |
| 35 | 35 | 'dblValue' => 104.45, |
| 36 | 36 | 'strDescription' => 'Ein Eidgenosse...', |
| 37 | - 'strName' => '', // missing Name |
|
| 37 | + 'strName' => '', // missing Name |
|
| 38 | 38 | 'strIBAN' => 'CH18 0483 5029 8829 8100 0', |
| 39 | 39 | 'strBIC' => 'CRESCHZZ80A', |
| 40 | 40 | 'strMandateId' => 'ID-0815', |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | ), |
| 43 | 43 | array( |
| 44 | 44 | // 'dblValue' => 104.45, // no value |
| 45 | - 'strDescription' => '', // missing descr |
|
| 45 | + 'strDescription' => '', // missing descr |
|
| 46 | 46 | 'strName' => 'Mustermann, Max', |
| 47 | 47 | 'strIBAN' => 'FR14 2004 1010 0505 0001 3M02 606', |
| 48 | 48 | 'strBIC' => 'GENODE61LAH', |
@@ -53,8 +53,8 @@ discard block |
||
| 53 | 53 | 'dblValue' => 205.67, |
| 54 | 54 | 'strDescription' => 'Test Betreff 2 - enthält Umlaute, Sonderzeichen {} _@ und ungültige Zeichen [&%]',
|
| 55 | 55 | 'strName' => 'Musterfrau, Karin', |
| 56 | - 'strIBAN' => 'DE71664600500070143559', // Wrong checksum |
|
| 57 | - 'strBIC' => 'SOLADES1OG', // missing sign |
|
| 56 | + 'strIBAN' => 'DE71664600500070143559', // Wrong checksum |
|
| 57 | + 'strBIC' => 'SOLADES1OG', // missing sign |
|
| 58 | 58 | 'strMandateId' => 'ID-0816', |
| 59 | 59 | 'strDateOfSignature' => '2019-06-09' |
| 60 | 60 | ) |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | // test for direct call of SepaTxInf::setXXX Methods |
| 107 | 107 | $oTxInf = new SepaTxInf($type); |
| 108 | 108 | |
| 109 | - $oTxInf->setValue( 168.24 ); |
|
| 109 | + $oTxInf->setValue(168.24); |
|
| 110 | 110 | $oTxInf->setDescription('Test Betreff 3');
|
| 111 | 111 | $oTxInf->setName('Doe, John');
|
| 112 | 112 | $oTxInf->setIBAN('DE71664500500070143559');
|
@@ -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!' |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | if (isset(self::$aValidation[$strCntry])) {
|
| 226 | 226 | trigger_error('validation for cntry ' . $strCntry . ' already defined!', E_USER_ERROR);
|
| 227 | 227 | } |
| 228 | - if (!is_subclass_of ($strValidationClass, 'SKien\Sepa\CntryValidation\SepaCntryValidation', true)) {
|
|
| 228 | + if (!is_subclass_of($strValidationClass, 'SKien\Sepa\CntryValidation\SepaCntryValidation', true)) {
|
|
| 229 | 229 | trigger_error('class ' . $strValidationClass . ' must implement SepaCntryValidation interface!', E_USER_ERROR);
|
| 230 | 230 | } |
| 231 | 231 | self::$aValidation[$strCntry] = $strValidationClass; |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | * Load error messages from JSON file |
| 266 | 266 | * @param string $strFilename |
| 267 | 267 | */ |
| 268 | - public static function loadErrorMsg(string $strFilename='sepa_error.json') : void |
|
| 268 | + public static function loadErrorMsg(string $strFilename = 'sepa_error.json') : void |
|
| 269 | 269 | {
|
| 270 | 270 | /* |
| 271 | 271 | // ... testcode to create sample json file |
@@ -71,21 +71,21 @@ discard block |
||
| 71 | 71 | if (!Sepa::checkValidation(Sepa::V_NO_IBAN_VALIDATION)) {
|
| 72 | 72 | if (strlen($this->strIBAN) == 0) {
|
| 73 | 73 | $iErr |= Sepa::ERR_PMT_IBAN_MISSING; |
| 74 | - } else if( Sepa::validateIBAN($this->strIBAN) != Sepa::OK) {
|
|
| 74 | + } else if (Sepa::validateIBAN($this->strIBAN) != Sepa::OK) {
|
|
| 75 | 75 | $iErr |= Sepa::ERR_PMT_INVALID_IBAN; |
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | if (!Sepa::checkValidation(Sepa::V_NO_BIC_VALIDATION)) {
|
| 79 | 79 | if (strlen($this->strBIC) == 0) {
|
| 80 | 80 | $iErr |= Sepa::ERR_PMT_BIC_MISSING; |
| 81 | - } else if( Sepa::validateBIC($this->strBIC) != Sepa::OK) {
|
|
| 81 | + } else if (Sepa::validateBIC($this->strBIC) != Sepa::OK) {
|
|
| 82 | 82 | $iErr |= Sepa::ERR_PMT_INVALID_BIC; |
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | if (!Sepa::checkValidation(Sepa::V_NO_CI_VALIDATION)) {
|
| 86 | 86 | if (strlen($this->strCI) == 0) {
|
| 87 | 87 | $iErr |= Sepa::ERR_PMT_CI_MISSING; |
| 88 | - } else if( Sepa::validateCI($this->strCI) != Sepa::OK) {
|
|
| 88 | + } else if (Sepa::validateCI($this->strCI) != Sepa::OK) {
|
|
| 89 | 89 | $iErr |= Sepa::ERR_PMT_INVALID_CI; |
| 90 | 90 | } |
| 91 | 91 | } |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | } |
| 96 | 96 | if (strlen($this->strSeqType) == 0) {
|
| 97 | 97 | $iErr |= Sepa::ERR_PMT_SEQ_TYPE_MISSING; |
| 98 | - } else if( $this->strSeqType != Sepa::SEQ_FIRST && $this->strSeqType != Sepa::SEQ_RECURRENT && $this->strSeqType != Sepa::SEQ_ONE_OFF && $this->strSeqType != Sepa::SEQ_FINAL) {
|
|
| 98 | + } else if ($this->strSeqType != Sepa::SEQ_FIRST && $this->strSeqType != Sepa::SEQ_RECURRENT && $this->strSeqType != Sepa::SEQ_ONE_OFF && $this->strSeqType != Sepa::SEQ_FINAL) {
|
|
| 99 | 99 | $iErr |= Sepa::ERR_PMT_INVALID_SEQ_TYPE; |
| 100 | 100 | } |
| 101 | 101 | } |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | $iErr = $oTxInf->validate(); |
| 130 | - if ( $iErr == Sepa::OK) {
|
|
| 130 | + if ($iErr == Sepa::OK) {
|
|
| 131 | 131 | if ($oTxInf->getType() == Sepa::CDD) {
|
| 132 | 132 | $xmlTx = $this->addChild(null, 'DrctDbtTxInf'); |
| 133 | 133 | |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | |
| 160 | 160 | // Ultimate Debitor if requested |
| 161 | 161 | $strUltmtDbtr = $oTxInf->getUltimateName(); |
| 162 | - if ( strlen($strUltmtDbtr) > 0) {
|
|
| 162 | + if (strlen($strUltmtDbtr) > 0) {
|
|
| 163 | 163 | $xmlNode = $this->addChild($xmlTx, 'UltmtDbtr'); |
| 164 | 164 | $this->addChild($xmlNode, 'Nm', $strUltmtDbtr); |
| 165 | 165 | } |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | |
| 188 | 188 | // Ultimate Creditor if requested |
| 189 | 189 | $strUltmtCbtr = $oTxInf->getUltimateName(); |
| 190 | - if ( strlen($strUltmtCbtr) > 0) {
|
|
| 190 | + if (strlen($strUltmtCbtr) > 0) {
|
|
| 191 | 191 | $xmlNode = $this->addChild($xmlTx, 'UltmtCbtr'); |
| 192 | 192 | $this->addChild($xmlNode, 'Nm', $strUltmtCbtr); |
| 193 | 193 | } |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | */ |
| 216 | 216 | protected function addChild(?\DOMElement $xmlParent, string $strNode, $value = '') |
| 217 | 217 | {
|
| 218 | - if($xmlParent == null) {
|
|
| 218 | + if ($xmlParent == null) {
|
|
| 219 | 219 | $xmlParent = $this; |
| 220 | 220 | } |
| 221 | 221 | $xmlNode = $this->sepaDoc->createElement($strNode); |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | /** @var string type of sepa document */ |
| 28 | 28 | protected string $type = ''; |
| 29 | 29 | /** @var \DOMElement XML Base-Element */ |
| 30 | - protected ?\DOMElement $xmlBase = null; |
|
| 30 | + protected ?\DOMElement $xmlBase = null; |
|
| 31 | 31 | /** @var int overall count of transactions */ |
| 32 | 32 | protected int $iTxCount = 0; |
| 33 | 33 | /** @var \DOMElement DOM element containing overall count of transactions */ |
@@ -50,8 +50,8 @@ discard block |
||
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | $aTypeInfo = array( |
| 53 | - Sepa::CCT => array( 'pain' => '001.002.03', 'base' => 'CstmrCdtTrfInitn' ), |
|
| 54 | - Sepa::CDD => array( 'pain' => '008.002.02', 'base' => 'CstmrDrctDbtInitn' ) |
|
| 53 | + Sepa::CCT => array('pain' => '001.002.03', 'base' => 'CstmrCdtTrfInitn'),
|
|
| 54 | + Sepa::CDD => array('pain' => '008.002.02', 'base' => 'CstmrDrctDbtInitn')
|
|
| 55 | 55 | ); |
| 56 | 56 | |
| 57 | 57 | $strPain = $aTypeInfo[$type]['pain']; |
@@ -62,12 +62,12 @@ discard block |
||
| 62 | 62 | $this->type = $type; |
| 63 | 63 | |
| 64 | 64 | $this->formatOutput = true; |
| 65 | - $this->preserveWhiteSpace = false; // 'formatOutput' only works if 'preserveWhiteSpace' set to false |
|
| 65 | + $this->preserveWhiteSpace = false; // 'formatOutput' only works if 'preserveWhiteSpace' set to false |
|
| 66 | 66 | |
| 67 | 67 | $xmlRoot = $this->createElement("Document");
|
| 68 | - $xmlRoot->setAttribute("xmlns", "urn:iso:std:iso:20022:tech:xsd:pain." . $strPain);
|
|
| 69 | - $xmlRoot->setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
|
|
| 70 | - $xmlRoot->setAttribute("xsi:schemaLocation", "urn:iso:std:iso:20022:tech:xsd:pain." . $strPain . " pain." . $strPain . ".xsd");
|
|
| 68 | + $xmlRoot->setAttribute("xmlns", "urn:iso:std:iso:20022:tech:xsd:pain." . $strPain);
|
|
| 69 | + $xmlRoot->setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
|
|
| 70 | + $xmlRoot->setAttribute("xsi:schemaLocation", "urn:iso:std:iso:20022:tech:xsd:pain." . $strPain . " pain." . $strPain . ".xsd");
|
|
| 71 | 71 | $this->appendChild($xmlRoot); |
| 72 | 72 | |
| 73 | 73 | $this->xmlBase = $this->createElement($strBase); |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | $this->id = self::createUID(); |
| 91 | 91 | |
| 92 | 92 | $this->addChild($xmlGrpHdr, 'MsgId', $this->id); |
| 93 | - $this->addChild($xmlGrpHdr, 'CreDtTm', date(DATE_ATOM)); // str_replace(' ', 'T', date('Y-m-d h:i:s')));
|
|
| 93 | + $this->addChild($xmlGrpHdr, 'CreDtTm', date(DATE_ATOM)); // str_replace(' ', 'T', date('Y-m-d h:i:s')));
|
|
| 94 | 94 | $this->xmlTxCount = $this->addChild($xmlGrpHdr, 'NbOfTxs', 0); |
| 95 | 95 | $this->xmlCtrlSum = $this->addChild($xmlGrpHdr, 'CtrlSum', sprintf("%01.2f", 0.0));
|
| 96 | 96 | |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | $iErr = $oPmtInf->validate(); |
| 121 | - if ( $iErr == Sepa::OK) {
|
|
| 121 | + if ($iErr == Sepa::OK) {
|
|
| 122 | 122 | $this->xmlBase->appendChild($oPmtInf); |
| 123 | 123 | |
| 124 | 124 | $this->addChild($oPmtInf, 'PmtInfId', $this->id); |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | * @param string $strName output filename |
| 187 | 187 | * @param string $strTarget target (default: 'attachment') |
| 188 | 188 | */ |
| 189 | - function output(string $strName, string $strTarget='attachment') : void |
|
| 189 | + function output(string $strName, string $strTarget = 'attachment') : void |
|
| 190 | 190 | {
|
| 191 | 191 | // send to browser |
| 192 | 192 | header('Content-Type: application/xml');
|
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | * @param mixed $value nodevalue. If empty, no value will be assigned (to create node only containing child elements) |
| 232 | 232 | * @return \DOMElement |
| 233 | 233 | */ |
| 234 | - protected function addChild(\DOMElement $xmlParent, string $strNode, $value='') : \DOMElement |
|
| 234 | + protected function addChild(\DOMElement $xmlParent, string $strNode, $value = '') : \DOMElement |
|
| 235 | 235 | {
|
| 236 | 236 | $xmlNode = $this->createElement($strNode); |
| 237 | 237 | if (!empty($value)) {
|
@@ -66,14 +66,14 @@ discard block |
||
| 66 | 66 | if (!Sepa::checkValidation(Sepa::V_NO_IBAN_VALIDATION)) {
|
| 67 | 67 | if (strlen($this->strIBAN) == 0) {
|
| 68 | 68 | $iErr |= Sepa::ERR_TX_IBAN_MISSING; |
| 69 | - } else if( Sepa::validateIBAN($this->strIBAN) != Sepa::OK) {
|
|
| 69 | + } else if (Sepa::validateIBAN($this->strIBAN) != Sepa::OK) {
|
|
| 70 | 70 | $iErr |= Sepa::ERR_TX_INVALID_IBAN; |
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | if (!Sepa::checkValidation(Sepa::V_NO_BIC_VALIDATION)) {
|
| 74 | 74 | if (strlen($this->strBIC) == 0) {
|
| 75 | 75 | $iErr |= Sepa::ERR_TX_BIC_MISSING; |
| 76 | - } else if( Sepa::validateBIC($this->strBIC) != Sepa::OK) {
|
|
| 76 | + } else if (Sepa::validateBIC($this->strBIC) != Sepa::OK) {
|
|
| 77 | 77 | $iErr |= Sepa::ERR_TX_INVALID_BIC; |
| 78 | 78 | } |
| 79 | 79 | } |
@@ -127,31 +127,31 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | public function fromArray(array $aProperties) : void |
| 129 | 129 | {
|
| 130 | - if (isset( $aProperties['strName']) ) {
|
|
| 130 | + if (isset($aProperties['strName'])) {
|
|
| 131 | 131 | $this->setName($aProperties['strName']); |
| 132 | 132 | } |
| 133 | - if (isset( $aProperties['strIBAN']) ) {
|
|
| 133 | + if (isset($aProperties['strIBAN'])) {
|
|
| 134 | 134 | $this->setIBAN($aProperties['strIBAN']); |
| 135 | 135 | } |
| 136 | - if (isset( $aProperties['strBIC']) ) {
|
|
| 136 | + if (isset($aProperties['strBIC'])) {
|
|
| 137 | 137 | $this->setBIC($aProperties['strBIC']); |
| 138 | 138 | } |
| 139 | - if (isset( $aProperties['strMandateId']) ) {
|
|
| 139 | + if (isset($aProperties['strMandateId'])) {
|
|
| 140 | 140 | $this->setMandateId($aProperties['strMandateId']); |
| 141 | 141 | } |
| 142 | - if (isset( $aProperties['strDateOfSignature']) ) {
|
|
| 142 | + if (isset($aProperties['strDateOfSignature'])) {
|
|
| 143 | 143 | $this->setDateOfSignature($aProperties['strDateOfSignature']); |
| 144 | 144 | } |
| 145 | - if (isset( $aProperties['strDescription']) ) {
|
|
| 145 | + if (isset($aProperties['strDescription'])) {
|
|
| 146 | 146 | $this->setDescription($aProperties['strDescription']); |
| 147 | 147 | } |
| 148 | - if (isset( $aProperties['dblValue']) ) {
|
|
| 148 | + if (isset($aProperties['dblValue'])) {
|
|
| 149 | 149 | $this->setValue(floatval($aProperties['dblValue'])); |
| 150 | 150 | } |
| 151 | - if (isset( $aProperties['strUltimateName']) ) {
|
|
| 151 | + if (isset($aProperties['strUltimateName'])) {
|
|
| 152 | 152 | $this->setUltimateName($aProperties['strUltimateName']); |
| 153 | 153 | } |
| 154 | - if (isset( $aProperties['strPaymentId']) ) {
|
|
| 154 | + if (isset($aProperties['strPaymentId'])) {
|
|
| 155 | 155 | $this->setPaymentId($aProperties['strPaymentId']); |
| 156 | 156 | } |
| 157 | 157 | } |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | $bAlphaNum = false; |
| 87 | 87 | if (strlen($strCheck) == 17) {
|
| 88 | 88 | $strRegEx = '/^([A-Z]){2}([0-9]){2}([0-9A-Z]){3}([0-9]){10}?$/';
|
| 89 | - } else if(strlen($strCheck) == 20) {
|
|
| 89 | + } else if (strlen($strCheck) == 20) {
|
|
| 90 | 90 | $strRegEx = '/^([A-Z]){2}([0-9]){2}([0-9A-Z]){3}([0-9]){3}D([0-9]){9}?$/';
|
| 91 | 91 | $bAlphaNum = true; |
| 92 | 92 | } else {
|
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | if (!preg_match($strRegEx, $strCheck)) {
|
| 100 | 100 | return Sepa::ERR_CI_INVALID_SIGN; |
| 101 | 101 | } |
| 102 | - $strCS = substr($strCheck, 2, 2); |
|
| 102 | + $strCS = substr($strCheck, 2, 2); |
|
| 103 | 103 | // NOTE: the CBC is not taken into account when calculating the checksum! |
| 104 | 104 | $strCheck = substr($strCheck, 7); |
| 105 | 105 | if ($bAlphaNum) {
|
@@ -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 |
@@ -162,9 +162,9 @@ discard block |
||
| 162 | 162 | return Sepa::ERR_CI_INVALID_SIGN; |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - $strCS = substr($strCheck, 2, 2); |
|
| 165 | + $strCS = substr($strCheck, 2, 2); |
|
| 166 | 166 | // NOTE: the CBC is not taken into account when calculating the checksum! |
| 167 | - $strCheck = substr($strCheck, 7); |
|
| 167 | + $strCheck = substr($strCheck, 7); |
|
| 168 | 168 | if ($this->bAlphaNumCI) {
|
| 169 | 169 | $strCheck = $this->replaceAlpha($strCheck); |
| 170 | 170 | } |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | // 3. subtract value from 98 |
| 200 | 200 | $strCS = $this->adjustFP(bcsub('98', $strCS2));
|
| 201 | 201 | // 4. always 2 digits... |
| 202 | - if (strlen($strCS) < 2 ) {
|
|
| 202 | + if (strlen($strCS) < 2) {
|
|
| 203 | 203 | $strCS = '0' . $strCS; |
| 204 | 204 | } |
| 205 | 205 | $this->strLastCheckSum = $strCS; |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | */ |
| 216 | 216 | protected function adjustFP(string $str) : string |
| 217 | 217 | {
|
| 218 | - if( strpos( '.', $str ) !== false ) {
|
|
| 218 | + if (strpos('.', $str) !== false) {
|
|
| 219 | 219 | $str = substr($str, 0, strpos('.', $str));
|
| 220 | 220 | } |
| 221 | 221 | return $str; |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | protected function replaceAlpha(string $strCheck) : string |
| 242 | 242 | {
|
| 243 | 243 | // account number may contains characters |
| 244 | - foreach (range('A', 'Z') as $ch){
|
|
| 244 | + foreach (range('A', 'Z') as $ch) {
|
|
| 245 | 245 | $strCheck = str_replace((string)$ch, $this->convCharToNum((string)$ch), $strCheck); |
| 246 | 246 | } |
| 247 | 247 | return $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' |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | protected function isValidType(string $type) : bool |
| 27 | 27 | {
|
| 28 | - if( $type != Sepa::CCT && $type != Sepa::CDD ) {
|
|
| 28 | + if ($type != Sepa::CCT && $type != Sepa::CDD) {
|
|
| 29 | 29 | trigger_error('invalid type for ' . get_class($this), E_USER_ERROR);
|
| 30 | 30 | } |
| 31 | 31 | return true; |
@@ -41,10 +41,10 @@ discard block |
||
| 41 | 41 | {
|
| 42 | 42 | mt_srand((int)microtime(true) * 10000); |
| 43 | 43 | $charid = strtoupper(md5(uniqid((string)rand(), true))); |
| 44 | - $uuid = substr($charid, 0, 8) . chr( 45 ) |
|
| 45 | - .substr($charid, 8, 4) . chr( 45 ) |
|
| 46 | - .substr($charid, 12, 4) . chr( 45 ) |
|
| 47 | - .substr($charid, 16,12); |
|
| 44 | + $uuid = substr($charid, 0, 8) . chr(45) |
|
| 45 | + .substr($charid, 8, 4) . chr(45) |
|
| 46 | + .substr($charid, 12, 4) . chr(45) |
|
| 47 | + .substr($charid, 16, 12); |
|
| 48 | 48 | |
| 49 | 49 | return $uuid; |
| 50 | 50 | } |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | $strValid = self::replaceSpecialChars($str); |
| 89 | 89 | |
| 90 | 90 | // regular expresion for 'standard' types MAXxxx |
| 91 | - $strRegEx = '/[^A-Za-z0-9 \.,\-\/\+():?]/'; // A...Z, a...z, 0...9, blank, dot, comma plus, minus, slash, questionmark, colon, open/closing bracket |
|
| 91 | + $strRegEx = '/[^A-Za-z0-9 \.,\-\/\+():?]/'; // A...Z, a...z, 0...9, blank, dot, comma plus, minus, slash, questionmark, colon, open/closing bracket |
|
| 92 | 92 | $strReplace = ' '; |
| 93 | 93 | $iMaxLen = 1025; |
| 94 | 94 | switch ($iType) {
|
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | break; |
| 100 | 100 | case Sepa::ID2: |
| 101 | 101 | $iMaxLen = 35; |
| 102 | - $strRegEx = '/[^A-Za-z0-9\.,\+\-\/]/'; // same as ID1 except blank... |
|
| 102 | + $strRegEx = '/[^A-Za-z0-9\.,\+\-\/]/'; // same as ID1 except blank... |
|
| 103 | 103 | $strReplace = ''; |
| 104 | 104 | break; |
| 105 | 105 | case Sepa::MAX35: |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | public static function replaceSpecialChars(string $str) : string |
| 132 | 132 | {
|
| 133 | 133 | $strReplaced = ''; |
| 134 | - if( strlen($str) > 0 ) {
|
|
| 134 | + if (strlen($str) > 0) {
|
|
| 135 | 135 | // replace known special chars |
| 136 | 136 | $aSpecialChars = array( |
| 137 | 137 | 'á' => 'a', 'à' => 'a', 'ä' => 'ae', 'â' => 'a', 'ã' => 'a', 'å' => 'a', 'æ' => 'ae', |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | '_' => '-', '@' => '(at)', '€' => 'EUR' |
| 152 | 152 | ); |
| 153 | 153 | |
| 154 | - $strReplaced = strtr( $str, $aSpecialChars ); |
|
| 154 | + $strReplaced = strtr($str, $aSpecialChars); |
|
| 155 | 155 | } |
| 156 | 156 | return $strReplaced; |
| 157 | 157 | } |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | * @param int $dtStart unix timestamp start date (if null, current date is used) |
| 164 | 164 | * @return int unix timestamp |
| 165 | 165 | */ |
| 166 | - public static function calcCollectionDate(int $iDays, ?int $dtStart=null) : int |
|
| 166 | + public static function calcCollectionDate(int $iDays, ?int $dtStart = null) : int |
|
| 167 | 167 | {
|
| 168 | 168 | $dtCollect = ($dtStart == null) ? time() : $dtStart; |
| 169 | 169 | |
@@ -202,14 +202,14 @@ discard block |
||
| 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' |
|
| 206 | - ,'2020-01-01', '2020-04-10', '2020-04-13', '2020-05-01', '2020-12-25', '2020-12-26' |
|
| 207 | - ,'2021-01-01', '2021-04-02', '2021-04-05', '2021-05-01', '2021-12-25', '2021-12-26' |
|
| 208 | - ,'2022-01-01', '2022-04-15', '2022-04-18', '2022-05-01', '2022-12-25', '2022-12-26' |
|
| 209 | - ,'2023-01-01', '2023-04-07', '2023-04-10', '2023-05-01', '2023-12-25', '2023-12-26' |
|
| 210 | - ,'2024-01-01', '2024-03-29', '2024-04-01', '2024-05-01', '2024-12-25', '2024-12-26' |
|
| 211 | - ,'2025-01-01', '2025-04-18', '2025-04-21', '2025-05-01', '2025-12-25', '2025-12-26' |
|
| 205 | + '2019-01-01', '2019-04-18', '2019-04-21', '2019-05-01', '2019-12-25', '2019-12-26' |
|
| 206 | + ,'2020-01-01', '2020-04-10', '2020-04-13', '2020-05-01', '2020-12-25', '2020-12-26' |
|
| 207 | + ,'2021-01-01', '2021-04-02', '2021-04-05', '2021-05-01', '2021-12-25', '2021-12-26' |
|
| 208 | + ,'2022-01-01', '2022-04-15', '2022-04-18', '2022-05-01', '2022-12-25', '2022-12-26' |
|
| 209 | + ,'2023-01-01', '2023-04-07', '2023-04-10', '2023-05-01', '2023-12-25', '2023-12-26' |
|
| 210 | + ,'2024-01-01', '2024-03-29', '2024-04-01', '2024-05-01', '2024-12-25', '2024-12-26' |
|
| 211 | + ,'2025-01-01', '2025-04-18', '2025-04-21', '2025-05-01', '2025-12-25', '2025-12-26' |
|
| 212 | 212 | ); |
| 213 | - return ($iWeekDay > 5 || in_array( date( 'Y-m-d', $dt ), $aTarget2 )); |
|
| 213 | + return ($iWeekDay > 5 || in_array(date('Y-m-d', $dt), $aTarget2));
|
|
| 214 | 214 | } |
| 215 | 215 | } |