-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathPaypalProCheckoutGatewayFactory.php
54 lines (46 loc) · 1.98 KB
/
PaypalProCheckoutGatewayFactory.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
<?php
namespace Payum\Paypal\ProCheckout\Nvp;
use Payum\Core\Bridge\Spl\ArrayObject;
use Payum\Core\GatewayFactory;
use Payum\Paypal\ProCheckout\Nvp\Action\CaptureAction;
use Payum\Paypal\ProCheckout\Nvp\Action\ConvertPaymentAction;
use Payum\Paypal\ProCheckout\Nvp\Action\RefundAction;
use Payum\Paypal\ProCheckout\Nvp\Action\StatusAction;
class PaypalProCheckoutGatewayFactory extends GatewayFactory
{
protected function populateConfig(ArrayObject $config): void
{
$config->defaults([
'payum.factory_name' => 'paypal_pro_checkout_nvp',
'payum.factory_title' => 'PayPal ProCheckout',
'payum.action.capture' => new CaptureAction(),
'payum.action.refund' => new RefundAction(),
'payum.action.convert_payment' => new ConvertPaymentAction(),
'payum.action.status' => new StatusAction(),
]);
if (! $config['payum.api']) {
$config['payum.default_options'] = [
'username' => '',
'password' => '',
'partner' => '',
'vendor' => '',
'tender' => '',
'sandbox' => true,
];
$config->defaults($config['payum.default_options']);
$config['payum.required_options'] = ['username', 'password', 'partner', 'vendor', 'tender'];
$config['payum.api'] = function (ArrayObject $config) {
$config->validateNotEmpty($config['payum.required_options']);
$paypalConfig = [
'username' => $config['username'],
'password' => $config['password'],
'partner' => $config['partner'],
'vendor' => $config['vendor'],
'tender' => $config['tender'],
'sandbox' => $config['sandbox'],
];
return new Api($paypalConfig, $config['payum.http_client'], $config['httplug.message_factory']);
};
}
}
}