|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
namespace Karser\PayumSaferpay; |
|
4
|
|
|
|
|
5
|
|
|
use Karser\PayumSaferpay\Action\Api\AssertInsertAliasAction; |
|
6
|
|
|
use Karser\PayumSaferpay\Action\Api\AssertPaymentPageAction; |
|
7
|
|
|
use Karser\PayumSaferpay\Action\Api\AuthorizeReferencedTransactionAction; |
|
8
|
|
|
use Karser\PayumSaferpay\Action\Api\AuthorizeTransactionAction; |
|
9
|
|
|
use Karser\PayumSaferpay\Action\Api\CaptureTransactionAction; |
|
10
|
|
|
use Karser\PayumSaferpay\Action\Api\DeleteAliasAction; |
|
11
|
|
|
use Karser\PayumSaferpay\Action\Api\InitPaymentPageAction; |
|
12
|
|
|
use Karser\PayumSaferpay\Action\Api\InitTransactionAction; |
|
13
|
|
|
use Karser\PayumSaferpay\Action\Api\InsertAliasAction; |
|
14
|
|
|
use Karser\PayumSaferpay\Action\Api\RefundTransactionAction; |
|
15
|
|
|
use Karser\PayumSaferpay\Action\AuthorizeAction; |
|
16
|
|
|
use Karser\PayumSaferpay\Action\CancelAction; |
|
17
|
|
|
use Karser\PayumSaferpay\Action\CaptureReferencedAction; |
|
18
|
|
|
use Karser\PayumSaferpay\Action\ConvertPaymentAction; |
|
19
|
|
|
use Karser\PayumSaferpay\Action\CaptureAction; |
|
20
|
|
|
use Karser\PayumSaferpay\Action\InsertCardAliasAction; |
|
21
|
|
|
use Karser\PayumSaferpay\Action\NotifyAction; |
|
22
|
|
|
use Karser\PayumSaferpay\Action\RefundAction; |
|
23
|
|
|
use Karser\PayumSaferpay\Action\StatusAction; |
|
24
|
|
|
use Karser\PayumSaferpay\Action\SyncAction; |
|
25
|
|
|
use Payum\Core\Bridge\Spl\ArrayObject; |
|
26
|
|
|
use Payum\Core\GatewayFactory; |
|
27
|
|
|
|
|
28
|
|
|
class SaferpayGatewayFactory extends GatewayFactory |
|
29
|
|
|
{ |
|
30
|
|
|
/** |
|
31
|
|
|
* {@inheritDoc} |
|
32
|
|
|
*/ |
|
33
|
20 |
|
protected function populateConfig(ArrayObject $config): void |
|
34
|
|
|
{ |
|
35
|
20 |
|
$config->defaults([ |
|
36
|
20 |
|
'payum.factory_name' => 'saferpay', |
|
37
|
20 |
|
'payum.factory_title' => 'saferpay', |
|
38
|
|
|
|
|
39
|
20 |
|
'payum.action.capture' => new CaptureAction(), |
|
40
|
20 |
|
'payum.action.insert_card_alias' => new InsertCardAliasAction(), |
|
41
|
20 |
|
'payum.action.capture_referenced' => new CaptureReferencedAction(), |
|
42
|
20 |
|
'payum.action.authorize' => new AuthorizeAction(), |
|
43
|
20 |
|
'payum.action.refund' => new RefundAction(), |
|
44
|
20 |
|
'payum.action.cancel' => new CancelAction(), |
|
45
|
20 |
|
'payum.action.notify' => new NotifyAction(), |
|
46
|
20 |
|
'payum.action.status' => new StatusAction(), |
|
47
|
20 |
|
'payum.action.sync' => new SyncAction(), |
|
48
|
20 |
|
'payum.action.convert_payment' => new ConvertPaymentAction(), |
|
49
|
|
|
|
|
50
|
20 |
|
'payum.action.api.init_payment_page' => new InitPaymentPageAction(), |
|
51
|
20 |
|
'payum.action.api.assert_payment_page' => new AssertPaymentPageAction(), |
|
52
|
20 |
|
'payum.action.api.init_transaction' => new InitTransactionAction(), |
|
53
|
20 |
|
'payum.action.api.authorize_transaction' => new AuthorizeTransactionAction(), |
|
54
|
20 |
|
'payum.action.api.capture_transaction' => new CaptureTransactionAction(), |
|
55
|
20 |
|
'payum.action.api.authorize_referenced_transaction' => new AuthorizeReferencedTransactionAction(), |
|
56
|
20 |
|
'payum.action.api.refund_transaction' => new RefundTransactionAction(), |
|
57
|
20 |
|
'payum.action.api.insert_alias' => new InsertAliasAction(), |
|
58
|
20 |
|
'payum.action.api.assert_insert_alias' => new AssertInsertAliasAction(), |
|
59
|
20 |
|
'payum.action.api.delete_alias' => new DeleteAliasAction(), |
|
60
|
20 |
|
]); |
|
61
|
|
|
|
|
62
|
20 |
|
$prependActions = $config['payum.prepend_actions'] ?? []; |
|
63
|
20 |
|
$prependActions[] = 'payum.action.capture_referenced'; |
|
64
|
20 |
|
$prependActions[] = 'payum.action.insert_card_alias'; |
|
65
|
20 |
|
$config['payum.prepend_actions'] = $prependActions; |
|
66
|
|
|
|
|
67
|
20 |
|
if (false == $config['payum.api']) { |
|
68
|
20 |
|
$config['payum.default_options'] = [ |
|
69
|
20 |
|
'sandbox' => true, |
|
70
|
20 |
|
'instantCapturing' => true, |
|
71
|
20 |
|
]; |
|
72
|
20 |
|
$config->defaults($config['payum.default_options']); |
|
73
|
20 |
|
$config['payum.required_options'] = ['username', 'password', 'customerId', 'terminalId']; |
|
74
|
|
|
|
|
75
|
20 |
|
$config['payum.api'] = function (ArrayObject $config) { |
|
76
|
20 |
|
$config->validateNotEmpty($config['payum.required_options']); |
|
77
|
|
|
|
|
78
|
20 |
|
return new Api((array) $config, $config['payum.http_client'], $config['httplug.message_factory']); |
|
79
|
20 |
|
}; |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|