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 fd46e3cc authored by Aleffio's avatar Aleffio

PW-560: changed JSON status request to array, added new total_timeout value in...

PW-560: changed JSON status request to array, added new total_timeout value in config, reverted serviceID to previous dateformat
parent 6ba9e902
...@@ -81,44 +81,46 @@ class TransactionPosCloudSync implements ClientInterface ...@@ -81,44 +81,46 @@ class TransactionPosCloudSync implements ClientInterface
$service = new \Adyen\Service\PosPayment($this->_client); $service = new \Adyen\Service\PosPayment($this->_client);
$poiId = $this->_adyenHelper->getPoiId(); $poiId = $this->_adyenHelper->getPoiId();
$newServiceID = date("U"); $newServiceID = date("dHis");
$timeDiff = (int)$newServiceID - (int)$request['serviceID']; $statusDate = date("U");
if ($timeDiff > 120) { $timeDiff = (int)$statusDate - (int)$request['initiateDate'];
$totalTimeout = $this->_adyenHelper->getAdyenPosCloudConfigData('total_timeout');
if ($timeDiff > $totalTimeout) {
throw new \Magento\Framework\Exception\LocalizedException(__("Pos Timeout.")); throw new \Magento\Framework\Exception\LocalizedException(__("Pos Timeout."));
} }
//Provide receipt to the shopper //Provide receipt to the shopper
$jsonStatus = '{
"SaleToPOIRequest": { $request = [
"MessageHeader": { 'SaleToPOIRequest' => [
"ProtocolVersion": "3.0", 'MessageHeader' => [
"MessageClass": "Service", 'ProtocolVersion' => '3.0',
"MessageCategory": "TransactionStatus", 'MessageClass' => 'Service',
"MessageType": "Request", 'MessageCategory' => 'TransactionStatus',
"ServiceID": "' . $newServiceID . '", 'MessageType' => 'Request',
"SaleID": "Magento2CloudStatus", 'ServiceID' => $newServiceID,
"POIID": "' . $poiId . '" 'SaleID' => 'Magento2CloudStatus',
}, 'POIID' => $poiId
"TransactionStatusRequest": { ],
"MessageReference": { 'TransactionStatusRequest' => [
"MessageCategory": "Payment", 'MessageReference' => [
"SaleID": "Magento2Cloud", 'MessageCategory' => 'Payment',
"ServiceID": "' . $request['serviceID'] . '" 'SaleID' => 'Magento2Cloud',
}, 'ServiceID' => $request['serviceID']
"DocumentQualifier" : [ ],
'DocumentQualifier' => [
"CashierReceipt", "CashierReceipt",
"CustomerReceipt" "CustomerReceipt"
], ],
"ReceiptReprintFlag" : true 'ReceiptReprintFlag' => true
} ]
} ]
}'; ];
$params = json_decode($jsonStatus, true); //Create associative array for passing along
try { try {
$response = $service->runTenderSync($params); $response = $service->runTenderSync($request);
} catch (\Adyen\AdyenException $e) { } catch (\Adyen\AdyenException $e) {
$response['error'] = $e->getMessage(); $response['error'] = $e->getMessage();
} }
......
...@@ -66,13 +66,10 @@ class PosCloudBuilder implements BuilderInterface ...@@ -66,13 +66,10 @@ class PosCloudBuilder implements BuilderInterface
$payment = $paymentDataObject->getPayment(); $payment = $paymentDataObject->getPayment();
$fullOrder = $payment->getOrder();
$quote = $this->_quoteRepository->getActive($fullOrder->getQuoteId());
return [ return [
"response" => $quote->getPayment()->getAdditionalInformation("terminalResponse"), "response" => $payment->getAdditionalInformation("terminalResponse"),
"serviceID" => $quote->getPayment()->getAdditionalInformation("serviceID") "serviceID" => $payment->getAdditionalInformation("serviceID"),
"initiateDate" => $payment->getAdditionalInformation("initiateDate")
]; ];
} }
} }
\ No newline at end of file
...@@ -104,7 +104,8 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface ...@@ -104,7 +104,8 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface
$service = new \Adyen\Service\PosPayment($this->_client); $service = new \Adyen\Service\PosPayment($this->_client);
$transactionType = \Adyen\TransactionType::NORMAL; $transactionType = \Adyen\TransactionType::NORMAL;
$poiId = $this->_adyenHelper->getPoiId(); $poiId = $this->_adyenHelper->getPoiId();
$serviceID = date("U"); $serviceID = date("dHis");
$initiateDate = date("U");
$timeStamper = date("Y-m-d") . "T" . date("H:i:s+00:00"); $timeStamper = date("Y-m-d") . "T" . date("H:i:s+00:00");
$customerId = $quote->getCustomerId(); $customerId = $quote->getCustomerId();
...@@ -165,6 +166,8 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface ...@@ -165,6 +166,8 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface
$quote->getPayment()->getMethodInstance()->getInfoInstance()->setAdditionalInformation('serviceID', $quote->getPayment()->getMethodInstance()->getInfoInstance()->setAdditionalInformation('serviceID',
$serviceID); $serviceID);
$quote->getPayment()->getMethodInstance()->getInfoInstance()->setAdditionalInformation('initiateDate',
$initiateDate);
try { try {
$response = $service->runTenderSync($request); $response = $service->runTenderSync($request);
......
...@@ -168,6 +168,7 @@ ...@@ -168,6 +168,7 @@
<can_void>1</can_void> <can_void>1</can_void>
<can_cancel>1</can_cancel> <can_cancel>1</can_cancel>
<pos_timeout>30</pos_timeout> <pos_timeout>30</pos_timeout>
<total_timeout>120</total_timeout>
<recurring_type>ONECLICK</recurring_type> <recurring_type>ONECLICK</recurring_type>
<group>adyen</group> <group>adyen</group>
</adyen_pos_cloud> </adyen_pos_cloud>
......
...@@ -30,7 +30,6 @@ $_info = $this->getInfo(); ...@@ -30,7 +30,6 @@ $_info = $this->getInfo();
?> ?>
<dl class="payment-method adyen_pos_cloud"> <dl class="payment-method adyen_pos_cloud">
<?php echo $this->escapeHtml($this->getMethod()->getTitle()) ?><br/>
<dt class="title"><?php echo $block->escapeHtml($block->getMethod()->getTitle()) ?></dt> <dt class="title"><?php echo $block->escapeHtml($block->getMethod()->getTitle()) ?></dt>
<style> <style>
table.terminal-api-receipt{margin-top: 10px} table.terminal-api-receipt{margin-top: 10px}
......
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