示例#1
0
 /**
  * {@inheritDoc}
  */
 public function createConfig(array $config = array())
 {
     $config = ArrayObject::ensureArrayObject($config);
     $config->defaults($this->defaultConfig);
     $config->defaults(array('payum.template.layout' => '@PayumCore/layout.html.twig', 'payum.http_client' => HttpClientFactory::create(), 'guzzle.client' => HttpClientFactory::createGuzzle(), 'twig.env' => function (ArrayObject $config) {
         $loader = new \Twig_Loader_Filesystem();
         foreach ($config['payum.paths'] as $namespace => $path) {
             $loader->addPath($path, $namespace);
         }
         return new \Twig_Environment($loader);
     }, 'payum.action.get_http_request' => new GetHttpRequestAction(), 'payum.action.capture_payment' => new CapturePaymentAction(), 'payum.action.execute_same_request_with_model_details' => new ExecuteSameRequestWithModelDetailsAction(), 'payum.action.render_template' => function (ArrayObject $config) {
         return new RenderTemplateAction($config['twig.env'], $config['payum.template.layout']);
     }, 'payum.extension.endless_cycle_detector' => new EndlessCycleDetectorExtension(), 'payum.action.get_currency' => function (ArrayObject $config) {
         return new GetCurrencyAction($config['payum.iso4217']);
     }, 'payum.prepend_actions' => array(), 'payum.prepend_extensions' => array(), 'payum.prepend_apis' => array(), 'payum.default_options' => array(), 'payum.required_options' => array(), 'payum.api.http_client' => function (ArrayObject $config) {
         return $config['payum.http_client'];
     }, 'payum.security.token_storage' => null));
     if ($config['payum.security.token_storage']) {
         $config['payum.action.get_token'] = function (ArrayObject $config) {
             return new GetTokenAction($config['payum.security.token_storage']);
         };
     }
     $config['payum.paths'] = array_replace(['PayumCore' => __DIR__ . '/Resources/views'], $config['payum.paths'] ?: []);
     return (array) $config;
 }
示例#2
0
 /**
  * @param array $options
  * @param HttpClientInterface|null $client
  */
 public function __construct(array $options, HttpClientInterface $client = null)
 {
     $options = ArrayObject::ensureArrayObject($options);
     $options->defaults($this->options);
     $options->validateNotEmpty(['id']);
     $this->options = $options;
     $this->client = $client ?: HttpClientFactory::create();
 }
示例#3
0
文件: Api.php 项目: eamador/Payum
 /**
  * @param array               $options
  * @param HttpClientInterface $client
  */
 public function __construct(array $options, HttpClientInterface $client = null)
 {
     $this->client = $client ?: HttpClientFactory::create();
     $this->options = $options;
     if (false == (isset($this->options['sandbox']) && is_bool($this->options['sandbox']))) {
         throw new InvalidArgumentException('The boolean sandbox option must be set.');
     }
 }
示例#4
0
 /**
  * @param array               $options
  * @param HttpClientInterface $client
  *
  * @throws \Payum\Core\Exception\InvalidArgumentException if an option is invalid
  * @throws \Payum\Core\Exception\LogicException if a sandbox is not boolean
  */
 public function __construct(array $options, HttpClientInterface $client = null)
 {
     $options = ArrayObject::ensureArrayObject($options);
     $options->validatedKeysSet(['api_private_key', 'api_public_key', 'test_private_key', 'test_public_key']);
     if (false == is_bool($options['sandbox'])) {
         throw new LogicException('The boolean sandbox option must be set.');
     }
     $this->options = $options;
     $this->client = HttpClientFactory::create();
 }
示例#5
0
 /**
  * @param array               $options
  * @param HttpClientInterface $client
  *
  * @throws \Payum\Core\Exception\InvalidArgumentException if an option is invalid
  * @throws \Payum\Core\Exception\LogicException if a sandbox is not boolean
  */
 public function __construct(array $options, HttpClientInterface $client = null)
 {
     $options = ArrayObject::ensureArrayObject($options);
     $options->defaults($this->options);
     $options->validateNotEmpty(['skinCode', 'merchantAccount', 'hmacKey']);
     if (false == is_bool($options['sandbox'])) {
         throw new LogicException('The boolean sandbox option must be set.');
     }
     $this->options = $options;
     $this->client = $client ?: HttpClientFactory::create();
 }
示例#6
0
 /**
  * @param array $options
  * @param HttpClientInterface $client
  *
  * @throws \Payum\Core\Exception\InvalidArgumentException if an option is invalid
  */
 public function __construct(array $options, HttpClientInterface $client = null)
 {
     $options = ArrayObject::ensureArrayObject($options);
     $options->defaults($this->options);
     $options->validateNotEmpty(['payee_account', 'alternate_passphrase', 'display_name']);
     if (!is_bool($options['sandbox'])) {
         throw new LogicException('The boolean sandbox option must be set.');
     }
     $this->options = $options;
     $this->client = $client ?: HttpClientFactory::create();
 }
