|
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
|
8 |
|
public function __construct(string $planId) |
|
20
|
|
|
{ |
|
21
|
8 |
|
$this->planId = $planId; |
|
22
|
8 |
|
} |
|
23
|
|
|
|
|
24
|
2 |
|
public function getPlanId(): string |
|
25
|
|
|
{ |
|
26
|
2 |
|
return $this->planId; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
1 |
|
public function setPlanId(string $planId): self |
|
30
|
|
|
{ |
|
31
|
1 |
|
$this->planId = $planId; |
|
32
|
|
|
|
|
33
|
1 |
|
return $this; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
1 |
|
public function getStartTime(): ?string |
|
37
|
|
|
{ |
|
38
|
1 |
|
return $this->startTime; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
1 |
|
public function setStartTime(?string $startTime): self |
|
42
|
|
|
{ |
|
43
|
1 |
|
$this->startTime = $startTime; |
|
44
|
|
|
|
|
45
|
1 |
|
return $this; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
1 |
|
public function getQuantity(): ?string |
|
49
|
|
|
{ |
|
50
|
1 |
|
return $this->quantity; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
1 |
|
public function setQuantity(?string $quantity): self |
|
54
|
|
|
{ |
|
55
|
1 |
|
$this->quantity = $quantity; |
|
56
|
|
|
|
|
57
|
1 |
|
return $this; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
1 |
|
public function getShippingAmount(): ?Money |
|
61
|
|
|
{ |
|
62
|
1 |
|
return $this->shippingAmount; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
1 |
|
public function setShippingAmount(?Money $shippingAmount): self |
|
66
|
|
|
{ |
|
67
|
1 |
|
$this->shippingAmount = $shippingAmount; |
|
68
|
|
|
|
|
69
|
1 |
|
return $this; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
1 |
|
public function getSubscriber(): ?Subscriber |
|
73
|
|
|
{ |
|
74
|
1 |
|
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
|
1 |
|
public function getApplicationContext(): ?ApplicationContext |
|
85
|
|
|
{ |
|
86
|
1 |
|
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
|
1 |
|
public function getCustomId(): ?string |
|
97
|
|
|
{ |
|
98
|
1 |
|
return $this->customId; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
1 |
|
public function setCustomId(?string $customId): self |
|
102
|
|
|
{ |
|
103
|
1 |
|
$this->customId = $customId; |
|
104
|
|
|
|
|
105
|
1 |
|
return $this; |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
8 |
|
public function toArray(): array |
|
109
|
|
|
{ |
|
110
|
|
|
$data = [ |
|
111
|
8 |
|
'plan_id' => $this->planId, |
|
112
|
|
|
]; |
|
113
|
|
|
|
|
114
|
8 |
|
if ($this->startTime) { |
|
115
|
1 |
|
$data['start_time'] = $this->startTime; |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
8 |
|
if ($this->quantity) { |
|
119
|
1 |
|
$data['quantity'] = $this->quantity; |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
8 |
|
if ($this->shippingAmount) { |
|
123
|
1 |
|
$data['shipping_amount'] = $this->shippingAmount->toArray(); |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
8 |
|
if ($this->subscriber) { |
|
127
|
2 |
|
$data['subscriber'] = $this->subscriber->toArray(); |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
8 |
|
if ($this->applicationContext) { |
|
131
|
2 |
|
$data['application_context'] = $this->applicationContext->toArray(); |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
8 |
|
if ($this->customId) { |
|
135
|
1 |
|
$data['custom_id'] = $this->customId; |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
8 |
|
return $data; |
|
139
|
|
|
} |
|
140
|
|
|
} |
|
141
|
|
|
|