-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathPayexGatewayFactory.php
114 lines (97 loc) · 4.89 KB
/
PayexGatewayFactory.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
namespace Payum\Payex;
use LogicException;
use Payum\Core\Bridge\Spl\ArrayObject;
use Payum\Core\GatewayFactory;
use Payum\Payex\Action\AgreementDetailsStatusAction;
use Payum\Payex\Action\AgreementDetailsSyncAction;
use Payum\Payex\Action\Api\AutoPayAgreementAction;
use Payum\Payex\Action\Api\CheckAgreementAction;
use Payum\Payex\Action\Api\CheckOrderAction;
use Payum\Payex\Action\Api\CheckRecurringPaymentAction;
use Payum\Payex\Action\Api\CompleteOrderAction;
use Payum\Payex\Action\Api\CreateAgreementAction;
use Payum\Payex\Action\Api\DeleteAgreementAction;
use Payum\Payex\Action\Api\InitializeOrderAction;
use Payum\Payex\Action\Api\StartRecurringPaymentAction;
use Payum\Payex\Action\Api\StopRecurringPaymentAction;
use Payum\Payex\Action\AutoPayPaymentDetailsCaptureAction;
use Payum\Payex\Action\AutoPayPaymentDetailsStatusAction;
use Payum\Payex\Action\ConvertPaymentAction;
use Payum\Payex\Action\PaymentDetailsCaptureAction;
use Payum\Payex\Action\PaymentDetailsStatusAction;
use Payum\Payex\Action\PaymentDetailsSyncAction;
use Payum\Payex\Api\AgreementApi;
use Payum\Payex\Api\OrderApi;
use Payum\Payex\Api\RecurringApi;
use Payum\Payex\Api\SoapClientFactory;
use SoapClient;
class PayexGatewayFactory extends GatewayFactory
{
protected function populateConfig(ArrayObject $config): void
{
if (! class_exists(SoapClient::class)) {
throw new LogicException('You must install "ext-soap" extension.');
}
$config['payum.default_options'] = [
'account_number' => '',
'encryption_key' => '',
'sandbox' => true,
];
$config->defaults($config['payum.default_options']);
$config['payum.required_options'] = ['account_number', 'encryption_key'];
$config->defaults([
'payum.factory_name' => 'payex',
'payum.factory_title' => 'Payex',
'soap.client_factory' => new SoapClientFactory(),
'payum.api.order' => function (ArrayObject $config) {
$config->validateNotEmpty($config['payum.required_options']);
$payexConfig = [
'account_number' => $config['account_number'],
'encryption_key' => $config['encryption_key'],
'sandbox' => $config['sandbox'],
];
return new OrderApi($config['soap.client_factory'], $payexConfig);
},
'payum.api.agreement' => function (ArrayObject $config) {
$config->validateNotEmpty($config['payum.required_options']);
$payexConfig = [
'account_number' => $config['account_number'],
'encryption_key' => $config['encryption_key'],
'sandbox' => $config['sandbox'],
];
return new AgreementApi($config['soap.client_factory'], $payexConfig);
},
'payum.api.recurring' => function (ArrayObject $config) {
$config->validateNotEmpty($config['payum.required_options']);
$payexConfig = [
'account_number' => $config['account_number'],
'encryption_key' => $config['encryption_key'],
'sandbox' => $config['sandbox'],
];
return new RecurringApi($config['soap.client_factory'], $payexConfig);
},
'payum.action.capture' => new PaymentDetailsCaptureAction(),
'payum.action.status' => new PaymentDetailsStatusAction(),
'payum.action.sync' => new PaymentDetailsSyncAction(),
'payum.action.auto_pay_capture' => new AutoPayPaymentDetailsCaptureAction(),
'payum.action.auto_pay_status' => new AutoPayPaymentDetailsStatusAction(),
'payum.action.convert_payment' => new ConvertPaymentAction(),
// agreement actions
'payum.action.api.agreement_details_status' => new AgreementDetailsStatusAction(),
'payum.action.api.agreement_details_sync' => new AgreementDetailsSyncAction(),
'payum.action.api.create_agreement' => new CreateAgreementAction(),
'payum.action.api.delete_agreement' => new DeleteAgreementAction(),
'payum.action.api.check_agreement' => new CheckAgreementAction(),
'payum.action.api.auto_pay_agreement' => new AutoPayAgreementAction(),
//recurring actions
'payum.action.api.start_recurring_gateway' => new StartRecurringPaymentAction(),
'payum.action.api.stop_recurring_gateway' => new StopRecurringPaymentAction(),
'payum.action.api.check_recurring_gateway' => new CheckRecurringPaymentAction(),
//order actions
'payum.action.api.initialize_order' => new InitializeOrderAction(),
'payum.action.api.complete_order' => new CompleteOrderAction(),
'payum.action.api.check_order' => new CheckOrderAction(),
]);
}
}