Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Commit 4310161

Browse files
IngenicoEPaymentsjenkins
authored andcommitted
Release 3.5.0.
1 parent a98899c commit 4310161

File tree

62 files changed

+1332
-1022
lines changed

Some content is hidden

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

62 files changed

+1332
-1022
lines changed

Block/Adminhtml/System/Config/Field/Merchant/Link.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function __construct(
2525
*/
2626
public function render(AbstractElement $element)
2727
{
28-
$element->setData('href', 'mailto:merchantservices@ingenico.com');
28+
$element->setData('href', 'mailto:merchantservices@worldline.com');
2929
$element->setData('value', 'Worldline ePayments - Merchant Services');
3030

3131
return parent::render($element);

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8+
## 3.5.0 - 2024-03-01
9+
10+
- Introduce "Pending Payment" status
11+
- Handle redirections to 3DS using inline flow
12+
- Create cancelled orders for 3DS rejections
13+
- Add errors to transaction table
14+
- Register cancellations
15+
- Add payment methods: Maestro, Mastercard Debit, Visa Debit, Visa Electron
16+
- Add vault support to additional cards
17+
818
## 3.4.0 - 2023-12-22
919

1020
- Resolve some issues surrounding card tokenization when using 3DS

Controller/HostedCheckoutPage/ProcessReturn.php

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Worldline\Connect\Model\Config;
1919
use Worldline\Connect\Model\ConfigInterface;
2020
use Worldline\Connect\Model\Worldline\Action\GetHostedCheckoutStatus;
21+
use Worldline\Connect\Model\Worldline\Api\ClientInterface;
2122

2223
class ProcessReturn extends Action
2324
{
@@ -44,6 +45,7 @@ class ProcessReturn extends Action
4445
*/
4546
// phpcs:ignore SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint
4647
private $logger;
48+
private ClientInterface $client;
4749

4850
/**
4951
* ProcessReturn constructor.
@@ -59,14 +61,16 @@ public function __construct(
5961
SessionManagerInterface $checkoutSession,
6062
GetHostedCheckoutStatus $checkoutStatus,
6163
ConfigInterface $config,
62-
LoggerInterface $logger
64+
LoggerInterface $logger,
65+
ClientInterface $client,
6366
) {
6467
parent::__construct($context);
6568

6669
$this->checkoutSession = $checkoutSession;
6770
$this->checkoutStatus = $checkoutStatus;
6871
$this->ePaymentsConfig = $config;
6972
$this->logger = $logger;
73+
$this->client = $client;
7074
}
7175

7276
/**
@@ -77,8 +81,10 @@ public function __construct(
7781
public function execute()
7882
{
7983
try {
80-
$hostedCheckoutId = $this->retrieveHostedCheckoutId();
81-
$order = $this->checkoutStatus->process($hostedCheckoutId);
84+
$order = $this->checkoutSession->getLastRealOrder();
85+
$getHostedCheckoutResponse = $this->client->getHostedCheckout($this->retrieveHostedCheckoutId($order));
86+
87+
$this->checkoutStatus->process($order, $getHostedCheckoutResponse);
8288

8389
// Handle order cancellation:
8490
if ($order->getState() === Order::STATE_CANCELED) {
@@ -90,14 +96,6 @@ public function execute()
9096
return $this->redirect('checkout/cart');
9197
}
9298

93-
/** @var string $transactionStatus */
94-
// phpcs:ignore SlevomatCodingStandard.Variables.UnusedVariable.UnusedVariable
95-
$transactionStatus = $order->getPayment()->getAdditionalInformation(Config::PAYMENT_STATUS_KEY);
96-
// /** @var string $info */
97-
// $info = $this->ePaymentsConfig->getPaymentStatusInfo(mb_strtolower($transactionStatus));
98-
99-
// $this->messageManager->addSuccessMessage(__('Payment status:') . ' ' . ($info ?: 'Unknown status'));
100-
10199
return $this->redirect('checkout/onepage/success');
102100
} catch (Exception $e) {
103101
$this->messageManager->addErrorMessage($e->getMessage());
@@ -129,15 +127,11 @@ private function redirect($url)
129127
* @return string
130128
* @throws NotFoundException
131129
*/
132-
private function retrieveHostedCheckoutId()
130+
private function retrieveHostedCheckoutId(Order $order)
133131
{
134132
$hostedCheckoutId = $this->getRequest()->getParam('hostedCheckoutId', false);
135-
136133
if ($hostedCheckoutId === false && $this->checkoutSession->getLastRealOrder()->getPayment() !== null) {
137-
$hostedCheckoutId = $this->checkoutSession
138-
->getLastRealOrder()
139-
->getPayment()
140-
->getAdditionalInformation(Config::HOSTED_CHECKOUT_ID_KEY);
134+
$hostedCheckoutId = $order->getPayment()->getAdditionalInformation(Config::HOSTED_CHECKOUT_ID_KEY);
141135
}
142136

143137
// $hostedCheckoutId can be false or null in error case

Controller/InlinePayment/ProcessReturn.php

Lines changed: 83 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,23 @@
99
use Magento\Framework\App\Action\Action;
1010
use Magento\Framework\App\Action\Context;
1111
use Magento\Framework\App\ResponseInterface;
12+
use Magento\Framework\Controller\Result\Redirect;
1213
use Magento\Framework\Controller\ResultFactory;
1314
use Magento\Framework\Controller\ResultInterface;
1415
use Magento\Framework\Exception\LocalizedException;
1516
use Magento\Framework\Exception\NotFoundException;
17+
use Magento\Sales\Model\Order;
1618
use Psr\Log\LoggerInterface;
1719
use Worldline\Connect\Model\Config;
1820
use Worldline\Connect\Model\ConfigInterface;
21+
use Worldline\Connect\Model\Order\OrderServiceInterface;
1922
use Worldline\Connect\Model\Worldline\Action\GetInlinePaymentStatus;
23+
use Worldline\Connect\Model\Worldline\Api\ClientInterface;
2024
use Worldline\Connect\Model\Worldline\StatusInterface;
2125

26+
use function __;
27+
use function mb_strtolower;
28+
2229
class ProcessReturn extends Action
2330
{
2431
/**
@@ -45,6 +52,13 @@ class ProcessReturn extends Action
4552
// phpcs:ignore SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint
4653
private $inlinePaymentStatus;
4754

55+
/**
56+
* @var ClientInterface
57+
*/
58+
// phpcs:ignore SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint
59+
protected $worldlineClient;
60+
private OrderServiceInterface $orderService;
61+
4862
/**
4963
* ProcessReturn constructor.
5064
*
@@ -59,27 +73,64 @@ public function __construct(
5973
Session $checkoutSession,
6074
ConfigInterface $config,
6175
LoggerInterface $logger,
62-
GetInlinePaymentStatus $getInlinePaymentStatus
76+
GetInlinePaymentStatus $getInlinePaymentStatus,
77+
ClientInterface $worldlineClient,
78+
OrderServiceInterface $orderService
6379
) {
6480
parent::__construct($context);
6581

6682
$this->checkoutSession = $checkoutSession;
6783
$this->ePaymentsConfig = $config;
6884
$this->logger = $logger;
6985
$this->inlinePaymentStatus = $getInlinePaymentStatus;
86+
$this->worldlineClient = $worldlineClient;
87+
$this->orderService = $orderService;
7088
}
7189

7290
/**
7391
* Executes when a customer returns from an inline payment that caused a redirect.
7492
*
7593
* @return ResponseInterface|ResultInterface
7694
*/
95+
// phpcs:ignore SlevomatCodingStandard.Functions.FunctionLength.FunctionLength
7796
public function execute()
7897
{
98+
$payment = $this->worldlineClient->worldlinePayment($this->retrievePaymentRefId());
99+
100+
if ($payment->status === StatusInterface::REJECTED) {
101+
/** @var Order $order */
102+
$order = $this->orderService->getByIncrementId($payment->paymentOutput->references->merchantReference);
103+
104+
$this->inlinePaymentStatus->process($order, $payment);
105+
106+
$order->setState(Order::STATE_PAYMENT_REVIEW);
107+
108+
/** @var Order\Payment $orderPayment */
109+
$orderPayment = $order->getPayment();
110+
$orderPayment->setIsTransactionClosed(true);
111+
$orderPayment->setIsTransactionDenied(true);
112+
$orderPayment->update();
113+
114+
$this->orderService->save($order);
115+
116+
$message = $this->ePaymentsConfig->getPaymentStatusInfo($payment->status);
117+
118+
$this->messageManager->addErrorMessage($message);
119+
$this->logger->error(__($message));
120+
$this->checkoutSession->restoreQuote();
121+
122+
return $this->redirect('checkout/cart');
123+
}
124+
79125
try {
80-
$paymentRefId = $this->retrievePaymentRefId();
126+
$payment = $this->worldlineClient->worldlinePayment($this->retrievePaymentRefId());
127+
128+
/** @var Order $order */
129+
$order = $this->orderService->getByIncrementId($payment->paymentOutput->references->merchantReference);
81130

82-
$order = $this->inlinePaymentStatus->process($paymentRefId);
131+
$this->inlinePaymentStatus->process($order, $payment);
132+
133+
$this->orderService->save($order);
83134

84135
/** @var string $worldlinePaymentStatus */
85136
$worldlinePaymentStatus = $order->getPayment()->getAdditionalInformation(Config::PAYMENT_STATUS_KEY);
@@ -91,10 +142,38 @@ public function execute()
91142
// phpcs:ignore SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFallbackGlobalName
92143
throw new LocalizedException($info ? __($info) : __('Unknown status'));
93144
}
145+
94146
// phpcs:ignore SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFallbackGlobalName
95147
$this->messageManager->addSuccessMessage(__('Payment status:') . ' ' . ($info ?: 'Unknown status'));
96148

97-
return $this->redirect('checkout/onepage/success');
149+
/** @var Redirect $resultRedirect */
150+
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
151+
152+
$redirectUrl = $order->getPayment()->getAdditionalInformation(Config::REDIRECT_URL_KEY);
153+
154+
if ($redirectUrl) {
155+
$order->getPayment()->setAdditionalInformation(Config::REDIRECT_URL_KEY, null);
156+
157+
$this->orderService->save($order);
158+
159+
$resultRedirect->setUrl($redirectUrl);
160+
161+
return $resultRedirect;
162+
} else {
163+
$resultRedirect->setPath('checkout/onepage/success');
164+
165+
$message = $this->ePaymentsConfig->getPaymentStatusInfo(mb_strtolower($worldlinePaymentStatus));
166+
if ($message) {
167+
// phpcs:ignore SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFallbackGlobalName, Squiz.Strings.DoubleQuoteUsage.ContainsVar
168+
$this->messageManager->addSuccessMessage(__('Payment status:') . " $message");
169+
}
170+
$resultsMessage = $order->getPayment()->getAdditionalInformation(Config::TRANSACTION_RESULTS_KEY);
171+
if ($resultsMessage) {
172+
$this->messageManager->addNoticeMessage($resultsMessage);
173+
}
174+
175+
return $this->redirect('checkout/onepage/success');
176+
}
98177
} catch (Exception $e) {
99178
$this->messageManager->addErrorMessage($e->getMessage());
100179
$this->logger->error($e->getMessage());

Gateway/Command/AcceptPaymentCommand.php

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,30 @@
55
use Ingenico\Connect\Sdk\ResponseException;
66
use Magento\Payment\Gateway\CommandInterface;
77
use Magento\Sales\Model\Order\Payment;
8-
use Worldline\Connect\Model\Worldline\Api\ClientInterface;
8+
use Worldline\Connect\Model\Worldline\Action\CapturePayment;
99

1010
class AcceptPaymentCommand implements CommandInterface
1111
{
1212
/**
13-
* @var ClientInterface
13+
* @var ApiErrorHandler
1414
*/
1515
// phpcs:ignore SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint
16-
private $worldlineClient;
16+
private $apiErrorHandler;
1717

1818
/**
19-
* @var ApiErrorHandler
19+
* @var CapturePayment
2020
*/
2121
// phpcs:ignore SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint
22-
private $apiErrorHandler;
22+
private $capturePayment;
2323

2424
/**
25-
* WorldlineCancelCommand constructor.
26-
*
27-
* @param ClientInterface $worldlineClient
2825
* @param ApiErrorHandler $apiErrorHandler
26+
* @param CapturePayment $capturePayment
2927
*/
30-
public function __construct(ClientInterface $worldlineClient, ApiErrorHandler $apiErrorHandler)
28+
public function __construct(ApiErrorHandler $apiErrorHandler, CapturePayment $capturePayment)
3129
{
32-
$this->worldlineClient = $worldlineClient;
3330
$this->apiErrorHandler = $apiErrorHandler;
31+
$this->capturePayment = $capturePayment;
3432
}
3533

3634
// phpcs:disable SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFullyQualifiedName, SlevomatCodingStandard.TypeHints.DisallowArrayTypeHintSyntax.DisallowedArrayTypeHintSyntax
@@ -46,10 +44,7 @@ public function execute(array $commandSubject)
4644
try {
4745
/** @var Payment $payment */
4846
$payment = $commandSubject['payment']->getPayment();
49-
$this->worldlineClient->worldlinePaymentAccept(
50-
$payment->getLastTransId(),
51-
$payment->getOrder()->getStoreId()
52-
);
47+
$this->capturePayment->process($payment, $payment->getOrder()->getBaseGrandTotal());
5348
} catch (ResponseException $e) {
5449
$this->apiErrorHandler->handleError($e);
5550
}

Gateway/Command/AuthorizeCommand.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\Framework\Exception\LocalizedException;
1010
use Magento\Payment\Gateway\Command\CommandException;
1111
use Magento\Payment\Gateway\CommandInterface;
12+
use Magento\Payment\Model\MethodInterface;
1213
use Magento\Sales\Api\OrderRepositoryInterface;
1314
use Magento\Sales\Model\Order;
1415
use Magento\Sales\Model\Order\Payment;
@@ -138,7 +139,7 @@ public function execute(array $commandSubject)
138139
case Config::CONFIG_INGENICO_CHECKOUT_TYPE_OPTIMIZED_FLOW:
139140
$request = $this->createPaymentRequestBuilder->build(
140141
$payment,
141-
$payment->getMethodInstance()->getConfigData('payment_action')
142+
$payment->getMethodInstance()->getConfigData('payment_action') === MethodInterface::ACTION_AUTHORIZE
142143
);
143144
$order->addCommentToStatusHistory($request->toJson());
144145
$response = $this->client->createPayment($request);
@@ -147,7 +148,10 @@ public function execute(array $commandSubject)
147148
$this->handleCreatePaymentResponse($response, $payment);
148149
break;
149150
case Config::CONFIG_INGENICO_CHECKOUT_TYPE_HOSTED_CHECKOUT:
150-
$request = $this->createHostedCheckoutRequestBuilder->build($payment, $commandSubject['paymentAction']);
151+
$request = $this->createHostedCheckoutRequestBuilder->build(
152+
$payment,
153+
$commandSubject['paymentAction'] === MethodInterface::ACTION_AUTHORIZE
154+
);
151155
$order->addCommentToStatusHistory($request->toJson());
152156
$response = $this->client->createHostedCheckout($request, $order->getStoreId());
153157
$order->addCommentToStatusHistory($response->toJson());
@@ -186,6 +190,9 @@ private function handleCreatePaymentResponse(
186190
$amount = $order->getBaseGrandTotal();
187191

188192
switch ($paymentResponse->status) {
193+
case StatusInterface::REDIRECTED:
194+
$payment->setOrderState(Order::STATE_PENDING_PAYMENT);
195+
break;
189196
case StatusInterface::PENDING_APPROVAL:
190197
case StatusInterface::AUTHORIZATION_REQUESTED:
191198
$order->setState(Order::STATE_PENDING_PAYMENT);

Gateway/Command/Card/AuthorizeCaptureCommand.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,15 @@
55
namespace Worldline\Connect\Gateway\Command\Card;
66

77
use Magento\Payment\Gateway\CommandInterface;
8-
use Magento\Payment\Model\MethodInterface;
9-
use Magento\Sales\Model\Order;
108
use Magento\Sales\Model\Order\Payment;
119
use Worldline\Connect\Model\Config;
12-
use Worldline\Connect\Model\Worldline\Action\AuthorizeCapturePayment;
1310
use Worldline\Connect\Model\Worldline\Action\CreateHostedCheckout;
11+
use Worldline\Connect\Model\Worldline\Action\CreatePayment;
1412

1513
class AuthorizeCaptureCommand implements CommandInterface
1614
{
1715
public function __construct(
18-
private readonly AuthorizeCapturePayment $authorizeCapturePayment,
16+
private readonly CreatePayment $createPayment,
1917
private readonly CreateHostedCheckout $createHostedCheckout
2018
) {
2119
}
@@ -24,15 +22,12 @@ public function execute(array $commandSubject): void
2422
{
2523
/** @var Payment $payment */
2624
$payment = $commandSubject['payment']->getPayment();
27-
$payment->setIsTransactionClosed(true);
28-
$payment->getOrder()->setState(Order::STATE_PROCESSING);
29-
$payment->getOrder()->setStatus(Order::STATE_PROCESSING);
3025

3126
match ($payment->getMethodInstance()->getConfigData('payment_flow')) {
3227
Config::CONFIG_INGENICO_CHECKOUT_TYPE_OPTIMIZED_FLOW =>
33-
$this->authorizeCapturePayment->process($payment),
28+
$this->createPayment->process($payment, false),
3429
Config::CONFIG_INGENICO_CHECKOUT_TYPE_HOSTED_CHECKOUT =>
35-
$this->createHostedCheckout->process($payment, MethodInterface::ACTION_AUTHORIZE_CAPTURE),
30+
$this->createHostedCheckout->process($payment, false),
3631
};
3732
}
3833
}

0 commit comments

Comments
 (0)