<?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();
/** * 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; }
/** * @test */ public function shouldAllowAddGatewayConfigSeveralTimes() { $payumBuilder = new PayumBuilder(); $payumBuilder->addGateway('foo', ['factory' => 'aFactory', 'foo' => 'fooVal', 'bar' => 'barVal']); $this->assertAttributeSame(['foo' => ['factory' => 'aFactory', 'foo' => 'fooVal', 'bar' => 'barVal']], 'gatewayConfigs', $payumBuilder); $payumBuilder->addGateway('foo', ['baz' => 'bazVal', 'foo' => 'fooNewVal']); $this->assertAttributeSame(['foo' => ['factory' => 'aFactory', 'foo' => 'fooNewVal', 'bar' => 'barVal', 'baz' => 'bazVal']], 'gatewayConfigs', $payumBuilder); }