示例#7
0
 /**
  * {@inheritDoc}
  */
 public function createConfig(array $config = array())
 {
     $config = ArrayObject::ensureArrayObject($config);
     $config->defaults($this->defaultConfig);
     $config->defaults(array('payum.template.layout' => '@PayumCore/layout.html.twig', 'payum.http_client' => HttpClientFactory::create(), 'twig.env' => TwigFactory::createGeneric(), 'payum.action.get_http_request' => new GetHttpRequestAction(), 'payum.action.capture_payment' => new CapturePaymentAction(), 'payum.action.execute_same_request_with_model_details' => new ExecuteSameRequestWithModelDetailsAction(), 'payum.action.render_template' => function (ArrayObject $config) {
         return new RenderTemplateAction($config['twig.env'], $config['payum.template.layout']);
     }, 'payum.extension.endless_cycle_detector' => new EndlessCycleDetectorExtension(), 'payum.action.get_currency' => function (ArrayObject $config) {
         return new GetCurrencyAction($config['payum.iso4217']);
     }, 'payum.prepend_actions' => array(), 'payum.prepend_extensions' => array(), 'payum.prepend_apis' => array(), 'payum.default_options' => array(), 'payum.required_options' => array(), 'payum.api.http_client' => function (ArrayObject $config) {
         return $config['payum.http_client'];
     }));
     return (array) $config;
 }
示例#8
0
 /**
  * @test
  */
 public function shouldReturnGuzzleClient()
 {
     $client = HttpClientFactory::createGuzzle();
     $this->assertInstanceOf(GuzzleClientInterface::class, $client);
 }
示例#9
0
文件: Api.php 项目: tumbochka/Payum
 /**
  * @param array               $options
  * @param HttpClientInterface $client
  *
  * @throws \Payum\Core\Exception\InvalidArgumentException if an option is invalid
  */
 public function __construct(array $options, HttpClientInterface $client = null)
 {
     $this->options = $options;
     $this->client = $client ?: HttpClientFactory::create();
 }
示例#10
0
 /**
  * @return Payum
  */
 public function getPayum()
 {
     if (false == ($tokenStorage = $this->tokenStorage)) {
         throw new \LogicException('Token storage must be configured.');
     }
     $storages = $this->storages;
     $tokenFactory = $this->buildTokenFactory($this->tokenStorage, $this->buildRegistry([], $storages));
     $genericTokenFactory = $this->buildGenericTokenFactory($tokenFactory, array_replace(['capture' => 'capture.php', 'notify' => 'notify.php', 'authorize' => 'authorize.php', 'refund' => 'refund.php'], $this->genericTokenFactoryPaths));
     $httpRequestVerifier = $this->buildHttpRequestVerifier($this->tokenStorage);
     if (false == ($httpClient = $this->httpClient)) {
         $httpClient = HttpClientFactory::create();
     }
     $coreGatewayFactory = $this->buildCoreGatewayFactory(array_replace(['payum.extension.token_factory' => new GenericTokenFactoryExtension($genericTokenFactory), 'payum.security.token_storage' => $tokenStorage, 'payum.http_client' => $httpClient], $this->coreGatewayFactoryConfig));
     $gatewayFactories = array_replace($this->buildGatewayFactories($coreGatewayFactory), $this->buildOmnipayGatewayFactories($coreGatewayFactory), $this->gatewayFactories);
     $registry = $this->buildRegistry($this->gateways, $storages, $gatewayFactories);
     if ($this->gatewayConfigs) {
         $gateways = $this->gateways;
         foreach ($this->gatewayConfigs as $name => $gatewayConfig) {
             $gatewayFactory = $registry->getGatewayFactory($gatewayConfig['factory']);
             unset($gatewayConfig['factory']);
             $gateways[$name] = $gatewayFactory->create($gatewayConfig);
         }
         $registry = $this->buildRegistry($gateways, $storages, $gatewayFactories);
     }
     return new Payum($registry, $httpRequestVerifier, $genericTokenFactory, $tokenStorage);
 }
示例#11
0
 /**
  * @test
  */
 public function shouldReturnHttpClient()
 {
     $client = HttpClientFactory::create();
     $this->assertInstanceOf('Payum\\Core\\HttpClientInterface', $client);
     $this->assertInstanceOf('Payum\\Core\\Bridge\\Guzzle\\HttpClient', $client);
 }
示例#12
0
 /**
  * @param array                $options
  * @param HttpClientInterface|null $client
  */
 public function __construct(array $options, HttpClientInterface $client = null)
 {
     $options = ArrayObject::ensureArrayObject($options);
     $options->defaults($this->options);
     $options->validateNotEmpty(array('username', 'password', 'signature'));
     if (false == is_bool($options['sandbox'])) {
         throw new InvalidArgumentException('The boolean sandbox option must be set.');
     }
     $this->options = $options;
     $this->client = $client ?: HttpClientFactory::create();
 }