Skip to content

Commit 4ad90ae

Browse files
author
Ivan Tagil
authored
Merge pull request #16 from Itonomy/feature/CMP-68_сreate-payment-service-test
CMP-68, CMP-69 - Create payment service test, iDeal tests
2 parents 39d3073 + cc664ab commit 4ad90ae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2401
-257
lines changed

.github/workflows/integration-test.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ jobs:
2424
- name: Start Docker
2525
run: docker run --detach --name magento-project-community-edition michielgerritsen/magento-project-community-edition:${{ matrix.PHP_VERSION }}-magento${{ matrix.MAGENTO_VERSION }}
2626

27+
# Create separate branch and remove version from `composer.json`.
28+
- name: Create branch for Composer and remove version from composer.json
29+
run: git checkout -b integration-test-branch && sed -i '/version/d' ./composer.json
30+
2731
# If your code is not in the root but in a subdirectory you need to change this command.
2832
# Example: If your code is in the `src` folder then you need to do this:
2933
# run: docker cp $(pwd)/src magento-project-community-edition:/data/extensions/
@@ -32,7 +36,7 @@ jobs:
3236

3337
# Replace <VENDOR> and <MODULE> with the name in your `composer.json`.
3438
- name: Install the extension in Magento
35-
run: docker exec magento-project-community-edition composer require cm/payments:"dev-${GITHUB_SHA} as 1.x-dev"
39+
run: docker exec magento-project-community-edition composer require cm/payments:dev-integration-test-branch
3640

3741
# This step is optional but good to include in your pipeline.
3842
- name: Run setup:di:compile

.github/workflows/unit-test.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ jobs:
2525
- name: Start Docker
2626
run: docker run --detach --name magento-project-community-edition michielgerritsen/magento-project-community-edition:${{ matrix.PHP_VERSION }}-magento${{ matrix.MAGENTO_VERSION }}
2727

28+
# Create separate branch and remove version from `composer.json`.
29+
- name: Create branch for Composer and remove version from composer.json
30+
run: git checkout -b unit-test-branch && sed -i '/version/d' ./composer.json
31+
2832
# If your code is not in the root but in a subdirecty you need to change this command.
2933
# Example: If your code is in the `src` folder then you need to do this:
3034
# run: docker cp $(pwd)/src magento-project-community-edition:/data/extensions/
@@ -33,7 +37,7 @@ jobs:
3337

3438
# Replace <VENDOR> and <MODULE> with the name in your `composer.json`.
3539
- name: Install the extension in Magento
36-
run: docker exec magento-project-community-edition composer require cm/payments:"dev-${GITHUB_SHA} as 1.x-dev"
40+
run: docker exec magento-project-community-edition composer require cm/payments:dev-unit-test-branch
3741

3842
# Only the tests in your repository will be run, the default Magento tests are not included in this.
3943
- name: Run tests

Api/Model/OrderRepositoryInterface.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313

1414
interface OrderRepositoryInterface
1515
{
16+
/**
17+
* @param string $incrementId
18+
* @return OrderInterface
19+
*/
20+
public function getByIncrementId(string $incrementId): OrderInterface;
21+
1622
/**
1723
* @param string $orderKey
1824
* @return OrderInterface

Api/Model/PaymentRepositoryInterface.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,16 @@ interface PaymentRepositoryInterface
1717
* @return PaymentInterface
1818
*/
1919
public function save(PaymentInterface $payment): PaymentInterface;
20+
21+
/**
22+
* @param string $orderKey
23+
* @return PaymentInterface
24+
*/
25+
public function getByOrderKey(string $orderKey): PaymentInterface;
26+
27+
/**
28+
* @param string $paymentId
29+
* @return PaymentInterface
30+
*/
31+
public function getByPaymentId(string $paymentId): PaymentInterface;
2032
}

Api/Service/OrderServiceInterface.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use CM\Payments\Api\Model\Domain\CMOrderInterface;
1212
use CM\Payments\Api\Model\Data\OrderInterface as CMOrder;
13+
use CM\Payments\Client\Api\OrderDetailInterface;
1314

