Ejemplo n.º 1
0
 /**
  * calculates the sum of all payments in this collection
  *
  * @param mixed[] $paymentInfo needed keys: 'pmtId', 'instdAmt', 'mndtId', 'dtOfSgntr', 'bic',
  *                             'dbtr', 'iban';
  *                             optional keys: 'amdmntInd', 'orgnlMndtId', 'orgnlCdtrSchmeId_nm',
  *                             'orgnlCdtrSchmeId_id', 'orgnlDbtrAcct_iban', 'orgnlDbtrAgt',
  *                             'elctrncSgntr', 'ultmtDbtr', 'purp', 'rmtInf'
  * @throws SephpaInputException
  * @return void
  */
 public function addPayment(array $paymentInfo)
 {
     if ($this->checkAndSanitize) {
         if (!SepaUtilities::checkRequiredPaymentKeys($paymentInfo, self::VERSION)) {
             throw new SephpaInputException('One of the required inputs \'pmtId\', \'instdAmt\', \'mndtId\', \'dtOfSgntr\', \'dbtr\', \'iban\' is missing.');
         }
         $bicRequired = !SepaUtilities::isEEATransaction($this->cdtrIban, $paymentInfo['iban']);
         $checkResult = SepaUtilities::checkAndSanitizeAll($paymentInfo, $this->sanitizeFlags, array('allowEmptyBic' => $bicRequired, 'version' => self::VERSION));
         if ($checkResult !== true) {
             throw new SephpaInputException('The values of ' . $checkResult . ' are invalid.');
         }
         if (!empty($paymentInfo['amdmntInd']) && $paymentInfo['amdmntInd'] === 'true') {
             if (SepaUtilities::containsNotAnyKey($paymentInfo, array('orgnlMndtId', 'orgnlCdtrSchmeId_nm', 'orgnlCdtrSchmeId_id', 'orgnlDbtrAcct_iban', 'orgnlDbtrAgt'))) {
                 throw new SephpaInputException('You set \'amdmntInd\' to \'true\', so you have to set also at least one of the following inputs: \'orgnlMndtId\', \'orgnlCdtrSchmeId_nm\', \'orgnlCdtrSchmeId_id\', \'orgnlDbtrAcct_iban\', \'orgnlDbtrAgt\'.');
             }
             if (!empty($paymentInfo['orgnlDbtrAgt']) && $paymentInfo['orgnlDbtrAgt'] === 'SMNDA' && $this->debitInfo['seqTp'] !== SepaUtilities::SEQUENCE_TYPE_RECURRING && $this->debitInfo['seqTp'] !== SepaUtilities::SEQUENCE_TYPE_FIRST) {
                 throw new SephpaInputException('You set \'amdmntInd\' to \'true\' and \'orgnlDbtrAgt\' to \'SMNDA\', \'seqTp\' has to be \'' . SepaUtilities::SEQUENCE_TYPE_FIRST . '\' or \'' . SepaUtilities::SEQUENCE_TYPE_RECURRING . '\'.');
             }
         }
         // IBAN and BIC can belong to each other?
         if (!empty($paymentInfo['bic']) && !SepaUtilities::crossCheckIbanBic($paymentInfo['iban'], $paymentInfo['bic'])) {
             throw new SephpaInputException('IBAN and BIC do not belong to each other.');
         }
     }
     // adjustments
     // local instrument COR1 got included into CORE.
     if ($this->debitInfo['lclInstrm'] === SepaUtilities::LOCAL_INSTRUMENT_CORE_DIRECT_DEBIT_D_1) {
         $this->debitInfo['lclInstrm'] = SepaUtilities::LOCAL_INSTRUMENT_CORE_DIRECT_DEBIT;
     }
     // it is no longer required to use FRST as sequence type for the first direct debit
     // instead it is recommended to use RCUR
     if ($this->debitInfo['seqTp'] === SepaUtilities::SEQUENCE_TYPE_FIRST) {
         $this->debitInfo['seqTp'] = SepaUtilities::SEQUENCE_TYPE_RECURRING;
     }
     $this->payments[] = $paymentInfo;
 }
Ejemplo n.º 2
0
 /**
  * calculates the sum of all payments in this collection
  *
  * @param mixed[] $paymentInfo needed keys: 'pmtId', 'instdAmt', 'mndtId', 'dtOfSgntr', 'bic',
  *                             'dbtr', 'iban';
  *                             optional keys: 'amdmntInd', 'orgnlMndtId', 'orgnlCdtrSchmeId_nm',
  *                             'orgnlCdtrSchmeId_id', 'orgnlDbtrAcct_iban', 'orgnlDbtrAgt',
  *                             'elctrncSgntr', 'ultmtDbtr', 'purp', 'rmtInf'
  * @throws SephpaInputException
  * @return void
  */
 public function addPayment(array $paymentInfo)
 {
     if (!SepaUtilities::checkRequiredPaymentKeys($paymentInfo, self::VERSION)) {
         throw new SephpaInputException('One of the required inputs \'pmtId\', \'instdAmt\', \'mndtId\', \'dtOfSgntr\', \'bic\', \'dbtr\', \'iban\' is missing.');
     }
     if ($this->checkAndSanitize) {
         $checkResult = SepaUtilities::checkAndSanitizeAll($paymentInfo, $this->sanitizeFlags, array('version' => self::VERSION));
         if ($checkResult !== true) {
             throw new SephpaInputException('The values of ' . $checkResult . ' are invalid.');
         }
         if (!empty($paymentInfo['amdmntInd']) && $paymentInfo['amdmntInd'] === 'true') {
             if (SepaUtilities::containsNotAnyKey($paymentInfo, array('orgnlMndtId', 'orgnlCdtrSchmeId_nm', 'orgnlCdtrSchmeId_id', 'orgnlDbtrAcct_iban', 'orgnlDbtrAgt'))) {
                 throw new SephpaInputException('You set \'amdmntInd\' to \'true\', so you have to set also at least one of the following inputs: \'orgnlMndtId\', \'orgnlCdtrSchmeId_nm\', \'orgnlCdtrSchmeId_id\', \'orgnlDbtrAcct_iban\', \'orgnlDbtrAgt\'.');
             }
             if (!empty($paymentInfo['orgnlDbtrAgt']) && $paymentInfo['orgnlDbtrAgt'] === 'SMNDA' && $this->debitInfo['seqTp'] !== SepaUtilities::SEQUENCE_TYPE_FIRST) {
                 throw new SephpaInputException('You set \'amdmntInd\' to \'true\' and \'orgnlDbtrAgt\' to \'SMNDA\', \'seqTp\' has to be \'' . SepaUtilities::SEQUENCE_TYPE_FIRST . '\'.');
             }
         }
         // IBAN and BIC can belong to each other?
         if (!SepaUtilities::crossCheckIbanBic($paymentInfo['iban'], $paymentInfo['bic'])) {
             throw new SephpaInputException('IBAN and BIC do not belong to each other.');
         }
     }
     $this->payments[] = $paymentInfo;
 }
Ejemplo n.º 3
0
 public function testContainsNotAnyKey()
 {
     $this->assertTrue(SepaUtilities::containsNotAnyKey(array('a' => 1, 'b' => 2, 'd' => 2), array('e', 'f', 'g')));
     $this->assertFalse(SepaUtilities::containsNotAnyKey(array('a' => 1, 'b' => 2, 'd' => 2), array('e', 'f', 'b')));
 }