Exemple #1
0
 /**
  * @test
  */
 public function shouldAllowGetGatewayFactoriesFromRegistryInConstructor()
 {
     $registry = new SimpleRegistry(['foo' => 'fooGateway', 'bar' => 'barGateway'], ['foo' => 'fooStorage', 'bar' => 'barStorage'], ['foo' => 'fooGatewayFactory', 'bar' => 'barGatewayFactory']);
     $payum = new Payum($registry, $this->createHttpRequestVerifierMock(), $this->createGenericTokenFactoryMock());
     $this->assertSame('fooGatewayFactory', $payum->getGatewayFactory('foo'));
     $this->assertSame('barGatewayFactory', $payum->getGatewayFactory('bar'));
     $this->assertSame(['foo' => 'fooGatewayFactory', 'bar' => 'barGatewayFactory'], $payum->getGatewayFactories());
 }
 /**
  * request.
  *
  * @method request
  *
  * @param string   $gatewayName
  * @param callable $closure
  * @param string   $afterPath
  * @param array    $afterParameters
  * @param string   $tokenType
  *
  * @return mixed
  */
 public function request($gatewayName, callable $closure, $afterPath = 'payment.done', array $afterParameters = [], $tokenType = 'Capture')
 {
     $payum = $this->getPayum();
     $storage = $payum->getStorage($this->getPaymentModelName($payum));
     $payment = $storage->create();
     $closure($payment, $gatewayName, $storage, $this->payum);
     $storage->update($payment);
     $tokenFactory = $this->payum->getTokenFactory();
     $method = 'create' . ucfirst($tokenType) . 'Token';
     $token = call_user_func_array([$tokenFactory, $method], [$gatewayName, $payment, $afterPath, $afterParameters]);
     return $this->responseFactory->redirectTo($token->getTargetUrl());
 }
 /**
  * @return HttpRequestVerifierInterface
  */
 private function getHttpRequestVerifier()
 {
     return $this->payum->getHttpRequestVerifier();
 }