/** * @param $paymentName * @param array $paymentInformation * - id * - creditorName * - creditorAccountIBAN * - creditorAgentBIC * - seqType * - creditorId * - [dueDate] if not set: now + 5 days * * @throws \Digitick\Sepa\Exception\InvalidArgumentException * @return mixed * */ public function addPaymentInfo($paymentName, array $paymentInformation) { if (isset($this->payments[$paymentName])) { throw new InvalidArgumentException(sprintf('Payment with the name %s already exists', $paymentName)); } $payment = new PaymentInformation($paymentInformation['id'], $paymentInformation['creditorAccountIBAN'], $paymentInformation['creditorAgentBIC'], $paymentInformation['creditorName']); $payment->setSequenceType($paymentInformation['seqType']); $payment->setCreditorId($paymentInformation['creditorId']); if (isset($paymentInformation['localInstrumentCode'])) { $payment->setLocalInstrumentCode($paymentInformation['localInstrumentCode']); } if (isset($paymentInformation['dueDate'])) { if ($paymentInformation['dueDate'] instanceof \DateTime) { $payment->setDueDate($paymentInformation['dueDate']); } else { $payment->setDueDate(new \DateTime($paymentInformation['dueDate'])); } } else { $payment->setDueDate(new \DateTime(date('Y-m-d', strtotime('now + 5 days')))); } $this->payments[$paymentName] = $payment; }