1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
namespace Zoho\Subscription\Api; |
5
|
|
|
|
6
|
|
|
use Zoho\Subscription\Client\Client; |
7
|
|
|
|
8
|
|
|
class HostedPage extends Client |
9
|
|
|
{ |
10
|
|
|
public function listHostedPages(): array |
11
|
|
|
{ |
12
|
|
|
$response = $this->sendRequest('GET', 'hostedpages', ['content-type' => 'application/json'], json_encode($data)); |
|
|
|
|
13
|
|
|
|
14
|
|
|
return $this->processResponse($response); |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
public function createSubscription(array $data): array |
18
|
|
|
{ |
19
|
|
|
$response = $this->sendRequest('POST', 'hostedpages/newsubscription', ['content-type' => 'application/json'], json_encode($data)); |
20
|
|
|
|
21
|
|
|
return $this->processResponse($response); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
public function updateSubscription(array $data): array |
25
|
|
|
{ |
26
|
|
|
$response = $this->sendRequest('POST', 'hostedpages/updatesubscription', ['content-type' => 'application/json'], json_encode($data)); |
27
|
|
|
|
28
|
|
|
return $this->processResponse($response); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function updateCard(array $data): array |
32
|
|
|
{ |
33
|
|
|
$response = $this->sendRequest('POST', 'hostedpages/updatecard', ['content-type' => 'application/json'], json_encode($data)); |
34
|
|
|
|
35
|
|
|
return $this->processResponse($response); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function buyOneTimeAddon(array $data): array |
39
|
|
|
{ |
40
|
|
|
$response = $this->sendRequest('POST', 'hostedpages/buyonetimeaddon', ['content-type' => 'application/json'], json_encode($data)); |
41
|
|
|
|
42
|
|
|
return $this->processResponse($response); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function retrieveHostedPageFromSubscriptionId(string $subscriptionId): array |
46
|
|
|
{ |
47
|
|
|
$hostedPages = $this->listHostedPages(); |
48
|
|
|
|
49
|
|
|
foreach ($hostedPages as $hostedPage) { |
50
|
|
|
if (!empty($hostedPage['data'])) { |
51
|
|
|
if ($hostedPage['data']['subscription']['subscription_id'] == $subscriptionId) { |
52
|
|
|
return $hostedPage; |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
return null; |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.