Skip to content

Commit 43bf50b

Browse files
Merge pull request #34 from Itonomy/feature/CMP-98-finalize-direct-flow
CMP-98 finalize direct flow
2 parents 1554826 + 17c4fd7 commit 43bf50b

27 files changed

+907
-262
lines changed

Client/Api/OrderInterface.php

+9
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,22 @@
1010

1111
use CM\Payments\Client\Model\Response\OrderCreate;
1212
use CM\Payments\Client\Model\Response\OrderDetail;
13+
use CM\Payments\Client\Model\Response\OrderListItem;
1314
use CM\Payments\Client\Model\Response\PaymentMethod;
1415
use CM\Payments\Client\Request\OrderCreateRequest;
1516
use CM\Payments\Client\Request\OrderGetMethodsRequest;
1617
use GuzzleHttp\Exception\RequestException;
1718

1819
interface OrderInterface
1920
{
21+
/**
22+
* @param string $date
23+
* @return OrderListItem[]
24+
*
25+
* @throws RequestException
26+
*/
27+
public function getList(string $date): array;
28+
2029
/**
2130
* @param string $orderKey
2231
* @return OrderDetail
+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?php
2+
/**
3+
* Copyright © CM.com. All rights reserved.
4+
* See LICENSE.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace CM\Payments\Client\Model\Response;
10+
11+
class OrderListItem
12+
{
13+
/**
14+
* string
15+
*/
16+
private $orderReference;
17+
18+
/**
19+
* string
20+
*/
21+
private $timestamp;
22+
23+
/**
24+
* string
25+
*/
26+
private $expiresOn;
27+
28+
/**
29+
* string
30+
*/
31+
private $orderKey;
32+
33+
/**
34+
* @var string
35+
*/
36+
private $url;
37+
38+
/**
39+
* OrderDetail constructor
40+
*
41+
* @param array $orderDetail
42+
*/
43+
public function __construct(
44+
array $orderListItem
45+
) {
46+
$this->orderReference = $orderListItem['order_reference'];
47+
$this->timestamp = $orderListItem['timestamp'];
48+
$this->expiresOn = $orderListItem['expires_on'];
49+
$this->orderKey = $orderListItem['order_key'];
50+
$this->url = $orderListItem['url'];
51+
}
52+
53+
/**
54+
* @inheritDoc
55+
*/
56+
public function getOrderReference(): string
57+
{
58+
return $this->orderReference;
59+
}
60+
61+
/**
62+
* @inheritDoc
63+
*/
64+
public function getExpiresOn(): string
65+
{
66+
return $this->expiresOn;
67+
}
68+
/**
69+
* @inheritDoc
70+
*/
71+
public function getTimestamp(): string
72+
{
73+
return $this->timestamp;
74+
}
75+
76+
/**
77+
* @return string
78+
*/
79+
public function getOrderKey(): string
80+
{
81+
return $this->orderKey;
82+
}
83+
84+
/**
85+
* @return string
86+
*/
87+
public function getUrl(): string
88+
{
89+
return $this->url;
90+
}
91+
}

Client/Order.php

+20
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
use CM\Payments\Client\Api\OrderInterface;
1313
use CM\Payments\Client\Model\Response\OrderCreate;
1414
use CM\Payments\Client\Model\Response\OrderDetail;
15+
use CM\Payments\Client\Model\Response\OrderListItem;
1516
use CM\Payments\Client\Model\Response\PaymentMethod;
1617
use CM\Payments\Client\Request\OrderCreateRequest;
1718
use CM\Payments\Client\Request\OrderGetMethodsRequest;
1819
use CM\Payments\Client\Request\OrderGetRequest;
20+
use CM\Payments\Client\Request\OrdersRequest;
1921
use GuzzleHttp\Exception\RequestException;
2022

2123
class Order implements OrderInterface
@@ -34,6 +36,24 @@ public function __construct(ApiClientInterface $apiClient)
3436
$this->apiClient = $apiClient;
3537
}
3638

39+
/**
40+
* @return OrderListItem[]
41+
*
42+
* @throws RequestException
43+
*/
44+
public function getList(string $date): array
45+
{
46+
$ordersRequest = new OrdersRequest($date);
47+
48+
$response = $this->apiClient->execute(
49+
$ordersRequest
50+
);
51+
52+
return array_map(function ($order) {
53+
return new OrderListItem($order);
54+
}, $response);
55+
}
56+
3757
/**
3858
* @param string $orderKey
3959
* @return OrderDetail

Client/Request/OrdersRequest.php

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
/**
3+
* Copyright © CM.com. All rights reserved.
4+
* See LICENSE.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace CM\Payments\Client\Request;
10+
11+
use CM\Payments\Client\Api\RequestInterface;
12+
13+
class OrdersRequest implements RequestInterface
14+
{
15+
/**
16+
* Order Get Endpoint
17+
*/
18+
public const ENDPOINT = 'orders';
19+
20+
/**
21+
* @var false|string
22+
*/
23+
private $date;
24+
25+
/**
26+
* OrdersRequest constructor.
27+
* @param string $date
28+
*/
29+
public function __construct(string $date)
30+
{
31+
$this->date = $date ?? date('Y-m-d');
32+
}
33+
/**
34+
* @inheritDoc
35+
*/
36+
public function getEndpoint(): string
37+
{
38+
return self::ENDPOINT;
39+
}
40+
41+
/**
42+
* @inheritDoc
43+
*/
44+
public function getRequestMethod(): string
45+
{
46+
return RequestInterface::HTTP_GET;
47+
}
48+
49+
/**
50+
* @inheritDoc
51+
*/
52+
public function getPayload(): array
53+
{
54+
return [
55+
'date' => $this->date
56+
];
57+
}
58+
}

Controller/Payment/IdealRedirect.php

-141
This file was deleted.

Controller/Payment/Notification.php

+3
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ public function execute()
9393
$resultPage->setHttpResponseCode(400);
9494

9595
return $resultPage;
96+
} catch (\Exception $e) {
97+
$this->logger->error($e->getMessage(), $e->getTrace());
98+
$resultPage->setHttpResponseCode(500);
9699
}
97100
}
98101

0 commit comments

Comments
 (0)