We will work on Apr 26th (Saturday) and will be off from Apr 30th (Wednesday) until May 2nd (Friday) for public holiday 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
$service = new \Adyen\Service\PosPayment($this->_client);
$poiId = $this->_adyenHelper->getPoiId();
$newServiceID = date("U");
$newServiceID = date("dHis");
$timeDiff = (int)$newServiceID - (int)$request['serviceID'];
if ($timeDiff > 120) {
$statusDate = date("U");
$timeDiff = (int)$statusDate - (int)$request['initiateDate'];
$totalTimeout = $this->_adyenHelper->getAdyenPosCloudConfigData('total_timeout');
if ($timeDiff > $totalTimeout) {
throw new \Magento\Framework\Exception\LocalizedException(__("Pos Timeout."));
}
//Provide receipt to the shopper
$jsonStatus = '{
"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
}
}
}';
$params = json_decode($jsonStatus, true); //Create associative array for passing along
$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($params);
$response = $service->runTenderSync($request);
} catch (\Adyen\AdyenException $e) {
$response['error'] = $e->getMessage();
}
......
......@@ -66,13 +66,10 @@ class PosCloudBuilder implements BuilderInterface
$payment = $paymentDataObject->getPayment();
$fullOrder = $payment->getOrder();
$quote = $this->_quoteRepository->getActive($fullOrder->getQuoteId());
return [
"response" => $quote->getPayment()->getAdditionalInformation("terminalResponse"),
"serviceID" => $quote->getPayment()->getAdditionalInformation("serviceID")
"response" => $payment->getAdditionalInformation("terminalResponse"),
"serviceID" => $payment->getAdditionalInformation("serviceID"),
"initiateDate" => $payment->getAdditionalInformation("initiateDate")
];
}
}
\ No newline at end of file
......@@ -104,7 +104,8 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface
$service = new \Adyen\Service\PosPayment($this->_client);
$transactionType = \Adyen\TransactionType::NORMAL;
$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");
$customerId = $quote->getCustomerId();
......@@ -165,6 +166,8 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface
$quote->getPayment()->getMethodInstance()->getInfoInstance()->setAdditionalInformation('serviceID',
$serviceID);
$quote->getPayment()->getMethodInstance()->getInfoInstance()->setAdditionalInformation('initiateDate',
$initiateDate);
try {
$response = $service->runTenderSync($request);
......
......@@ -168,6 +168,7 @@
<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>
......
......@@ -30,7 +30,6 @@ $_info = $this->getInfo();
?>
<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>
<style>
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