Issues (36)

src/Services/PayPal.php (2 issues)

1
<?php
2
3
namespace Srmklive\PayPal\Services;
4
5
use Exception;
6
use Srmklive\PayPal\Traits\PayPalRequest as PayPalAPIRequest;
7
use Srmklive\PayPal\Traits\PayPalVerifyIPN;
8
9
class PayPal
10
{
11
    use PayPalAPIRequest;
0 ignored issues
show
The trait Srmklive\PayPal\Traits\PayPalRequest requires some properties which are not provided by Srmklive\PayPal\Services\PayPal: $return_url, $cancel_url
Loading history...
12
    use PayPalVerifyIPN;
0 ignored issues
show
The trait Srmklive\PayPal\Traits\PayPalVerifyIPN requires the property $headers which is not provided by Srmklive\PayPal\Services\PayPal.
Loading history...
13
14
    /**
15
     * PayPal constructor.
16
     *
17
     * @param array $config
18
     *
19
     * @throws Exception
20
     */
21
    public function __construct(array $config = [])
22
    {
23
        // Setting PayPal API Credentials
24
        $this->setConfig($config);
25
26
        $this->httpBodyParam = 'form_params';
27
28
        $this->options = [];
29
30
        $this->setRequestHeader('Accept', 'application/json');
31
    }
32
33
    /**
34
     * Set ExpressCheckout API endpoints & options.
35
     *
36
     * @param array $credentials
37
     */
38
    protected function setOptions(array $credentials): void
39
    {
40
        // Setting API Endpoints
41
        $this->config['api_url'] = 'https://api-m.paypal.com';
42
43
        $this->config['gateway_url'] = 'https://www.paypal.com';
44
        $this->config['ipn_url'] = 'https://ipnpb.paypal.com/cgi-bin/webscr';
45
46
        if ($this->mode === 'sandbox') {
47
            $this->config['api_url'] = 'https://api-m.sandbox.paypal.com';
48
49
            $this->config['gateway_url'] = 'https://www.sandbox.paypal.com';
50
            $this->config['ipn_url'] = 'https://ipnpb.sandbox.paypal.com/cgi-bin/webscr';
51
        }
52
53
        // Adding params outside sandbox / live array
54
        $this->config['payment_action'] = $credentials['payment_action'];
55
        $this->config['notify_url'] = $credentials['notify_url'];
56
        $this->config['locale'] = $credentials['locale'];
57
    }
58
}
59