forked from dachcom-digital/payum-saferpay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSaferpayGatewayFactory.php
executable file
·79 lines (71 loc) · 3.41 KB
/
SaferpayGatewayFactory.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
namespace DachcomDigital\Payum\Saferpay;
use DachcomDigital\Payum\Saferpay\Action\Api\CapturePaymentAction;
use DachcomDigital\Payum\Saferpay\Action\Api\CreateTransactionAction;
use DachcomDigital\Payum\Saferpay\Action\Api\GetTransactionDataAction;
use DachcomDigital\Payum\Saferpay\Action\Api\RefundTransactionAction;
use DachcomDigital\Payum\Saferpay\Action\CaptureAction;
use DachcomDigital\Payum\Saferpay\Action\ConvertPaymentAction;
use DachcomDigital\Payum\Saferpay\Action\NotifyAction;
use DachcomDigital\Payum\Saferpay\Action\RefundAction;
use DachcomDigital\Payum\Saferpay\Action\StatusAction;
use DachcomDigital\Payum\Saferpay\Action\SyncAction;
use Payum\Core\Bridge\Spl\ArrayObject;
use Payum\Core\GatewayFactory;
class SaferpayGatewayFactory extends GatewayFactory
{
/**
* {@inheritDoc}
*/
protected function populateConfig(ArrayObject $config)
{
$config->defaults([
'payum.factory_name' => 'saferpay',
'payum.factory_title' => 'Saferpay',
'payum.action.capture' => new CaptureAction(),
'payum.action.status' => new StatusAction(),
'payum.action.notify' => new NotifyAction($config['payum.security.token_storage']),
'payum.action.sync' => new SyncAction(),
'payum.action.refund' => new RefundAction(),
'payum.action.convert_payment' => new ConvertPaymentAction(),
'payum.action.api.create_transaction' => new CreateTransactionAction(),
'payum.action.api.get_transaction_data' => new GetTransactionDataAction(),
'payum.action.api.refund_transaction' => new RefundTransactionAction(),
'payum.action.api.capture_payment' => new CapturePaymentAction(),
]);
if (false == $config['payum.api']) {
$config['payum.default_options'] = [
'environment' => Api::TEST,
'specVersion' => '1.10', //https://saferpay.github.io/jsonapi/index.html
'optionalParameters' => [],
'sandbox' => true,
];
$config->defaults($config['payum.default_options']);
$config['payum.required_options'] = [
'username',
'password',
'specVersion',
'customerId',
'terminalId',
'lockPath'
];
$config['payum.api'] = function (ArrayObject $config) {
$config->validateNotEmpty($config['payum.required_options']);
return new Api(
[
'sandbox' => $config['environment'] === Api::TEST,
'username' => $config['username'],
'password' => $config['password'],
'spec_version' => $config['specVersion'],
'customer_id' => $config['customerId'],
'terminal_id' => $config['terminalId'],
'lock_path' => $config['lockPath'],
'optional_params' => isset($config['optionalParameters']) && is_array($config['optionalParameters']) ? $config['optionalParameters'] : []
],
$config['payum.http_client'],
$config['httplug.message_factory']
);
};
}
}
}