1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PaymentGateway\PayPalSdk\Subscriptions\Requests; |
4
|
|
|
|
5
|
|
|
use PaymentGateway\PayPalSdk\Subscriptions\ApplicationContext; |
6
|
|
|
use PaymentGateway\PayPalSdk\Subscriptions\Money; |
7
|
|
|
use PaymentGateway\PayPalSdk\Subscriptions\Subscriber; |
8
|
|
|
|
9
|
|
|
class StoreSubscriptionRequest |
10
|
|
|
{ |
11
|
|
|
private string $planId; |
12
|
|
|
private ?string $startTime = null; |
13
|
|
|
private ?string $quantity = null; |
14
|
|
|
private ?Money $shippingAmount = null; |
15
|
|
|
private ?Subscriber $subscriber = null; |
16
|
|
|
private ?ApplicationContext $applicationContext = null; |
17
|
|
|
private ?string $customId = null; |
18
|
|
|
|
19
|
6 |
|
public function __construct(string $planId) |
20
|
|
|
{ |
21
|
6 |
|
$this->planId = $planId; |
22
|
6 |
|
} |
23
|
|
|
|
24
|
|
|
public function getPlanId(): string |
25
|
|
|
{ |
26
|
|
|
return $this->planId; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function setPlanId(string $planId): void |
30
|
|
|
{ |
31
|
|
|
$this->planId = $planId; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function getStartTime(): ?string |
35
|
|
|
{ |
36
|
|
|
return $this->startTime; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function setStartTime(?string $startTime): void |
40
|
|
|
{ |
41
|
|
|
$this->startTime = $startTime; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function getQuantity(): ?string |
45
|
|
|
{ |
46
|
|
|
return $this->quantity; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function setQuantity(?string $quantity): void |
50
|
|
|
{ |
51
|
|
|
$this->quantity = $quantity; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function getShippingAmount(): ?Money |
55
|
|
|
{ |
56
|
|
|
return $this->shippingAmount; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function setShippingAmount(?Money $shippingAmount): void |
60
|
|
|
{ |
61
|
|
|
$this->shippingAmount = $shippingAmount; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function getSubscriber(): ?Subscriber |
65
|
|
|
{ |
66
|
|
|
return $this->subscriber; |
67
|
|
|
} |
68
|
|
|
|
69
|
2 |
|
public function setSubscriber(?Subscriber $subscriber): void |
70
|
|
|
{ |
71
|
2 |
|
$this->subscriber = $subscriber; |
72
|
2 |
|
} |
73
|
|
|
|
74
|
|
|
public function getApplicationContext(): ?ApplicationContext |
75
|
|
|
{ |
76
|
|
|
return $this->applicationContext; |
77
|
|
|
} |
78
|
|
|
|
79
|
2 |
|
public function setApplicationContext(?ApplicationContext $applicationContext): void |
80
|
|
|
{ |
81
|
2 |
|
$this->applicationContext = $applicationContext; |
82
|
2 |
|
} |
83
|
|
|
|
84
|
|
|
public function getCustomId(): ?string |
85
|
|
|
{ |
86
|
|
|
return $this->customId; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
public function setCustomId(?string $customId): void |
90
|
|
|
{ |
91
|
|
|
$this->customId = $customId; |
92
|
|
|
} |
93
|
|
|
|
94
|
6 |
|
public function toArray(): array |
95
|
|
|
{ |
96
|
|
|
$data = [ |
97
|
6 |
|
'plan_id' => $this->planId, |
98
|
|
|
]; |
99
|
|
|
|
100
|
6 |
|
if ($this->startTime) { |
101
|
|
|
$data['start_time'] = $this->startTime; |
102
|
|
|
} |
103
|
|
|
|
104
|
6 |
|
if ($this->quantity) { |
105
|
|
|
$data['quantity'] = $this->quantity; |
106
|
|
|
} |
107
|
|
|
|
108
|
6 |
|
if ($this->shippingAmount) { |
109
|
|
|
$data['shipping_amount'] = $this->shippingAmount->toArray(); |
110
|
|
|
} |
111
|
|
|
|
112
|
6 |
|
if ($this->subscriber) { |
113
|
2 |
|
$data['subscriber'] = $this->subscriber->toArray(); |
114
|
|
|
} |
115
|
|
|
|
116
|
6 |
|
if ($this->applicationContext) { |
117
|
2 |
|
$data['application_context'] = $this->applicationContext->toArray(); |
118
|
|
|
} |
119
|
|
|
|
120
|
6 |
|
if ($this->customId) { |
121
|
|
|
$data['custom_id'] = $this->customId; |
122
|
|
|
} |
123
|
|
|
|
124
|
6 |
|
return $data; |
125
|
|
|
} |
126
|
|
|
} |
127
|
|
|
|