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