/**
  * @param mixed[] $debitInfo        Needed keys: 'pmtInfId', 'lclInstrm', 'seqTp', 'cdtr',
  *                                  'iban', 'bic', 'ci'; optional keys: 'ccy', 'btchBookg',
  *                                  'ctgyPurp', 'ultmtCdtr', 'reqdColltnDt'
  * @param bool    $checkAndSanitize All inputs will be checked and sanitized before creating
  *                                  the collection. If you check the inputs yourself you can
  *                                  set this to false.
  * @param int     $flags            The flags used for sanitizing
  * @throws SephpaInputException
  */
 public function __construct(array $debitInfo, $checkAndSanitize = true, $flags = 0)
 {
     $this->checkAndSanitize = $checkAndSanitize;
     $this->sanitizeFlags = $flags;
     if ($this->checkAndSanitize) {
         if (!SepaUtilities::checkRequiredCollectionKeys($debitInfo, self::VERSION)) {
             throw new SephpaInputException('One of the required inputs \'pmtInfId\', \'lclInstrm\', \'seqTp\', \'cdtr\', \'iban\', \'bic\', \'ci\' is missing.');
         }
         $checkResult = SepaUtilities::checkAndSanitizeAll($debitInfo, $this->sanitizeFlags, array('version' => self::VERSION));
         if ($checkResult !== true) {
             throw new SephpaInputException('The values of ' . $checkResult . ' are invalid.');
         }
         // IBAN and BIC can belong to each other?
         if (!SepaUtilities::crossCheckIbanBic($debitInfo['iban'], $debitInfo['bic'])) {
             throw new SephpaInputException('IBAN and BIC do not belong to each other.');
         }
     }
     $this->debitInfo = $debitInfo;
 }
 /**
  * @param mixed[] $transferInfo needed keys: 'pmtInfId', 'dbtr', 'iban', 'bic';
  *                              optional keys: 'ccy', 'btchBookg', 'ctgyPurp',
  *                              'reqdExctnDt', 'ultmtDebtr'
  * @param bool    $checkAndSanitize        All inputs will be checked and sanitized before creating
  *                              the collection. If you check the inputs yourself you can
  *                              set this to false.
  * @param int     $flags        The flags used for sanitizing
  * @throws SephpaInputException
  */
 public function __construct(array $transferInfo, $checkAndSanitize = true, $flags = 0)
 {
     $this->checkAndSanitize = $checkAndSanitize;
     $this->sanitizeFlags = $flags;
     // All required information is provided?
     if (!SepaUtilities::checkRequiredCollectionKeys($transferInfo, self::VERSION)) {
         throw new SephpaInputException('The values of \'pmtInfId\', \'dbtr\', \'iban\', \'bic\' must not be empty.');
     }
     if ($this->checkAndSanitize) {
         // All fields contain valid information?
         $checkResult = SepaUtilities::checkAndSanitizeAll($transferInfo, $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($transferInfo['iban'], $transferInfo['bic'])) {
             throw new SephpaInputException('IBAN and BIC do not belong to each other.');
         }
     }
     $this->transferInfo = $transferInfo;
 }
 /**
  * @param mixed[] $transferInfo needed keys: 'pmtInfId', 'dbtr', 'iban';
  *                              optional keys: 'ccy', 'btchBookg', 'ctgyPurp', 'reqdExctnDt', 'ultmtDebtr', 'bic'
  * @param bool $checkAndSanitize           All inputs will be checked and sanitized before creating the
  *                              collection. If you check the inputs yourself you can set this
  *                              to false.
  * @param int     $flags        The flags used for sanitizing
  * @throws SephpaInputException
  */
 public function __construct(array $transferInfo, $checkAndSanitize = true, $flags = 0)
 {
     $this->today = (int) date('Ymd');
     $this->checkAndSanitize = $checkAndSanitize;
     $this->sanitizeFlags = $flags;
     if (!SepaUtilities::checkRequiredCollectionKeys($transferInfo, self::VERSION)) {
         throw new SephpaInputException('The values of \'pmtInfId\', \'dbtr\', \'iban\' must not be empty.');
     }
     if ($this->checkAndSanitize) {
         // All fields contain valid information?
         $checkResult = SepaUtilities::checkAndSanitizeAll($transferInfo, $this->sanitizeFlags, array('allowEmptyBic' => true));
         if ($checkResult !== true) {
             throw new SephpaInputException('The values of ' . $checkResult . ' are invalid.');
         }
         $this->dbtrIban = $transferInfo['iban'];
         if (!empty($transferInfo['bic']) && !SepaUtilities::crossCheckIbanBic($transferInfo['iban'], $transferInfo['bic'])) {
             throw new SephpaInputException('IBAN and BIC do not belong to each other.');
         }
     }
     $this->transferInfo = $transferInfo;
 }
Exemplo n.º 4
0
 public function testCheckRequiredCollectionKeys()
 {
     $collectionInfo1 = array('pmtInfId' => 'PaymentID-1234', 'dbtr' => 'Name of Debtor2', 'iban' => 'DE21500500001234567897', 'bic' => 'BELADEBEXXX');
     $collectionInfo2 = array('pmtInfId' => 'PaymentID-1234', 'dbtr' => 'Name of Debtor2', 'iban' => 'DE21500500001234567897');
     $this->assertTrue(SepaUtilities::checkRequiredCollectionKeys($collectionInfo1, SepaUtilities::SEPA_PAIN_001_002_03));
     $this->assertFalse(SepaUtilities::checkRequiredCollectionKeys($collectionInfo2, SepaUtilities::SEPA_PAIN_001_002_03));
     $this->assertTrue(SepaUtilities::checkRequiredCollectionKeys($collectionInfo2, SepaUtilities::SEPA_PAIN_001_003_03));
 }