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

PW-365: Added checks, Changed getPaymentRequest to buildPosPaymentRequest

parent e2ac5f30
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
namespace Adyen\Payment\Gateway\Http\Client; namespace Adyen\Payment\Gateway\Http\Client;
use Adyen\Util\Util;
use Magento\Payment\Gateway\Http\ClientInterface; use Magento\Payment\Gateway\Http\ClientInterface;
class TransactionPosCloudSync implements ClientInterface class TransactionPosCloudSync implements ClientInterface
...@@ -75,7 +75,7 @@ class TransactionPosCloudSync implements ClientInterface ...@@ -75,7 +75,7 @@ class TransactionPosCloudSync implements ClientInterface
$service = new \Adyen\Service\PosPayment($this->_client); $service = new \Adyen\Service\PosPayment($this->_client);
$transactionType = \Adyen\TransactionType::GOODS_SERVICES; $transactionType = \Adyen\TransactionType::GOODS_SERVICES;
$poiId = $this->_adyenHelper->getPoiId(); $poiId = $this->_adyenHelper->getPoiId();
$json = $service->getPaymentRequest($poiId, $request['amount']['value'], $request['amount']['currency'], $json = Util::buildPosPaymentRequest($poiId, $request['amount']['value'], $request['amount']['currency'],
$request['reference'], $transactionType); $request['reference'], $transactionType);
$params = json_decode($json, true); //Create associative array for passing along $params = json_decode($json, true); //Create associative array for passing along
try { try {
......
...@@ -54,8 +54,9 @@ class MerchantAccountDataBuilder implements BuilderInterface ...@@ -54,8 +54,9 @@ class MerchantAccountDataBuilder implements BuilderInterface
$order = $paymentDataObject->getOrder(); $order = $paymentDataObject->getOrder();
$storeId = $order->getStoreId(); $storeId = $order->getStoreId();
$payment = $paymentDataObject->getPayment(); $payment = $paymentDataObject->getPayment();
$method = $payment->getMethod();
$merchantAccount = $this->adyenHelper->getAdyenMerchantAccount($payment, $storeId); $merchantAccount = $this->adyenHelper->getAdyenMerchantAccount($method, $storeId);
return ["merchantAccount" => $merchantAccount]; return ["merchantAccount" => $merchantAccount];
} }
......
...@@ -63,17 +63,16 @@ class PosCloudBuilder implements BuilderInterface ...@@ -63,17 +63,16 @@ class PosCloudBuilder implements BuilderInterface
$payment = $paymentDataObject->getPayment(); $payment = $paymentDataObject->getPayment();
$fullOrder = $payment->getOrder(); $fullOrder = $payment->getOrder();
$currencyCode = $fullOrder->getOrderCurrencyCode(); $currencyCode = $fullOrder->getOrderCurrencyCode();
$amount = $fullOrder->getGrandTotal(); $grandTotal = $fullOrder->getGrandTotal();
$amount = [ $amount = [
'currency' => $currencyCode, 'currency' => $currencyCode,
'value' => $this->adyenHelper->formatAmount($amount, $currencyCode) 'value' => $grandTotal
]; ];
return [ return [
"amount" => $amount, "amount" => $amount,
"reference" => $order->getOrderIncrementId(), "reference" => $order->getOrderIncrementId()
"fraudOffset" => "0"
]; ];
} }
} }
\ No newline at end of file
...@@ -26,6 +26,7 @@ namespace Adyen\Payment\Gateway\Response; ...@@ -26,6 +26,7 @@ namespace Adyen\Payment\Gateway\Response;
use Magento\Payment\Gateway\Response\HandlerInterface; use Magento\Payment\Gateway\Response\HandlerInterface;
use Magento\Setup\Exception;
class PaymentPosCloudHandler implements HandlerInterface class PaymentPosCloudHandler implements HandlerInterface
{ {
...@@ -75,8 +76,13 @@ class PaymentPosCloudHandler implements HandlerInterface ...@@ -75,8 +76,13 @@ class PaymentPosCloudHandler implements HandlerInterface
$payment->getOrder()->setCanSendNewEmailFlag(false); $payment->getOrder()->setCanSendNewEmailFlag(false);
// set transaction // set transaction
if (!empty($response['SaleToPOIResponse']['PaymentResponse']['PaymentResult']['PaymentAcquirerData']['AcquirerTransactionID']['TransactionID'])) {
$pspReference = $response['SaleToPOIResponse']['PaymentResponse']['PaymentResult']['PaymentAcquirerData']['AcquirerTransactionID']['TransactionID']; $pspReference = $response['SaleToPOIResponse']['PaymentResponse']['PaymentResult']['PaymentAcquirerData']['AcquirerTransactionID']['TransactionID'];
$payment->setTransactionId($pspReference); $payment->setTransactionId($pspReference);
} 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 // do not close transaction so you can do a cancel() and void
$payment->setIsTransactionClosed(false); $payment->setIsTransactionClosed(false);
......
...@@ -57,7 +57,11 @@ class PosCloudResponseValidator extends AbstractValidator ...@@ -57,7 +57,11 @@ class PosCloudResponseValidator extends AbstractValidator
$errorMessages = []; $errorMessages = [];
$isValid = true; $isValid = true;
$response = \Magento\Payment\Gateway\Helper\SubjectReader::readResponse($validationSubject); $response = \Magento\Payment\Gateway\Helper\SubjectReader::readResponse($validationSubject);
if ($response['SaleToPOIResponse']['PaymentResponse']['Response']['Result'] != 'Success') {
if ((!empty($response['SaleToPOIResponse']['PaymentResponse']['Response']['Result']) &&
$response['SaleToPOIResponse']['PaymentResponse']['Response']['Result'] != 'Success'
) || empty($response['SaleToPOIResponse']['PaymentResponse']['Response']['Result'])
) {
$errorMsg = __('Problem with POS terminal'); $errorMsg = __('Problem with POS terminal');
$this->adyenLogger->error($errorMsg); $this->adyenLogger->error($errorMsg);
$errorMessages[] = $errorMsg; $errorMessages[] = $errorMsg;
......
...@@ -1203,12 +1203,12 @@ class Data extends AbstractHelper ...@@ -1203,12 +1203,12 @@ class Data extends AbstractHelper
return $poiId; return $poiId;
} }
public function getAdyenMerchantAccount($payment, $storeId) public function getAdyenMerchantAccount($method, $storeId)
{ {
$merchantAccount = $this->getAdyenAbstractConfigData("merchant_account", $storeId); $merchantAccount = $this->getAdyenAbstractConfigData("merchant_account", $storeId);
$merchantAccountPos = $this->getAdyenPosCloudConfigData('pos_merchant_account', $storeId); $merchantAccountPos = $this->getAdyenPosCloudConfigData('pos_merchant_account', $storeId);
if ($payment->getMethod() == 'adyen_pos_cloud' && !empty($merchantAccountPos)) { if ($method == 'adyen_pos_cloud' && !empty($merchantAccountPos)) {
return $merchantAccountPos; return $merchantAccountPos;
} }
return $merchantAccount; return $merchantAccount;
......
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