Commit 495edf80 authored by attilak's avatar attilak

Merge branch 'develop' into PW-2212

# Conflicts:
#	Gateway/Request/CheckoutDataBuilder.php
#	view/frontend/web/template/payment/hpp-form.html
parents b1b1603c 83a35dd9
**Magento version**: x.y.z
**Plugin version**: x.y.z
**Description**
<!--
- Please provide a description of the issue. In case of bug report, please provide the necessary steps to reproduce.
- For merchant specific requests, please use https://support.adyen.com
-->
\ No newline at end of file
blank_issues_enabled: false
contact_links:
- name: Adyen Support
url: https://support.adyen.com/hc/en-us/requests/new?ticket_form_id=360000705420
about: For other questions, contact our support team
......@@ -231,6 +231,8 @@ class Redirect extends \Magento\Framework\App\Action\Action
*/
$order->addStatusHistoryComment(__('3D-secure validation was unsuccessful. This order will be cancelled when the related notification has been processed.'))->save();
$this->messageManager->addErrorMessage("3D-secure validation was unsuccessful");
// reactivate the quote
$session = $this->_getCheckout();
......
......@@ -135,6 +135,19 @@ class CheckoutDataBuilder implements BuilderInterface
$requestBody['deviceFingerprint'] = $payment->getAdditionalInformation("df_value");
}
//Boleto data
if ($payment->getAdditionalInformation("social_security_number")) {
$requestBody['socialSecurityNumber'] = $payment->getAdditionalInformation("social_security_number");
}
if ($payment->getAdditionalInformation("firstname")) {
$requestBody['shopperName']['firstName'] = $payment->getAdditionalInformation("firstname");
}
if ($payment->getAdditionalInformation("lastname")) {
$requestBody['shopperName']['lastName'] = $payment->getAdditionalInformation("lastname");
}
if ($payment->getMethod() == \Adyen\Payment\Model\Ui\AdyenBoletoConfigProvider::CODE) {
// TODO check if this is coming from the component now
/*$boletoTypes = $this->adyenHelper->getAdyenBoletoConfigData('boletotypes');
......
......@@ -63,9 +63,8 @@ class GooglePayAuthorizationDataBuilder implements BuilderInterface
$requestBody['paymentMethod']['type'] = 'paywithgoogle';
// get payment data
if ($token) {
$parsedToken = json_decode($token);
try {
$requestBody['paymentMethod']['paywithgoogle.token'] = $parsedToken;
$requestBody['paymentMethod']['paywithgoogle.token'] = $token;
} catch (\Exception $exception) {
$this->adyenLogger->addAdyenDebug("exception: " . $exception->getMessage());
}
......
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2020 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Helper;
use Magento\Framework\App\Config\ScopeConfigInterface;
class Config
{
const XML_PAYMENT_PREFIX = "payment";
const XML_ADYEN_ABSTRACT_PREFIX = "adyen_abstract";
const XML_NOTIFICATIONS_CAN_CANCEL_FIELD = "notifications_can_cancel";
/**
* @var Magento\Framework\App\Config\ScopeConfigInterface
*/
protected $scopeConfig;
/**
* Config constructor.
* @param Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
*/
public function __construct(
ScopeConfigInterface $scopeConfig
) {
$this->scopeConfig = $scopeConfig;
}
/**
* Retrieve flag for notifications_can_cancel
*
* @param int $storeId
* @return bool
*/
public function getNotificationsCanCancel($storeId = null)
{
return (bool)$this->getConfigData(
self::XML_NOTIFICATIONS_CAN_CANCEL_FIELD,
self::XML_ADYEN_ABSTRACT_PREFIX,
$storeId,
true
);
}
/**
* Retrieve information from payment configuration
*
* @param string $field
* @param string $xmlPrefix
* @param int $storeId
* @param bool|false $flag
* @return bool|mixed
*/
private function getConfigData($field, $xmlPrefix, $storeId, $flag = false)
{
$path = implode("/", [self::XML_PAYMENT_PREFIX, $xmlPrefix, $field]);
if (!$flag) {
return $this->scopeConfig->getValue($path, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
} else {
return $this->scopeConfig->isSetFlag($path, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
}
}
......@@ -86,11 +86,14 @@ class AdyenThreeDS2Process implements AdyenThreeDS2ProcessInterface
// Validate if order id is present
if (empty($payload['orderId'])) {
throw new \Magento\Framework\Exception\LocalizedException(__('3D secure 2.0 failed because of a missing order id'));
$order = $this->getOrder();
// In the next major release remove support for retrieving order from session and throw exception instead
//throw new \Magento\Framework\Exception\LocalizedException(__('3D secure 2.0 failed because of a missing order id'));
} else {
// Create order by order id
$order = $this->orderFactory->create()->load($payload['orderId']);
}
// Create order by order id
$order = $this->orderFactory->create()->load($payload['orderId']);
$payment = $order->getPayment();
......@@ -147,4 +150,18 @@ class AdyenThreeDS2Process implements AdyenThreeDS2ProcessInterface
$response['result'] = $result['resultCode'];
return json_encode($response);
}
/**
* Get order object
*
* @return \Magento\Sales\Model\Order
* @deprecated Will be removed in 7.0.0
*/
protected function getOrder()
{
$incrementId = $this->checkoutSession->getLastRealOrderId();
$order = $this->orderFactory->create()->loadByIncrementId($incrementId);
return $order;
}
}
......@@ -235,6 +235,11 @@ class Cron
*/
private $timezone;
/**
* @var \Adyen\Payment\Helper\Config
*/
protected $configHelper;
/**
* Cron constructor.
*
......@@ -282,7 +287,8 @@ class Cron
\Magento\Sales\Model\Order\Payment\Transaction\Builder $transactionBuilder,
\Magento\Framework\Serialize\SerializerInterface $serializer,
\Magento\Framework\Notification\NotifierInterface $notifierPool,
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezone
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezone,
\Adyen\Payment\Helper\Config $configHelper
) {
$this->_scopeConfig = $scopeConfig;
$this->_adyenLogger = $adyenLogger;
......@@ -307,6 +313,7 @@ class Cron
$this->serializer = $serializer;
$this->notifierPool = $notifierPool;
$this->timezone = $timezone;
$this->configHelper = $configHelper;
}
/**
......@@ -432,7 +439,9 @@ class Cron
$this->_eventCode == Notification::ORDER_CLOSED
) {
// Move the order from PAYMENT_REVIEW to NEW, so that can be cancelled
if ($this->_order->getState() === \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW) {
if ($this->_order->getState() === \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW &&
$this->configHelper->getNotificationsCanCancel($this->_order->getStoreId())
) {
$this->_order->setState(\Magento\Sales\Model\Order::STATE_NEW);
}
$this->_holdCancelOrder(false);
......@@ -829,6 +838,11 @@ class Cron
*/
protected function _holdCancelOrder($ignoreHasInvoice)
{
if (!$this->configHelper->getNotificationsCanCancel($this->_order->getStoreId())) {
$this->_adyenLogger->addAdyenNotificationCronjob('Order cannot be canceled based on the plugin configuration');
return;
}
$orderStatus = $this->_getConfigData(
'payment_cancelled',
'adyen_abstract',
......@@ -992,7 +1006,7 @@ class Cron
break;
}
if (!$this->_order->canCancel()) {
if (!$this->_order->canCancel() && $this->configHelper->getNotificationsCanCancel($this->_order->getStoreId())) {
// Move the order from PAYMENT_REVIEW to NEW, so that can be cancelled
$this->_order->setState(\Magento\Sales\Model\Order::STATE_NEW);
}
......@@ -1951,7 +1965,9 @@ class Cron
private function addNotificationErrorComment($errorMessage)
{
$comment = __('The order failed to update: %1', $errorMessage);
$this->_order->addStatusHistoryComment($comment);
$this->_order->save();
if ($this->_order) {
$this->_order->addStatusHistoryComment($comment);
$this->_order->save();
}
}
}
......@@ -50,7 +50,7 @@ We have defined this:
```
## Support
You can create issues on our Magento Repository. In case of specific problems with your account, please contact <a href="mailto:support@adyen.com">support@adyen.com</a>.
If you have a feature request, or spotted a bug or a technical problem, create a GitHub issue. For other questions, contact our [support team](https://support.adyen.com/hc/en-us/requests/new?ticket_form_id=360000705420).
## API Library
This module is using the Adyen APIs Library for PHP for all (API) connections to Adyen.
......
......@@ -2,7 +2,7 @@
"name": "adyen/module-payment",
"description": "Official Magento2 Plugin to connect to Payment Service Provider Adyen.",
"type": "magento2-module",
"version": "6.0.0",
"version": "6.1.0",
"license": [
"OSL-3.0",
"AFL-3.0"
......
......@@ -38,6 +38,7 @@
<enable_oneclick>1</enable_oneclick>
<enable_recurring>0</enable_recurring>
<group>adyen</group>
<notifications_can_cancel>1</notifications_can_cancel>
</adyen_abstract>
<adyen_cc>
<active>1</active>
......
......@@ -1042,4 +1042,34 @@
<argument name="resourceModel" xsi:type="string">Adyen\Payment\Model\ResourceModel\Notification</argument>
</arguments>
</virtualType>
<!--Sensitive and system-specific configuration-->
<type name="Magento\Config\Model\Config\TypePool">
<arguments>
<argument name="environment" xsi:type="array">
<item name="payment/adyen_abstract/demo_mode" xsi:type="string">1</item>
<item name="payment/adyen_abstract/debug" xsi:type="string">1</item>
<item name="payment/adyen_apple_pay/full_path_location_pem_file_test" xsi:type="string">1</item>
<item name="payment/adyen_apple_pay/full_path_location_pem_file_live" xsi:type="string">1</item>
</argument>
<argument name="sensitive" xsi:type="array">
<item name="payment/adyen_abstract/merchant_account" xsi:type="string">1</item>
<item name="payment/adyen_abstract/api_key_test" xsi:type="string">1</item>
<item name="payment/adyen_abstract/api_key_live" xsi:type="string">1</item>
<item name="payment/adyen_abstract/notification_username" xsi:type="string">1</item>
<item name="payment/adyen_abstract/notification_password" xsi:type="string">1</item>
<item name="payment/adyen_abstract/live_endpoint_url_prefix" xsi:type="string">1</item>
<item name="payment/adyen_pos_cloud/pos_merchant_account" xsi:type="string">1</item>
<item name="payment/adyen_pos_cloud/api_key_test" xsi:type="string">1</item>
<item name="payment/adyen_pos_cloud/api_key_live" xsi:type="string">1</item>
<item name="payment/adyen_pos_cloud/pos_store_id" xsi:type="string">1</item>
<item name="payment/adyen_pay_by_mail/skin_code" xsi:type="string">1</item>
<item name="payment/adyen_pay_by_mail/hmac_test" xsi:type="string">1</item>
<item name="payment/adyen_pay_by_mail/hmac_live" xsi:type="string">1</item>
<item name="payment/adyen_apple_pay/merchant_identifier_test" xsi:type="string">1</item>
<item name="payment/adyen_apple_pay/merchant_identifier_live" xsi:type="string">1</item>
<item name="payment/adyen_google_pay/merchant_identifier" xsi:type="string">1</item>
</argument>
</arguments>
</type>
</config>
......@@ -142,27 +142,29 @@
</div>
</fieldset>
</form>
<div class="checkout-agreements-block">
<!-- ko foreach: $parent.getRegion('before-place-order') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
</div>
<div class="actions-toolbar">
<div class="primary">
<button class="action primary checkout"
type="submit"
data-bind="
click: placeOrder,
attr: {title: $t('Place Order')},
enable: (getCode() == isChecked()),
css: {disabled: !isPlaceOrderActionAllowed()}
"
disabled>
<span data-bind="text: $t('Place Order')"></span>
</button>
<div class="checkout-agreements-block">
<!-- ko foreach: $parent.getRegion('before-place-order') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
</div>
</div>
<div class="actions-toolbar">
<div class="primary">
<button class="action primary checkout"
type="submit"
data-bind="
click: placeOrder,
attr: {title: $t('Place Order')},
enable: (getCode() == isChecked()),
css: {disabled: !isPlaceOrderActionAllowed()}
"
disabled>
<span data-bind="text: $t('Place Order')"></span>
</button>
</div>
</div>
</form>
</div>
</div>
......@@ -114,27 +114,26 @@
<!-- /ko -->
</fieldset>
</form>
<div class="checkout-agreements-block">
<!-- ko foreach: $parent.getRegion('before-place-order') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
</div>
<div class="checkout-agreements-block">
<!-- ko foreach: $parent.getRegion('before-place-order') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
</div>
<div class="actions-toolbar">
<div class="primary">
<button class="action primary checkout"
type="submit"
data-bind="click: placeOrder,
attr: {title: $t('Place Order')},
enable: isButtonActive()"
disabled>
<span data-bind="text: $t('Place Order')"></span>
</button>
<div class="actions-toolbar">
<div class="primary">
<button class="action primary checkout"
type="submit"
data-bind="click: placeOrder,
attr: {title: $t('Place Order')},
enable: isButtonActive()"
disabled>
<span data-bind="text: $t('Place Order')"></span>
</button>
</div>
</div>
</div>
</form>
</div>
</div>
......@@ -52,30 +52,35 @@
</div>
<form class="form" data-role="adyen-hpp-form" action="#" method="post" data-bind="mageInit: { 'validation':[]}, attr: {id: 'payment_form_' + $parent.getCode() + '_' + value}">
<fieldset class="fieldset" data-bind='attr: {id: "payment_fieldset_" + $parent.getCode() + "_" + value}'>
<div class="adyen-alternative-payment-container"></div>
</fieldset>
</form>
<fieldset class="fieldset" data-bind='attr: {id: "payment_fieldset_" + $parent.getCode() + "_" + value}'>
<div class="adyen-alternative-payment-container"></div>
</fieldset>
<div class="checkout-agreements-block">
<!-- ko foreach: $parents[1].getRegion('before-place-order') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
</div>
<div>
<span class="message message-error error hpp-message" data-bind="attr: {id: 'messages-' + value}"></span>
</div>
<div class="actions-toolbar">
<div class="primary">
<button class="action primary checkout"
type="submit"
data-bind="click: $parent.continueToAdyenBrandCode, enable: placeOrderAllowed() && (value == $parent.isBrandCodeChecked())"
disabled>
<span data-bind="text: $t('Place Order')"></span>
</button>
<div class="checkout-agreements-block">
<!-- ko foreach: $parents[1].getRegion('before-place-order') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
</div>
</div>
<div>
<span class="message message-error error hpp-message" data-bind="attr: {id: 'messages-' + value}"></span>
</div>
<div class="actions-toolbar">
<div class="primary">
<button class="action primary checkout"
type="submit"
data-bind="
click: $parent.continueToAdyenBrandCode,
enable: placeOrderAllowed() && (value == $parent.isBrandCodeChecked()),
css: {disabled: !$parent.isPlaceOrderActionAllowed()}"
disabled>
<span data-bind="text: $t('Place Order')"></span>
</button>
</div>
</div>
</form>
</div>
</div>
<!--/ko-->
......@@ -81,25 +81,27 @@
</div>
</fieldset>
</form>
<div class="checkout-agreements-block">
<!-- ko foreach: $parents[1].getRegion('before-place-order') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
</div>
<div class="actions-toolbar">
<div class="primary">
<button class="action primary checkout"
type="submit"
data-bind="
click: placeOrder,
attr: {title: $t('Place Order')},
enable: isButtonActive()"
disabled>
<span data-bind="text: $t('Place Order')"></span>
</button>
<div class="checkout-agreements-block">
<!-- ko foreach: $parents[1].getRegion('before-place-order') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
</div>
</div>
<div class="actions-toolbar">
<div class="primary">
<button class="action primary checkout"
type="submit"
data-bind="
click: placeOrder,
attr: {title: $t('Place Order')},
enable: isButtonActive()"
disabled>
<span data-bind="text: $t('Place Order')"></span>
</button>
</div>
</div>
</form>
</div>
</div>
<!--/ko-->
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment