|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace PaymentGateway\PayPalSdk\Subscriptions; |
|
4
|
|
|
|
|
5
|
|
|
class ApplicationContext |
|
6
|
|
|
{ |
|
7
|
|
|
private ?string $brandName = null; |
|
8
|
|
|
private ?string $locale = null; |
|
9
|
|
|
private ?string $shippingPreference = null; |
|
10
|
|
|
private ?string $userAction = null; |
|
11
|
|
|
private ?PaymentMethod $paymentMethod = null; |
|
12
|
|
|
private string $returnUrl; |
|
13
|
|
|
private string $cancelUrl; |
|
14
|
|
|
|
|
15
|
2 |
|
public function __construct(string $returnUrl, string $cancelUrl) |
|
16
|
|
|
{ |
|
17
|
2 |
|
$this->returnUrl = $returnUrl; |
|
18
|
2 |
|
$this->cancelUrl = $cancelUrl; |
|
19
|
2 |
|
} |
|
20
|
|
|
|
|
21
|
|
|
public function getBrandName(): ?string |
|
22
|
|
|
{ |
|
23
|
|
|
return $this->brandName; |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function setBrandName(?string $brandName): void |
|
27
|
|
|
{ |
|
28
|
|
|
$this->brandName = $brandName; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function getLocale(): ?string |
|
32
|
|
|
{ |
|
33
|
|
|
return $this->locale; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function setLocale(?string $locale): void |
|
37
|
|
|
{ |
|
38
|
|
|
$this->locale = $locale; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function getShippingPreference(): ?string |
|
42
|
|
|
{ |
|
43
|
|
|
return $this->shippingPreference; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @param string|null $shippingPreference |
|
48
|
|
|
*/ |
|
49
|
|
|
public function setShippingPreference(?string $shippingPreference): void |
|
50
|
|
|
{ |
|
51
|
|
|
$this->shippingPreference = $shippingPreference; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function getUserAction(): ?string |
|
55
|
|
|
{ |
|
56
|
|
|
return $this->userAction; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public function setUserAction(?string $userAction): void |
|
60
|
|
|
{ |
|
61
|
|
|
$this->userAction = $userAction; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
public function getPaymentMethod(): ?PaymentMethod |
|
65
|
|
|
{ |
|
66
|
|
|
return $this->paymentMethod; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
public function setPaymentMethod(?PaymentMethod $paymentMethod): void |
|
70
|
|
|
{ |
|
71
|
|
|
$this->paymentMethod = $paymentMethod; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
public function getReturnUrl(): string |
|
75
|
|
|
{ |
|
76
|
|
|
return $this->returnUrl; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
public function setReturnUrl(string $returnUrl): void |
|
80
|
|
|
{ |
|
81
|
|
|
$this->returnUrl = $returnUrl; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
public function getCancelUrl(): string |
|
85
|
|
|
{ |
|
86
|
|
|
return $this->cancelUrl; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
public function setCancelUrl(string $cancelUrl): void |
|
90
|
|
|
{ |
|
91
|
|
|
$this->cancelUrl = $cancelUrl; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
2 |
|
public function toArray(): array |
|
95
|
|
|
{ |
|
96
|
|
|
$data = [ |
|
97
|
2 |
|
'return_url' => $this->returnUrl, |
|
98
|
2 |
|
'cancel_url' => $this->cancelUrl |
|
99
|
|
|
]; |
|
100
|
|
|
|
|
101
|
2 |
|
if ($this->brandName) { |
|
102
|
|
|
$data['brand_name'] = $this->brandName; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
2 |
|
if ($this->locale) { |
|
106
|
|
|
$data['locale'] = $this->locale; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
2 |
|
if ($this->shippingPreference) { |
|
110
|
|
|
$data['shipping_preference'] = $this->shippingPreference; |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
2 |
|
if ($this->userAction) { |
|
114
|
|
|
$data['user_action'] = $this->userAction; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
2 |
|
if ($this->paymentMethod) { |
|
118
|
|
|
$data['payment_method'] = $this->paymentMethod->toArray(); |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
2 |
|
return $data; |
|
122
|
|
|
} |
|
123
|
|
|
} |
|
124
|
|
|
|