We will be off from 27/1 (Monday) to 31/1 (Friday) (GMT +7) for our Tet Holiday (Lunar New Year) in our country

Commit 01469611 authored by Rik ter Beek's avatar Rik ter Beek Committed by GitHub

Merge pull request #191 from Adyen/develop

2.1.2 hotfix release
parents 81a7ce1e fbb6d058
......@@ -200,7 +200,7 @@ class Redirect extends \Magento\Payment\Block\Form
$countryCode = trim($this->_adyenHelper->getAdyenHppConfigData('country_code'));
$countryCode = (!empty($countryCode)) ? $countryCode : false;
// if directory lookup is enabled use the billingadress as countrycode
// if directory lookup is enabled use the billingaddress as countrycode
if ($countryCode == false) {
if ($this->_order->getBillingAddress() &&
$this->_order->getBillingAddress()->getCountryId() != "") {
......
......@@ -287,9 +287,12 @@ class Json extends \Magento\Framework\App\Action\Action
$pspReference = trim($response['pspReference']);
$eventCode = trim($response['eventCode']);
$success = trim($response['success']);
$originalReference = null;
if(isset($response['originalReference'])) {
$originalReference = trim($response['originalReference']);
}
$notification = $this->_objectManager->create('Adyen\Payment\Model\Notification');
return $notification->isDuplicate($pspReference, $eventCode, $success);
return $notification->isDuplicate($pspReference, $eventCode, $success, $originalReference);
}
/**
......@@ -297,22 +300,25 @@ class Json extends \Magento\Framework\App\Action\Action
*/
protected function _fixCgiHttpAuthentication()
{
if (isset($_SERVER['REDIRECT_REMOTE_AUTHORIZATION']) &&
// do nothing if values are already there
if(!empty($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_PW'])) {
return;
} elseif (isset($_SERVER['REDIRECT_REMOTE_AUTHORIZATION']) &&
$_SERVER['REDIRECT_REMOTE_AUTHORIZATION'] != '') {
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) =
explode(':', base64_decode($_SERVER['REDIRECT_REMOTE_AUTHORIZATION']));
explode(':', base64_decode($_SERVER['REDIRECT_REMOTE_AUTHORIZATION']),2);
} elseif (!empty($_SERVER['REDIRECT_HTTP_AUTHORIZATION'])) {
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) =
explode(':', base64_decode(substr($_SERVER['REDIRECT_HTTP_AUTHORIZATION'], 6)));
explode(':', base64_decode(substr($_SERVER['REDIRECT_HTTP_AUTHORIZATION'], 6)),2);
} elseif (!empty($_SERVER['HTTP_AUTHORIZATION'])) {
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) =
explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6)));
explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6)),2);
} elseif (!empty($_SERVER['REMOTE_USER'])) {
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) =
explode(':', base64_decode(substr($_SERVER['REMOTE_USER'], 6)));
explode(':', base64_decode(substr($_SERVER['REMOTE_USER'], 6)),2);
} elseif (!empty($_SERVER['REDIRECT_REMOTE_USER'])) {
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) =
explode(':', base64_decode(substr($_SERVER['REDIRECT_REMOTE_USER'], 6)));
explode(':', base64_decode(substr($_SERVER['REDIRECT_REMOTE_USER'], 6)),2);
}
}
......
......@@ -89,10 +89,11 @@ class Validate3d extends \Magento\Framework\App\Action\Action
if ($order->getPayment()) {
$active = $order->getPayment()->getAdditionalInformation('3dActive');
$success = $order->getPayment()->getAdditionalInformation('3dSuccess');
}
// check if 3D secure is active. If not just go to success page
if ($active) {
if ($active && $success != true) {
$this->_adyenLogger->addAdyenResult("3D secure is active");
......@@ -131,6 +132,7 @@ class Validate3d extends \Magento\Framework\App\Action\Action
$order->addStatusHistoryComment(__('3D-secure validation was successful'))->save();
// set back to false so when pressed back button on the success page it will reactivate 3D secure
$order->getPayment()->setAdditionalInformation('3dActive', '');
$order->getPayment()->setAdditionalInformation('3dSuccess', true);
$this->_orderRepository->save($order);
$this->_redirect('checkout/onepage/success', ['_query' => ['utm_nooverride' => '1']]);
......
......@@ -770,6 +770,11 @@ class Data extends AbstractHelper
}
}
public function getRatePayId()
{
return $this->getAdyenHppConfigData("ratepay_id");
}
/**
* For Klarna And AfterPay use VatCategory High others use none
*
......
This diff is collapsed.
......@@ -48,7 +48,7 @@ class Adapter extends Method\Adapter
* @param PaymentDataObjectFactory $paymentDataObjectFactory
* @param string $code
* @param string $formBlockType
* @param CommandPoolInterface $infoBlockType
* @param string $infoBlockType
* @param CommandPoolInterface|null $commandPool
* @param ValidatorPoolInterface|null $validatorPool
* @param CommandManagerInterface|null $commandExecutor
......
......@@ -84,11 +84,12 @@ class Notification extends \Magento\Framework\Model\AbstractModel
* @param $pspReference
* @param $eventCode
* @param $success
* @param $originalReference
* @return bool (true if the notification is a duplicate)
*/
public function isDuplicate($pspReference, $eventCode, $success)
public function isDuplicate($pspReference, $eventCode, $success, $originalReference)
{
$result = $this->getResource()->getNotification($pspReference, $eventCode, $success);
$result = $this->getResource()->getNotification($pspReference, $eventCode, $success, $originalReference);
return (empty($result)) ? false : true;
}
......
......@@ -40,15 +40,17 @@ class Notification extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
* @param $pspReference
* @param $eventCode
* @param $success
* @param $originalReference
* @return array
*/
public function getNotification($pspReference, $eventCode, $success)
public function getNotification($pspReference, $eventCode, $success, $originalReference)
{
$select = $this->getConnection()->select()
->from(['notification' => $this->getTable('adyen_notification')])
->where('notification.pspreference=?', $pspReference)
->where('notification.event_code=?', $eventCode)
->where('notification.success=?', $success);
->where('notification.success=?', $success)
->where('notification.original_reference=?', $originalReference);
return $this->getConnection()->fetchAll($select);
}
}
\ No newline at end of file
......@@ -59,6 +59,10 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
*/
protected $_customerSession;
/**
* @var \Magento\Checkout\Model\Session
*/
protected $_session;
/**
* AdyenHppConfigProvider constructor.
......@@ -68,23 +72,26 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
* @param \Magento\Framework\App\RequestInterface $request
* @param \Magento\Framework\UrlInterface $urlBuilder
* @param \Magento\Customer\Model\Session $customerSession
* @param \Magento\Checkout\Model\Session $session
*/
public function __construct(
PaymentHelper $paymentHelper,
\Adyen\Payment\Helper\Data $adyenHelper,
\Magento\Framework\App\RequestInterface $request,
\Magento\Framework\UrlInterface $urlBuilder,
\Magento\Customer\Model\Session $customerSession
\Magento\Customer\Model\Session $customerSession,
\Magento\Checkout\Model\Session $session
) {
$this->_paymentHelper = $paymentHelper;
$this->_adyenHelper = $adyenHelper;
$this->_request = $request;
$this->_urlBuilder = $urlBuilder;
$this->_customerSession = $customerSession;
$this->_session = $session;
}
/**
* Set configuration for AdyenHPP payemnt method
* Set configuration for AdyenHPP payment method
*
* @return array
*/
......@@ -133,7 +140,8 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
$config['payment'] ['adyenHpp']['showTelephone'] = $this->_adyenHelper->getAdyenHppConfigDataFlag(
'show_telephone'
);
$config['payment'] ['adyenHpp']['ratePayId'] = $this->_adyenHelper->getRatePayId();
$config['payment'] ['adyenHpp']['deviceIdentToken'] = md5($this->_session->getQuoteId().date('c'));
return $config;
......
......@@ -2,26 +2,13 @@
"name": "adyen/module-payment",
"description": "Official Magento2 Plugin to connect to Payment Service Provider Adyen.",
"type": "magento2-module",
"version": "2.1.1",
"version": "2.1.2",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"require": {
"php": "~5.5.0|~5.6.0|~7.0.0",
"magento/module-config": "100.1.*",
"magento/module-store": "100.1.*",
"magento/module-checkout": "100.1.*",
"magento/module-catalog": "101.0.*",
"magento/module-sales": "100.1.*",
"magento/module-customer": "100.1.*",
"magento/module-payment": "100.1.*",
"magento/module-quote": "100.1.*",
"magento/module-backend": "100.1.*",
"magento/module-directory": "100.1.*",
"magento/module-theme": "100.1.*",
"magento/module-paypal": "100.1.*",
"magento/framework": "100.1.*",
"adyen/php-api-library": "*"
},
"autoload": {
......
......@@ -79,6 +79,11 @@
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/adyen_hpp/ignore_second_address_field</config_path>
</field>
<field id="ratepay_id" translate="label" type="text" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
<label>RatePAY Device Ident SId</label>
<tooltip>Unique RatePAY Id provided by RatePAY integration consultant</tooltip>
<config_path>payment/adyen_hpp/ratepay_id</config_path>
</field>
</group>
<group id="adyen_hpp_advanced_settings" translate="label" showInDefault="1" showInWebsite="1" sortOrder="200">
<label>Advanced Settings</label>
......
......@@ -96,6 +96,7 @@
<payment_routine>single</payment_routine>
<delivery_days>5</delivery_days>
<allowspecific>0</allowspecific>
<ratepay_id>oj9GsQ</ratepay_id>
<sort_order>3</sort_order>
<payment_action>order</payment_action>
<can_initialize>1</can_initialize>
......@@ -191,5 +192,12 @@
<group>adyen</group>
</adyen_boleto>
</payment>
<dev>
<js>
<minify_exclude>
live.adyen.com/hpp/js/df
</minify_exclude>
</js>
</dev>
</default>
</config>
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/cron_groups.xsd">
<group id="adyen_payment">
<schedule_generate_every>1</schedule_generate_every>
<schedule_ahead_for>4</schedule_ahead_for>
<schedule_lifetime>2</schedule_lifetime>
<history_cleanup_every>10</history_cleanup_every>
<history_success_lifetime>60</history_success_lifetime>
<history_failure_lifetime>600</history_failure_lifetime>
<use_separate_process>1</use_separate_process>
</group>
</config>
......@@ -23,7 +23,7 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd">
<group id="index">
<group id="adyen_payment">
<job name="adyen_payment_process_notification" instance="Adyen\Payment\Model\Cron" method="processNotification">
<schedule>*/1 * * * *</schedule>
</job>
......
......@@ -24,7 +24,7 @@
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Adyen_Payment" setup_version="2.1.1">
<module name="Adyen_Payment" setup_version="2.1.2">
<sequence>
<module name="Magento_Sales"/>
<module name="Magento_Quote"/>
......
......@@ -7,7 +7,7 @@
var config = {
paths: {
'adyen/encrypt' : 'Adyen_Payment/js/view/payment/adyen.encrypt.min',
'adyen/df' : 'Adyen_Payment/js/view/payment/df.min'
'adyen/df' : 'https://live.adyen.com/hpp/js/df'
},
config: {
mixins: {
......
This diff is collapsed.
......@@ -63,6 +63,7 @@ define(
return this;
},
initialize: function () {
var self = this;
this._super();
fullScreenLoader.startLoader();
......@@ -73,7 +74,6 @@ define(
// retrieve payment methods
var serviceUrl,
payload;
if(customer.isLoggedIn()) {
serviceUrl = urlBuilder.createUrl('/carts/mine/retrieve-adyen-payment-methods', {});
} else {
......@@ -92,7 +92,23 @@ define(
).done(
function (response) {
adyenPaymentService.setPaymentMethods(response);
if(JSON.stringify(response).indexOf("ratepay") > -1) {
var ratePayId = window.checkoutConfig.payment.adyenHpp.ratePayId;
window.di = {t: '', v: ratePayId, l: 'Checkout'};
function waitForDfValue() {
var dfValueRatePay = self.getRatePayDeviceIdentToken();
if (dfValueRatePay) {
window.di.t = dfValueRatePay.replace(':', '');
var scriptTag = document.createElement('script');
scriptTag.src = "//d.ratepay.com/" + ratePayId + "/di.js";
scriptTag.type = "text/javascript";
document.body.appendChild(scriptTag);
} else {
setTimeout(waitForDfValue, 200);
}
}
waitForDfValue();
}
// set device fingerprint value
dfSet('dfValue', 0);
// propagate this manually to knockoutjs otherwise it would not work
......@@ -107,7 +123,6 @@ define(
},
getAdyenHppPaymentMethods: function() {
var self = this;
var paymentMethods = adyenPaymentService.getAvailablePaymentMethods();
var paymentList = _.map(paymentMethods, function(value) {
......@@ -135,6 +150,9 @@ define(
result.isPaymentMethodOpenInvoiceMethod = function() {
return value.isPaymentMethodOpenInvoiceMethod;
}
result.getRatePayDeviceIdentToken = function() {
return window.checkoutConfig.payment.adyenHpp.deviceIdentToken;
}
return result;
});
return paymentList;
......@@ -176,6 +194,9 @@ define(
additionalData.gender = this.gender();
additionalData.dob = this.dob();
additionalData.telephone = this.telephone();
if(brandCode() == "ratepay"){
additionalData.df_value = this.getRatePayDeviceIdentToken();
}
}
data.additional_data = additionalData;
......@@ -237,6 +258,9 @@ define(
},
validate: function () {
return true;
},
getRatePayDeviceIdentToken: function(){
return window.checkoutConfig.payment.adyenHpp.deviceIdentToken;
}
});
}
......
......@@ -37,6 +37,7 @@ define(
],
function (ko, _, $, Component, placeOrderAction, $t, additionalValidators, selectPaymentMethodAction, quote, checkoutData) {
'use strict';
var updatedExpiryDate = false;
var recurringDetailReference = ko.observable(null);
var paymentMethod = ko.observable(null);
return Component.extend({
......@@ -90,10 +91,7 @@ define(
// only use CSE and installments for cards
if (self.agreement_data.card) {
var cse_key = this.getCSEKey();
var options = { enableValidations: false};
var cseInstance = adyen.encrypt.createEncryption(cse_key, options);
var generationtime = self.getGenerationTime();
var cardData = {
......@@ -103,10 +101,17 @@ define(
generationtime : generationtime
};
var encryptedData = cseInstance.encrypt(cardData);
if(updatedExpiryDate || self.hasVerification()){
var options = { enableValidations: false};
var cse_key = this.getCSEKey();
var cseInstance = adyen.encrypt.createEncryption(cse_key, options);
var encryptedData = cseInstance.encrypt(cardData);
data.additional_data.encrypted_data = encryptedData;
}
// set payment method to adyen_hpp
data.additional_data.encrypted_data = encryptedData;
data.additional_data.number_of_installments = self.installment;
}
......@@ -180,6 +185,9 @@ define(
getGenerationTime: function() {
return window.checkoutConfig.payment.adyenCc.generationTime;
},
hasVerification: function() {
return window.checkoutConfig.payment.adyenOneclick.hasCustomerInteraction;
},
validate: function () {
var code = self.item.method;
......@@ -192,13 +200,13 @@ define(
// if oneclick or recurring is a card do validation on expiration date
if(this.agreement_data.card) {
// add extra validation because jqeury validation will not work on non name attributes
// add extra validation because jquery validation will not work on non name attributes
var expiration = Boolean($(form + ' #' + codeValue + '_expiration').valid());
var expiration_yr = Boolean($(form + ' #' + codeValue + '_expiration_yr').valid());
// only check if recurring type is set to oneclick
var cid = true;
if(self.hasVerification()) {
if(this.hasVerification()) {
var cid = Boolean($(form + ' #' + codeValue + '_cc_cid').valid());
}
} else {
......@@ -214,6 +222,7 @@ define(
return true;
},
selectExpiry: function() {
updatedExpiryDate = true;
var self = this;
self.expiry(true);
return true;
......@@ -224,6 +233,8 @@ define(
},
selectBillingAgreement: function() {
var self = this;
self.expiry(false);
updatedExpiryDate = false;
// set payment method data
var data = {
......@@ -256,9 +267,6 @@ define(
}
return null;
}),
hasVerification: function() {
return window.checkoutConfig.payment.adyenOneclick.hasCustomerInteraction;
},
getPlaceOrderUrl: function() {
return window.checkoutConfig.payment.iframe.placeOrderUrl[this.getCode()];
}
......
......@@ -131,7 +131,7 @@
</div>
<!-- ko if: ($parent.hasVerification())-->
<!-- ko if: hasVerification()-->
<div class="field cvv required" data-bind="attr: {id: getCode() + '_' + value + '_cc_type_cvv_div'}">
<label data-bind="attr: {for: getCode() + '_' + value + '_cc_cid'}" class="label">
<span><!-- ko text: $t('Card Verification Number')--><!-- /ko --></span>
......
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