Skip to content

Commit 7cd6386

Browse files
Merge pull request #51 from Itonomy/feature/CMP-123_correctly-separate-different-payment-methods
CMP-123 - Correctly separate different CC payment methods, improvements
2 parents bda7d44 + b38601b commit 7cd6386

File tree

81 files changed

+4541
-179
lines changed

Some content is hidden

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

81 files changed

+4541
-179
lines changed

Api/Config/ConfigInterface.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ interface ConfigInterface
2626
public const XML_PATH_GENERAL_MODE = 'cm_payments/general/mode';
2727
public const XML_PATH_PAYMENT_PROFILE = 'payment/cm_payments_methods/profile';
2828
public const XML_PATH_PAYMENT_CREDIT_CARD_PROFILE = 'payment/cm_payments_creditcard/profile';
29+
public const XML_PATH_PAYMENT_CREDIT_CARD_MODE = 'payment/cm_payments_creditcard/mode';
30+
public const XML_PATH_PAYMENT_CREDIT_CARD_ALLOWED_TYPES = 'payment/cm_payments_creditcard/allowed_cctypes';
2931
public const XML_PATH_PAYMENT_BANCONTACT_PROFILE = 'payment/cm_payments_bancontact/profile';
3032
public const XML_PATH_PAYMENT_AFTERPAY_PROFILE = 'payment/cm_payments_afterpay/profile';
3133
public const XML_PATH_PAYMENT_CM_PAYMENTS_PROFILE = 'payment/cm_payments/profile';
@@ -143,4 +145,33 @@ public function getOrderExpiryUnit(string $paymentMethodCode): ?string;
143145
* @throws NoSuchEntityException
144146
*/
145147
public function getOrderExpiryDuration(string $paymentMethodCode): ?string;
148+
149+
/**
150+
* Get Cart Details encrypt library
151+
*
152+
* @return string
153+
* @throws NoSuchEntityException
154+
*/
155+
public function getEncryptLibrary(): string;
156+
157+
/**
158+
* Get NSA 3D Secure library
159+
*
160+
* @return string
161+
* @throws NoSuchEntityException
162+
*/
163+
public function getNsa3dsLibrary(): string;
164+
165+
/**
166+
* @return bool
167+
*/
168+
public function isCreditCardDirect(): bool;
169+
170+
/**
171+
* Get Credit Cart Allowed Types
172+
*
173+
* @return string
174+
* @throws NoSuchEntityException
175+
*/
176+
public function getCreditCardAllowedTypes(): string;
146177
}

Api/Data/BrowserDetailsInterface.php

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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\Data;
10+
11+
/**
12+
* Interface BrowserDetailsInterface
13+
*
14+
* @api
15+
*/
16+
interface BrowserDetailsInterface
17+
{
18+
/**
19+
* Properties
20+
*/
21+
public const SHOPPER_IP = 'shopper_ip';
22+
public const ACCEPT = 'accept';
23+
public const USER_AGENT = 'user_agent';
24+
25+
/**
26+
* Get option shopperIp
27+
*
28+
* @return string|null
29+
*/
30+
public function getShopperIp(): ?string;
31+
32+
/**
33+
* Set option shopperIp
34+
*
35+
* @param string $shopperIp
36+
* @return $this
37+
*/
38+
public function setShopperIp(string $shopperIp): BrowserDetailsInterface;
39+
40+
/**
41+
* Get option accept
42+
*
43+
* @return string|null
44+
*/
45+
public function getAccept(): ?string;
46+
47+
/**
48+
* Set option accept
49+
*
50+
* @param string $accept
51+
* @return $this
52+
*/
53+
public function setAccept(string $accept): BrowserDetailsInterface;
54+
55+
/**
56+
* Get option userAgent
57+
*
58+
* @return string|null
59+
*/
60+
public function getUserAgent(): ?string;
61+
62+
/**
63+
* Set option userAgent
64+
*
65+
* @param string $userAgent
66+
* @return $this
67+
*/
68+
public function setUserAgent(string $userAgent): BrowserDetailsInterface;
69+
}

