-
Notifications
You must be signed in to change notification settings - Fork 6
/
AuthorizeNetAimGatewayFactory.php
48 lines (40 loc) · 1.67 KB
/
AuthorizeNetAimGatewayFactory.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
namespace Payum\AuthorizeNet\Aim;
use LogicException;
use Payum\AuthorizeNet\Aim\Action\CaptureAction;
use Payum\AuthorizeNet\Aim\Action\ConvertPaymentAction;
use Payum\AuthorizeNet\Aim\Action\StatusAction;
use Payum\AuthorizeNet\Aim\Bridge\AuthorizeNet\AuthorizeNetAIM;
use Payum\Core\Bridge\Spl\ArrayObject;
use Payum\Core\GatewayFactory;
class AuthorizeNetAimGatewayFactory extends GatewayFactory
{
protected function populateConfig(ArrayObject $config): void
{
if (! class_exists(\AuthorizeNetAIM::class)) {
throw new LogicException('You must install "authorizenet/authorizenet" library.');
}
$config->defaults([
'payum.factory_name' => 'authorize_net_aim',
'payum.factory_title' => 'Authorize.NET AIM',
'payum.action.capture' => new CaptureAction(),
'payum.action.status' => new StatusAction(),
'payum.action.convert_payment' => new ConvertPaymentAction(),
]);
if (! $config['payum.api']) {
$config['payum.default_options'] = [
'login_id' => '',
'transaction_key' => '',
'sandbox' => true,
];
$config->defaults($config['payum.default_options']);
$config['payum.required_options'] = ['login_id', 'transaction_key'];
$config['payum.api'] = function (ArrayObject $config) {
$config->validateNotEmpty($config['payum.required_options']);
$api = new AuthorizeNetAIM($config['login_id'], $config['transaction_key']);
$api->setSandbox($config['sandbox']);
return $api;
};
}
}
}