Exemplo n.º 1
0
 /**
  * @param PaymentInformation $paymentInformation
  */
 public function addPaymentInformation(PaymentInformation $paymentInformation)
 {
     $numberOfTransactions = $this->getGroupHeader()->getNumberOfTransactions() + $paymentInformation->getNumberOfTransactions();
     $transactionTotal = $this->getGroupHeader()->getControlSumCents() + $paymentInformation->getControlSumCents();
     $this->groupHeader->setNumberOfTransactions($numberOfTransactions);
     $this->groupHeader->setControlSumCents($transactionTotal);
     $this->paymentInformations[] = $paymentInformation;
 }
 /**
  * @param $paymentName
  * @param array $paymentInformation
  *     - id
  *     - creditorName
  *     - creditorAccountIBAN
  *     - creditorAgentBIC
  *     - seqType
  *     - creditorId
  *     - [dueDate] if not set: now + 5 days
  *
  * @throws \Digitick\Sepa\Exception\InvalidArgumentException
  *
  * @return PaymentInformation
  */
 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;
     return $payment;
 }
 /**
  * Crawl PaymentInformation containing the Transactions
  *
  * @param PaymentInformation $paymentInformation
  * @return mixed
  */
 public function visitPaymentInformation(PaymentInformation $paymentInformation)
 {
     $this->currentPayment = $this->createElement('PmtInf');
     $this->currentPayment->appendChild($this->createElement('PmtInfId', $paymentInformation->getId()));
     $this->currentPayment->appendChild($this->createElement('PmtMtd', $paymentInformation->getPaymentMethod()));
     $this->currentPayment->appendChild($this->createElement('NbOfTxs', $paymentInformation->getNumberOfTransactions()));
     $this->currentPayment->appendChild($this->createElement('CtrlSum', $this->intToCurrency($paymentInformation->getControlSumCents())));
     $paymentTypeInformation = $this->createElement('PmtTpInf');
     $serviceLevel = $this->createElement('SvcLvl');
     $serviceLevel->appendChild($this->createElement('Cd', 'SEPA'));
     $paymentTypeInformation->appendChild($serviceLevel);
     if ($paymentInformation->getCategoryPurposeCode()) {
         $categoryPurpose = $this->createElement('CtgyPurp');
         $categoryPurpose->appendChild($this->createElement('Cd', $paymentInformation->getCategoryPurposeCode()));
         $paymentTypeInformation->appendChild($categoryPurpose);
     }
     $this->currentPayment->appendChild($paymentTypeInformation);
     if ($paymentInformation->getLocalInstrumentCode()) {
         $localInstrument = $this->createElement('LclInstr');
         $localInstrument->appendChild($this->createElement('Cd', $paymentInformation->getLocalInstrumentCode()));
         $this->currentPayment->appendChild($localInstrument);
     }
     $this->currentPayment->appendChild($this->createElement('ReqdExctnDt', $paymentInformation->getDueDate()));
     $debtor = $this->createElement('Dbtr');
     $debtor->appendChild($this->createElement('Nm', $paymentInformation->getOriginName()));
     $this->currentPayment->appendChild($debtor);
     $debtorAccount = $this->createElement('DbtrAcct');
     $id = $this->createElement('Id');
     $id->appendChild($this->createElement('IBAN', $paymentInformation->getOriginAccountIBAN()));
     $debtorAccount->appendChild($id);
     if ($paymentInformation->getOriginAccountCurrency()) {
         $debtorAccount->appendChild($this->createElement('Ccy', $paymentInformation->getOriginAccountCurrency()));
     }
     $this->currentPayment->appendChild($debtorAccount);
     $debtorAgent = $this->createElement('DbtrAgt');
     $financialInstitutionId = $this->createElement('FinInstnId');
     $financialInstitutionId->appendChild($this->createElement('BIC', $paymentInformation->getOriginAgentBIC()));
     $debtorAgent->appendChild($financialInstitutionId);
     $this->currentPayment->appendChild($debtorAgent);
     $this->currentPayment->appendChild($this->createElement('ChrgBr', 'SLEV'));
     $this->currentTransfer->appendChild($this->currentPayment);
 }
 /**
  * @param PaymentInformation $paymentInformation
  */
 public function addPaymentInformation(PaymentInformation $paymentInformation)
 {
     $paymentInformation->setValidPaymentMethods(array('TRF'));
     $paymentInformation->setPaymentMethod('TRF');
     parent::addPaymentInformation($paymentInformation);
 }
 /**
  * Crawl PaymentInformation containing the Transactions
  *
  * @param PaymentInformation $paymentInformation
  * @return mixed
  */
 public function visitPaymentInformation(PaymentInformation $paymentInformation)
 {
     $this->currentPayment = $this->createElement('PmtInf');
     $this->currentPayment->appendChild($this->createElement('PmtInfId', $paymentInformation->getId()));
     $this->currentPayment->appendChild($this->createElement('PmtMtd', $paymentInformation->getPaymentMethod()));
     $this->currentPayment->appendChild($this->createElement('NbOfTxs', $paymentInformation->getNumberOfTransactions()));
     $this->currentPayment->appendChild($this->createElement('CtrlSum', $this->intToCurrency($paymentInformation->getControlSumCents())));
     $paymentTypeInformation = $this->createElement('PmtTpInf');
     $serviceLevel = $this->createElement('SvcLvl');
     $serviceLevel->appendChild($this->createElement('Cd', 'SEPA'));
     $paymentTypeInformation->appendChild($serviceLevel);
     $this->currentPayment->appendChild($paymentTypeInformation);
     $localInstrument = $this->createElement('LclInstrm');
     if ($paymentInformation->getLocalInstrumentCode()) {
         $localInstrument->appendChild($this->createElement('Cd', $paymentInformation->getLocalInstrumentCode()));
     } else {
         $localInstrument->appendChild($this->createElement('Cd', 'CORE'));
     }
     $paymentTypeInformation->appendChild($localInstrument);
     $paymentTypeInformation->appendChild($this->createElement('SeqTp', $paymentInformation->getSequenceType()));
     $this->currentPayment->appendChild($this->createElement('ReqdColltnDt', $paymentInformation->getDueDate()));
     $creditor = $this->createElement('Cdtr');
     $creditor->appendChild($this->createElement('Nm', $paymentInformation->getOriginName()));
     $this->currentPayment->appendChild($creditor);
     // <CdtrAcct>
     $creditorAccount = $this->createElement('CdtrAcct');
     $id = $this->getIbanElement($paymentInformation->getOriginAccountIBAN());
     $creditorAccount->appendChild($id);
     $this->currentPayment->appendChild($creditorAccount);
     // <CdtrAgt>
     if ($paymentInformation->getOriginAgentBIC()) {
         $creditorAgent = $this->createElement('CdtrAgt');
         $creditorAgent->appendChild($this->getFinancialInstitutionElement($paymentInformation->getOriginAgentBIC()));
         $this->currentPayment->appendChild($creditorAgent);
     }
     $this->currentPayment->appendChild($this->createElement('ChrgBr', 'SLEV'));
     $creditorSchemeId = $this->createElement('CdtrSchmeId');
     $id = $this->createElement('Id');
     $privateId = $this->createElement('PrvtId');
     $other = $this->createElement('Othr');
     $other->appendChild($this->createElement('Id', $paymentInformation->getCreditorId()));
     $schemeName = $this->createElement('SchmeNm');
     $schemeName->appendChild($this->createElement('Prtry', 'SEPA'));
     $other->appendChild($schemeName);
     $privateId->appendChild($other);
     $id->appendChild($privateId);
     $creditorSchemeId->appendChild($id);
     $this->currentPayment->appendChild($creditorSchemeId);
     $this->currentTransfer->appendChild($this->currentPayment);
 }