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 24df1cac authored by Alessio Zampatti's avatar Alessio Zampatti Committed by GitHub

Merge pull request #317 from Adyen/develop

Release 2.3.2
parents d1635b1e d00f0689
...@@ -88,7 +88,6 @@ class PaymentLink extends AbstractInfo ...@@ -88,7 +88,6 @@ class PaymentLink extends AbstractInfo
return strpos($this->getPayment()->getMethod(), 'adyen_') === 0 return strpos($this->getPayment()->getMethod(), 'adyen_') === 0
&& $this->_scopeConfig->getValue('payment/adyen_hpp/active') && $this->_scopeConfig->getValue('payment/adyen_hpp/active')
&& $this->_scopeConfig->getValue('payment/adyen_pay_by_mail/active') && $this->_scopeConfig->getValue('payment/adyen_pay_by_mail/active')
&& $this->getOrder()->getTotalInvoiced() > 0
&& $this->getOrder()->getTotalDue() > 0 && $this->getOrder()->getTotalDue() > 0
? parent::_toHtml() ? parent::_toHtml()
: ''; : '';
......
...@@ -60,6 +60,7 @@ class Converter implements \Magento\Framework\Config\ConverterInterface ...@@ -60,6 +60,7 @@ class Converter implements \Magento\Framework\Config\ConverterInterface
break; break;
case 'code_alt': case 'code_alt':
$typeArray['code_alt'] = $typeSubNode->nodeValue; $typeArray['code_alt'] = $typeSubNode->nodeValue;
break;
default: default:
break; break;
} }
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
namespace Adyen\Payment\Model; namespace Adyen\Payment\Model;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\Webapi\Exception; use Magento\Framework\Webapi\Exception;
use Magento\Sales\Model\Order\Email\Sender\OrderSender; use Magento\Sales\Model\Order\Email\Sender\OrderSender;
use Magento\Sales\Model\Order\Email\Sender\InvoiceSender; use Magento\Sales\Model\Order\Email\Sender\InvoiceSender;
...@@ -30,6 +31,7 @@ use Magento\Framework\App\Area; ...@@ -30,6 +31,7 @@ use Magento\Framework\App\Area;
use Magento\Framework\App\AreaList; use Magento\Framework\App\AreaList;
use Magento\Framework\Phrase\Renderer\Placeholder; use Magento\Framework\Phrase\Renderer\Placeholder;
use Magento\Framework\Phrase; use Magento\Framework\Phrase;
use Magento\Sales\Model\OrderRepository;
class Cron class Cron
{ {
...@@ -192,6 +194,16 @@ class Cron ...@@ -192,6 +194,16 @@ class Cron
*/ */
protected $_orderStatusCollection; protected $_orderStatusCollection;
/**
* @var SearchCriteriaBuilder
*/
private $searchCriteriaBuilder;
/**
* @var OrderRepository
*/
private $orderRepository;
/** /**
* Cron constructor. * Cron constructor.
* *
...@@ -211,6 +223,8 @@ class Cron ...@@ -211,6 +223,8 @@ class Cron
* @param InvoiceFactory $adyenInvoiceFactory * @param InvoiceFactory $adyenInvoiceFactory
* @param AreaList $areaList * @param AreaList $areaList
* @param \Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory $orderStatusCollection * @param \Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory $orderStatusCollection
* @param SearchCriteriaBuilder $searchCriteriaBuilder
* @param OrderRepository $orderRepository
*/ */
public function __construct( public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
...@@ -228,7 +242,9 @@ class Cron ...@@ -228,7 +242,9 @@ class Cron
\Adyen\Payment\Model\ResourceModel\Order\Payment\CollectionFactory $adyenOrderPaymentCollectionFactory, \Adyen\Payment\Model\ResourceModel\Order\Payment\CollectionFactory $adyenOrderPaymentCollectionFactory,
\Adyen\Payment\Model\InvoiceFactory $adyenInvoiceFactory, \Adyen\Payment\Model\InvoiceFactory $adyenInvoiceFactory,
AreaList $areaList, AreaList $areaList,
\Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory $orderStatusCollection \Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory $orderStatusCollection,
SearchCriteriaBuilder $searchCriteriaBuilder,
OrderRepository $orderRepository
) )
{ {
$this->_scopeConfig = $scopeConfig; $this->_scopeConfig = $scopeConfig;
...@@ -247,6 +263,8 @@ class Cron ...@@ -247,6 +263,8 @@ class Cron
$this->_adyenInvoiceFactory = $adyenInvoiceFactory; $this->_adyenInvoiceFactory = $adyenInvoiceFactory;
$this->_areaList = $areaList; $this->_areaList = $areaList;
$this->_orderStatusCollection = $orderStatusCollection; $this->_orderStatusCollection = $orderStatusCollection;
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
$this->orderRepository = $orderRepository;
} }
/** /**
...@@ -331,8 +349,17 @@ class Cron ...@@ -331,8 +349,17 @@ class Cron
// get order // get order
$incrementId = $notification->getMerchantReference(); $incrementId = $notification->getMerchantReference();
$this->_order = $this->_orderFactory->create()->loadByIncrementId($incrementId); $searchCriteria = $this->searchCriteriaBuilder
if (!$this->_order->getId()) { ->addFilter('increment_id', $incrementId, 'eq')
->create();
$orderList = $this->orderRepository->getList($searchCriteria)->getItems();
/** @var \Magento\Sales\Model\Order $order */
$order = reset($orderList);
$this->_order = $order;
if (!$this->_order) {
// order does not exists remove from queue // order does not exists remove from queue
$notification->delete(); $notification->delete();
......
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment Module
*
* Copyright (c) 2017 Adyen B.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Observer\Adminhtml;
use Magento\Framework\Event\Observer;
use Magento\Payment\Observer\AbstractDataAssignObserver;
/**
* Class DataAssignObserver
*/
class BeforeShipmentObserver extends AbstractDataAssignObserver
{
private $_adyenHelper;
/**
* BeforeShipmentObserver constructor.
*
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/
public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper
)
{
$this->_adyenHelper = $adyenHelper;
}
/**
* @param Observer $observer
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function execute(Observer $observer)
{
$shipment = $observer->getEvent()->getShipment();
$order = $shipment->getOrder();
$captureOnShipment = $this->_adyenHelper->getConfigData('capture_on_shipment', 'adyen_abstract', $order->getStoreId());
if ($this->isPaymentMethodAdyen($order) && $captureOnShipment) {
$payment = $order->getPayment();
$brandCode = $payment->getAdditionalInformation(
\Adyen\Payment\Observer\AdyenHppDataAssignObserver::BRAND_CODE
);
if ($this->_adyenHelper->isPaymentMethodOpenInvoiceMethod($brandCode)) {
if ($order->canInvoice()) {
try {
$invoice = $order->prepareInvoice();
$invoice->getOrder()->setIsInProcess(true);
// set transaction id so you can do a online refund from credit memo
$pspReference = $order->getPayment()->getAdyenPspReference();
$invoice->setTransactionId($pspReference);
$invoice->register()->pay();
$invoice->save();
} catch (Exception $e) {
throw new Exception(sprintf('Error saving invoice. The error message is:', $e->getMessage()));
}
}
}
}
}
/**
* Determine if the payment method is Adyen
*/
public function isPaymentMethodAdyen($order)
{
return strpos($order->getPayment()->getMethod(), 'adyen') !== false;
}
}
# Adyen_Magento2 # Adyen Payment plugin for Magento2
Adyen Payment plugin for Magento2. This plugin supports Magento2 version 2.1 and higher. <br/> Use Adyen's plugin for Magento 2 to offer frictionless payments online, in-app, and in-store.
For Magento2 version 2.0 support, use plugin version 1.4.6.
## Installation ## ## Requirements
This plugin supports Magento2 version 2.1 and higher
## Collaboration
We commit all our new features directly into our GitHub repository.
But you can also request or suggest new features or code changes yourself!
## Installation
You can install our plugin through Composer:
``` ```
composer require adyen/module-payment composer require adyen/module-payment
bin/magento module:enable Adyen_Payment bin/magento module:enable Adyen_Payment
bin/magento setup:upgrade bin/magento setup:upgrade
``` ```
For more information see our [installation section](https://docs.adyen.com/developers/plug-ins-and-partners/magento-2/set-up-the-plugin-in-magento#step1installtheplugin)
## Manual ## ## Documentation
[Magento 2 documentation](https://docs.adyen.com/developers/plug-ins-and-partners/magento/magento-2) [Magento 2 documentation](https://docs.adyen.com/developers/plug-ins-and-partners/magento-2)
## Setup Cron ##
Make sure that your magento cron is running every minute. We are using a cronjob to process the notifications. The cronjob will be executed every minute. It only executes the notifications that have been received at least 2 minutes ago. We have built in this 2 minutes so we are sure Magento has created the order and all save after events are executed. A handy tool to get insight into your cronjobs is AOE scheduler. You can download this tool through Magento Connect or GitHub
## Support ##
You can create issues on our Magento Repository or if you have some specific problems for your account you can contact magento@adyen.com as well.
## API Library ##
This module is using the Adyen APIs Library for PHP for all (API) connections to Adyen.
<a href="https://github.com/Adyen/adyen-php-api-library" target="_blank">This library can be found here</a>
## Setting up cronjob ## ## Setup Cron
The notifications of Adyen (this will give you the indication of the payment status) is processed by a cronjob. You need to setup your cronjob. <a href="http://devdocs.magento.com/guides/v2.0/config-guide/cli/config-cli-subcommands-cron.html" target="_blank">This is described here</a> Make sure that your Magento cron is running every minute. We are using a cronjob to process the notifications, our webhook service. The cronjob will be executed every minute. It only executes the notifications that have been received at least 2 minutes ago. This is to ensure that Magento has created the order, and all save after events are executed. A handy tool to get insight into your cronjobs is AOE scheduler. You can download this tool through Magento Connect or GitHub.
If you need to setup your cronjob in Magento <a href="http://devdocs.magento.com/guides/v2.0/config-guide/cli/config-cli-subcommands-cron.html" target="_blank">this is described here</a>
We have defined this: We have defined this:
``` ```
<group id="index"> <group id="index">
<job name="adyen_payment_process_notification" instance="Adyen\Payment\Model\Cron" method="processNotification"> <job name="adyen_payment_process_notification" instance="Adyen\Payment\Model\Cron" method="processNotification">
...@@ -33,3 +33,13 @@ We have defined this: ...@@ -33,3 +33,13 @@ We have defined this:
</job> </job>
</group> </group>
``` ```
## 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>.
## API Library
This module is using the Adyen APIs Library for PHP for all (API) connections to Adyen.
<a href="https://github.com/Adyen/adyen-php-api-library" target="_blank">This library can be found here</a>
## License
MIT license. For more information, see the LICENSE file.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"name": "adyen/module-payment", "name": "adyen/module-payment",
"description": "Official Magento2 Plugin to connect to Payment Service Provider Adyen.", "description": "Official Magento2 Plugin to connect to Payment Service Provider Adyen.",
"type": "magento2-module", "type": "magento2-module",
"version": "2.3.1", "version": "2.3.2",
"license": [ "license": [
"OSL-3.0", "OSL-3.0",
"AFL-3.0" "AFL-3.0"
......
<?xml version="1.0"?>
<!--
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="sales_order_shipment_save_before">
<observer name="adyen_shipment_save_before" instance="Adyen\Payment\Observer\Adminhtml\BeforeShipmentObserver" />
</event>
</config>
...@@ -32,6 +32,12 @@ ...@@ -32,6 +32,12 @@
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model> <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/adyen_abstract/paypal_capture_mode</config_path> <config_path>payment/adyen_abstract/paypal_capture_mode</config_path>
</field> </field>
<field id="capture_on_shipment" translate="label" type="select" sortOrder="15" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Capture on shipment for OpenInvoice Methods (Klarna, Ratepay and Afterpay)</label>
<tooltip>If you enable this function it will do a capture request to Adyen if you do a shipment for openinvoice payment methods.</tooltip>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/adyen_abstract/capture_on_shipment</config_path>
</field>
<field id="auto_capture_openinvoice" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1"> <field id="auto_capture_openinvoice" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Use auto-capture for OpenInvoice payments</label> <label>Use auto-capture for OpenInvoice payments</label>
<tooltip>Applicable for Klarna and AfterPay only. By default OpenInvoice is set to manual capture. If you want auto capture you need to contact magento@adyen.com. After approval has been given, then you can set this option to 'Yes'.</tooltip> <tooltip>Applicable for Klarna and AfterPay only. By default OpenInvoice is set to manual capture. If you want auto capture you need to contact magento@adyen.com. After approval has been given, then you can set this option to 'Yes'.</tooltip>
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
--> -->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> <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.3.1"> <module name="Adyen_Payment" setup_version="2.3.2">
<sequence> <sequence>
<module name="Magento_Sales"/> <module name="Magento_Sales"/>
<module name="Magento_Quote"/> <module name="Magento_Quote"/>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"Credit Card Information","Creditcard gegevens" "Credit Card Information","Creditcard gegevens"
"Credit Card Type","Creditcard type" "Credit Card Type","Creditcard type"
"Credit Card Number","Creditcard Number" "Credit Card Number","Creditcard Number"
"Credit Card Owner","Creditcardnummer" "Credit Card Owner","Creditcard Houder"
"Expiration Date","Verloopdatum" "Expiration Date","Verloopdatum"
"Card Verification Number","Creditcard Verificatie Nummer" "Card Verification Number","Creditcard Verificatie Nummer"
"--Please Select--","--Selecteer--" "--Please Select--","--Selecteer--"
......
...@@ -242,12 +242,8 @@ define( ...@@ -242,12 +242,8 @@ define(
}, },
/** Redirect to adyen */ /** Redirect to adyen */
continueToAdyen: function () { continueToAdyen: function () {
var self = this;
if (this.validate() && additionalValidators.validate()) { if (this.validate() && additionalValidators.validate()) {
var data = {}; this.placeRedirectOrder(this.getData());
data.method = self.method;
this.placeRedirectOrder(data);
return false; return false;
} }
}, },
......
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