protected function registerServices()
 {
     $this->app->bind('payum.builder', function ($app) {
         $builder = new PayumBuilder();
         $builder->setTokenFactory(function (StorageInterface $tokenStorage, StorageRegistryInterface $registry) {
             return new TokenFactory($tokenStorage, $registry);
         })->setHttpRequestVerifier(function (StorageInterface $tokenStorage) {
             return new HttpRequestVerifier($tokenStorage);
         })->setCoreGatewayFactory(function (array $defaultConfig) {
             $factory = new CoreGatewayFactory($defaultConfig);
             $factory->setContainer($this->app);
             return $factory;
         })->setCoreGatewayFactoryConfig(['payum.action.get_http_request' => 'payum.action.get_http_request', 'payum.action.obtain_credit_card' => 'payum.action.obtain_credit_card'])->setGenericTokenFactoryPaths(['capture' => 'payum_capture_do', 'notify' => 'payum_notify_do', 'authorize' => 'payum_authorize_do', 'refund' => 'payum_refund_do']);
         return $builder;
     });
     $this->app['payum'] = $this->app->share(function ($app) {
         return $app['payum.builder']->getPayum();
     });
     $this->app['payum.converter.reply_to_http_response'] = $this->app->share(function ($app) {
         return new ReplyToSymfonyResponseConverter();
     });
     $this->app['payum.action.get_http_request'] = $this->app->share(function ($app) {
         return new GetHttpRequestAction();
     });
     $this->app['payum.action.obtain_credit_card'] = $this->app->share(function ($app) {
         return new ObtainCreditCardAction();
     });
 }
Example #2
1
<?php

// config.php
$autoload = is_file(__DIR__ . '/../vendor/autoload.php') ? __DIR__ . '/../vendor/autoload.php' : __DIR__ . '/../../../../vendor/autoload.php';
require_once $autoload;
use Payum\Core\GatewayFactoryInterface;
use Payum\Core\Model\Payment;
use Payum\Core\PayumBuilder;
$paymentClass = Payment::class;
$gatewayName = 'adyen';
$defaultConfig = ['factory' => $gatewayName, 'sandbox' => true, 'skinCode' => '', 'merchantAccount' => '', 'hmacKey' => ''];
$builder = new PayumBuilder();
$builder->addGatewayFactory($gatewayName, function (array $config, GatewayFactoryInterface $coreGatewayFactory) {
    return new \Payum\Adyen\AdyenGatewayFactory($config, $coreGatewayFactory);
});
$builder->addGateway($gatewayName, $defaultConfig);
$builder->addDefaultStorages();
$builder->setGenericTokenFactoryPaths(['capture' => 'Examples/capture.php', 'notify' => 'Examples/notify.php']);
$payum = $builder->getPayum();
Example #3
1
 /**
  * @test
  */
 public function shouldAllowBuildGatewayWithCoreGatewayFactory()
 {
     $payumBuilder = new PayumBuilder();
     $payum = $payumBuilder->addDefaultStorages()->addGateway('foo', ['factory' => 'core'])->getPayum();
     $gateway = $payum->getGateway('foo');
     $this->assertInstanceOf(Gateway::class, $gateway);
 }
 /**
  * setGatewayConfig.
  *
  * @method setGatewayConfig
  *
  * @return self
  */
 protected function setGatewayConfig()
 {
     foreach ($this->gatewayConfigs as $gatewayName => $gatewayConfig) {
         $factoryName = Arr::get($gatewayConfig, 'factory');
         if (empty($factoryName) === false && class_exists($factoryName) === true) {
             $this->payumBuilder->addGatewayFactory($gatewayName, function ($gatewayConfig, GatewayFactoryInterface $coreGatewayFactory) use($factoryName) {
                 return $this->app->make($factoryName, [$gatewayConfig, $coreGatewayFactory]);
             });
         }
         $gatewayConfig['factory'] = $gatewayName;
         $this->payumBuilder->addGateway($gatewayName, $gatewayConfig);
     }
     return $this;
 }
Example #5
0
 /**
  * @test
  */
 public function shouldAllowAddCoreGatewayConfig()
 {
     $payumBuilder = new PayumBuilder();
     $payumBuilder->setCoreGatewayFactoryConfig(['foo' => 'fooVal', 'bar' => 'barVal']);
     $this->assertAttributeSame(['foo' => 'fooVal', 'bar' => 'barVal'], 'coreGatewayFactoryConfig', $payumBuilder);
     $payumBuilder->addCoreGatewayFactoryConfig(['baz' => 'bazVal', 'foo' => 'fooNewVal']);
     $this->assertAttributeSame(['foo' => 'fooNewVal', 'bar' => 'barVal', 'baz' => 'bazVal'], 'coreGatewayFactoryConfig', $payumBuilder);
 }