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 35c040d1 authored by Rik ter Beek's avatar Rik ter Beek Committed by GitHub

Merge pull request #348 from Adyen/develop

New Release Adyen Payment 2.4.0
parents 733bd419 5ea387ef
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment Module
*
* Copyright (c) 2018 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\Api;
interface AdyenInitiateTerminalApiInterface
{
/**
* Trigger sync call on terminal
* @return mixed
*/
public function initiate();
}
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment Module
*
* Copyright (c) 2018 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\Block\Form;
class PosCloud extends \Magento\Payment\Block\Form
{
/**
* @var string
*/
protected $_template = 'Adyen_Payment::form/pos_cloud.phtml';
}
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment Module
*
* Copyright (c) 2018 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\Block\Info;
class PosCloud extends AbstractInfo
{
/**
* @var string
*/
protected $_template = 'Adyen_Payment::info/adyen_pos_cloud.phtml';
}
...@@ -538,4 +538,4 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -538,4 +538,4 @@ class Redirect extends \Magento\Payment\Block\Form
{ {
return $this->_checkoutSession; return $this->_checkoutSession;
} }
} }
\ No newline at end of file
...@@ -267,21 +267,15 @@ class Json extends \Magento\Framework\App\Action\Action ...@@ -267,21 +267,15 @@ class Json extends \Magento\Framework\App\Action\Action
return false; return false;
} }
$accountCmp = !$this->_adyenHelper->getAdyenAbstractConfigDataFlag('multiple_merchants')
? strcmp($submitedMerchantAccount, $internalMerchantAccount)
: 0;
$usernameCmp = strcmp($_SERVER['PHP_AUTH_USER'], $username); $usernameCmp = strcmp($_SERVER['PHP_AUTH_USER'], $username);
$passwordCmp = strcmp($_SERVER['PHP_AUTH_PW'], $password); $passwordCmp = strcmp($_SERVER['PHP_AUTH_PW'], $password);
if ($accountCmp === 0 && $usernameCmp === 0 && $passwordCmp === 0) { if ($usernameCmp === 0 && $passwordCmp === 0) {
return true; return true;
} }
// If notification is test check if fields are correct if not return error // If notification is test check if fields are correct if not return error
if ($this->_isTestNotification($response['pspReference'])) { if ($this->_isTestNotification($response['pspReference'])) {
if ($accountCmp != 0) { if ($usernameCmp != 0 || $passwordCmp != 0) {
$this->_returnResult('MerchantAccount in notification is not the same as in Magento settings');
} elseif ($usernameCmp != 0 || $passwordCmp != 0) {
$this->_returnResult( $this->_returnResult(
'username (PHP_AUTH_USER) and\or password (PHP_AUTH_PW) are not the same as Magento settings' 'username (PHP_AUTH_USER) and\or password (PHP_AUTH_PW) are not the same as Magento settings'
); );
......
...@@ -218,4 +218,4 @@ class PayByMailCommand implements CommandInterface ...@@ -218,4 +218,4 @@ class PayByMailCommand implements CommandInterface
{ {
return str_replace(':', '\\:', str_replace('\\', '\\\\', $val)); return str_replace(':', '\\:', str_replace('\\', '\\\\', $val));
} }
} }
\ No newline at end of file
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment Module
*
* Copyright (c) 2018 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\Gateway\Http\Client;
use Adyen\Util\Util;
use Magento\Payment\Gateway\Http\ClientInterface;
class TransactionPosCloudSync implements ClientInterface
{
/**
* @var int
*/
protected $storeId;
/**
* @var \Adyen\Client
*/
protected $client;
/**
* @var \Adyen\Payment\Helper\Data
*/
protected $adyenHelper;
/**
* @var \Adyen\Payment\Logger\AdyenLogger
*/
protected $adyenLogger;
public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger,
\Magento\Store\Model\StoreManagerInterface $storeManager,
array $data = []
) {
$this->adyenHelper = $adyenHelper;
$this->adyenLogger = $adyenLogger;
$this->storeId = $storeManager->getStore()->getId();
$apiKey = $this->adyenHelper->getPosApiKey($this->storeId);
// initialize client
$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->client = $client;
}
/**
* Places request to gateway. Returns result as ENV array
*
* @param \Magento\Payment\Gateway\Http\TransferInterface $transferObject
* @return array
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $transferObject)
{
$request = $transferObject->getBody();
if (!empty($request['response']['SaleToPOIResponse']['PaymentResponse'])) {
$paymentResponse = $request['response']['SaleToPOIResponse']['PaymentResponse'];
//Initiate has already a response
return $paymentResponse;
}
//always do status call and return the response of the status call
$service = $this->adyenHelper->createAdyenPosPaymentService($this->client);
$poiId = $this->adyenHelper->getPoiId($this->storeId);
$newServiceID = date("dHis");
$statusDate = date("U");
$timeDiff = (int)$statusDate - (int)$request['initiateDate'];
$totalTimeout = $this->adyenHelper->getAdyenPosCloudConfigData('total_timeout', $this->storeId);
if ($timeDiff > $totalTimeout) {
throw new \Magento\Framework\Exception\LocalizedException(__("POS connection timed out."));
}
//Provide receipt to the shopper
$request = [
'SaleToPOIRequest' => [
'MessageHeader' => [
'ProtocolVersion' => '3.0',
'MessageClass' => 'Service',
'MessageCategory' => 'TransactionStatus',
'MessageType' => 'Request',
'ServiceID' => $newServiceID,
'SaleID' => 'Magento2CloudStatus',
'POIID' => $poiId
],
'TransactionStatusRequest' => [
'MessageReference' => [
'MessageCategory' => 'Payment',
'SaleID' => 'Magento2Cloud',
'ServiceID' => $request['serviceID']
],
'DocumentQualifier' => [
"CashierReceipt",
"CustomerReceipt"
],
'ReceiptReprintFlag' => true
]
]
];
try {
$response = $service->runTenderSync($request);
} catch (\Adyen\AdyenException $e) {
$response['error'] = $e->getMessage();
return $response;
}
if (!empty($response['SaleToPOIResponse']['TransactionStatusResponse'])) {
$statusResponse = $response['SaleToPOIResponse']['TransactionStatusResponse'];
if ($statusResponse['Response']['Result'] == 'Failure') {
$errorMsg = __('In Progress');
throw new \Magento\Framework\Exception\LocalizedException(__($errorMsg));
} else {
$paymentResponse = $statusResponse['RepeatedMessageResponse']['RepeatedResponseMessageBody']['PaymentResponse'];
}
} else {
// probably SaleToPOIRequest, that means terminal unreachable, log the response as error
$this->adyenLogger->error(json_encode($response));
throw new \Magento\Framework\Exception\LocalizedException(__("The terminal could not be reached."));
}
return $paymentResponse;
}
}
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
* *
* Author: Adyen <magento@adyen.com> * Author: Adyen <magento@adyen.com>
*/ */
namespace Adyen\Payment\Gateway\Request; namespace Adyen\Payment\Gateway\Request;
use Magento\Payment\Gateway\Request\BuilderInterface; use Magento\Payment\Gateway\Request\BuilderInterface;
...@@ -30,7 +31,7 @@ class MerchantAccountDataBuilder implements BuilderInterface ...@@ -30,7 +31,7 @@ class MerchantAccountDataBuilder implements BuilderInterface
* @var \Adyen\Payment\Helper\Data * @var \Adyen\Payment\Helper\Data
*/ */
private $adyenHelper; private $adyenHelper;
/** /**
* RecurringDataBuilder constructor. * RecurringDataBuilder constructor.
* *
...@@ -52,8 +53,10 @@ class MerchantAccountDataBuilder implements BuilderInterface ...@@ -52,8 +53,10 @@ class MerchantAccountDataBuilder implements BuilderInterface
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject); $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
$order = $paymentDataObject->getOrder(); $order = $paymentDataObject->getOrder();
$storeId = $order->getStoreId(); $storeId = $order->getStoreId();
$payment = $paymentDataObject->getPayment();
$method = $payment->getMethod();
$merchantAccount = $this->adyenHelper->getAdyenAbstractConfigData("merchant_account", $storeId); $merchantAccount = $this->adyenHelper->getAdyenMerchantAccount($method, $storeId);
return ["merchantAccount" => $merchantAccount]; return ["merchantAccount" => $merchantAccount];
} }
......
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment Module
*
* Copyright (c) 2018 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\Gateway\Request;
use Magento\Payment\Gateway\Request\BuilderInterface;
class PosCloudBuilder implements BuilderInterface
{
/**
* @param array $buildSubject
* @return array
*/
public function build(array $buildSubject)
{
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
$payment = $paymentDataObject->getPayment();
return [
"response" => $payment->getAdditionalInformation("terminalResponse"),
"serviceID" => $payment->getAdditionalInformation("serviceID"),
"initiateDate" => $payment->getAdditionalInformation("initiateDate")
];
}
}
...@@ -76,7 +76,8 @@ class RefundDataBuilder implements BuilderInterface ...@@ -76,7 +76,8 @@ class RefundDataBuilder implements BuilderInterface
$pspReference = $payment->getCcTransId(); $pspReference = $payment->getCcTransId();
$currency = $payment->getOrder()->getOrderCurrencyCode(); $currency = $payment->getOrder()->getOrderCurrencyCode();
$storeId = $order->getStoreId(); $storeId = $order->getStoreId();
$merchantAccount = $this->adyenHelper->getAdyenAbstractConfigData("merchant_account", $storeId); $method = $payment->getMethod();
$merchantAccount = $this->adyenHelper->getAdyenMerchantAccount($method, $storeId);
$grandTotal = $payment->getOrder()->getGrandTotal(); $grandTotal = $payment->getOrder()->getGrandTotal();
......
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment Module
*
* Copyright (c) 2018 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\Gateway\Response;
use Magento\Payment\Gateway\Response\HandlerInterface;
use Magento\Setup\Exception;
class PaymentPosCloudHandler implements HandlerInterface
{
/**
* @var \Adyen\Payment\Helper\Data
*/
private $adyenHelper;
/**
* @var \Adyen\Payment\Logger\AdyenLogger
*/
private $adyenLogger;
/**
* PaymentDataBuilder constructor.
*
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/
public function __construct(
\Adyen\Payment\Logger\AdyenLogger $adyenLogger,
\Adyen\Payment\Helper\Data $adyenHelper
) {
$this->adyenLogger = $adyenLogger;
$this->adyenHelper = $adyenHelper;
}
/**
* Handles response
*
* @param array $handlingSubject
* @param array $paymentResponse
* @return void
* @throws Exception
*/
public function handle(array $handlingSubject, array $paymentResponse)
{
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($handlingSubject);
/** @var OrderPaymentInterface $payment */
$payment = $paymentDataObject->getPayment();
// set transaction not to processing by default wait for notification
$payment->setIsTransactionPending(true);
// do not send order confirmation mail
$payment->getOrder()->setCanSendNewEmailFlag(false);
// set transaction(status)
if (!empty($paymentResponse['PaymentResult']['PaymentAcquirerData']['AcquirerTransactionID']['TransactionID'])) {
$pspReference = $paymentResponse['PaymentResult']['PaymentAcquirerData']['AcquirerTransactionID']['TransactionID'];
$payment->setTransactionId($pspReference);
// set transaction(payment)
} else {
$this->adyenLogger->error("Missing POS Transaction ID");
throw new Exception("Missing POS Transaction ID");
}
// do not close transaction so you can do a cancel() and void
$payment->setIsTransactionClosed(false);
$payment->setShouldCloseParentTransaction(false);
}
}
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment Module
*
* Copyright (c) 2018 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\Gateway\Validator;
use Magento\Payment\Gateway\Validator\AbstractValidator;
class PosCloudResponseValidator extends AbstractValidator
{
/**
* @var \Adyen\Payment\Logger\AdyenLogger
*/
private $adyenLogger;
/**
* @var \Adyen\Payment\Helper\Data
*/
private $adyenHelper;
/**
* PosCloudResponseValidator constructor.
*
* @param \Magento\Payment\Gateway\Validator\ResultInterfaceFactory $resultFactory
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/
public function __construct(
\Magento\Payment\Gateway\Validator\ResultInterfaceFactory $resultFactory,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger,
\Adyen\Payment\Helper\Data $adyenHelper
) {
$this->adyenLogger = $adyenLogger;
$this->adyenHelper = $adyenHelper;
parent::__construct($resultFactory);
}
/**
* @param array $validationSubject
* @return \Magento\Payment\Gateway\Validator\ResultInterface
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function validate(array $validationSubject)
{
$errorMessages = [];
$isValid = true;
$response = \Magento\Payment\Gateway\Helper\SubjectReader::readResponse($validationSubject);
$paymentDataObjectInterface = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($validationSubject);
$payment = $paymentDataObjectInterface->getPayment();
$this->adyenLogger->addAdyenDebug(print_r($response, true));
// Check for errors
if (!empty($response['error'])) {
if (!empty($response['code']) && $response['code'] == CURLE_OPERATION_TIMEOUTED) {
// If the initiate call resulted in a timeout, do a status call(try to place an order)
return $this->createResult($isValid, $errorMessages);
} else {
// There is an error which is not a timeout, stop the transaction and show the error
$this->adyenLogger->error(json_encode($response));
throw new \Magento\Framework\Exception\LocalizedException(__($response['error']));
}
} else {
// We have a paymentResponse from the terminal
$paymentResponse = $response;
}
if (!empty($paymentResponse) && $paymentResponse['Response']['Result'] != 'Success') {
$errorMsg = __($paymentResponse['Response']['ErrorCondition']);
$this->adyenLogger->error($errorMsg);
$this->adyenLogger->error(json_encode($response));
throw new \Magento\Framework\Exception\LocalizedException(__("The transaction could not be completed."));
}
if (!empty($paymentResponse['PaymentReceipt'])) {
$formattedReceipt = $this->adyenHelper->formatTerminalAPIReceipt($paymentResponse['PaymentReceipt']);
$payment->setAdditionalInformation('receipt', $formattedReceipt);
}
return $this->createResult($isValid, $errorMessages);
}
}
...@@ -426,7 +426,7 @@ class Data extends AbstractHelper ...@@ -426,7 +426,7 @@ class Data extends AbstractHelper
/** /**
* @desc Gives back adyen_pos configuration values * @desc Gives back adyen_pos configuration values
* @param $field * @param $field
* @param null $storeId * @param int|null $storeId
* @return mixed * @return mixed
*/ */
public function getAdyenPosConfigData($field, $storeId = null) public function getAdyenPosConfigData($field, $storeId = null)
...@@ -437,7 +437,7 @@ class Data extends AbstractHelper ...@@ -437,7 +437,7 @@ class Data extends AbstractHelper
/** /**
* @desc Gives back adyen_pos configuration values as flag * @desc Gives back adyen_pos configuration values as flag
* @param $field * @param $field
* @param null $storeId * @param int|null $storeId
* @return mixed * @return mixed
*/ */
public function getAdyenPosConfigDataFlag($field, $storeId = null) public function getAdyenPosConfigDataFlag($field, $storeId = null)
...@@ -445,10 +445,30 @@ class Data extends AbstractHelper ...@@ -445,10 +445,30 @@ class Data extends AbstractHelper
return $this->getConfigData($field, 'adyen_pos', $storeId, true); return $this->getConfigData($field, 'adyen_pos', $storeId, true);
} }
/**
* @param $field
* @param int|null $storeId
* @return bool|mixed
*/
public function getAdyenPosCloudConfigData($field, $storeId = null)
{
return $this->getConfigData($field, 'adyen_pos_cloud', $storeId);
}
/**
* @param $field
* @param int|null $storeId
* @return bool|mixed
*/
public function getAdyenPosCloudConfigDataFlag($field, $storeId = null)
{
return $this->getConfigData($field, 'adyen_pos_cloud', $storeId, true);
}
/** /**
* @desc Gives back adyen_pay_by_mail configuration values * @desc Gives back adyen_pay_by_mail configuration values
* @param $field * @param $field
* @param null $storeId * @param int|null $storeId
* @return mixed * @return mixed
*/ */
public function getAdyenPayByMailConfigData($field, $storeId = null) public function getAdyenPayByMailConfigData($field, $storeId = null)
...@@ -459,7 +479,7 @@ class Data extends AbstractHelper ...@@ -459,7 +479,7 @@ class Data extends AbstractHelper
/** /**
* @desc Gives back adyen_pay_by_mail configuration values as flag * @desc Gives back adyen_pay_by_mail configuration values as flag
* @param $field * @param $field
* @param null $storeId * @param int|null $storeId
* @return mixed * @return mixed
*/ */
public function getAdyenPayByMailConfigDataFlag($field, $storeId = null) public function getAdyenPayByMailConfigDataFlag($field, $storeId = null)
...@@ -1164,23 +1184,105 @@ class Data extends AbstractHelper ...@@ -1164,23 +1184,105 @@ class Data extends AbstractHelper
return $formFields; return $formFields;
} }
/**
* @param int|null $storeId
* @return string the X API Key for the specified or current store
*/
public function getPosApiKey($storeId = null)
{
if ($this->isDemoMode($storeId)) {
$apiKey = $this->_encryptor->decrypt(trim($this->getAdyenPosCloudConfigData('api_key_test', $storeId)));
} else {
$apiKey = $this->_encryptor->decrypt(trim($this->getAdyenPosCloudConfigData('api_key_live', $storeId)));
}
return $apiKey;
}
/**
* Return the Terminal ID for the current store/mode
*
* @param int|null $storeId
* @return mixed
*/
public function getPoiId($storeId = null)
{
return $this->getAdyenPosCloudConfigData('pos_terminal_id', $storeId);
}
/**
* Return the merchant account name configured for the proper payment method.
* If it is not configured for the specific payment method,
* return the merchant account name defined in required settings.
*
* @param $paymentMethod
* @param int $storeId
* @return string
*/
public function getAdyenMerchantAccount($paymentMethod, $storeId)
{
$merchantAccount = $this->getAdyenAbstractConfigData("merchant_account", $storeId);
$merchantAccountPos = $this->getAdyenPosCloudConfigData('pos_merchant_account', $storeId);
if ($paymentMethod == 'adyen_pos_cloud' && !empty($merchantAccountPos)) {
return $merchantAccountPos;
}
return $merchantAccount;
}
/**
* Format the Receipt sent in the Terminal API response in HTML
* so that it can be easily shown to the shopper
*
* @param $paymentReceipt
* @return string
*/
public function formatTerminalAPIReceipt($paymentReceipt)
{
$formattedHtml = "<table class='terminal-api-receipt'>";
foreach ($paymentReceipt as $receipt) {
if ($receipt['DocumentQualifier'] == "CustomerReceipt") {
foreach ($receipt['OutputContent']['OutputText'] as $item) {
parse_str($item['Text'], $textParts);
$formattedHtml .= "<tr class='terminal-api-receipt'>";
if (!empty($textParts['name'])) {
$formattedHtml .= "<td class='terminal-api-receipt-name'>" . $textParts['name'] . "</td>";
} else {
$formattedHtml .= "<td class='terminal-api-receipt-name'>&nbsp;</td>";
}
if (!empty($textParts['value'])) {
$formattedHtml .= "<td class='terminal-api-receipt-value' align='right'>" . $textParts['value'] . "</td>";
} else {
$formattedHtml .= "<td class='terminal-api-receipt-value' align='right'>&nbsp;</td>";
}
$formattedHtml .= "</tr>";
}
}
}
$formattedHtml .= "</table>";
return $formattedHtml;
}
/** /**
* Initializes and returns Adyen Client and sets the required parameters of it * Initializes and returns Adyen Client and sets the required parameters of it
* *
* @param $storeId * @param int|null $storeId
* @param string|null $apiKey
* @return \Adyen\Client * @return \Adyen\Client
* @throws \Adyen\AdyenException * @throws \Adyen\AdyenException
*/ */
public function initializeAdyenClient($storeId = null) public function initializeAdyenClient($storeId = null, $apiKey = null)
{ {
// initialize client // initialize client
$webserviceUsername = $this->getWsUsername($storeId);
$webservicePassword = $this->getWsPassword($storeId);
$client = new \Adyen\Client(); $client = new \Adyen\Client();
if ($apiKey) {
$client->setXApiKey($apiKey);
} else {
$client->setUsername($this->getWsUsername($storeId));
$client->setPassword($this->getWsPassword($storeId));
}
$client->setApplicationName("Magento 2 plugin"); $client->setApplicationName("Magento 2 plugin");
$client->setUsername($webserviceUsername);
$client->setPassword($webservicePassword);
$client->setAdyenPaymentSource($this->getModuleName(), $this->getModuleVersion()); $client->setAdyenPaymentSource($this->getModuleName(), $this->getModuleVersion());
...@@ -1189,11 +1291,23 @@ class Data extends AbstractHelper ...@@ -1189,11 +1291,23 @@ class Data extends AbstractHelper
if ($this->isDemoMode($storeId)) { if ($this->isDemoMode($storeId)) {
$client->setEnvironment(\Adyen\Environment::TEST); $client->setEnvironment(\Adyen\Environment::TEST);
} else { } else {
$client->setEnvironment(\Adyen\Environment::LIVE); $client->setEnvironment(\Adyen\Environment::LIVE, $this->getLiveEndpointPrefix($storeId));
} }
$client->setLogger($this->adyenLogger); $client->setLogger($this->adyenLogger);
return $client; return $client;
} }
/**
* @param \Adyen\Clien $client
* @return \Adyen\Service\PosPayment
* @throws \Adyen\AdyenException
*/
public function createAdyenPosPaymentService($client)
{
return new \Adyen\Service\PosPayment($client);
}
} }
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment Module
*
* Copyright (c) 2018 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\Model;
use Adyen\Payment\Api\AdyenInitiateTerminalApiInterface;
use Adyen\Payment\Model\Ui\AdyenPosCloudConfigProvider;
use Adyen\Util\Util;
class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface
{
/**
* @var \Adyen\Payment\Helper\Data
*/
private $adyenHelper;
/**
* @var \Adyen\Payment\Logger\AdyenLogger
*/
private $adyenLogger;
/**
* @var \Adyen\Client
*/
protected $client;
/**
* @var int
*/
protected $storeId;
/**
* @var \Magento\Checkout\Model\Session
*/
protected $checkoutSession;
/**
* AdyenInitiateTerminalApi constructor.
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Magento\Checkout\Model\Session $_checkoutSession
* @param array $data
*/
public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger,
\Magento\Checkout\Model\Session $checkoutSession,
\Magento\Store\Model\StoreManagerInterface $storeManager,
array $data = []
)
{
$this->adyenHelper = $adyenHelper;
$this->adyenLogger = $adyenLogger;
$this->checkoutSession = $checkoutSession;
$this->storeId = $storeManager->getStore()->getId();
// initialize client
$apiKey = $this->adyenHelper->getPosApiKey($this->storeId);
$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->client = $client;
}
/**
* Trigger sync call on terminal
* @return mixed
* @throws \Exception
*/
public function initiate()
{
$quote = $this->checkoutSession->getQuote();
$payment = $quote->getPayment();
$payment->setMethod(AdyenPosCloudConfigProvider::CODE);
$reference = $quote->reserveOrderId()->getReservedOrderId();
$service = $this->adyenHelper->createAdyenPosPaymentService($this->client);
$transactionType = \Adyen\TransactionType::NORMAL;
$poiId = $this->adyenHelper->getPoiId($this->storeId);
$serviceID = date("dHis");
$initiateDate = date("U");
$timeStamper = date("Y-m-d") . "T" . date("H:i:s+00:00");
$customerId = $quote->getCustomerId();
$request = [
'SaleToPOIRequest' =>
[
'MessageHeader' =>
[
'MessageType' => 'Request',
'MessageClass' => 'Service',
'MessageCategory' => 'Payment',
'SaleID' => 'Magento2Cloud',
'POIID' => $poiId,
'ProtocolVersion' => '3.0',
'ServiceID' => $serviceID,
],
'PaymentRequest' =>
[
'SaleData' =>
[
'TokenRequestedType' => 'Customer',
'SaleTransactionID' =>
[
'TransactionID' => $reference,
'TimeStamp' => $timeStamper,
],
],
'PaymentTransaction' =>
[
'AmountsReq' =>
[
'Currency' => $quote->getCurrency()->getQuoteCurrencyCode(),
'RequestedAmount' => doubleval($quote->getGrandTotal()),
],
],
'PaymentData' =>
[
'PaymentType' => $transactionType,
],
],
],
];
// If customer exists add it into the request to store request
if (!empty($customerId)) {
$shopperEmail = $quote->getCustomerEmail();
$recurringContract = $this->adyenHelper->getAdyenPosCloudConfigData('recurring_type', $this->storeId);
if (!empty($recurringContract) && !empty($shopperEmail)) {
$recurringDetails = [
'shopperEmail' => $shopperEmail,
'shopperReference' => strval($customerId),
'recurringContract' => $recurringContract
];
$request['SaleToPOIRequest']['PaymentRequest']['SaleData']['SaleToAcquirerData'] = http_build_query($recurringDetails);
}
}
$quote->getPayment()->getMethodInstance()->getInfoInstance()->setAdditionalInformation('serviceID',
$serviceID);
$quote->getPayment()->getMethodInstance()->getInfoInstance()->setAdditionalInformation('initiateDate',
$initiateDate);
try {
$response = $service->runTenderSync($request);
} catch (\Adyen\AdyenException $e) {
//Not able to perform a payment
$this->adyenLogger->addAdyenDebug("adyenexception");
$response['error'] = $e->getMessage();
} catch (\Exception $e) {
//Probably timeout
$quote->getPayment()->getMethodInstance()->getInfoInstance()->setAdditionalInformation('terminalResponse',
null);
$quote->save();
$response['error'] = $e->getMessage();
throw $e;
}
$quote->getPayment()->getMethodInstance()->getInfoInstance()->setAdditionalInformation('terminalResponse',
$response);
$quote->save();
return $response;
}
}
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment Module
*
* Copyright (c) 2018 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\Model;
class AdyenPaymentInformationManagement extends \Magento\Checkout\Model\PaymentInformationManagement
{
/**
* {@inheritDoc}
*/
public function savePaymentInformationAndPlaceOrder(
$cartId,
\Magento\Quote\Api\Data\PaymentInterface $paymentMethod,
\Magento\Quote\Api\Data\AddressInterface $billingAddress = null
) {
$this->savePaymentInformation($cartId, $paymentMethod, $billingAddress);
try {
$orderId = $this->cartManagement->placeOrder($cartId);
} catch (\Exception $e) {
throw $e;
}
return $orderId;
}
}
...@@ -162,4 +162,4 @@ class Agreement extends \Magento\Paypal\Model\Billing\Agreement ...@@ -162,4 +162,4 @@ class Agreement extends \Magento\Paypal\Model\Billing\Agreement
{ {
return json_decode($this->getData('agreement_data'), true); return json_decode($this->getData('agreement_data'), true);
} }
} }
\ No newline at end of file
...@@ -119,6 +119,11 @@ class Cron ...@@ -119,6 +119,11 @@ class Cron
*/ */
protected $_acquirerReference; protected $_acquirerReference;
/**
* @var
*/
protected $ratepayDescriptor;
/** /**
* @var * @var
*/ */
...@@ -327,22 +332,6 @@ class Cron ...@@ -327,22 +332,6 @@ class Cron
continue; continue;
} }
/**
* If the event is a RECURRING_CONTRACT wait an extra 5 minutes
* before processing so we are sure the RECURRING_CONTRACT
*/
if (trim($notification->getEventCode()) == Notification::RECURRING_CONTRACT &&
strtotime($notification->getCreatedAt()) >= strtotime('-5 minutes', time())
) {
$this->_adyenLogger->addAdyenNotificationCronjob(
"This is a recurring_contract notification wait an extra 5 minutes
before processing this to make sure the contract exists"
);
// set processing back to false
$this->_updateNotification($notification, false, false);
continue;
}
// log the executed notification // log the executed notification
$this->_adyenLogger->addAdyenNotificationCronjob(print_r($notification->debug(), 1)); $this->_adyenLogger->addAdyenNotificationCronjob(print_r($notification->debug(), 1));
...@@ -531,6 +520,10 @@ class Cron ...@@ -531,6 +520,10 @@ class Cron
if ($acquirerReference != "") { if ($acquirerReference != "") {
$this->_acquirerReference = $acquirerReference; $this->_acquirerReference = $acquirerReference;
} }
$ratepayDescriptor = isset($additionalData['openinvoicedata.descriptor']) ? $additionalData['openinvoicedata.descriptor'] : "";
if ($ratepayDescriptor !== "") {
$this->ratepayDescriptor = $ratepayDescriptor;
}
} }
} }
...@@ -730,6 +723,12 @@ class Cron ...@@ -730,6 +723,12 @@ class Cron
if (!empty($expiryDate)) { if (!empty($expiryDate)) {
$this->_order->getPayment()->setAdditionalInformation('adyen_expiry_date', $expiryDate); $this->_order->getPayment()->setAdditionalInformation('adyen_expiry_date', $expiryDate);
} }
if ($this->ratepayDescriptor !== "") {
$this->_order->getPayment()->setAdditionalInformation(
'adyen_ratepay_descriptor', $this->ratepayDescriptor
);
}
} }
/** /**
...@@ -1310,6 +1309,22 @@ class Cron ...@@ -1310,6 +1309,22 @@ class Cron
return true; return true;
} }
if ($_paymentCode == "adyen_pos_cloud") {
$captureModePos = $this->_adyenHelper->getAdyenPosCloudConfigData('capture_mode_pos', $this->_order->getStoreId());
if (strcmp($captureModePos, 'auto') === 0) {
$this->_adyenLogger->addAdyenNotificationCronjob(
'This payment method is POS Cloud and configured to be working as auto capture '
);
return true;
} elseif (strcmp($captureModePos, 'manual') === 0) {
$this->_adyenLogger->addAdyenNotificationCronjob(
'This payment method is POS Cloud and configured to be working as manual capture '
);
return false;
}
}
// if auto capture mode for openinvoice is turned on then use auto capture // if auto capture mode for openinvoice is turned on then use auto capture
if ($captureModeOpenInvoice == true && if ($captureModeOpenInvoice == true &&
$this->_adyenHelper->isPaymentMethodOpenInvoiceMethod($this->_paymentMethod) $this->_adyenHelper->isPaymentMethodOpenInvoiceMethod($this->_paymentMethod)
......
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment Module
*
* Copyright (c) 2018 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\Model\Ui;
use Magento\Checkout\Model\ConfigProviderInterface;
class AdyenPosCloudConfigProvider implements ConfigProviderInterface
{
const CODE = 'adyen_pos_cloud';
/**
* Request object
*
* @var \Magento\Framework\App\RequestInterface
*/
protected $request;
/**
* @var \Magento\Framework\UrlInterface
*/
protected $urlBuilder;
/**
* AdyenHppConfigProvider constructor.
*
* @param PaymentHelper $paymentHelper
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/
public function __construct(
\Magento\Framework\App\RequestInterface $request,
\Magento\Framework\UrlInterface $urlBuilder
) {
$this->request = $request;
$this->urlBuilder = $urlBuilder;
}
/**
* Set configuration for POS Cloud Api payment method
*
* @return array
*/
public function getConfig()
{
// set to active
$config = [
'payment' => [
self::CODE => [
'isActive' => true,
'redirectUrl' => $this->urlBuilder->getUrl(
'/checkout/onepage/success/', ['_secure' => $this->getRequest()->isSecure()])
]
]
];
return $config;
}
/**
* Retrieve request object
*
* @return \Magento\Framework\App\RequestInterface
*/
protected function getRequest()
{
return $this->request;
}
}
...@@ -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.3", "version": "2.4.0",
"license": [ "license": [
"OSL-3.0", "OSL-3.0",
"AFL-3.0" "AFL-3.0"
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
<include path="Adyen_Payment::system/adyen_hpp.xml"/> <include path="Adyen_Payment::system/adyen_hpp.xml"/>
<include path="Adyen_Payment::system/adyen_sepa.xml"/> <include path="Adyen_Payment::system/adyen_sepa.xml"/>
<include path="Adyen_Payment::system/adyen_pos.xml"/> <include path="Adyen_Payment::system/adyen_pos.xml"/>
<include path="Adyen_Payment::system/adyen_pos_cloud.xml"/>
<include path="Adyen_Payment::system/adyen_pay_by_mail.xml"/> <include path="Adyen_Payment::system/adyen_pay_by_mail.xml"/>
<include path="Adyen_Payment::system/adyen_boleto.xml"/> <include path="Adyen_Payment::system/adyen_boleto.xml"/>
<include path="Adyen_Payment::system/adyen_apple_pay.xml"/> <include path="Adyen_Payment::system/adyen_apple_pay.xml"/>
......
...@@ -32,11 +32,5 @@ ...@@ -32,11 +32,5 @@
<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/ignore_refund_notification</config_path> <config_path>payment/adyen_abstract/ignore_refund_notification</config_path>
</field> </field>
<field id="multiple_merchants" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Allow multiple merchants</label>
<tooltip><![CDATA[Allow notifications sent from other Adyen merchant accounts. Keep in mind that the Notification user name and password should be the same for all the merchant accounts]]></tooltip>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/adyen_abstract/multiple_merchants</config_path>
</field>
</group> </group>
</include> </include>
\ No newline at end of file
...@@ -50,4 +50,4 @@ ...@@ -50,4 +50,4 @@
<config_path>payment/adyen_oneclick/recurring_payment_type</config_path> <config_path>payment/adyen_oneclick/recurring_payment_type</config_path>
</field> </field>
</group> </group>
</include> </include>
\ No newline at end of file
<?xml version="1.0"?>
<!--
~ ######
~ ######
~ ############ ####( ###### #####. ###### ############ ############
~ ############# #####( ###### #####. ###### ############# #############
~ ###### #####( ###### #####. ###### ##### ###### ##### ######
~ ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
~ ###### ###### #####( ###### #####. ###### ##### ##### ######
~ ############# ############# ############# ############# ##### ######
~ ############ ############ ############# ############ ##### ######
~ ######
~ #############
~ ############
~
~ Adyen Payment Module
~
~ Copyright (c) 2018 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>
-->
<include xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_include.xsd">
<group id="adyen_pos_cloud" translate="label" type="text" sortOrder="350" showInDefault="1" showInWebsite="1" showInStore="1">
<label><![CDATA[Point of Sale (POS) integration with Cloud API]]></label>
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Payment</frontend_model>
<fieldset_css>adyen-method-adyen-cc</fieldset_css>
<comment>Process Point of Sales transactions</comment>
<field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enabled</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/adyen_pos_cloud/active</config_path>
</field>
<field id="title" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Title</label>
<config_path>payment/adyen_pos_cloud/title</config_path>
</field>
<field id="sort_order" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Sort Order</label>
<frontend_class>validate-number</frontend_class>
<config_path>payment/adyen_pos_cloud/sort_order</config_path>
</field>
<field id="pos_terminal_id" translate="label" type="text" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Unique Terminal ID for Cloud API</label>
<tooltip>Copy this from the Adyen Customer Area => Point of sale => Terminal Fleet Manager => Unique Terminal Id </tooltip>
<config_path>payment/adyen_pos_cloud/pos_terminal_id</config_path>
</field>
<field id="pos_merchant_account" translate="label" type="text" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Merchant Account for Cloud API</label>
<can_be_empty>1</can_be_empty>
<tooltip>Please insert your Merchant Account name used by the Cloud API. Please leave it blank if the Merchant Account is the same as the one configured in the Required Settings</tooltip>
<config_path>payment/adyen_pos_cloud/pos_merchant_account</config_path>
</field>
<field id="api_key_test" translate="label" type="obscure" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0">
<label>API key for Cloud API TEST</label>
<tooltip>Copy this from the Test Adyen Customer Area => Settings => Users => System => [web service user]=> Checkout API Key.</tooltip>
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
<config_path>payment/adyen_pos_cloud/api_key_test</config_path>
</field>
<field id="api_key_live" translate="label" type="obscure" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="0">
<label>API key for Cloud API LIVE</label>
<tooltip>Copy this from the Live Adyen Customer Area => Settings => Users => System => [web service user]=> Checkout API Key.</tooltip>
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
<config_path>payment/adyen_pos_cloud/api_key_live</config_path>
</field>
<field id="capture_mode_pos" translate="label" type="select" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Capture Delay</label>
<tooltip>Please set your Capture Delay for POS transactions. Immediate is the default. Set to manual if you want to perform the capture of funds manually later. You need to change this setting as well in Adyen Customer Area => Settings => Merchant Settings => POS Capture Delay. If you have selected a capture delay of a couple of days in Adyen keep it here on immediate</tooltip>
<source_model>Adyen\Payment\Model\Config\Source\CaptureMode</source_model>
<config_path>payment/adyen_pos_cloud/capture_mode_pos</config_path>
</field>
<field id="recurring_type" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Agreement Type</label>
<tooltip>You can set different value for POS because you have to have the permission of the customer</tooltip>
<source_model>Adyen\Payment\Model\Config\Source\RecurringType</source_model>
<config_path>payment/adyen_pos_cloud/recurring_type</config_path>
</field>
<group id="adyen_pos_country_specific" translate="label" showInDefault="1" showInWebsite="1" sortOrder="210">
<label>Country Specific Settings</label>
<frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
<field id="allowspecific" translate="label" type="allowspecific" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Payment from Applicable Countries</label>
<source_model>Magento\Payment\Model\Config\Source\Allspecificcountries</source_model>
<config_path>payment/adyen_pos_cloud/allowspecific</config_path>
</field>
<field id="specificcountry" translate="label" type="multiselect" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Payment from Specific Countries</label>
<source_model>Magento\Directory\Model\Config\Source\Country</source_model>
<can_be_empty>1</can_be_empty>
<config_path>payment/adyen_pos_cloud/specificcountry</config_path>
</field>
</group>
</group>
</include>
\ No newline at end of file
...@@ -149,13 +149,36 @@ ...@@ -149,13 +149,36 @@
<can_cancel>1</can_cancel> <can_cancel>1</can_cancel>
<group>adyen</group> <group>adyen</group>
</adyen_pos> </adyen_pos>
<adyen_pos_cloud>
<active>0</active>
<model>AdyenPaymentPosCloudFacade</model>
<order_status>pending</order_status>
<title>Adyen POS Cloud API</title>
<allowspecific>0</allowspecific>
<sort_order>6</sort_order>
<payment_action>authorize</payment_action>
<is_gateway>1</is_gateway>
<can_authorize>1</can_authorize>
<can_use_checkout>1</can_use_checkout>
<can_capture>1</can_capture>
<can_capture_partial>1</can_capture_partial>
<can_use_internal>0</can_use_internal>
<can_refund_partial_per_invoice>1</can_refund_partial_per_invoice>
<can_refund>1</can_refund>
<can_void>1</can_void>
<can_cancel>1</can_cancel>
<pos_timeout>30</pos_timeout>
<total_timeout>120</total_timeout>
<recurring_type>ONECLICK</recurring_type>
<group>adyen</group>
</adyen_pos_cloud>
<adyen_pay_by_mail> <adyen_pay_by_mail>
<active>0</active> <active>0</active>
<model>AdyenPaymentPayByMailFacade</model> <model>AdyenPaymentPayByMailFacade</model>
<order_status>pending</order_status> <order_status>pending</order_status>
<title>Adyen PayByMail</title> <title>Adyen PayByMail</title>
<allowspecific>0</allowspecific> <allowspecific>0</allowspecific>
<sort_order>6</sort_order> <sort_order>7</sort_order>
<session_validity>3</session_validity> <session_validity>3</session_validity>
<payment_action>order</payment_action> <payment_action>order</payment_action>
<is_gateway>1</is_gateway> <is_gateway>1</is_gateway>
...@@ -175,7 +198,7 @@ ...@@ -175,7 +198,7 @@
<model>AdyenPaymentBoletoFacade</model> <model>AdyenPaymentBoletoFacade</model>
<title>Boleto</title> <title>Boleto</title>
<allowspecific>0</allowspecific> <allowspecific>0</allowspecific>
<sort_order>7</sort_order> <sort_order>8</sort_order>
<payment_action>authorize</payment_action> <payment_action>authorize</payment_action>
<delivery_days>5</delivery_days> <delivery_days>5</delivery_days>
<is_gateway>1</is_gateway> <is_gateway>1</is_gateway>
...@@ -195,7 +218,7 @@ ...@@ -195,7 +218,7 @@
<model>AdyenPaymentApplePayFacade</model> <model>AdyenPaymentApplePayFacade</model>
<title>Adyen Apple Pay</title> <title>Adyen Apple Pay</title>
<allowspecific>0</allowspecific> <allowspecific>0</allowspecific>
<sort_order>8</sort_order> <sort_order>9</sort_order>
<payment_action>authorize</payment_action> <payment_action>authorize</payment_action>
<is_gateway>1</is_gateway> <is_gateway>1</is_gateway>
<can_use_checkout>1</can_use_checkout> <can_use_checkout>1</can_use_checkout>
......
...@@ -94,6 +94,16 @@ ...@@ -94,6 +94,16 @@
<argument name="commandPool" xsi:type="object">AdyenPaymentPosCommandPool</argument> <argument name="commandPool" xsi:type="object">AdyenPaymentPosCommandPool</argument>
</arguments> </arguments>
</virtualType> </virtualType>
<virtualType name="AdyenPaymentPosCloudFacade" type="Magento\Payment\Model\Method\Adapter">
<arguments>
<argument name="code" xsi:type="const">Adyen\Payment\Model\Ui\AdyenPosCloudConfigProvider::CODE</argument>
<argument name="formBlockType" xsi:type="string">Adyen\Payment\Block\Form\PosCloud</argument>
<argument name="infoBlockType" xsi:type="string">Adyen\Payment\Block\Info\PosCloud</argument>
<argument name="valueHandlerPool" xsi:type="object">AdyenPaymentPosCloudValueHandlerPool</argument>
<argument name="validatorPool" xsi:type="object">AdyenPaymentPosCloudValidatorPool</argument>
<argument name="commandPool" xsi:type="object">AdyenPaymentPosCloudCommandPool</argument>
</arguments>
</virtualType>
<virtualType name="AdyenPaymentPayByMailFacade" type="Magento\Payment\Model\Method\Adapter"> <virtualType name="AdyenPaymentPayByMailFacade" type="Magento\Payment\Model\Method\Adapter">
<arguments> <arguments>
<argument name="code" xsi:type="const">Adyen\Payment\Model\Ui\AdyenPayByMailConfigProvider::CODE</argument> <argument name="code" xsi:type="const">Adyen\Payment\Model\Ui\AdyenPayByMailConfigProvider::CODE</argument>
...@@ -202,11 +212,23 @@ ...@@ -202,11 +212,23 @@
</argument> </argument>
</arguments> </arguments>
</virtualType> </virtualType>
<virtualType name="AdyenPaymentPosCloudValueHandlerPool" type="Magento\Payment\Gateway\Config\ValueHandlerPool">
<arguments>
<argument name="handlers" xsi:type="array">
<item name="default" xsi:type="string">AdyenPaymentPosCloudConfigValueHandler</item>
</argument>
</arguments>
</virtualType>
<virtualType name="AdyenPaymentPosConfigValueHandler" type="Magento\Payment\Gateway\Config\ConfigValueHandler"> <virtualType name="AdyenPaymentPosConfigValueHandler" type="Magento\Payment\Gateway\Config\ConfigValueHandler">
<arguments> <arguments>
<argument name="configInterface" xsi:type="object">AdyenPaymentPosConfig</argument> <argument name="configInterface" xsi:type="object">AdyenPaymentPosConfig</argument>
</arguments> </arguments>
</virtualType> </virtualType>
<virtualType name="AdyenPaymentPosCloudConfigValueHandler" type="Magento\Payment\Gateway\Config\ConfigValueHandler">
<arguments>
<argument name="configInterface" xsi:type="object">AdyenPaymentPosCloudConfig</argument>
</arguments>
</virtualType>
<virtualType name="AdyenPaymentPayByMailValueHandlerPool" type="Magento\Payment\Gateway\Config\ValueHandlerPool"> <virtualType name="AdyenPaymentPayByMailValueHandlerPool" type="Magento\Payment\Gateway\Config\ValueHandlerPool">
<arguments> <arguments>
...@@ -271,6 +293,11 @@ ...@@ -271,6 +293,11 @@
<argument name="methodCode" xsi:type="const">Adyen\Payment\Model\Ui\AdyenPosConfigProvider::CODE</argument> <argument name="methodCode" xsi:type="const">Adyen\Payment\Model\Ui\AdyenPosConfigProvider::CODE</argument>
</arguments> </arguments>
</virtualType> </virtualType>
<virtualType name="AdyenPaymentPosCloudConfig" type="Magento\Payment\Gateway\Config\Config">
<arguments>
<argument name="methodCode" xsi:type="const">Adyen\Payment\Model\Ui\AdyenPosCloudConfigProvider::CODE</argument>
</arguments>
</virtualType>
<virtualType name="AdyenPaymentPayByMailConfig" type="Magento\Payment\Gateway\Config\Config"> <virtualType name="AdyenPaymentPayByMailConfig" type="Magento\Payment\Gateway\Config\Config">
<arguments> <arguments>
<argument name="methodCode" xsi:type="const">Adyen\Payment\Model\Ui\AdyenPayByMailConfigProvider::CODE</argument> <argument name="methodCode" xsi:type="const">Adyen\Payment\Model\Ui\AdyenPayByMailConfigProvider::CODE</argument>
...@@ -358,6 +385,18 @@ ...@@ -358,6 +385,18 @@
</arguments> </arguments>
</virtualType> </virtualType>
<virtualType name="AdyenPaymentPosCloudCommandPool" type="Magento\Payment\Gateway\Command\CommandPool">
<arguments>
<argument name="commands" xsi:type="array">
<item name="authorize" xsi:type="string">AdyenPaymentPosCloudAuthorizeCommand</item>
<item name="capture" xsi:type="string">AdyenPaymentCaptureCommand</item>
<item name="void" xsi:type="string">AdyenPaymentCancelCommand</item>
<item name="refund" xsi:type="string">AdyenPaymentRefundCommand</item>
<item name="cancel" xsi:type="string">AdyenPaymentCancelCommand</item>
</argument>
</arguments>
</virtualType>
<virtualType name="AdyenPaymentPayByMailCommandPool" type="Magento\Payment\Gateway\Command\CommandPool"> <virtualType name="AdyenPaymentPayByMailCommandPool" type="Magento\Payment\Gateway\Command\CommandPool">
<arguments> <arguments>
<argument name="commands" xsi:type="array"> <argument name="commands" xsi:type="array">
...@@ -432,6 +471,16 @@ ...@@ -432,6 +471,16 @@
</arguments> </arguments>
</virtualType> </virtualType>
<virtualType name="AdyenPaymentPosCloudAuthorizeCommand" type="Magento\Payment\Gateway\Command\GatewayCommand">
<arguments>
<argument name="requestBuilder" xsi:type="object">AdyenPaymentPosCloudAuthorizeRequest</argument>
<argument name="transferFactory" xsi:type="object">Adyen\Payment\Gateway\Http\TransferFactory</argument>
<argument name="client" xsi:type="object">Adyen\Payment\Gateway\Http\Client\TransactionPosCloudSync</argument>
<argument name="validator" xsi:type="object">PosCloudResponseValidator</argument>
<argument name="handler" xsi:type="object">AdyenPaymentPosCloudResponseHandlerComposite</argument>
</arguments>
</virtualType>
<virtualType name="AdyenPaymentApplePayAuthorizeCommand" type="Magento\Payment\Gateway\Command\GatewayCommand"> <virtualType name="AdyenPaymentApplePayAuthorizeCommand" type="Magento\Payment\Gateway\Command\GatewayCommand">
<arguments> <arguments>
<argument name="requestBuilder" xsi:type="object">AdyenPaymentApplePayAuthorizeRequest</argument> <argument name="requestBuilder" xsi:type="object">AdyenPaymentApplePayAuthorizeRequest</argument>
...@@ -547,6 +596,14 @@ ...@@ -547,6 +596,14 @@
</arguments> </arguments>
</virtualType> </virtualType>
<virtualType name="AdyenPaymentPosCloudAuthorizeRequest" type="Magento\Payment\Gateway\Request\BuilderComposite">
<arguments>
<argument name="builders" xsi:type="array">
<item name="poscloud" xsi:type="string">Adyen\Payment\Gateway\Request\PosCloudBuilder</item>
</argument>
</arguments>
</virtualType>
<virtualType name="AdyenPaymentApplePayAuthorizeRequest" type="Magento\Payment\Gateway\Request\BuilderComposite"> <virtualType name="AdyenPaymentApplePayAuthorizeRequest" type="Magento\Payment\Gateway\Request\BuilderComposite">
<arguments> <arguments>
<argument name="builders" xsi:type="array"> <argument name="builders" xsi:type="array">
...@@ -614,6 +671,14 @@ ...@@ -614,6 +671,14 @@
</argument> </argument>
</arguments> </arguments>
</virtualType> </virtualType>
<virtualType name="AdyenPaymentPosCloudResponseHandlerComposite" type="Magento\Payment\Gateway\Response\HandlerChain">
<arguments>
<argument name="handlers" xsi:type="array">
<item name="payment_details" xsi:type="string">Adyen\Payment\Gateway\Response\PaymentPosCloudHandler</item>
</argument>
</arguments>
</virtualType>
<virtualType name="AdyenPaymentResponseHandlerComposite" type="Magento\Payment\Gateway\Response\HandlerChain"> <virtualType name="AdyenPaymentResponseHandlerComposite" type="Magento\Payment\Gateway\Response\HandlerChain">
<arguments> <arguments>
<argument name="handlers" xsi:type="array"> <argument name="handlers" xsi:type="array">
...@@ -724,11 +789,23 @@ ...@@ -724,11 +789,23 @@
</argument> </argument>
</arguments> </arguments>
</virtualType> </virtualType>
<virtualType name="AdyenPaymentPosCloudValidatorPool" type="Magento\Payment\Gateway\Validator\ValidatorPool">
<arguments>
<argument name="validators" xsi:type="array">
<item name="country" xsi:type="string">AdyenPosCloudCountryValidator</item>
</argument>
</arguments>
</virtualType>
<virtualType name="AdyenPosCountryValidator" type="Magento\Payment\Gateway\Validator\CountryValidator"> <virtualType name="AdyenPosCountryValidator" type="Magento\Payment\Gateway\Validator\CountryValidator">
<arguments> <arguments>
<argument name="config" xsi:type="object">AdyenPaymentPosConfig</argument> <argument name="config" xsi:type="object">AdyenPaymentPosConfig</argument>
</arguments> </arguments>
</virtualType> </virtualType>
<virtualType name="AdyenPosCloudCountryValidator" type="Magento\Payment\Gateway\Validator\CountryValidator">
<arguments>
<argument name="config" xsi:type="object">AdyenPaymentPosCloudConfig</argument>
</arguments>
</virtualType>
<virtualType name="AdyenPaymentPayByMailValidatorPool" type="Magento\Payment\Gateway\Validator\ValidatorPool"> <virtualType name="AdyenPaymentPayByMailValidatorPool" type="Magento\Payment\Gateway\Validator\ValidatorPool">
<arguments> <arguments>
...@@ -764,6 +841,11 @@ ...@@ -764,6 +841,11 @@
</arguments> </arguments>
</virtualType> </virtualType>
<virtualType name="PosCloudResponseValidator" type="Adyen\Payment\Gateway\Validator\PosCloudResponseValidator">
<arguments>
<argument name="loggerInterface" xsi:type="object">Adyen\Payment\Logger\AdyenLogger</argument>
</arguments>
</virtualType>
<preference for="Magento\Paypal\Model\Billing\Agreement" type="Adyen\Payment\Model\Billing\Agreement" /> <preference for="Magento\Paypal\Model\Billing\Agreement" type="Adyen\Payment\Model\Billing\Agreement" />
<type name="Adyen\Payment\Logger\Handler\AdyenDebug"> <type name="Adyen\Payment\Logger\Handler\AdyenDebug">
...@@ -833,4 +915,6 @@ ...@@ -833,4 +915,6 @@
<preference for="Adyen\Payment\Api\GuestAdyenPaymentMethodManagementInterface" type="Adyen\Payment\Model\GuestAdyenPaymentMethodManagement" /> <preference for="Adyen\Payment\Api\GuestAdyenPaymentMethodManagementInterface" type="Adyen\Payment\Model\GuestAdyenPaymentMethodManagement" />
<preference for="Adyen\Payment\Api\AdyenPaymentMethodManagementInterface" type="Adyen\Payment\Model\AdyenPaymentMethodManagement" /> <preference for="Adyen\Payment\Api\AdyenPaymentMethodManagementInterface" type="Adyen\Payment\Model\AdyenPaymentMethodManagement" />
<preference for="Adyen\Payment\Api\AdyenRequestMerchantSessionInterface" type="Adyen\Payment\Model\AdyenRequestMerchantSession" /> <preference for="Adyen\Payment\Api\AdyenRequestMerchantSessionInterface" type="Adyen\Payment\Model\AdyenRequestMerchantSession" />
<preference for="Adyen\Payment\Api\AdyenInitiateTerminalApiInterface" type="Adyen\Payment\Model\AdyenInitiateTerminalApi" />
<preference for="Magento\Checkout\Api\PaymentInformationManagementInterface" type="Adyen\Payment\Model\AdyenPaymentInformationManagement" />
</config> </config>
\ No newline at end of file
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
<item name="adyen_sepa_config_provider" xsi:type="object">Adyen\Payment\Model\Ui\AdyenSepaConfigProvider</item> <item name="adyen_sepa_config_provider" xsi:type="object">Adyen\Payment\Model\Ui\AdyenSepaConfigProvider</item>
<item name="adyen_boleto_config_provider" xsi:type="object">Adyen\Payment\Model\Ui\AdyenBoletoConfigProvider</item> <item name="adyen_boleto_config_provider" xsi:type="object">Adyen\Payment\Model\Ui\AdyenBoletoConfigProvider</item>
<item name="adyen_pos_config_provider" xsi:type="object">Adyen\Payment\Model\Ui\AdyenPosConfigProvider</item> <item name="adyen_pos_config_provider" xsi:type="object">Adyen\Payment\Model\Ui\AdyenPosConfigProvider</item>
<item name="adyen_pos_cloud_config_provider" xsi:type="object">Adyen\Payment\Model\Ui\AdyenPosCloudConfigProvider</item>
<item name="adyen_apple_pay_config_provider" xsi:type="object">Adyen\Payment\Model\Ui\AdyenApplePayConfigProvider</item> <item name="adyen_apple_pay_config_provider" xsi:type="object">Adyen\Payment\Model\Ui\AdyenApplePayConfigProvider</item>
</argument> </argument>
</arguments> </arguments>
......
...@@ -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.3"> <module name="Adyen_Payment" setup_version="2.4.0">
<sequence> <sequence>
<module name="Magento_Sales"/> <module name="Magento_Sales"/>
<module name="Magento_Quote"/> <module name="Magento_Quote"/>
......
...@@ -50,4 +50,11 @@ ...@@ -50,4 +50,11 @@
<resource ref="anonymous"/> <resource ref="anonymous"/>
</resources> </resources>
</route> </route>
<route url="/V1/adyen/initiate" method="POST">
<service class="Adyen\Payment\Api\AdyenInitiateTerminalApiInterface" method="initiate"/>
<resources>
<resource ref="anonymous"/>
</resources>
</route>
</routes> </routes>
\ No newline at end of file
...@@ -85,4 +85,9 @@ $_isDemoMode = $block->isDemoMode(); ...@@ -85,4 +85,9 @@ $_isDemoMode = $block->isDemoMode();
</table> </table>
<?php endif;?> <?php endif;?>
<?php if ($ratepayDescriptor = $_info->getAdditionalInformation('adyen_ratepay_descriptor')):?>
<div><?php echo __('Invoice Descriptor: %1', $ratepayDescriptor); ?>
</div>
<?php endif;?>
<?php echo $block->getChildHtml()?> <?php echo $block->getChildHtml()?>
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2018 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
// @codingStandardsIgnoreFile
?>
<?php
/**
* @see \Magento\Payment\Block\Info
*/
?>
<?php echo $block->escapeHtml($block->getMethod()->getTitle()) ?>
<?php
$_info = $this->getInfo();
$_isDemoMode = $block->isDemoMode();
?>
<?php if ($_pspReference = $_info->getAdditionalInformation('pspReference')):?>
<div>
<?php if($_isDemoMode): ?>
<?php echo __('Adyen PSP Reference: <a href="https://ca-test.adyen.com/ca/ca/accounts/showTx.shtml?pspReference=%1&txType=Payment" target="__blank">%1</a>', $block->escapeHtml($_pspReference), $block->escapeHtml($_pspReference)) ?>
<?php else: ?>
<?php echo __('Adyen PSP Reference: <a href="https://ca-live.adyen.com/ca/ca/accounts/showTx.shtml?pspReference=%1&txType=Payment" target="__blank">%1</a>', $block->escapeHtml($_pspReference), $block->escapeHtml($_pspReference)) ?>
<?php endif; ?>
</div>
<?php endif;?>
<?php if($_info->getAdditionalInformation('adyen_total_fraud_score') != ""): ?>
<?php echo __('Total fraud score: %1', $_info->getAdditionalInformation('adyen_total_fraud_score')) ?><br/>
<?php endif; ?>
<?php if ($_specificInfo = $block->getSpecificInformation()):?>
<table class="data-table admin__table-secondary">
<?php foreach ($_specificInfo as $_label => $_value):?>
<tr>
<th><?php echo $block->escapeHtml($_label)?>:</th>
<td><?php echo nl2br(implode("\n", $block->getValueAsArray($_value, true)))?></td>
</tr>
<?php endforeach; ?>
</table>
<?php endif;?>
<?php echo $block->getChildHtml()?>
<style>
table.terminal-api-receipt{margin-top: 10px}
td.terminal-api-receipt-name{padding:inherit; font-weight: 700}
td.terminal-api-receipt-value{padding:inherit;}
tr.terminal-api-receipt{padding-bottom: 5px;}
</style>
<?php echo $this->getMethod()->getInfoInstance()->getAdditionalInformation('receipt');?>
\ No newline at end of file
...@@ -61,10 +61,13 @@ ...@@ -61,10 +61,13 @@
<item name="adyen_boleto" xsi:type="array"> <item name="adyen_boleto" xsi:type="array">
<item name="isBillingAddressRequired" xsi:type="boolean">true</item> <item name="isBillingAddressRequired" xsi:type="boolean">true</item>
</item> </item>
<item name="adyen_apple_pay" xsi:type="array">
<item name="isBillingAddressRequired" xsi:type="boolean">true</item>
</item>
<item name="adyen_pos" xsi:type="array"> <item name="adyen_pos" xsi:type="array">
<item name="isBillingAddressRequired" xsi:type="boolean">true</item> <item name="isBillingAddressRequired" xsi:type="boolean">true</item>
</item> </item>
<item name="adyen_apple_pay" xsi:type="array"> <item name="adyen_pos_cloud" xsi:type="array">
<item name="isBillingAddressRequired" xsi:type="boolean">true</item> <item name="isBillingAddressRequired" xsi:type="boolean">true</item>
</item> </item>
</item> </item>
......
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment Module
*
* Copyright (c) 2018 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>
*/
// @codingStandardsIgnoreFile
?>
<?php
$_info = $this->getInfo();
?>
<dl class="payment-method adyen_pos_cloud">
<dt class="title"><?php echo $block->escapeHtml($block->getMethod()->getTitle()) ?></dt>
<style>
table.terminal-api-receipt{margin-top: 10px}
td.terminal-api-receipt-name{padding:inherit; font-weight: 700}
td.terminal-api-receipt-value{padding:inherit;}
tr.terminal-api-receipt{padding-bottom: 5px;}
</style>
<?php
$receipt = $this->getMethod()->getInfoInstance()->getAdditionalInformation('receipt');
echo $receipt;
?>
</dl>
...@@ -53,6 +53,10 @@ ...@@ -53,6 +53,10 @@
background-position: 0 -1819px; background-position: 0 -1819px;
} }
.checkout-payment-method .payment-method-title label div.adyen-sprite.adyen_pos_cloud {
background-position: 0 -1819px;
}
.checkout-payment-method .payment-method-title label div.adyen-sprite.adyen_sepa { .checkout-payment-method .payment-method-title label div.adyen-sprite.adyen_sepa {
background-position: 0 -1910px; background-position: 0 -1910px;
} }
......
...@@ -59,6 +59,10 @@ define( ...@@ -59,6 +59,10 @@ define(
{ {
type: 'adyen_apple_pay', type: 'adyen_apple_pay',
component: 'Adyen_Payment/js/view/payment/method-renderer/adyen-apple-pay-method' component: 'Adyen_Payment/js/view/payment/method-renderer/adyen-apple-pay-method'
},
{
type: 'adyen_pos_cloud',
component: 'Adyen_Payment/js/view/payment/method-renderer/adyen-pos-cloud-method'
} }
); );
/** Add view logic here if needed */ /** Add view logic here if needed */
......
/*
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment Module
*
* Copyright (c) 2018 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>
*/
/*browser:true*/
/*global define*/
define(
[
'ko',
'jquery',
'Magento_Checkout/js/view/payment/default',
'Magento_Checkout/js/model/payment/additional-validators',
'Magento_Checkout/js/action/place-order',
'Magento_Checkout/js/model/quote',
'Magento_CheckoutAgreements/js/model/agreements-assigner',
'Magento_Customer/js/model/customer',
'Magento_Checkout/js/model/url-builder',
'mage/storage',
'Magento_Checkout/js/model/full-screen-loader',
'Magento_Checkout/js/model/error-processor',
'Magento_Ui/js/model/messages',
'Magento_Checkout/js/action/redirect-on-success'
],
function (ko, $, Component, additionalValidators, placeOrderAction, quote, agreementsAssigner, customer, urlBuilder, storage, fullScreenLoader, errorProcessor, Messages, redirectOnSuccessAction) {
'use strict';
return Component.extend({
self: this,
defaults: {
template: 'Adyen_Payment/payment/pos-cloud-form'
},
initiate: function () {
var self = this,
serviceUrl,
paymentData = quote.paymentMethod();
// use core code to assign the agreement
agreementsAssigner(paymentData);
serviceUrl = urlBuilder.createUrl('/adyen/initiate', {});
fullScreenLoader.startLoader();
return storage.post(
serviceUrl
).always(function(){
self.placeOrderPos()});
return false;
},
posComplete: function () {
this.afterPlaceOrder();
if (this.redirectAfterPlaceOrder) {
redirectOnSuccessAction.execute();
}
},
placeOrderPos: function () {
var self = this;
return $.when(
placeOrderAction(self.getData(), new Messages())
).fail(
function (response) {
if (response.responseText.indexOf("In Progress") > -1) {
window.setTimeout(function(){
self.placeOrderPos()},5000);
return;
}
errorProcessor.process(response);
fullScreenLoader.stopLoader();
self.isPlaceOrderActionAllowed(true);
}
).done(
function () {
self.posComplete();
}
)
},
showLogo: function () {
return window.checkoutConfig.payment.adyen.showLogo;
},
validate: function () {
return true;
}
});
}
);
...@@ -101,7 +101,7 @@ ...@@ -101,7 +101,7 @@
<span><!-- ko text: $t('Credit Card Number')--><!-- /ko --></span> <span><!-- ko text: $t('Credit Card Number')--><!-- /ko --></span>
</label> </label>
<div class="control"> <div class="control">
<input type="number" class="input-text" value="" <input type="tel" class="input-text" value=""
data-encrypted-name="number" data-encrypted-name="number"
data-bind="attr: { data-bind="attr: {
autocomplete: off, autocomplete: off,
......
<!--
~ ######
~ ######
~ ############ ####( ###### #####. ###### ############ ############
~ ############# #####( ###### #####. ###### ############# #############
~ ###### #####( ###### #####. ###### ##### ###### ##### ######
~ ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
~ ###### ###### #####( ###### #####. ###### ##### ##### ######
~ ############# ############# ############# ############# ##### ######
~ ############ ############ ############# ############ ##### ######
~ ######
~ #############
~ ############
~
~ Adyen Payment Module
~
~ Copyright (c) 2018 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>
-->
<div class="payment-method" data-bind="css: {'_active': (getCode() == isChecked())}">
<div class="payment-method-title field choice">
<input type="radio"
name="payment[method]"
class="radio"
data-bind="attr: {'id': getCode()}, value: getCode(), checked: isChecked, click: selectPaymentMethod, visible: isRadioButtonVisible()"/>
<label data-bind="attr: {'for': getCode()}" class="label">
<!-- ko if: showLogo() -->
<div data-bind="attr: { 'class': 'adyen-sprite ' + getCode() }"></div>
<!--/ko-->
<span data-bind="text: getTitle()"></span>
</label>
</div>
<!-- ko foreach: getRegion('messages') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
<div class="payment-method-content">
<div class="payment-method-billing-address">
<!-- ko foreach: $parent.getRegion(getBillingAddressFormName()) -->
<!-- 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: initiate,
attr: {title: $t('Place Order')},
enable: (getCode() == isChecked()),
css: {disabled: !isPlaceOrderActionAllowed()}
"
disabled>
<span data-bind="text: $t('Place Order')"></span>
</button>
</div>
</div>
</div>
</div>
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