/**
  * @test
  * @expectedException \Accesto\Component\Payum\PayU\Exception\PayUException
  */
 public function shouldThrowExceptionAfterFailure()
 {
     $createResponse = new \stdClass();
     $createResponse->status = new \stdClass();
     $createResponse->status->statusCode = 'Error';
     $createResponse->orderId = 1;
     $createResponse->redirectUri = 'example.com';
     $action = $this->setupSetPayUAction($createResponse);
     $t = new Token();
     $t->setGatewayName('payu');
     $t->setDetails(new \ArrayObject());
     $request = new SetPayU($t);
     $request->setModel(new ArrayObject());
     $action->execute($request);
 }
 /**
  * @test
  */
 public function shouldSetTokenTargetUrlAsCancelUrlIfCapturePassedWithToken()
 {
     $testCase = $this;
     $expectedCancelUrl = 'theCancelUrl';
     $token = new Token();
     $token->setTargetUrl($expectedCancelUrl);
     $token->setDetails(array());
     $paymentMock = $this->createPaymentMock();
     $paymentMock->expects($this->at(0))->method('execute')->with($this->isInstanceOf('Eki\\Payum\\Nganluong\\Request\\Api\\SetExpressCheckout'))->will($this->returnCallback(function ($request) use($testCase, $expectedCancelUrl) {
         $model = $request->getModel();
         $testCase->assertEquals($expectedCancelUrl, $model['cancel_url']);
     }));
     $action = new CaptureAction();
     $action->setPayment($paymentMock);
     $request = new Capture($token);
     $request->setModel(array());
     $action->execute($request);
 }
Beispiel #3
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);
 }
 /**
  * @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);
 }
 /**
  * @test
  */
 public function shouldSetResponseStringDataToDetails()
 {
     $details = new \ArrayObject(['card' => array('cvv' => 123), 'clientIp' => '']);
     $responseMock = $this->getMock(OmnipayAbstractResponse::class, [], [], '', false);
     $responseMock->expects($this->any())->method('getData')->willReturn('someData');
     $requestMock = $this->getMock(OmnipayRequestInterface::class);
     $requestMock->expects($this->any())->method('send')->will($this->returnValue($responseMock));
     $omnipayGateway = $this->getMock(OffsiteGateway::class);
     $omnipayGateway->expects($this->once())->method('purchase')->willReturn($requestMock);
     $captureToken = new Token();
     $captureToken->setTargetUrl('theCaptureUrl');
     $captureToken->setDetails($identity = new Identity('theId', new \stdClass()));
     $captureToken->setGatewayName('theGatewayName');
     $notifyToken = new Token();
     $notifyToken->setTargetUrl('theNotifyUrl');
     $tokenFactoryMock = $this->getMock(GenericTokenFactoryInterface::class);
     $tokenFactoryMock->expects($this->once())->method('createNotifyToken')->with('theGatewayName', $this->identicalTo($identity))->willReturn($notifyToken);
     $request = new Capture($captureToken);
     $request->setModel($details);
     $action = new OffsiteCaptureAction();
     $action->setApi($omnipayGateway);
     $action->setGateway($this->createGatewayMock());
     $action->setGenericTokenFactory($tokenFactoryMock);
     $action->execute($request);
     $details = (array) $details;
     $this->assertArrayHasKey('_data', $details);
     $this->assertEquals('someData', $details['_data']);
 }
Beispiel #6
0
 /**
  * @test
  */
 public function shouldAllowGetIdentificatorPreviouslySetAsDetails()
 {
     $expectedIdentificator = new Identificator('anId', 'stdClass');
     $token = new Token();
     $token->setDetails($expectedIdentificator);
     $this->assertSame($expectedIdentificator, $token->getDetails());
 }