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 getHostedPageById(string $hostedPageId): array |
11
|
|
|
{ |
12
|
|
|
$response = $this->sendRequest('GET', sprintf('hostedpages/%s', $hostedPageId)); |
13
|
|
|
|
14
|
|
|
return $this->processResponse($response); |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
public function listHostedPages(): array |
18
|
|
|
{ |
19
|
|
|
$response = $this->sendRequest('GET', 'hostedpages', ['content-type' => 'application/json'], json_encode($data)); |
|
|
|
|
20
|
|
|
|
21
|
|
|
return $this->processResponse($response); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
public function createSubscription(array $data): array |
25
|
|
|
{ |
26
|
|
|
$response = $this->sendRequest('POST', 'hostedpages/newsubscription', ['content-type' => 'application/json'], json_encode($data)); |
27
|
|
|
|
28
|
|
|
return $this->processResponse($response); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function updateSubscription(array $data): array |
32
|
|
|
{ |
33
|
|
|
$response = $this->sendRequest('POST', 'hostedpages/updatesubscription', ['content-type' => 'application/json'], json_encode($data)); |
34
|
|
|
|
35
|
|
|
return $this->processResponse($response); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function updateCard(array $data): array |
39
|
|
|
{ |
40
|
|
|
$response = $this->sendRequest('POST', 'hostedpages/updatecard', ['content-type' => 'application/json'], json_encode($data)); |
41
|
|
|
|
42
|
|
|
return $this->processResponse($response); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function buyOneTimeAddon(array $data): array |
46
|
|
|
{ |
47
|
|
|
$response = $this->sendRequest('POST', 'hostedpages/buyonetimeaddon', ['content-type' => 'application/json'], json_encode($data)); |
48
|
|
|
|
49
|
|
|
return $this->processResponse($response); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function retrieveHostedPageFromSubscriptionId(string $subscriptionId): array |
53
|
|
|
{ |
54
|
|
|
$hostedPages = $this->listHostedPages(); |
55
|
|
|
|
56
|
|
|
foreach ($hostedPages as $hostedPage) { |
57
|
|
|
if (!empty($hostedPage['data'])) { |
58
|
|
|
if ($hostedPage['data']['subscription']['subscription_id'] == $subscriptionId) { |
59
|
|
|
return $hostedPage; |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
return null; |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|
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.