Skip to content

Commit

Permalink
[PW-7285][PW-7149] - Align Magento api call timeout with POS device (#…
Browse files Browse the repository at this point in the history
…1761)

* PW-7149 - Stop using order as a private data member and instead pass it around between functions

* PW-7149 - Update PosCloudBackendBuilder to set the reservedOrderId on the quote

* Revert "PW-7149 - Update PosCloudBackendBuilder to set the reservedOrderId on the quote"

This reverts commit 287197f.

* Recurring payments added functionality (#1729)

* PW-6764 - Delete TransactionAuthorization class and start using checkout to process payments using vault tokens

* PW-6764 - Create new AdyenPaymentMethod model, repository and data patch

* PW-6764 - Move function to build payment method recurring data to vault helper. Also create ResourceModel

* PW-6764 - Add try catch block to function in Vault

* PW-6764 - Save paypal token in vault table

* PW-6764 - Create new exception. Add creation logic to CheckoutPaymentsDetailsHandler. Move validation in the getVaultPaymentMethodToken function

* PW-6764 - Do not force exception

* PW-6764 - Create function to check if recurringDetailReference is included in response

* PW-6764 - Update AdyenHppObserver to add string in additionalData to ensure that token is visible, IF it is eventually created

* PW-6764 - Setup functionality to display a payment method in the checkout page

* PW-6764 - Create new paymentMethodVault which will be used to ensure that for hpp tokens, no initialization is required

* PW-6764 - Create PayPal tokens w/type=Account and the brand in the details column

* PW-6764 - Update PaymentMethodRenderer

* PW-6764 - Add exception handling around createAdyenPaymentMethod function

* PW-6764 - Create new vault data builder to be used for hpp methods. Also save the tokenType when it is created and then re-use it when token is to be re-used

* PW-6764 - Add functionality to only CardOnFile payment method tokens, in checkout

* PW-6764 - Add instantPurchase functionality to Payment Methods

* PW-6764 - Add SEPA

* PW-6764 - Update admin tooltip. Rename functions in Vault helper to make it clear which one is used for what

* PW-6764 - Update label shown in checkout page

* PW-6764 - Run upgrade scripts on newer version

* PW-6764 - Create new observer which will call Adyen to disable a token, after it is disabled on magento side

* PW-6764 - Add exception handling to disable call

* PW-6764 - Update shopper template

* PW-6764 - Add function to check if provider is a recurring one and use it to send the shopper interaction

* PW-6764 - Split enableRecurring in payment methods to enableSubscription And enableCardOnFile. Use either, depending on what token type is in use

* PW-6790 - Move functionality to get the creditcard types to the paymentMethods Helper. Also create new payment method class for googlepay

* PW-6790 - Create new parent uiComponentProvider to be able to render the card provider even in the hpp provider (used for googlepay, applepay)

* PW-6790 - Render card tokens created with googlepay in the card section, on the user page

* PW-6790 - Remove useless methods from PaymentMethodInterface

* PW-6790 - Add token handling in the PaymentResponseHandler and update vault to not need the object payment method

* PW-6790 - Add isWallet function and use it for GooglePay

* PW-6790 - Add Apple pay classes

* PW-6790 - Create Abstract token formatter for instantPurchase, to show card formatting if a wallet payment (googlepay) was used

* PW-6790 - Update admin area tooltip

* PW-6790 - Remove unnecessary dependencies

* PW-6790 - Remove RecurringPmVaultDataBuilder and use the normal vault data builder instead

* PW-6790 - Remove SEPA related code that was previously unused

* [PW-6858] Add multiselect config for selecting which PMs to tokenize (#1605)

* [PW-6858] add config for selecting payment methods that should be tokenized

* [PW-6858] remove adyenpaymentmethods patch script

* [PW-6858] update property declaration syntax to support php 7.3

* Add UnscheduledCardOnFile for alternative payment methods (#1612)

* [PW-6910] Add functionality to tokenize AmazonPay payments (#1621)

* Add amazon pay payment method

* Add the payment method from statedata

* Update statedata property name as there is another statedata in the same class

* Add get variant method to statedata helper

* [PW-6974] - Handle tokenizations on wallet methods with the correct txVariant  (#1668)

* PW-6974 - Refactor payment method classes by creating a TxVariant class and an AbstractWalletPaymentMethod

* PW-6974 - Move functionality from CheckoutPaymentsDetailsHandler to VaultDetailsHandler. Update Vault function to save card type and wallet type

* PW-6974 - Update paymentMethod factory

* PW-6974 - Remove isWalletPaymentMethod function and instead check the instance of the object

* PW-6974 - Add comment to admin interface

* PW-6974 - Move IS_ACTIVE flag to vault handler. Also do not allow ApplePay to be selected for now, since it cannot be tested yet

* PW-6974 - Update comment

* PW-6974 - Remove SEPA specific field when handling webhook

* PW-6974 - Add signature to files

* [PW-6785] - Coverage report for SonarCloud (#1665)

* [PW-6785] - Coverage report for SonarCloud

* [PW-6785] - Coverage report for SonarCloud

* [PW-6785] - Coverage report for SonarCloud

* [PW-6785] - Coverage report for SonarCloud

* [PW-6785] - Coverage report for SonarCloud

* [PW-6785] - Coverage report for SonarCloud

* [PW-6785] - Coverage report for SonarCloud

* [PW-6785] - Coverage report for SonarCloud

* [PW-6785] - Coverage report for SonarCloud

* [PW-6785] - Refactor phpunit.xml for configuration and main.yml for pipeline

* [PW-6785] - Add sonar-project.properties file

* [PW-6785] - Remove sonar analysis from CI

* [PW-6785] - Remove unnecessary dependencies

* [PW-6785] - Coverage test function

* [PW-6785] - Enable CI based sonar analysis

* [PW-6785] - Code formatting

* [PW-6785] - Temporarily disable PHP8.1 matrix

* [PW-6785] - Change allowed list for scan

* [PW-6785] - Change allowed list for scan

* [PW-6785] - Exclude vendor directory from sonar analysis

* [PW-6785] - Remove the filter for sonar analysis and include all the project files

* [PW-6785] - Revert commits 6f6ca5d and bd74dd3

* [PW-7021] - Add failure counter for pay by link attempts (#1667)

* [PW-7021] - Add failure counter for pay by link attempts

* Update Helper/Webhook/AuthorisationWebhookHandler.php

Co-authored-by: Michael Paul <michael.paul@adyen.com>

* Update Helper/Webhook/AuthorisationWebhookHandler.php

Co-authored-by: Michael Paul <michael.paul@adyen.com>

* [PW-7021] - Code formatting

Co-authored-by: Michael Paul <michael.paul@adyen.com>

* Revert "[PW-6785] - Coverage report for SonarCloud (#1665)" (#1671)

This reverts commit f053b6f.

* Fix issue where CC vault tokens were not being created

* [PW-7100] Add CardOnFile and UnshceduledCardOnFile to Vault Card (#1693)

* update recurring_card_token_type in adyen_oneclick to show all contract types if vault is selected

* abstract recurring type value passed to buildCardRecurringData(), save tokenType in details field

* update TokenUiComponentProvider to display token if condition is met

* cleanup comment in the header

* add new template an js file for vault

* add interceptor that returns filtered customer session tokens

* remove banner

Co-authored-by: Michael Paul <michael.paul@adyen.com>

* remove comment

* update unit tests

* use different function for checking whether the value for tokenType is set

Co-authored-by: Jeantwan Teuma <Morerice@users.noreply.github.com>

* update tooltip for adyen_oneclick

Co-authored-by: Jeantwan Teuma <Morerice@users.noreply.github.com>

* update return type of afterGetCustomerSessionTokens function

Co-authored-by: Michael Paul <michael.paul@adyen.com>
Co-authored-by: Jeantwan Teuma <Morerice@users.noreply.github.com>

* [PW-7179] - Adjust vault tokenization functionality (#1709)

* PW-7179 - Re-add parent AdyenUiComponentProvider

* PW-7179 - Check if property exists before checking type

* PW-7179 - Fix issue created in merge commit and update PaymentVaultDeleteToken

* PW-7179 - Do not show ApplePay and AmazonPay for now. Also add to do annotations for them

* [PW-7157]Add India live prefix for frontend (#1708)

* Add India live prefix for frontend

* revert adyen-methods.js

Co-authored-by: Jeantwan Teuma <Morerice@users.noreply.github.com>

* PW-7179 - Move tooltip to comment

* PW-7129: Remove full request/response logging (#1712)

* PW-7129: Remove full request/response logging

Add new log processors to help with troubleshooting.

* PW-7129: Use context placeholders

* Adding number format to getAmountIncludingTax in test (#1715)

* Adding number format to getAmountIncludingTax in test

* Apply number format on getTaxAmount

Co-authored-by: Alexandros Moraitis <alexandros.moraitis@adyen.com>
Co-authored-by: Michael Paul <michael.paul@adyen.com>
Co-authored-by: Ángel Campos <angel.campos@adyen.com>

* recurring-changes - Remove unused paymentMethodsHelper

* Remove duplicate AdyenPaymentHppFacade

* Update formatting due to code smells

* More updates related to code smells

Co-authored-by: Peter Ojo <peterojo@users.noreply.github.com>
Co-authored-by: Alexandros Moraitis <alexandros.moraitis@adyen.com>
Co-authored-by: Can Demiralp <ecandemiralp@gmail.com>
Co-authored-by: Michael Paul <michael.paul@adyen.com>
Co-authored-by: Rok Popov Ledinski <rok.popovledinski@adyen.com>
Co-authored-by: Ángel Campos <angel.campos@adyen.com>

* [PW-7268] Change the way we are comparing payment amounts in handleCaptureWebhook() (#1751)

* use formatAmount() on $order and change comparison for $isFullAmountCaptured

* remove code smell

* [PW-7214] - Implement combo card funding source selection for POS payments in the frontend (#1749)

* [PW-7214] - Implement combo card funding source selection for POS payments in the frontend

* [PW-7214] - Code formatting

* [PW-7234] - CS code formatting

Co-authored-by: Jeantwan Teuma <Morerice@users.noreply.github.com>

* [PW-7275] - Add the hmac key field to the manual configuration mode (#1755)

* PW-7278 Fix HPP Naming for Ratepay (#1757)

* [PW-7278] Fix Ratepay Name in Admin HTML

* [PW-7270] - Allow auto configuration on test environment without webhook & hmac key (#1756)

* Version bump

* [PW-7234] - Update regular expression for address parsing (#1753)

* [PW-7234] - Update regular expression

* [PW-7234] - Update regex condition

* [PW-7234] - Update regex

* [PW-7234] - Update regex

* [PW-7234] - Code formatting

* [PW-7234] - Code formatting

* [PW-7234] - Update regex

Co-authored-by: Alexandros Moraitis <alexandros.moraitis@adyen.com>

* PW-7149 - Do not use deprecated function to get pos config data. Use the totalTimeout which by default will be 120

* PW-7149 - Create new PosException and surround plugin if condition with strval

* PW-7149 - Fix long line code smells

Co-authored-by: jeant <>
Co-authored-by: Peter Ojo <peterojo@users.noreply.github.com>
Co-authored-by: Alexandros Moraitis <alexandros.moraitis@adyen.com>
Co-authored-by: Can Demiralp <ecandemiralp@gmail.com>
Co-authored-by: Michael Paul <michael.paul@adyen.com>
Co-authored-by: Rok Popov Ledinski <rok.popovledinski@adyen.com>
Co-authored-by: Ángel Campos <angel.campos@adyen.com>
Co-authored-by: raoulritter <59527829+raoulritter@users.noreply.github.com>
  • Loading branch information
8 people committed Oct 10, 2022
1 parent df47757 commit a72ed17
Show file tree
Hide file tree
Showing 15 changed files with 199 additions and 209 deletions.
18 changes: 18 additions & 0 deletions Exception/PosException.php
@@ -0,0 +1,18 @@
<?php
/**
*
* Adyen Payment Module
*
* @author Adyen BV <support@adyen.com>
* @copyright (c) 2022 Adyen B.V.
* @license https://opensource.org/licenses/MIT MIT license
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*/

namespace Adyen\Payment\Exception;

class PosException extends AbstractAdyenException
{

}
35 changes: 18 additions & 17 deletions Gateway/Http/Client/TransactionPosCloudBackendSync.php
Expand Up @@ -14,6 +14,7 @@

use Adyen\AdyenException;
use Adyen\Client;
use Adyen\Payment\Helper\Config;
use Adyen\Payment\Helper\Data;
use Adyen\Payment\Logger\AdyenLogger;
use Magento\Framework\Exception\LocalizedException;
Expand All @@ -24,40 +25,40 @@

class TransactionPosCloudBackendSync implements ClientInterface
{
/**
* @var int
*/
/** @var int */
protected $storeId;

/**
* @var Client
*/
/** @var int */
protected $timeout;

/** @var Client */
protected $client;

/**
* @var Data
*/
/** @var Data */
protected $adyenHelper;

/**
* @var AdyenLogger
*/
/** @var AdyenLogger */
protected $adyenLogger;

/** @var Config */
protected $configHelper;

public function __construct(
Data $adyenHelper,
AdyenLogger $adyenLogger,
StoreManagerInterface $storeManager
StoreManagerInterface $storeManager,
Config $configHelper
) {
$this->adyenHelper = $adyenHelper;
$this->adyenLogger = $adyenLogger;
$this->configHelper = $configHelper;

$this->storeId = $storeManager->getStore()->getId();
$apiKey = $this->adyenHelper->getPosApiKey($this->storeId);
$client = $this->adyenHelper->initializeAdyenClient($this->storeId, $apiKey);
$posTimeout = $this->adyenHelper->getAdyenPosCloudConfigData('pos_timeout', $this->storeId);
if (!empty($posTimeout)) {
$client->setTimeout($posTimeout);
$this->timeout = $this->configHelper->getAdyenPosCloudConfigData('total_timeout', $this->storeId);
if (!empty($this->timeout)) {
$client->setTimeout($this->timeout);
}

$this->client = $client;
Expand All @@ -77,7 +78,7 @@ public function placeRequest(TransferInterface $transferObject): array
$initiateDate = $request['initiateDate'];

$statusDate = date("U");
$totalTimeout = $this->adyenHelper->getAdyenPosCloudConfigData('total_timeout', $this->storeId);
$totalTimeout = $this->configHelper->getAdyenPosCloudConfigData('total_timeout', $this->storeId);

// Make sync payments call to Adyen
$this->initiatePosPayment($paymentServiceRequest);
Expand Down
41 changes: 18 additions & 23 deletions Gateway/Http/Client/TransactionPosCloudSync.php
Expand Up @@ -3,7 +3,7 @@
*
* Adyen Payment Module
*
* Copyright (c) 2018 Adyen B.V.
* Copyright (c) 2022 Adyen B.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*
Expand All @@ -14,42 +14,36 @@

use Adyen\AdyenException;
use Adyen\Payment\Helper\ChargedCurrency;
use Adyen\Payment\Helper\Config;
use Adyen\Payment\Helper\Data;
use Adyen\Payment\Helper\PaymentMethods;
use Adyen\Payment\Helper\PointOfSale;
use Adyen\Payment\Logger\AdyenLogger;
use Adyen\Payment\Model\Ui\AdyenPosCloudConfigProvider;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Payment\Gateway\Http\ClientInterface;
use Magento\Checkout\Model\Session;
use Magento\Payment\Gateway\Http\TransferInterface;
use Magento\Quote\Api\Data\CartInterface;
use Magento\Quote\Model\Quote;
use Magento\Store\Model\StoreManagerInterface;

class TransactionPosCloudSync implements ClientInterface
{
/**
* @var int
*/
/** @var int */
protected $storeId;

/**
* @var \Adyen\Client
*/
/** @var int */
protected $timeout;

/** @var \Adyen\Client */
protected $client;

/**
* @var Data
*/
/** @var Data */
protected $adyenHelper;

/**
* @var AdyenLogger
*/
/** @var AdyenLogger */
protected $adyenLogger;

/** @var Config */
protected $configHelper;

/** @var Session */
private $session;

Expand All @@ -66,13 +60,15 @@ public function __construct(
Session $session,
ChargedCurrency $chargedCurrency,
PointOfSale $pointOfSale,
Config $configHelper,
array $data = []
) {
$this->adyenHelper = $adyenHelper;
$this->adyenLogger = $adyenLogger;
$this->session = $session;
$this->pointOfSale = $pointOfSale;
$this->chargedCurrency = $chargedCurrency;
$this->configHelper = $configHelper;

$this->storeId = $storeManager->getStore()->getId();

Expand All @@ -82,9 +78,9 @@ public function __construct(
$client = $this->adyenHelper->initializeAdyenClient($this->storeId, $apiKey);

//Set configurable option in M2
$posTimeout = $this->adyenHelper->getAdyenPosCloudConfigData('pos_timeout', $this->storeId);
if (!empty($posTimeout)) {
$client->setTimeout($posTimeout);
$this->timeout = $this->configHelper->getAdyenPosCloudConfigData('total_timeout', $this->storeId);
if (!empty($this->timeout)) {
$client->setTimeout($this->timeout);
}

$this->client = $client;
Expand All @@ -105,7 +101,6 @@ public function placeRequest(TransferInterface $transferObject): array
$service = $this->adyenHelper->createAdyenPosPaymentService($this->client);
$newServiceID = date("dHis");
$statusDate = date("U");

$terminalId = $request['terminalID'];

if (array_key_exists('chainCalls', $request)) {
Expand All @@ -122,7 +117,7 @@ public function placeRequest(TransferInterface $transferObject): array
$serviceId = $request['serviceID'];
}

$totalTimeout = $this->adyenHelper->getAdyenPosCloudConfigData('total_timeout', $this->storeId);
$totalTimeout = $this->configHelper->getAdyenPosCloudConfigData('total_timeout', $this->storeId);
if ($timeDiff > $totalTimeout) {
throw new LocalizedException(__("POS connection timed out."));
}
Expand Down
6 changes: 6 additions & 0 deletions Helper/Config.php
Expand Up @@ -44,6 +44,7 @@ class Config
const XML_STATUS_FRAUD_MANUAL_REVIEW = 'fraud_manual_review_status';
const XML_STATUS_FRAUD_MANUAL_REVIEW_ACCEPT = 'fraud_manual_review_accept_status';
const XML_MOTO_MERCHANT_ACCOUNTS = 'moto_merchant_accounts';
const XML_ADYEN_POS_CLOUD = 'adyen_pos_cloud';

/**
* @var ScopeConfigInterface
Expand Down Expand Up @@ -467,6 +468,11 @@ public function getAutoCaptureOpenInvoice(int $storeId): bool
return $this->getConfigData('auto_capture_openinvoice', self::XML_ADYEN_ABSTRACT_PREFIX, $storeId, true);
}

public function getAdyenPosCloudConfigData(string $field, int $storeId = null, bool $flag = false)
{
return $this->getConfigData($field, self::XML_ADYEN_POS_CLOUD, $storeId, $flag);
}

/**
* Retrieve information from payment configuration
*
Expand Down
8 changes: 4 additions & 4 deletions Helper/Data.php
Expand Up @@ -1355,14 +1355,14 @@ public function getOpenInvoiceLineData(
public function getPosApiKey($storeId = null)
{
if ($this->isDemoMode($storeId)) {
$encryptedApiKeyTest = $this->getAdyenPosCloudConfigData('api_key_test', $storeId);
$encryptedApiKeyTest = $this->configHelper->getAdyenPosCloudConfigData('api_key_test', $storeId);
if (is_null($encryptedApiKeyTest)) {
return null;
}

$apiKey = $this->_encryptor->decrypt(trim($encryptedApiKeyTest));
} else {
$encryptedApiKeyLive = $this->getAdyenPosCloudConfigData('api_key_live', $storeId);
$encryptedApiKeyLive = $this->configHelper->getAdyenPosCloudConfigData('api_key_live', $storeId);
if (is_null($encryptedApiKeyLive)) {
return null;
}
Expand All @@ -1380,7 +1380,7 @@ public function getPosApiKey($storeId = null)
*/
public function getPosStoreId($storeId = null)
{
return $this->getAdyenPosCloudConfigData('pos_store_id', $storeId);
return $this->configHelper->getAdyenPosCloudConfigData('pos_store_id', $storeId);
}

/**
Expand All @@ -1399,7 +1399,7 @@ public function getAdyenMerchantAccount($paymentMethod, $storeId = null)
}

$merchantAccount = $this->getAdyenAbstractConfigData("merchant_account", $storeId);
$merchantAccountPos = $this->getAdyenPosCloudConfigData('pos_merchant_account', $storeId);
$merchantAccountPos = $this->configHelper->getAdyenPosCloudConfigData('pos_merchant_account', $storeId);

if ($paymentMethod == 'adyen_pos_cloud' && !empty($merchantAccountPos)) {
return $merchantAccountPos;
Expand Down
11 changes: 11 additions & 0 deletions Helper/Order.php
Expand Up @@ -609,6 +609,17 @@ public function refundOrder(MagentoOrder $order, Notification $notification): Ma
return $order;
}

public function getOrderByIncrementId(string $incrementId): ?MagentoOrder
{
$searchCriteria = $this->searchCriteriaBuilder
->addFilter('increment_id', $incrementId)
->create();

$orders = $this->orderRepository->getList($searchCriteria)->getItems();

return reset($orders);
}

/**
* If the payment_authorized_virtual config is set, return the virtual status
*
Expand Down
2 changes: 1 addition & 1 deletion Helper/PaymentMethods.php
Expand Up @@ -684,7 +684,7 @@ public function isAutoCapture(Order $order, string $notificationPaymentMethod):
}

if ($paymentCode == "adyen_pos_cloud") {
$captureModePos = $this->adyenHelper->getAdyenPosCloudConfigData(
$captureModePos = $this->configHelper->getAdyenPosCloudConfigData(
'capture_mode_pos',
$order->getStoreId()
);
Expand Down
21 changes: 9 additions & 12 deletions Helper/PointOfSale.php
Expand Up @@ -19,26 +19,23 @@

class PointOfSale
{
/**
* @var Data
*/
/** @var Data */
private $dataHelper;

/**
* @var ProductMetadataInterface
*/
/** @var ProductMetadataInterface */
private $productMetadata;

/**
* @param \Adyen\Payment\Helper\Data $dataHelper
* @param ProductMetadataInterface $productMetadata
*/
/** @var Config */
protected $configHelper;

public function __construct(
Data $dataHelper,
ProductMetadataInterface $productMetadata
ProductMetadataInterface $productMetadata,
Config $configHelper
) {
$this->dataHelper = $dataHelper;
$this->productMetadata = $productMetadata;
$this->configHelper = $configHelper;
}

/**
Expand Down Expand Up @@ -68,7 +65,7 @@ public function addSaleToAcquirerData($request, Quote $quote = null, Order $orde

// If customer exists add it into the request to store request
if (!empty($customerId)) {
$recurringContract = $this->dataHelper->getAdyenPosCloudConfigData('recurring_type', $storeId);
$recurringContract = $this->configHelper->getAdyenPosCloudConfigData('recurring_type', $storeId);

if (!empty($recurringContract) && !empty($shopperEmail)) {
$saleToAcquirerData['shopperEmail'] = $shopperEmail;
Expand Down

0 comments on commit a72ed17

Please sign in to comment.