-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPowerpayGatewayFactory.php
executable file
·79 lines (65 loc) · 2.89 KB
/
PowerpayGatewayFactory.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\Powerpay;
use DachcomDigital\Payum\Powerpay\Action\Api\ActivateAction;
use DachcomDigital\Payum\Powerpay\Action\Api\CancelAction;
use DachcomDigital\Payum\Powerpay\Action\Api\ConfirmAction;
use DachcomDigital\Payum\Powerpay\Action\Api\CreditAmountAction;
use DachcomDigital\Payum\Powerpay\Action\Api\ReserveAmountAction;
use DachcomDigital\Payum\Powerpay\Action\Api\TransactionTransformerAction;
use DachcomDigital\Payum\Powerpay\Action\CaptureAction;
use DachcomDigital\Payum\Powerpay\Action\ConvertPaymentAction;
use DachcomDigital\Payum\Powerpay\Action\StatusAction;
use Payum\Core\Bridge\Spl\ArrayObject;
use Payum\Core\GatewayFactory;
class PowerpayGatewayFactory extends GatewayFactory
{
protected function populateConfig(ArrayObject $config): void
{
$config->defaults([
'payum.factory_name' => 'powerpay',
'payum.factory_title' => 'Powerpay',
'payum.action.capture' => new CaptureAction(),
'payum.action.status' => new StatusAction(),
'payum.action.convert_payment' => new ConvertPaymentAction(),
'payum.action.api.activate' => new ActivateAction(),
'payum.action.api.confirm' => new ConfirmAction(),
'payum.action.api.cancel' => new CancelAction(),
'payum.action.api.reserve_amount' => new ReserveAmountAction(),
'payum.action.api.credit_amount' => new CreditAmountAction(),
'payum.action.api.transaction_transformer' => new TransactionTransformerAction(),
]);
if (!empty($config['payum.api'])) {
return;
}
$config['payum.default_options'] = [
'environment' => Api::TEST,
'paymentMethod' => '',
'sandbox' => true,
];
$config->defaults($config['payum.default_options']);
$config['payum.required_options'] = [
'username',
'password',
'merchantId',
'filialId',
'terminalId',
'confirmationMethod'
];
$config['payum.api'] = static function (ArrayObject $config) {
$config->validateNotEmpty($config['payum.required_options']);
return new Api(
[
'sandbox' => $config['environment'] === Api::TEST,
'username' => $config['username'],
'password' => $config['password'],
'merchantId' => $config['merchantId'],
'filialId' => $config['filialId'],
'terminalId' => $config['terminalId'],
'confirmationMethod' => $config['confirmationMethod']
],
$config['payum.http_client'],
$config['httplug.message_factory']
);
};
}
}