1415
interface OrderServiceInterface
1516
{
@@ -19,10 +20,4 @@ interface OrderServiceInterface
1920
* @return CMOrderInterface
2021
*/
2122
public function create(string $orderId): CMOrderInterface;
22-
23-
/**
24-
* @param CMOrder $cmOrder
25-
* @return array
26-
*/
27-
public function get(CMOrder $cmOrder): array;
2823
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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\Api\Service;
10+
11+
use Magento\Framework\Exception\NoSuchEntityException;
12+
13+
interface OrderTransactionServiceInterface
14+
{
15+
/**
16+
* Process transaction
17+
*
18+
* @param string $cmOrderKey
19+
* @return void
20+
*
21+
* @throws NoSuchEntityException
22+
*/
23+
public function process(string $cmOrderKey): void;
24+
}

Api/Client/ApiClientInterface.php renamed to Client/Api/ApiClientInterface.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@
66

77
declare(strict_types=1);
88

9-
namespace CM\Payments\Api\Client;
10-
11-
use CM\Payments\Client\Api\RequestInterface;
9+
namespace CM\Payments\Client\Api;
1210

1311
interface ApiClientInterface
1412
{
1513
/**
1614
* Execute a request against the CM Payments Api.
15+
* @throws GuzzleException
1716
*/
1817
public function execute(RequestInterface $request): array;
1918
}

Client/Api/OrderDetailInterface.php

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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\Api;
10+
11+
use CM\Payments\Client\Model\Response\Payment\Payment;
12+
13+
interface OrderDetailInterface
14+
{
15+
const LEVEL_SAFE = 'SAFE';
16+
17+
/**
18+
* @return bool
19+
*/
20+
public function isSafe(): bool;
21+
22+
/**
23+
* @return Payment|null
24+
*/
25+
public function getAuthorizedPayment(): ?Payment;
26+
27+
/**
28+
* @return string
29+
*/
30+
public function getOrderReference(): string;
31+
32+
/**
33+
* @return string
34+
*/
35+
public function getExpiresOn(): string;
36+
37+
/**
38+
* @return string
39+
*/
40+
public function getDescription(): string;
41+
42+
/**
43+
* @return int
44+
*/
45+
public function getAmount(): int;
46+
47+
/**
48+
* @return string
49+
*/
50+
public function getEmail(): string;
51+
52+
/**
53+
* @return string
54+
*/
55+
public function getLanguage(): string;
56+
57+
/**
58+
* @return string
59+
*/
60+
public function getCountry(): string;
61+
62+
/**
63+
* @return string
64+
*/
65+
public function getProfile(): string;
66+
67+
/**
68+
* @return string
69+
*/
70+
public function getTimestamp(): string;
71+
72+
/**
73+
* @return array
74+
*/
75+
public function getConsideredSafe(): array;
76+
77+
/**
78+
* @return array
79+
*/
80+
public function getPayments(): array;
81+
}

Client/Api/OrderInterface.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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\Api;
10+
11+
use CM\Payments\Client\Model\Response\OrderCreate;
12+
use CM\Payments\Client\Model\Response\OrderDetail;
13+
use CM\Payments\Client\Request\OrderCreateRequest;
14+
use GuzzleHttp\Exception\RequestException;
15+
16+
interface OrderInterface
17+
{
18+
/**
19+
* @param string $orderKey
20+
* @return OrderDetail
21+
*
22+
* @throws RequestException
23+
*/
24+
public function getDetail(string $orderKey): OrderDetail;
25+
26+
/**
27+
* @param OrderCreateRequest $orderCreateRequest
28+
* @return OrderCreate
29+
*
30+
* @throws RequestException
31+
*/
32+
public function create(OrderCreateRequest $orderCreateRequest): OrderCreate;
33+
}

Client/ApiClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
namespace CM\Payments\Client;
1010

11-
use CM\Payments\Api\Client\ApiClientInterface;
11+
use CM\Payments\Client\Api\ApiClientInterface;
1212
use CM\Payments\Api\Config\ConfigInterface;
1313
use CM\Payments\Client\Api\RequestInterface;
1414
use CM\Payments\Model\AdminHtml\Source\Mode;

Client/Model/Request/PaymentCreate.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public function toArray(): array
4949
if ($this->idealDetails) {
5050
$data['ideal_details'] = $this->idealDetails;
5151
}
52+
5253
return $data;
5354
}
5455

Client/Model/Response/OrderCreate.php

Lines changed: 58 additions & 0 deletions
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+
namespace CM\Payments\Client\Model\Response;
8+
9+
class OrderCreate
10+
{
11+
/**
12+
* @var string|null
13+
*/
14+
private $url;
15+
/**
16+
* @var string|null
17+
*/
18+
private $orderKey;
19+
/**
20+
* @var string|null
21+
*/
22+
private $expiresOn;
23+
24+
/**
25+
* CMOrder constructor.
26+
* @param array $orderCreate
27+
*/
28+
public function __construct(array $orderCreate)
29+
{
30+
$this->url = $orderCreate['url'] ?? null;
31+
$this->orderKey = $orderCreate['order_key'] ?? null;
32+
$this->expiresOn = $orderCreate['expires_on'] ?? null;
33+
}
34+
35+
/**
36+
* @return string|null
37+
*/
38+
public function getUrl(): ?string
39+
{
40+
return $this->url;
41+
}
42+
43+
/**
44+
* @return string|null
45+
*/
46+
public function getExpiresOn(): ?string
47+
{
48+
return $this->expiresOn;
49+
}
50+
51+
/**
52+
* @return string|null
53+
*/
54+
public function getOrderKey(): ?string
55+
{
56+
return $this->orderKey;
57+
}
58+
}

0 commit comments

Comments
 (0)