/**
  * @test
  */
 public function shouldNotAddNotifyUrlIfTokenFactoryNotSet()
 {
     $details = new \ArrayObject(array());
     $captureToken = new Token();
     $captureToken->setGatewayName('theGatewayName');
     $captureToken->setDetails($details);
     $action = new AuthorizeAction();
     $action->setGateway($this->createGatewayMock());
     $request = new Authorize($captureToken);
     $request->setModel($details);
     $action->execute($request);
     $this->assertArrayNotHasKey('PAYMENTREQUEST_0_NOTIFYURL', $details);
 }
Esempio n. 2
0
 /**
  * @test
  */
 public function shouldGeneratePushUriIfNotSet()
 {
     $config = new Config();
     $config->termsUri = 'theTermsUri';
     $token = new Token();
     $token->setTargetUrl('theTargetUrl');
     $token->setGatewayName('theGatewayName');
     $token->setDetails($identity = new Identity('id', 'class'));
     $notifyToken = new Token();
     $notifyToken->setTargetUrl('theNotifyUrl');
     $tokenFactory = $this->getMock(GenericTokenFactoryInterface::class);
     $tokenFactory->expects($this->once())->method('createNotifyToken')->with('theGatewayName', $this->identicalTo($identity))->will($this->returnValue($notifyToken));
     $action = new AuthorizeAction('aTemplate');
     $action->setGateway($this->createGatewayMock());
     $action->setApi($config);
     $action->setGenericTokenFactory($tokenFactory);
     $authorize = new Authorize($token);
     $authorize->setModel(['location' => 'aLocation', 'merchant' => ['confirmation_uri' => 'theConfirmationUri', 'checkout_uri' => 'theCheckoutUri', 'terms_uri' => 'theTermsUri']]);
     $action->execute($authorize);
 }
Esempio n. 3
0
 /**
  * @test
  */
 public function shouldSetDetailsBackToPaymentEvenIfExceptionThrown()
 {
     $expectedDetails = array('foo' => 'fooVal');
     $payment = new Payment();
     $payment->setDetails($expectedDetails);
     $gatewayMock = $this->createGatewayMock();
     $gatewayMock->expects($this->at(0))->method('execute')->with($this->isInstanceOf(GetHumanStatus::class))->will($this->returnCallback(function (GetHumanStatus $request) {
         $request->markPending();
     }));
     $gatewayMock->expects($this->at(1))->method('execute')->with($this->isInstanceOf(Authorize::class))->will($this->returnCallback(function (Authorize $request) {
         $details = $request->getModel();
         $details['bar'] = 'barVal';
         throw new \Exception();
     }));
     $action = new AuthorizePaymentAction();
     $action->setGateway($gatewayMock);
     $this->setExpectedException('Exception');
     $action->execute($authorize = new Authorize($payment));
     $this->assertSame($payment, $authorize->getFirstModel());
     $this->assertInstanceOf('ArrayAccess', $authorize->getModel());
     $this->assertEquals(array('foo' => 'fooVal', 'bar' => 'barVal'), $payment->getDetails());
 }