1 | <?php |
||
2 | |||
3 | namespace App\Service\Paypal; |
||
4 | |||
5 | /** |
||
6 | * Class BillingAgreementService |
||
7 | * @package App\Service\Paypal |
||
8 | */ |
||
9 | class BillingAgreementService extends IdentityService |
||
10 | { |
||
11 | /** |
||
12 | * @param $requestBody |
||
13 | * @param string $url |
||
14 | * @param array $inputHeaders |
||
15 | * @param string $verb |
||
16 | * @return array|string|null |
||
17 | */ |
||
18 | public function doPaypalApiCall($requestBody, string $url, array $inputHeaders = [], string $verb = 'POST') |
||
19 | { |
||
20 | $accessToken = $this->getAccessToken(); |
||
21 | return $this->paypalApiCall($accessToken, $requestBody, $url, $inputHeaders, $verb); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
22 | } |
||
23 | |||
24 | /** |
||
25 | * @param $requestBody |
||
26 | * @return bool|string|null |
||
27 | */ |
||
28 | public function createBillingAgreementToken($requestBody) |
||
29 | { |
||
30 | return $this->doPaypalApiCall( |
||
0 ignored issues
–
show
|
|||
31 | $requestBody, |
||
32 | 'https://api.sandbox.paypal.com/v1/billing-agreements/agreement-tokens' |
||
33 | ); |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * @param $requestBody |
||
38 | * @return bool|string|null |
||
39 | */ |
||
40 | public function createBillingAgreement($requestBody) |
||
41 | { |
||
42 | return $this->doPaypalApiCall( |
||
0 ignored issues
–
show
|
|||
43 | $requestBody, |
||
44 | 'https://api.sandbox.paypal.com/v1/billing-agreements/agreements' |
||
45 | ); |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * @param $requestBody |
||
50 | * @param string $fraudnetSession |
||
51 | * @return bool|string|null |
||
52 | */ |
||
53 | public function createReferenceTransaction($requestBody, string $fraudnetSession) |
||
54 | { |
||
55 | return $this->doPaypalApiCall( |
||
0 ignored issues
–
show
|
|||
56 | $requestBody, |
||
57 | 'https://api.sandbox.paypal.com/v1/payments/payment', |
||
58 | ['PAYPAL-CLIENT-METADATA-ID: '.$fraudnetSession] |
||
59 | ); |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * @param string $billingAgreementId |
||
64 | * @return bool|string|null |
||
65 | */ |
||
66 | public function deleteBillingAgreement(string $billingAgreementId) |
||
67 | { |
||
68 | return $this->doPaypalApiCall( |
||
0 ignored issues
–
show
|
|||
69 | null, |
||
70 | 'https://api.sandbox.paypal.com/v1/billing-agreements/agreements/' . $billingAgreementId . '/cancel' |
||
71 | ); |
||
72 | } |
||
73 | } |
||
74 |