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): self |
30
|
|
|
{ |
31
|
|
|
$this->planId = $planId; |
32
|
|
|
|
33
|
|
|
return $this; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function getStartTime(): ?string |
37
|
|
|
{ |
38
|
|
|
return $this->startTime; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function setStartTime(?string $startTime): self |
42
|
|
|
{ |
43
|
|
|
$this->startTime = $startTime; |
44
|
|
|
|
45
|
|
|
return $this; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function getQuantity(): ?string |
49
|
|
|
{ |
50
|
|
|
return $this->quantity; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function setQuantity(?string $quantity): self |
54
|
|
|
{ |
55
|
|
|
$this->quantity = $quantity; |
56
|
|
|
|
57
|
|
|
return $this; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function getShippingAmount(): ?Money |
61
|
|
|
{ |
62
|
|
|
return $this->shippingAmount; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function setShippingAmount(?Money $shippingAmount): self |
66
|
|
|
{ |
67
|
|
|
$this->shippingAmount = $shippingAmount; |
68
|
|
|
|
69
|
|
|
return $this; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function getSubscriber(): ?Subscriber |
73
|
|
|
{ |
74
|
|
|
return $this->subscriber; |
75
|
|
|
} |
76
|
|
|
|
77
|
2 |
|
public function setSubscriber(?Subscriber $subscriber): self |
78
|
|
|
{ |
79
|
2 |
|
$this->subscriber = $subscriber; |
80
|
|
|
|
81
|
2 |
|
return $this; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
public function getApplicationContext(): ?ApplicationContext |
85
|
|
|
{ |
86
|
|
|
return $this->applicationContext; |
87
|
|
|
} |
88
|
|
|
|
89
|
2 |
|
public function setApplicationContext(?ApplicationContext $applicationContext): self |
90
|
|
|
{ |
91
|
2 |
|
$this->applicationContext = $applicationContext; |
92
|
|
|
|
93
|
2 |
|
return $this; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
public function getCustomId(): ?string |
97
|
|
|
{ |
98
|
|
|
return $this->customId; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
public function setCustomId(?string $customId): self |
102
|
|
|
{ |
103
|
|
|
$this->customId = $customId; |
104
|
|
|
|
105
|
|
|
return $this; |
106
|
|
|
} |
107
|
|
|
|
108
|
6 |
|
public function toArray(): array |
109
|
|
|
{ |
110
|
|
|
$data = [ |
111
|
6 |
|
'plan_id' => $this->planId, |
112
|
|
|
]; |
113
|
|
|
|
114
|
6 |
|
if ($this->startTime) { |
115
|
|
|
$data['start_time'] = $this->startTime; |
116
|
|
|
} |
117
|
|
|
|
118
|
6 |
|
if ($this->quantity) { |
119
|
|
|
$data['quantity'] = $this->quantity; |
120
|
|
|
} |
121
|
|
|
|
122
|
6 |
|
if ($this->shippingAmount) { |
123
|
|
|
$data['shipping_amount'] = $this->shippingAmount->toArray(); |
124
|
|
|
} |
125
|
|
|
|
126
|
6 |
|
if ($this->subscriber) { |
127
|
2 |
|
$data['subscriber'] = $this->subscriber->toArray(); |
128
|
|
|
} |
129
|
|
|
|
130
|
6 |
|
if ($this->applicationContext) { |
131
|
2 |
|
$data['application_context'] = $this->applicationContext->toArray(); |
132
|
|
|
} |
133
|
|
|
|
134
|
6 |
|
if ($this->customId) { |
135
|
|
|
$data['custom_id'] = $this->customId; |
136
|
|
|
} |
137
|
|
|
|
138
|
6 |
|
return $data; |
139
|
|
|
} |
140
|
|
|
} |
141
|
|
|
|