public function testRebuildSuccess()
 {
     $reference = AccountRegistrationReference::rebuild('eyJhciI6InRlc3QiLCJwYyI6IkNDLkRCIn0=');
     $this->assertInstanceOf('\\Omnipay\\PayUnity\\AccountRegistrationReference', $reference);
     /** @var $reference \Omnipay\PayUnity\AccountRegistrationReference */
     $this->assertSame('test', $reference->accountRegistration);
     $this->assertSame('CC.DB', $reference->paymentCode);
     $this->assertTrue($reference->isLoaded());
     $this->assertSame('eyJhciI6InRlc3QiLCJwYyI6IkNDLkRCIn0=', $reference->export());
 }
 /**
  * @return Message\GenericPostResponse
  */
 public function testAuthorizeSuccess()
 {
     if (empty($this->accountRegistrationReference)) {
         $this->markTestSkipped('Account registration reference not set');
     }
     $request = $this->gateway->authorize();
     $this->assertInstanceOf('\\Omnipay\\PayUnity\\Message\\PostAuthorizeRequest', $request);
     /** @var \Omnipay\PayUnity\Message\PostAuthorizeRequest $request  */
     $request->setAmount('1.20');
     $request->setCurrency('EUR');
     $request->setCardReference($this->accountRegistrationReference);
     $transactionId = 'TEST_AUTHORIZE_' . uniqid();
     $invoiceId = 'Test authorize invoice ID' . uniqid();
     $usage = 'SomeAuthorize' . uniqid();
     $request->setTransactionId($transactionId);
     $request->setPaymentMemo('Test authorization using token');
     $request->setIdentificationBulkId('Test authorize Bulk ID 123');
     $request->setIdentificationInvoiceId($invoiceId);
     $request->setPresentationUsage($usage);
     $response = $request->send();
     $this->checkSuccessfulResponse($response, $request);
     /** @var  \Omnipay\PayUnity\Message\GenericPostResponse $response */
     $this->assertSame('CC.PA.90.00', $response->getProcessingCode());
     $this->assertSame('CC.PA', $response->getPaymentCode());
     $referenceContainer = AccountRegistrationReference::rebuild($this->accountRegistrationReference);
     $this->assertSame($referenceContainer->accountRegistration, $response->getAccountRegistration());
     return $response;
 }
 /**
  * @return string|null
  */
 public function getCardReference()
 {
     $reference = new AccountRegistrationReference($this->getAccountRegistration(), $this->getPaymentCode());
     return $reference->export();
 }
 /**
  * @param array $data
  * @return array
  */
 protected function addCardReference(array $data)
 {
     if (empty($this->addCardReferenceMode)) {
         return $data;
     }
     $reference = AccountRegistrationReference::rebuild($this->getCardReference());
     if (empty($reference)) {
         return $data;
     }
     $paymentType = $this->getPaymentType() ?: $this->defaultPaymentType;
     $data['PAYMENT.CODE'] = $this->changePaymentTypeInCode($reference->paymentCode, $paymentType);
     if ($this->addCardReferenceMode === 'full') {
         $data['ACCOUNT.REGISTRATION'] = $reference->accountRegistration;
     }
     return $data;
 }
Ejemplo n.º 5
0
 /**
  * @return Message\GenericPostResponse
  */
 public function testAuthorizeSuccess()
 {
     $this->setMockHttpResponse('PostAuthorizeSuccess.txt');
     $request = $this->gateway->authorize();
     $this->assertInstanceOf('\\Omnipay\\PayUnity\\Message\\PostAuthorizeRequest', $request);
     /** @var \Omnipay\PayUnity\Message\PostAuthorizeRequest $request  */
     $request->setAmount('1.20');
     $request->setCurrency('EUR');
     $request->setCardReference($this->accountRegistrationReference);
     $transactionId = 'TEST_AUTHORIZE_ID';
     $invoiceId = 'Test authorize invoice ID';
     $request->setTransactionId($transactionId);
     $request->setPaymentMemo('Test authorization using token');
     $request->setIdentificationBulkId('Test authorize Bulk ID 123');
     $request->setIdentificationInvoiceId($invoiceId);
     $request->setDescription('Testing Authorization');
     $response = $request->send();
     $this->checkSuccessfulResponse($response, $request);
     /** @var  \Omnipay\PayUnity\Message\GenericPostResponse $response */
     $this->assertSame('CC.PA.90.00', $response->getProcessingCode());
     $this->assertSame('CC.PA', $response->getPaymentCode());
     $this->assertSame('some.short.id10', $response->getIdentificationShortId());
     $this->assertSame('SOME_TRANSACTION_IDENTIFICATION_UNIQUE_ID_10', $response->getTransactionReference());
     $referenceContainer = AccountRegistrationReference::rebuild($this->accountRegistrationReference);
     $this->assertSame($referenceContainer->accountRegistration, $response->getAccountRegistration());
     return $response;
 }