/**
  * Adds a payment to the payment collection
  *
  * @param mixed[] $paymentInfo needed keys: 'pmtId', 'instdAmt', 'iban', 'bic', 'cdtr';
  *                             optional keys: 'ultmtCdrt', '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\', \'iban\', \'bic\', \'cdtr\' is missing.');
         }
         $checkResult = SepaUtilities::checkAndSanitizeAll($paymentInfo, $this->sanitizeFlags);
         if ($checkResult !== true) {
             throw new SephpaInputException('The values of ' . $checkResult . ' are invalid.');
         }
         // 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.º 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
 /**
  * Adds a payment to the payment collection
  *
  * @param mixed[] $paymentInfo needed keys: 'pmtId', 'instdAmt', 'iban', 'bic', 'cdtr';
  *                             optional keys: 'ultmtCdrt', '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\', \'iban\', \'cdtr\' is missing.');
         }
         $bicRequired = !SepaUtilities::isNationalTransaction($this->dbtrIban, $paymentInfo['iban']) && $this->today <= SepaUtilities::BIC_REQUIRED_THRESHOLD;
         $checkResult = SepaUtilities::checkAndSanitizeAll($paymentInfo, $this->sanitizeFlags, array('allowEmptyBic' => $bicRequired));
         if ($checkResult !== true) {
             throw new SephpaInputException('The values of ' . $checkResult . ' are invalid.');
         }
         // 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.');
         }
     }
     $this->payments[] = $paymentInfo;
 }
Ejemplo n.º 4
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.º 5
0
 public function testCheckAndSanitizeAll()
 {
     $collectionInfo = array('pmtInfId' => 'PaymentID-1234', 'dbtr' => 'Name of Debtor2', 'iban' => 'DE21500500001234567897', 'bic' => 'BELADEBEXXX', 'ccy' => 'EUR', 'btchBookg' => 'true', 'reqdExctnDt' => '2013-11-25', 'ultmtDebtr' => 'Ultimate Debtor Name');
     $directDebitPaymentInformation = 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', 'elctrncSgntr' => 'test', 'ultmtDbtr' => 'Ultimate Debtor Name', 'rmtInf' => 'Remittance Information', 'orgnlMndtId' => 'Original-Mandat-ID', 'orgnlCdtrSchmeId_nm' => 'Creditor-Identifier Name', 'orgnlCdtrSchmeId_id' => 'DE98AAA09999999999', 'orgnlDbtrAcct_iban' => 'DE87200500001234567890', 'orgnlDbtrAgt' => 'SMNDA');
     $this->assertTrue(SepaUtilities::checkAndSanitizeAll($collectionInfo));
     $this->assertTrue(SepaUtilities::checkAndSanitizeAll($directDebitPaymentInformation));
 }