/**
  * @param  Transaction $transaction
  * @param  DOMDocument $document
  * @return \DOMElement
  */
 private function createRequisicaoAutorizacao(Transaction $transaction, DOMDocument $document)
 {
     $autorizacao = $document->createElementNS(RequestSerializer::NS, 'requisicao-autorizacao-tid');
     $autorizacao->setAttribute('id', $transaction->getOrder()->getNumber());
     $autorizacao->setAttribute('versao', RequestSerializer::VERSION);
     $autorizacao->appendChild($document->createElementNS(RequestSerializer::NS, 'tid', $transaction->getTid()));
     $autorizacao->appendChild($this->createDadosEc($transaction, $document));
     return $autorizacao;
 }
 protected function createDadosEc(Transaction $transaction, DOMDocument $document)
 {
     $merchant = $transaction->getMerchant();
     $dadosEc = $document->createElementNS(TransactionRequestSerializer::NS, 'dados-ec');
     $numero = $document->createElementNS(TransactionRequestSerializer::NS, 'numero', $merchant->getAffiliationId());
     $chave = $document->createElementNS(TransactionRequestSerializer::NS, 'chave', $merchant->getAffiliationKey());
     $dadosEc->appendChild($numero);
     $dadosEc->appendChild($chave);
     return $dadosEc;
 }
 private function readAutorizacao(Transaction $transaction)
 {
     $authorization = new Authorization();
     $authorization->setCode($this->getValue('//c:transacao/c:autorizacao/c:codigo'));
     $authorization->setMessage($this->getValue('//c:transacao/c:autorizacao/c:mensagem'));
     $authorization->setDateTime($this->getValue('//c:transacao/c:autorizacao/c:data-hora'));
     $authorization->setTotal($this->getValue('//c:transacao/c:autorizacao/c:valor'));
     $authorization->setLr($this->getValue('//c:transacao/c:autorizacao/c:lr'));
     $authorization->setArp($this->getValue('//c:transacao/c:autorizacao/c:arp'));
     $authorization->setNsu($this->getValue('//c:transacao/c:autorizacao/c:nsu'));
     $transaction->setAuthorization($authorization);
 }
 /**
  * @test
  */
 public function setGenerateTokenThrowsUnexpectedValue()
 {
     $this->setExpectedException(\UnexpectedValueException::class);
     $this->transaction->setGenerateToken(0);
 }
 /**
  * @param  Transaction $transaction
  * @param  DOMDocument $document
  * @return \DOMElement
  */
 private function createFormaPagamento(Transaction $transaction, DOMDocument $document)
 {
     $paymentMethod = $transaction->getPaymentMethod();
     $formaPagamento = $document->createElementNS(self::NS, 'forma-pagamento');
     $this->createElementAndAppendWithNs($formaPagamento, 'bandeira', $paymentMethod->getIssuer());
     $this->createElementAndAppendWithNs($formaPagamento, 'produto', $paymentMethod->getProduct());
     $this->createElementAndAppendWithNs($formaPagamento, 'parcelas', $paymentMethod->getInstallments());
     return $formaPagamento;
 }
 private function createFormaPagamento(Transaction $transaction, DOMDocument $document)
 {
     $paymentMethod = $transaction->getPaymentMethod();
     $formaPagamento = $document->createElementNS(TransactionRequestSerializer::NS, 'forma-pagamento');
     $formaPagamento->appendChild($document->createElementNS(TransactionRequestSerializer::NS, 'bandeira', $paymentMethod->getIssuer()));
     $formaPagamento->appendChild($document->createElementNS(TransactionRequestSerializer::NS, 'produto', $paymentMethod->getProduct()));
     $formaPagamento->appendChild($document->createElementNS(TransactionRequestSerializer::NS, 'parcelas', $paymentMethod->getInstallments()));
     return $formaPagamento;
 }
 /**
  * @param Transaction $transaction
  */
 private function readToken(Transaction $transaction)
 {
     $token = new Token();
     $token->setCode($this->getValue('//c:transacao/c:token/c:dados-token/c:codigo-token'));
     $token->setStatus($this->getValue('//c:transacao/c:token/c:dados-token/c:status'));
     $token->setNumero($this->getValue('//c:transacao/c:token/c:dados-token/c:numero-cartao-truncado'));
     $transaction->setToken($token);
 }
 /**
  * @param Transaction $transaction
  */
 private function readCancellation($transaction)
 {
     $cancellationInformation = new CancellationInformation();
     $cancellationInformation->setCode($this->getValue('//c:transacao/c:cancelamentos/c:cancelamento/c:codigo'));
     $cancellationInformation->setMessage($this->getValue('//c:transacao/c:cancelamentos/c:cancelamento/c:mensagem'));
     $cancellationInformation->setDateTime($this->getValue('//c:transacao/c:cancelamentos/c:cancelamento/c:data-hora'));
     $cancellationInformation->setValue($this->getValue('//c:transacao/c:cancelamentos/c:cancelamento/c:valor'));
     $transaction->setCancellationInformation($cancellationInformation);
 }
 public function testSetHolder_shouldBeSuccess_whenHolderHasToken()
 {
     $holder = new Holder('TuS6LeBHWjqFFtE7S3zR052Jl/KUlD+tYJFpAdlA87E=');
     $this->transaction->setHolder($holder);
 }