forked from karser/PayumSaferpay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SaferpayGatewayFactory.php
81 lines (72 loc) · 3.78 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
80
81
<?php declare(strict_types=1);
namespace Karser\PayumSaferpay;
use Karser\PayumSaferpay\Action\Api\AssertInsertAliasAction;
use Karser\PayumSaferpay\Action\Api\AssertPaymentPageAction;
use Karser\PayumSaferpay\Action\Api\AuthorizeReferencedTransactionAction;
use Karser\PayumSaferpay\Action\Api\AuthorizeTransactionAction;
use Karser\PayumSaferpay\Action\Api\CaptureTransactionAction;
use Karser\PayumSaferpay\Action\Api\DeleteAliasAction;
use Karser\PayumSaferpay\Action\Api\InitPaymentPageAction;
use Karser\PayumSaferpay\Action\Api\InitTransactionAction;
use Karser\PayumSaferpay\Action\Api\InsertAliasAction;
use Karser\PayumSaferpay\Action\Api\RefundTransactionAction;
use Karser\PayumSaferpay\Action\AuthorizeAction;
use Karser\PayumSaferpay\Action\CancelAction;
use Karser\PayumSaferpay\Action\CaptureReferencedAction;
use Karser\PayumSaferpay\Action\ConvertPaymentAction;
use Karser\PayumSaferpay\Action\CaptureAction;
use Karser\PayumSaferpay\Action\InsertCardAliasAction;
use Karser\PayumSaferpay\Action\NotifyAction;
use Karser\PayumSaferpay\Action\RefundAction;
use Karser\PayumSaferpay\Action\StatusAction;
use Karser\PayumSaferpay\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.insert_card_alias' => new InsertCardAliasAction(),
'payum.action.capture_referenced' => new CaptureReferencedAction(),
'payum.action.authorize' => new AuthorizeAction(),
'payum.action.refund' => new RefundAction(),
'payum.action.cancel' => new CancelAction(),
'payum.action.notify' => new NotifyAction(),
'payum.action.status' => new StatusAction(),
'payum.action.sync' => new SyncAction(),
'payum.action.convert_payment' => new ConvertPaymentAction(),
'payum.action.api.init_payment_page' => new InitPaymentPageAction(),
'payum.action.api.assert_payment_page' => new AssertPaymentPageAction(),
'payum.action.api.init_transaction' => new InitTransactionAction(),
'payum.action.api.authorize_transaction' => new AuthorizeTransactionAction(),
'payum.action.api.capture_transaction' => new CaptureTransactionAction(),
'payum.action.api.authorize_referenced_transaction' => new AuthorizeReferencedTransactionAction(),
'payum.action.api.refund_transaction' => new RefundTransactionAction(),
'payum.action.api.insert_alias' => new InsertAliasAction(),
'payum.action.api.assert_insert_alias' => new AssertInsertAliasAction(),
'payum.action.api.delete_alias' => new DeleteAliasAction(),
]);
$prependActions = $config['payum.prepend_actions'] ?? [];
$prependActions[] = 'payum.action.capture_referenced';
$prependActions[] = 'payum.action.insert_card_alias';
$config['payum.prepend_actions'] = $prependActions;
if (false == $config['payum.api']) {
$config['payum.default_options'] = [
'sandbox' => true,
];
$config->defaults($config['payum.default_options']);
$config['payum.required_options'] = ['username', 'password', 'customerId', 'terminalId'];
$config['payum.api'] = function (ArrayObject $config) {
$config->validateNotEmpty($config['payum.required_options']);
return new Api((array) $config, $config['payum.http_client'], $config['httplug.message_factory']);
};
}
}
}