コード例 #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 (!SepaUtilities::checkRequiredPaymentKeys($paymentInfo, self::VERSION)) {
         throw new SephpaInputException('One of the required inputs \'pmtId\', \'instdAmt\', \'mndtId\', \'dtOfSgntr\', \'dbtr\', \'iban\' is missing.');
     }
     if ($this->checkAndSanitize) {
         $bicRequired = !SepaUtilities::isNationalTransaction($this->cdtrIban, $paymentInfo['iban']) && $this->today <= SepaUtilities::BIC_REQUIRED_THRESHOLD;
         $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_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 (!empty($paymentInfo['bic']) && !SepaUtilities::crossCheckIbanBic($paymentInfo['iban'], $paymentInfo['bic'])) {
             throw new SephpaInputException('IBAN and BIC do not belong to each other.');
         }
     }
     $this->payments[] = $paymentInfo;
 }
コード例 #2
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;
 }