Skip to content

Commit 3951bdc

Browse files
Add checkout in-store API
1 parent 6938f43 commit 3951bdc

File tree

9 files changed

+414
-1
lines changed

9 files changed

+414
-1
lines changed

.DS_Store

6 KB
Binary file not shown.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "tamara-solution/php-sdk",
33
"license": "MIT",
44
"description": "Tamara PHP Client Library",
5-
"version": "2.0.4",
5+
"version": "2.0.5",
66
"keywords": [
77
"tamara",
88
"tamara php sdk",

src/.DS_Store

6 KB
Binary file not shown.

src/Tamara/Client.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Tamara\HttpClient\HttpClient;
66
use Tamara\Request\Checkout\CheckPaymentOptionsAvailabilityRequest;
77
use Tamara\Request\Checkout\CreateCheckoutRequest;
8+
use Tamara\Request\Checkout\CreateInstoreCheckoutRequest;
89
use Tamara\Request\Checkout\GetPaymentTypesRequest;
910
use Tamara\Request\Checkout\GetPaymentTypesV2Request;
1011
use Tamara\Request\Merchant\GetPublicConfigsRequest;
@@ -23,6 +24,7 @@
2324
use Tamara\Request\Webhook\UpdateWebhookRequest;
2425
use Tamara\Response\Checkout\CheckPaymentOptionsAvailabilityResponse;
2526
use Tamara\Response\Checkout\CreateCheckoutResponse;
27+
use Tamara\Response\Checkout\CreateInstoreCheckoutResponse;
2628
use Tamara\Response\Checkout\GetPaymentTypesResponse;
2729
use Tamara\Response\Merchant\GetPublicConfigsResponse;
2830
use Tamara\Response\Order\AuthoriseOrderResponse;
@@ -275,4 +277,14 @@ public function simplifyRefund(SimplifiedRefundRequest $request): SimplifiedRefu
275277
{
276278
return $this->requestDispatcher->dispatch($request);
277279
}
280+
281+
/**
282+
* @param CreateInstoreCheckoutRequest $createInstoreCheckoutRequest
283+
* @return CreateInstoreCheckoutResponse
284+
* @throws Exception\RequestDispatcherException
285+
*/
286+
public function createInstoreCheckout(CreateInstoreCheckoutRequest $createInstoreCheckoutRequest): CreateInstoreCheckoutResponse
287+
{
288+
return $this->requestDispatcher->dispatch($createInstoreCheckoutRequest);
289+
}
278290
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Tamara\Model\Checkout;
6+
7+
class InstoreCheckoutResponse
8+
{
9+
public const
10+
ORDER_ID = 'order_id',
11+
CHECKOUT_ID = 'checkout_id',
12+
CHECKOUT_DEEP_LINK = 'checkout_deeplink';
13+
14+
private $orderId;
15+
private $checkoutId;
16+
private $checkoutDeepLink;
17+
18+
public function __construct(array $response)
19+
{
20+
$this->orderId = $response[self::ORDER_ID];
21+
$this->checkoutId = $response[self::CHECKOUT_ID];
22+
$this->checkoutDeepLink = $response[self::CHECKOUT_DEEP_LINK];
23+
}
24+
25+
public function toArray(): array
26+
{
27+
return [
28+
self::ORDER_ID => $this->getOrderId(),
29+
self::CHECKOUT_ID => $this->getCheckoutId(),
30+
self::CHECKOUT_DEEP_LINK => $this->getCheckoutDeepLink(),
31+
];
32+
}
33+
34+
public function getOrderId(): string
35+
{
36+
return $this->orderId;
37+
}
38+
39+
public function getCheckoutId()
40+
{
41+
return $this->checkoutId;
42+
}
43+
44+
public function getCheckoutDeepLink()
45+
{
46+
return $this->checkoutDeepLink;
47+
}
48+
}
Lines changed: 275 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,275 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Tamara\Model\Order;
6+
7+
use Tamara\Model\Money;
8+
9+
class InstoreOrder
10+
{
11+
public const
12+
ORDER_ID = 'order_id',
13+
TOTAL_AMOUNT = 'total_amount',
14+
PHONE_NUMBER = 'phone_number',
15+
EMAIL = 'email',
16+
EXPIRY_TIME = 'expiry_time',
17+
ITEMS = 'items',
18+
PAYMENT_TYPE = 'payment_type',
19+
ORDER_REFERENCE_ID = 'order_reference_id',
20+
ORDER_NUMBER = 'order_number',
21+
LOCALE = 'locale',
22+
ADDITIONAL_DATA = 'additional_data';
23+
24+
/**
25+
* @var Money
26+
*/
27+
private $totalAmount;
28+
/**
29+
* @var string
30+
*/
31+
private $phoneNumber;
32+
/**
33+
* @var string|null
34+
*/
35+
private $email;
36+
/**
37+
* @var int|null
38+
*/
39+
private $expiryTime;
40+
/**
41+
* @var OrderItemCollection
42+
*/
43+
private $items;
44+
/**
45+
* @var string
46+
*/
47+
private $orderReferenceId;
48+
/**
49+
* @var string|null
50+
*/
51+
private $orderNumber;
52+
/**
53+
* @var array|null
54+
*/
55+
private $additionalData;
56+
/**
57+
* @var string|null
58+
*/
59+
private $locale;
60+
/**
61+
* @var string|null
62+
*/
63+
private $paymentType;
64+
65+
public function toArray(): array
66+
{
67+
$result = [
68+
self::TOTAL_AMOUNT => $this->getTotalAmount()->toArray(),
69+
self::PHONE_NUMBER => $this->getPhoneNumber(),
70+
self::ITEMS => $this->getItems()->toArray(),
71+
self::ORDER_REFERENCE_ID => $this->getOrderReferenceId(),
72+
];
73+
74+
if ($this->getEmail() !== null) {
75+
$result[self::EMAIL] = $this->getEmail();
76+
}
77+
if ($this->getExpiryTime() > 0) {
78+
$result[self::EXPIRY_TIME] = $this->getExpiryTime();
79+
}
80+
if ($this->getOrderNumber() !== null) {
81+
$result[self::ORDER_NUMBER] = $this->getOrderNumber();
82+
}
83+
if ($this->getAdditionalData() !== null) {
84+
$result[self::ADDITIONAL_DATA] = $this->getAdditionalData();
85+
}
86+
if ($this->getLocale() !== null) {
87+
$result[self::LOCALE] = $this->getLocale();
88+
}
89+
if ($this->getPaymentType() !== null) {
90+
$result[self::PAYMENT_TYPE] = $this->getPaymentType();
91+
}
92+
93+
return $result;
94+
}
95+
96+
/**
97+
* @return Money
98+
*/
99+
public function getTotalAmount(): Money
100+
{
101+
return $this->totalAmount;
102+
}
103+
104+
/**
105+
* @param Money $totalAmount
106+
* @return InstoreOrder
107+
*/
108+
public function setTotalAmount(Money $totalAmount): InstoreOrder
109+
{
110+
$this->totalAmount = $totalAmount;
111+
return $this;
112+
}
113+
114+
/**
115+
* @return string
116+
*/
117+
public function getPhoneNumber(): string
118+
{
119+
return $this->phoneNumber;
120+
}
121+
122+
/**
123+
* @param string $phoneNumber
124+
* @return InstoreOrder
125+
*/
126+
public function setPhoneNumber(string $phoneNumber): InstoreOrder
127+
{
128+
$this->phoneNumber = $phoneNumber;
129+
return $this;
130+
}
131+
132+
/**
133+
* @return OrderItemCollection
134+
*/
135+
public function getItems(): OrderItemCollection
136+
{
137+
return $this->items;
138+
}
139+
140+
/**
141+
* @param OrderItemCollection $items
142+
* @return InstoreOrder
143+
*/
144+
public function setItems(OrderItemCollection $items): InstoreOrder
145+
{
146+
$this->items = $items;
147+
return $this;
148+
}
149+
150+
/**
151+
* @return string
152+
*/
153+
public function getOrderReferenceId(): string
154+
{
155+
return $this->orderReferenceId;
156+
}
157+
158+
/**
159+
* @param string $orderReferenceId
160+
* @return InstoreOrder
161+
*/
162+
public function setOrderReferenceId(string $orderReferenceId): InstoreOrder
163+
{
164+
$this->orderReferenceId = $orderReferenceId;
165+
return $this;
166+
}
167+
168+
/**
169+
* @return string|null
170+
*/
171+
public function getEmail(): ?string
172+
{
173+
return $this->email;
174+
}
175+
176+
/**
177+
* @param string|null $email
178+
* @return InstoreOrder
179+
*/
180+
public function setEmail(?string $email): InstoreOrder
181+
{
182+
$this->email = $email;
183+
return $this;
184+
}
185+
186+
/**
187+
* @return int|null
188+
*/
189+
public function getExpiryTime(): ?int
190+
{
191+
return $this->expiryTime;
192+
}
193+
194+
/**
195+
* @param int|null $expiryTime
196+
* @return InstoreOrder
197+
*/
198+
public function setExpiryTime(?int $expiryTime): InstoreOrder
199+
{
200+
$this->expiryTime = $expiryTime;
201+
return $this;
202+
}
203+
204+
/**
205+
* @return string|null
206+
*/
207+
public function getOrderNumber(): ?string
208+
{
209+
return $this->orderNumber;
210+
}
211+
212+
/**
213+
* @param string|null $orderNumber
214+
* @return InstoreOrder
215+
*/
216+
public function setOrderNumber(?string $orderNumber): InstoreOrder
217+
{
218+
$this->orderNumber = $orderNumber;
219+
return $this;
220+
}
221+
222+
/**
223+
* @return array|null
224+
*/
225+
public function getAdditionalData(): ?array
226+
{
227+
return $this->additionalData;
228+
}
229+
230+
/**
231+
* @param array|null $additionalData
232+
* @return InstoreOrder
233+
*/
234+
public function setAdditionalData(?array $additionalData): InstoreOrder
235+
{
236+
$this->additionalData = $additionalData;
237+
return $this;
238+
}
239+
240+
/**
241+
* @return string|null
242+
*/
243+
public function getLocale(): ?string
244+
{
245+
return $this->locale;
246+
}
247+
248+
/**
249+
* @param string|null $locale
250+
* @return InstoreOrder
251+
*/
252+
public function setLocale(?string $locale): InstoreOrder
253+
{
254+
$this->locale = $locale;
255+
return $this;
256+
}
257+
258+
/**
259+
* @return string|null
260+
*/
261+
public function getPaymentType(): ?string
262+
{
263+
return $this->paymentType;
264+
}
265+
266+
/**
267+
* @param string|null $paymentType
268+
* @return InstoreOrder
269+
*/
270+
public function setPaymentType(?string $paymentType): InstoreOrder
271+
{
272+
$this->paymentType = $paymentType;
273+
return $this;
274+
}
275+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Tamara\Request\Checkout;
6+
7+
use Tamara\Model\Order\InstoreOrder;
8+
9+
class CreateInstoreCheckoutRequest
10+
{
11+
/**
12+
* @var InstoreOrder
13+
*/
14+
private $order;
15+
16+
public function __construct(InstoreOrder $order)
17+
{
18+
$this->order = $order;
19+
}
20+
21+
/**
22+
* @return InstoreOrder
23+
*/
24+
public function getOrder(): InstoreOrder
25+
{
26+
return $this->order;
27+
}
28+
29+
}

0 commit comments

Comments
 (0)