Api/Data/CardDetailsInterface.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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\Data;
10+
11+
/**
12+
* Interface CardDetailsInterface
13+
*
14+
* @api
15+
*/
16+
interface CardDetailsInterface
17+
{
18+
/**
19+
* Properties
20+
*/
21+
public const METHOD = 'method';
22+
public const ENCRYPTED_CARD_DATA = 'encrypted_card_data';
23+
24+
/**
25+
* Get option method
26+
*
27+
* @return string
28+
*/
29+
public function getMethod(): string;
30+
31+
/**
32+
* Set option method
33+
*
34+
* @param string $method
35+
* @return $this
36+
*/
37+
public function setMethod($method): CardDetailsInterface;
38+
39+
/**
40+
* Get option encryptedCardData
41+
*
42+
* @return string
43+
*/
44+
public function getEncryptedCardData(): string;
45+
46+
/**
47+
* Set option encryptedCardData
48+
*
49+
* @param string $cardData
50+
* @return $this
51+
*/
52+
public function setEncryptedCardData(string $cardData): CardDetailsInterface;
53+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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\Model\Domain;
10+
11+
interface PaymentOrderStatusInterface
12+
{
13+
/**
14+
* @return string
15+
*/
16+
public function getOrderId(): string;
17+
18+
/**
19+
* @return string
20+
*/
21+
public function getStatus(): string;
22+
}

Api/Service/MethodServiceInterface.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ interface MethodServiceInterface
2020
*/
2121
public const METHODS = [
2222
ConfigProvider::CODE_CREDIT_CARD,
23+
ConfigProvider::CODE_MAESTRO,
24+
ConfigProvider::CODE_VPAY,
2325
ConfigProvider::CODE_IDEAL,
2426
ConfigProvider::CODE_PAYPAL,
2527
ConfigProvider::CODE_BANCONTACT,
@@ -34,7 +36,8 @@ interface MethodServiceInterface
3436
public const METHODS_MAPPING = [
3537
'VISA' => ConfigProvider::CODE_CREDIT_CARD,
3638
'MASTERCARD' => ConfigProvider::CODE_CREDIT_CARD,
37-
'MAESTRO' => ConfigProvider::CODE_CREDIT_CARD,
39+
'MAESTRO' => ConfigProvider::CODE_MAESTRO,
40+
'V_PAY' => ConfigProvider::CODE_VPAY,
3841
'IDEAL' => ConfigProvider::CODE_IDEAL,
3942
'PAYPAL_EXPRESS_CHECKOUT' => ConfigProvider::CODE_PAYPAL,
4043
'BANCONTACT' => ConfigProvider::CODE_BANCONTACT,
@@ -43,6 +46,18 @@ interface MethodServiceInterface
4346
'AFTERPAY_OPEN_INVOICE' => ConfigProvider::CODE_AFTERPAY
4447
];
4548

49+
/**
50+
* Mapping of CM Credit Cards methods to Magento (by credit card type)
51+
*/
52+
public const METHODS_CC_MAPPING = [
53+
'VI' => 'VISA',
54+
'MC' => 'MASTERCARD',
55+
'MD' => 'MAESTRO',
56+
'MI' => 'MAESTRO',
57+
'AE' => 'AMEX',
58+
'VP' => 'V_PAY'
59+
];
60+
4661
/**
4762
* Mapping of Magento Payment methods to CM Api Payment methods
4863
*/

Api/Service/OrderServiceInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
interface OrderServiceInterface
1717
{
1818
/**
19-
* @param string $orderId
19+
* @param int $orderId
2020
* @return CMOrderInterface
2121
* @throws EmptyOrderKeyException
2222
* @throws LocalizedException
2323
*/
24-
public function create(string $orderId): CMOrderInterface;
24+
public function create(int $orderId): CMOrderInterface;
2525

2626
/**
2727
* @param string $orderKey

Api/Service/Payment/Request/RequestPartInterface.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,32 @@
22

33
namespace CM\Payments\Api\Service\Payment\Request;
44

5+
use CM\Payments\Api\Data\BrowserDetailsInterface;
6+
use CM\Payments\Api\Data\CardDetailsInterface;
57
use Magento\Sales\Api\Data\OrderInterface;
68
use CM\Payments\Client\Model\Request\PaymentCreate;
79

810
interface RequestPartInterface
911
{
1012
/**
11-
* @param OrderInterface $order
13+
* @param OrderInterface|null $order
14+
* @param CardDetailsInterface|null $cardDetails
15+
* @param BrowserDetailsInterface|null $browserDetails
1216
* @param PaymentCreate $paymentCreate
1317
*
1418
* @return PaymentCreate
1519
*/
16-
public function process(OrderInterface $order, PaymentCreate $paymentCreate): PaymentCreate;
20+
public function process(
21+
PaymentCreate $paymentCreate,
22+
OrderInterface $order = null,
23+
CardDetailsInterface $cardDetails = null,
24+
BrowserDetailsInterface $browserDetails = null
25+
): PaymentCreate;
26+
27+
/**
28+
* Determine if the request parts needs the order object
29+
*
30+
* @return bool
31+
*/
32+
public function needsOrder(): bool;
1733
}

Api/Service/PaymentRequestBuilderInterface.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,27 @@
88

99
namespace CM\Payments\Api\Service;
1010

11+
use CM\Payments\Api\Data\BrowserDetailsInterface;
12+
use CM\Payments\Api\Data\CardDetailsInterface;
1113
use CM\Payments\Client\Request\PaymentCreateRequest;
1214
use Magento\Sales\Api\Data\OrderInterface;
1315

1416
interface PaymentRequestBuilderInterface
1517
{
1618
/**
17-
* @param OrderInterface $order
19+
* @param string $orderId
1820
* @param string $orderKey
21+
* @param OrderInterface|null $order
22+
* @param CardDetailsInterface|null $cardDetails
23+
* @param BrowserDetailsInterface|null $browserDetails
1924
*
2025
* @return PaymentCreateRequest
2126
*/
22-
public function create(OrderInterface $order, string $orderKey): PaymentCreateRequest;
27+
public function create(
28+
string $orderId,
29+
string $orderKey,
30+
OrderInterface $order = null,
31+
CardDetailsInterface $cardDetails = null,
32+
BrowserDetailsInterface $browserDetails = null
33+
): PaymentCreateRequest;
2334
}

Api/Service/PaymentServiceInterface.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,32 @@
88

99
namespace CM\Payments\Api\Service;
1010

11+
use CM\Payments\Api\Data\BrowserDetailsInterface;
12+
use CM\Payments\Api\Data\CardDetailsInterface;
13+
use CM\Payments\Api\Model\Domain\PaymentOrderStatusInterface;
1114
use CM\Payments\Client\Api\CMPaymentInterface;
1215
use CM\Payments\Exception\EmptyPaymentIdException;
1316
use Magento\Framework\Exception\NoSuchEntityException;
1417

1518
interface PaymentServiceInterface
1619
{
1720
/**
18-
* @param string $orderId
21+
* @param int $orderId
22+
* @param CardDetailsInterface|null $cardDetails
23+
* @param BrowserDetailsInterface|null $browserDetails
1924
* @return CMPaymentInterface
2025
* @throws NoSuchEntityException
2126
* @throws EmptyPaymentIdException
2227
*/
23-
public function create(string $orderId): CMPaymentInterface;
28+
public function create(
29+
int $orderId,
30+
CardDetailsInterface $cardDetails = null,
31+
BrowserDetailsInterface $browserDetails = null
32+
): CMPaymentInterface;
33+
34+
/**
35+
* @param string $paymentId
36+
* @return PaymentOrderStatusInterface
37+
*/
38+
public function getPaymentStatus(string $paymentId): PaymentOrderStatusInterface;
2439
}

Client/Api/CMPaymentUrlInterface.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,9 @@ public function getMethod(): string;
3232
* @return string
3333
*/
3434
public function getPurpose(): string;
35+
36+
/**
37+
* @return string
38+
*/
39+
public function getParameters(): string;
3540
}

0 commit comments

Comments
 (0)