1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Xsolla\SDK\API\PaymentUI; |
4
|
|
|
|
5
|
|
|
class TokenRequest |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* @var array |
9
|
|
|
*/ |
10
|
|
|
protected $data = []; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @param int $projectId |
14
|
|
|
* @param string $userId |
15
|
|
|
*/ |
16
|
3 |
|
public function __construct($projectId, $userId) |
17
|
|
|
{ |
18
|
3 |
|
$this->data['user']['id']['value'] = $userId; |
19
|
3 |
|
$this->data['settings']['project_id'] = $projectId; |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @param string $email |
24
|
|
|
* |
25
|
|
|
* @return self |
26
|
|
|
*/ |
27
|
2 |
|
public function setUserEmail($email) |
28
|
|
|
{ |
29
|
2 |
|
$this->data['user']['email']['value'] = $email; |
30
|
|
|
|
31
|
2 |
|
return $this; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @param string $name |
36
|
|
|
* |
37
|
|
|
* @return self |
38
|
|
|
*/ |
39
|
2 |
|
public function setUserName($name) |
40
|
|
|
{ |
41
|
2 |
|
$this->data['user']['name']['value'] = $name; |
42
|
|
|
|
43
|
2 |
|
return $this; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @param string $currencyIsoCode |
48
|
|
|
* |
49
|
|
|
* @return self |
50
|
|
|
*/ |
51
|
2 |
|
public function setCurrency($currencyIsoCode) |
52
|
|
|
{ |
53
|
2 |
|
$this->data['settings']['currency'] = $currencyIsoCode; |
54
|
|
|
|
55
|
2 |
|
return $this; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @param array $customParameters |
60
|
|
|
* |
61
|
|
|
* @return self |
62
|
|
|
*/ |
63
|
2 |
|
public function setCustomParameters(array $customParameters) |
64
|
|
|
{ |
65
|
2 |
|
$this->data['custom_parameters'] = $customParameters; |
66
|
|
|
|
67
|
2 |
|
return $this; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @param string $externalId |
72
|
|
|
* |
73
|
|
|
* @return self |
74
|
|
|
*/ |
75
|
1 |
|
public function setExternalPaymentId($externalId) |
76
|
|
|
{ |
77
|
1 |
|
$this->data['settings']['external_id'] = $externalId; |
78
|
|
|
|
79
|
1 |
|
return $this; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @param bool $isSandbox |
84
|
|
|
* |
85
|
|
|
* @return self |
86
|
|
|
*/ |
87
|
3 |
|
public function setSandboxMode($isSandbox = true) |
88
|
|
|
{ |
89
|
3 |
|
if (true === $isSandbox) { |
90
|
3 |
|
$this->data['settings']['mode'] = 'sandbox'; |
91
|
|
|
} else { |
92
|
|
|
unset($this->data['settings']['mode']); |
93
|
|
|
} |
94
|
|
|
|
95
|
3 |
|
return $this; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @param float $amount |
100
|
|
|
* @param string $currency |
101
|
|
|
* |
102
|
|
|
* @return $this |
103
|
|
|
*/ |
104
|
2 |
|
public function setPurchase($amount, $currency) |
105
|
|
|
{ |
106
|
2 |
|
$this->data['purchase']['checkout']['amount'] = $amount; |
107
|
2 |
|
$this->data['purchase']['checkout']['currency'] = $currency; |
108
|
|
|
|
109
|
2 |
|
return $this; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @param array $userAttributes |
114
|
|
|
* |
115
|
3 |
|
* @return self |
116
|
|
|
*/ |
117
|
3 |
|
public function setUserAttributes(array $userAttributes) |
118
|
|
|
{ |
119
|
|
|
$this->data['user']['attributes'] = $userAttributes; |
120
|
|
|
|
121
|
|
|
return $this; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* @return array |
126
|
|
|
*/ |
127
|
|
|
public function toArray() |
128
|
|
|
{ |
129
|
|
|
return $this->data; |
130
|
|
|
} |
131
|
|
|
} |
132
|
|
|
|