1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PaymentGateway\PayPalSdk\Api; |
4
|
|
|
|
5
|
|
|
use PaymentGateway\PayPalSdk\Contracts\PayPalResponse; |
6
|
|
|
use PaymentGateway\PayPalSdk\PayPalApi; |
7
|
|
|
use PaymentGateway\PayPalSdk\Responses\GetResponse; |
8
|
|
|
use PaymentGateway\PayPalSdk\Responses\PatchResponse; |
9
|
|
|
use PaymentGateway\PayPalSdk\Responses\PostResponse; |
10
|
|
|
use PaymentGateway\PayPalSdk\Subscriptions\Requests\StorePlanRequest; |
11
|
|
|
use PaymentGateway\PayPalSdk\Subscriptions\Requests\UpdatePlanRequest; |
12
|
|
|
|
13
|
|
|
class BillingPlansApi extends PayPalApi |
14
|
|
|
{ |
15
|
1 |
|
public function getPlan(string $id): PayPalResponse |
16
|
|
|
{ |
17
|
1 |
|
$this->client->prepareRequest('GET', $this->baseUri . '/v1/billing/plans/' . $id); |
18
|
1 |
|
$this->setAuthentication(); |
19
|
|
|
|
20
|
1 |
|
return new GetResponse($this->client->execute()); |
21
|
|
|
} |
22
|
|
|
|
23
|
1 |
|
public function getPlans(): PayPalResponse |
24
|
|
|
{ |
25
|
1 |
|
$this->client->prepareRequest('GET', $this->baseUri . '/v1/billing/plans'); |
26
|
1 |
|
$this->setAuthentication(); |
27
|
|
|
|
28
|
1 |
|
return new GetResponse($this->client->execute()); |
29
|
|
|
} |
30
|
|
|
|
31
|
1 |
|
public function createPlan(StorePlanRequest $storePlanRequest): PayPalResponse |
32
|
|
|
{ |
33
|
1 |
|
$this->client->prepareRequest('POST', $this->baseUri . '/v1/billing/plans'); |
34
|
1 |
|
$this->setAuthentication()->setJson($storePlanRequest->toArray()); |
35
|
|
|
|
36
|
1 |
|
return new PostResponse($this->client->execute()); |
37
|
|
|
} |
38
|
|
|
|
39
|
2 |
|
public function updatePlan(UpdatePlanRequest $planRequest): PayPalResponse |
40
|
|
|
{ |
41
|
2 |
|
$this->client->prepareRequest('PATCH', $this->baseUri . '/v1/billing/plans/' . $planRequest->getId()); |
42
|
2 |
|
$this->setAuthentication()->setJson($planRequest->toArray()); |
43
|
|
|
|
44
|
2 |
|
return new PatchResponse($this->client->execute()); |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
|