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

PW-560: Rebuild the validator

parent 8d275529
...@@ -67,23 +67,44 @@ class PosCloudResponseValidator extends AbstractValidator ...@@ -67,23 +67,44 @@ class PosCloudResponseValidator extends AbstractValidator
$paymentDataObjectInterface = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($validationSubject); $paymentDataObjectInterface = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($validationSubject);
$payment = $paymentDataObjectInterface->getPayment(); $payment = $paymentDataObjectInterface->getPayment();
// Check In Progress status call $this->adyenLogger->addAdyenDebug(print_r($response, true));
if (!empty($response['SaleToPOIResponse']['TransactionStatusResponse']['Response']['Result']) && $response['SaleToPOIResponse']['TransactionStatusResponse']['Response']['Result'] == "Failure") {
// Check for errors
if (!empty($response['error'])) {
if (strpos($response['error'], "Could not connect") !== false) {
// Do the status call(try to place an order)
return $this->createResult($isValid, $errorMessages);
} else {
throw new \Magento\Framework\Exception\LocalizedException(__($response['error']));
}
}
// We receive a SaleToPOIRequest when the terminal is not reachable
if (!empty($response['SaleToPOIRequest'])){
throw new \Magento\Framework\Exception\LocalizedException(__("The terminal could not be reached."));
}
// Check if Status or PaymentResponse
if (!empty($response['SaleToPOIResponse']['TransactionStatusResponse'])) {
$statusResponse = $response['SaleToPOIResponse']['TransactionStatusResponse'];
if ($statusResponse['Response']['Result'] == 'Failure') {
$errorMsg = __('In Progress'); $errorMsg = __('In Progress');
$errorMessages[] = $errorMsg;
throw new \Magento\Framework\Exception\LocalizedException(__($errorMsg)); throw new \Magento\Framework\Exception\LocalizedException(__($errorMsg));
} else {
$paymentResponse = $statusResponse['RepeatedMessageResponse']['RepeatedResponseMessageBody']['PaymentResponse'];
} }
elseif ((!empty($response['SaleToPOIResponse']['PaymentResponse']['Response']['Result']) && } else {
$response['SaleToPOIResponse']['PaymentResponse']['Response']['Result'] != 'Success' $paymentResponse = $response['SaleToPOIResponse']['PaymentResponse'];
) || empty($response['SaleToPOIResponse']['PaymentResponse']['Response']['Result']) }
) {
$errorMsg = __('Problem with POS terminal'); if (!empty($paymentResponse) && $paymentResponse['Response']['Result'] != 'Success') {
$errorMsg = __($paymentResponse['Response']['ErrorCondition']);
$this->adyenLogger->error($errorMsg); $this->adyenLogger->error($errorMsg);
$errorMessages[] = $errorMsg; throw new \Magento\Framework\Exception\LocalizedException(__("The transaction could not be completed."));
$isValid = true;
} }
if(!empty($response['SaleToPOIResponse']['PaymentResponse']['PaymentReceipt'])) {
$formattedReceipt = $this->adyenHelper->formatTerminalAPIReceipt(json_encode($response['SaleToPOIResponse']['PaymentResponse']['PaymentReceipt'])); if (!empty($paymentResponse['PaymentReceipt'])) {
$formattedReceipt = $this->adyenHelper->formatTerminalAPIReceipt(json_encode($paymentResponse['PaymentReceipt']));
$payment->setAdditionalInformation('receipt', $formattedReceipt); $payment->setAdditionalInformation('receipt', $formattedReceipt);
} }
return $this->createResult($isValid, $errorMessages); return $this->createResult($isValid, $errorMessages);
......
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