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 092904d0 authored by attilak's avatar attilak

Add payload to AdyenInitiateTerminalApiInterface initiate

Enable place order when there are terminals connected only
Require php library v2.1.0
parent ce279470
......@@ -28,7 +28,8 @@ interface AdyenInitiateTerminalApiInterface
{
/**
* Trigger sync call on terminal
* @param string $payload
* @return mixed
*/
public function initiate();
public function initiate($payload);
}
......@@ -24,7 +24,6 @@
namespace Adyen\Payment\Model;
use Adyen\AdyenException;
use Adyen\Payment\Api\AdyenInitiateTerminalApiInterface;
use Adyen\Payment\Model\Ui\AdyenPosCloudConfigProvider;
use Adyen\Util\Util;
......@@ -94,8 +93,22 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface
* @return mixed
* @throws \Exception
*/
public function initiate()
public function initiate($payload)
{
// Decode payload from frontend
$payload = json_decode($payload, true);
// Validate JSON that has just been parsed if it was in a valid format
if (json_last_error() !== JSON_ERROR_NONE) {
throw new \Magento\Framework\Exception\LocalizedException(__('Terminal API initiate request was not a valid JSON'));
}
if (empty($payload['terminal_id'])) {
throw new \Adyen\AdyenException("Terminal ID is empty in initiate request");
}
$poiId = $payload['terminal_id'];
$quote = $this->checkoutSession->getQuote();
$payment = $quote->getPayment();
$payment->setMethod(AdyenPosCloudConfigProvider::CODE);
......@@ -104,12 +117,6 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface
$service = $this->adyenHelper->createAdyenPosPaymentService($this->client);
$transactionType = \Adyen\TransactionType::NORMAL;
if (empty($payment->getAdditionalInformation('terminal_id'))) {
throw new AdyenException("Terminal ID is empty in initiate request");
}
$poiId = $payment->getAdditionalInformation('terminal_id');
$serviceID = date("dHis");
$initiateDate = date("U");
$timeStamper = date("Y-m-d") . "T" . date("H:i:s+00:00");
......
......@@ -15,7 +15,7 @@
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* Copyright (c) 2019 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
......
......@@ -14,7 +14,7 @@
}
],
"require": {
"adyen/php-api-library": ">=2.0.0",
"adyen/php-api-library": ">=2.1.0",
"magento/framework": ">=101.0.8 <102 || >=102.0.1",
"magento/module-vault": "101.*"
},
......
......@@ -53,16 +53,18 @@ define(
serviceUrl,
paymentData = quote.paymentMethod();
if (this.getConnectedTerminals().length > 0) {
this.isPlaceOrderActionAllowed(true);
}
// use core code to assign the agreement
agreementsAssigner(paymentData);
serviceUrl = urlBuilder.createUrl('/adyen/initiate', {});
fullScreenLoader.startLoader();
let payload = {
"payload": JSON.stringify({terminal_id: self.terminalId()})
}
return storage.post(
serviceUrl
serviceUrl,
JSON.stringify(payload)
).always(function(){
self.placeOrderPos()});
return false;
......
......@@ -81,8 +81,7 @@
data-bind="
click: initiate,
attr: {title: $t('Place Order')},
enable: (getCode() == isChecked()),
css: {disabled: !isPlaceOrderActionAllowed()}
enable: getConnectedTerminals().length > 0
"
disabled>
<span data-bind="text: $t('Place Order')"></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