1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author @jenschude <[email protected]> |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
namespace Commercetools\Core\Model\Payment; |
7
|
|
|
|
8
|
|
|
use Commercetools\Core\Model\Common\Context; |
9
|
|
|
use Commercetools\Core\Model\Common\JsonObject; |
10
|
|
|
use Commercetools\Core\Model\Customer\CustomerReference; |
11
|
|
|
use Commercetools\Core\Model\Common\Money; |
12
|
|
|
use Commercetools\Core\Model\Common\DateTimeDecorator; |
13
|
|
|
use Commercetools\Core\Model\CustomField\CustomFieldObjectDraft; |
14
|
|
|
use Commercetools\Core\Model\CustomField\CustomFieldObjectDraftCollection; |
15
|
|
|
use DateTime; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @package Commercetools\Core\Model\Payment |
19
|
|
|
* @link https://docs.commercetools.com/http-api-projects-payments.html#paymentdraft |
20
|
|
|
* @method CustomerReference getCustomer() |
21
|
|
|
* @method PaymentDraft setCustomer(CustomerReference $customer = null) |
22
|
|
|
* @method string getInterfaceId() |
23
|
|
|
* @method PaymentDraft setInterfaceId(string $interfaceId = null) |
24
|
|
|
* @method Money getAmountPlanned() |
25
|
|
|
* @method PaymentDraft setAmountPlanned(Money $amountPlanned = null) |
26
|
|
|
* @method PaymentMethodInfo getPaymentMethodInfo() |
27
|
|
|
* @method PaymentDraft setPaymentMethodInfo(PaymentMethodInfo $paymentMethodInfo = null) |
28
|
|
|
* @method CustomFieldObjectDraft getCustom() |
29
|
|
|
* @method PaymentDraft setCustom(CustomFieldObjectDraft $custom = null) |
30
|
|
|
* @method PaymentStatus getPaymentStatus() |
31
|
|
|
* @method PaymentDraft setPaymentStatus(PaymentStatus $paymentStatus = null) |
32
|
|
|
* @method TransactionCollection getTransactions() |
33
|
|
|
* @method PaymentDraft setTransactions(TransactionCollection $transactions = null) |
34
|
|
|
* @method CustomFieldObjectDraftCollection getInterfaceInteractions() |
35
|
|
|
* @method PaymentDraft setInterfaceInteractions(CustomFieldObjectDraftCollection $interfaceInteractions = null) |
36
|
|
|
* @method string getKey() |
37
|
|
|
* @method PaymentDraft setKey(string $key = null) |
38
|
|
|
* @method string getAnonymousId() |
39
|
|
|
* @method PaymentDraft setAnonymousId(string $anonymousId = null) |
40
|
|
|
*/ |
41
|
|
|
class PaymentDraft extends JsonObject |
42
|
|
|
{ |
43
|
30 |
|
public function fieldDefinitions() |
44
|
|
|
{ |
45
|
|
|
return [ |
46
|
30 |
|
'key' => [static::TYPE => 'string'], |
47
|
30 |
|
'customer' => [static::TYPE => CustomerReference::class], |
48
|
30 |
|
'anonymousId' => [static::TYPE => 'string'], |
49
|
30 |
|
'externalId' => [static::TYPE => 'string'], |
50
|
30 |
|
'interfaceId' => [static::TYPE => 'string'], |
51
|
30 |
|
'amountPlanned' => [static::TYPE => Money::class], |
52
|
30 |
|
'amountAuthorized' => [static::TYPE => Money::class], |
53
|
|
|
'authorizedUntil' => [ |
54
|
30 |
|
static::TYPE => DateTime::class, |
55
|
30 |
|
static::DECORATOR => DateTimeDecorator::class |
56
|
|
|
], |
57
|
30 |
|
'amountPaid' => [static::TYPE => Money::class], |
58
|
30 |
|
'amountRefunded' => [static::TYPE => Money::class], |
59
|
30 |
|
'paymentMethodInfo' => [static::TYPE => PaymentMethodInfo::class], |
60
|
30 |
|
'custom' => [static::TYPE => CustomFieldObjectDraft::class], |
61
|
30 |
|
'paymentStatus' => [static::TYPE => PaymentStatus::class], |
62
|
30 |
|
'transactions' => [static::TYPE => TransactionCollection::class], |
63
|
|
|
'interfaceInteractions' => [ |
64
|
30 |
|
static::TYPE => CustomFieldObjectDraftCollection::class |
65
|
|
|
], |
66
|
|
|
]; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @deprecated |
71
|
|
|
* @return string |
72
|
|
|
*/ |
73
|
|
|
public function getExternalId() |
74
|
|
|
{ |
75
|
|
|
return parent::getExternalId(); |
|
|
|
|
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @deprecated use setKey() instead |
80
|
|
|
* @param string $externalId |
81
|
|
|
* @return static |
82
|
|
|
*/ |
83
|
28 |
|
public function setExternalId($externalId = null) |
84
|
|
|
{ |
85
|
28 |
|
return parent::setExternalId($externalId); |
|
|
|
|
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @deprecated |
90
|
|
|
* @return Money |
91
|
|
|
*/ |
92
|
|
|
public function getAmountAuthorized() |
93
|
|
|
{ |
94
|
|
|
return parent::getAmountAuthorized(); |
|
|
|
|
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @deprecated |
99
|
|
|
* @param Money $amountAuthorized |
100
|
|
|
* @return static |
101
|
|
|
*/ |
102
|
|
|
public function setAmountAuthorized(Money $amountAuthorized = null) |
103
|
|
|
{ |
104
|
|
|
return parent::setAmountAuthorized($amountAuthorized); |
|
|
|
|
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @deprecated |
109
|
|
|
* @return Money |
110
|
|
|
*/ |
111
|
|
|
public function getAmountPaid() |
112
|
|
|
{ |
113
|
|
|
return parent::getAmountPaid(); |
|
|
|
|
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @deprecated |
118
|
|
|
* @param Money $amountPaid |
119
|
|
|
* @return static |
120
|
|
|
*/ |
121
|
|
|
public function setAmountPaid(Money $amountPaid = null) |
122
|
|
|
{ |
123
|
|
|
return parent::setAmountPaid($amountPaid); |
|
|
|
|
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* @deprecated |
128
|
|
|
* @return Money |
129
|
|
|
*/ |
130
|
|
|
public function getAmountRefunded() |
131
|
|
|
{ |
132
|
|
|
return parent::getAmountRefunded(); |
|
|
|
|
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* @deprecated |
137
|
|
|
* @param Money $amountRefunded |
138
|
|
|
* @return static |
139
|
|
|
*/ |
140
|
|
|
public function setAmountRefunded(Money $amountRefunded = null) |
141
|
|
|
{ |
142
|
|
|
return parent::setAmountRefunded($amountRefunded); |
|
|
|
|
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* @deprecated |
147
|
|
|
* @return Money |
148
|
|
|
*/ |
149
|
|
|
public function getAuthorizedUntil() |
150
|
|
|
{ |
151
|
|
|
return parent::getAuthorizedUntil(); |
|
|
|
|
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* @deprecated |
156
|
|
|
* @param Money $amountUntil |
157
|
|
|
* @return static |
158
|
|
|
*/ |
159
|
|
|
public function setAuthorizedUntil(Money $amountUntil = null) |
160
|
|
|
{ |
161
|
|
|
return parent::setAuthorizedUntil($amountUntil); |
|
|
|
|
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* @param Money $amountPlanned |
166
|
|
|
* @param Context|callable $context |
167
|
|
|
* @return PaymentDraft |
168
|
|
|
*/ |
169
|
|
|
public static function ofAmountPlanned(Money $amountPlanned, $context = null) |
170
|
|
|
{ |
171
|
|
|
return static::of($context)->setAmountPlanned($amountPlanned); |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* @param string $key |
176
|
|
|
* @param string $externalId |
177
|
|
|
* @param Money $amountPlanned |
178
|
|
|
* @param Context|callable $context |
179
|
|
|
* @return PaymentDraft |
180
|
|
|
*/ |
181
|
21 |
|
public static function ofKeyExternalIdAndAmountPlanned($key, $externalId, Money $amountPlanned, $context = null) |
182
|
|
|
{ |
183
|
21 |
|
return static::of($context)->setKey($key)->setExternalId($externalId)->setAmountPlanned($amountPlanned); |
|
|
|
|
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* @param string $key |
188
|
|
|
* @param string $externalId |
189
|
|
|
* @param Money $amountPlanned |
190
|
|
|
* @param PaymentMethodInfo $paymentMethodInfo |
191
|
|
|
* @param Context|callable $context |
192
|
|
|
* @return PaymentDraft |
193
|
|
|
*/ |
194
|
7 |
|
public static function ofKeyExternalIdAmountPlannedAndPaymentMethodInfo( |
195
|
|
|
$key, |
196
|
|
|
$externalId, |
197
|
|
|
Money $amountPlanned, |
198
|
|
|
PaymentMethodInfo $paymentMethodInfo, |
199
|
|
|
$context = null |
200
|
|
|
) { |
201
|
7 |
|
return static::of($context) |
|
|
|
|
202
|
7 |
|
->setKey($key) |
203
|
7 |
|
->setExternalId($externalId) |
204
|
7 |
|
->setAmountPlanned($amountPlanned) |
205
|
7 |
|
->setPaymentMethodInfo($paymentMethodInfo); |
206
|
|
|
} |
207
|
|
|
} |
208
|
|
|
|