-
Notifications
You must be signed in to change notification settings - Fork 0
/
PostfinanceDirectLinkGatewayFactory.php
59 lines (52 loc) · 2.48 KB
/
PostfinanceDirectLinkGatewayFactory.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
<?php
namespace Payum\PostfinanceDirectLink;
use Payum\Core\Bridge\Spl\ArrayObject;
use Payum\Core\GatewayFactory;
use Payum\PostfinanceDirectLink\Action\Api\CleanupTransactionAction;
use Payum\PostfinanceDirectLink\Action\Api\CreateTransactionAction;
use Payum\PostfinanceDirectLink\Action\Api\CaptureTransactionAction;
use Payum\PostfinanceDirectLink\Action\AuthorizeAction;
use Payum\PostfinanceDirectLink\Action\CaptureAction;
use Payum\PostfinanceDirectLink\Action\CleanupAction;
use Payum\PostfinanceDirectLink\Action\StatusAction;
use Payum\PostfinanceDirectLink\Request\Api\CleanupTransaction;
class PostfinanceDirectLinkGatewayFactory extends GatewayFactory
{
/**
* {@inheritdoc}
*/
protected function populateConfig(ArrayObject $config)
{
$config->defaults(array(
'payum.factory_name' => 'postfinance_direct_link',
'payum.factory_title' => 'Postfinance DirectLink',
'payum.action.authorize' => new AuthorizeAction(),
'payum.action.capture' => new CaptureAction(),
'payum.action.status' => new StatusAction(),
//'payum.action.refund' => new RefundAction(), TODO: refund
'payum.action.api.create_transaction' => new CreateTransactionAction(),
'payum.action.api.capture_transaction' => new CaptureTransactionAction(),
'payum.action.api.cleanup_transaction' => new CleanupTransactionAction(),
//'payum.action.api.refund_transaction' => new RefundTransactionAction(), TODO: refund
));
if (false == $config['payum.api']) {
$config['payum.default_options'] = [
'user' => 'DIRECTLINK',
'environment' => Api::TEST
];
$config->defaults($config['payum.default_options']);
$config['payum.required_options'] = ['sha-in-passphrase', 'password', 'pspid'];
$config['payum.api'] = function (ArrayObject $config) {
$config->validateNotEmpty($config['payum.required_options']);
$postfinanceConfig = [
'sha-in-passphrase' => $config['sha-in-passphrase'],
'user' => $config['user'],
'password' => $config['password'],
'pspid' => $config['pspid'],
'environment' => $config['environment'],
];
return new Api($postfinanceConfig, $config['payum.http_client'], $config['httplug.message_factory']);
};
}
}
}