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 e215cee8 authored by Vitaliy Ryaboy's avatar Vitaliy Ryaboy Committed by GitHub

remove dependency from magento setup exception (#813)

* remove dependency from magento setup exception

* fix typo

* semplify FQCN

* fix CR feedback: use Adyen\AdyenException instead \Exception
Co-authored-by: default avatarAttila Kiss <42297201+cyattilakiss@users.noreply.github.com>
parent 7351be27
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
namespace Adyen\Payment\Gateway\Request; namespace Adyen\Payment\Gateway\Request;
use Magento\Payment\Gateway\Request\BuilderInterface; use Magento\Payment\Gateway\Request\BuilderInterface;
use Magento\Setup\Exception;
class ApplePayAuthorizationDataBuilder implements BuilderInterface class ApplePayAuthorizationDataBuilder implements BuilderInterface
{ {
...@@ -65,13 +64,7 @@ class ApplePayAuthorizationDataBuilder implements BuilderInterface ...@@ -65,13 +64,7 @@ class ApplePayAuthorizationDataBuilder implements BuilderInterface
// get payment data // get payment data
if ($token) { if ($token) {
$parsedToken = json_decode($token); $parsedToken = json_decode($token);
$paymentData = $parsedToken->token->paymentData; $requestBody['paymentMethod']['applepay.token'] = base64_encode(json_encode($parsedToken->token->paymentData));
try {
$paymentData = base64_encode(json_encode($paymentData));
$requestBody['paymentMethod']['applepay.token'] = $paymentData;
} catch (\Exception $exception) {
$this->_adyenLogger->addAdyenDebug("exception: " . $exception->getMessage());
}
} else { } else {
$this->_adyenLogger->addAdyenDebug("PaymentToken is empty"); $this->_adyenLogger->addAdyenDebug("PaymentToken is empty");
} }
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
namespace Adyen\Payment\Gateway\Request; namespace Adyen\Payment\Gateway\Request;
use Magento\Payment\Gateway\Request\BuilderInterface; use Magento\Payment\Gateway\Request\BuilderInterface;
use Magento\Setup\Exception;
class GooglePayAuthorizationDataBuilder implements BuilderInterface class GooglePayAuthorizationDataBuilder implements BuilderInterface
{ {
...@@ -63,11 +62,7 @@ class GooglePayAuthorizationDataBuilder implements BuilderInterface ...@@ -63,11 +62,7 @@ class GooglePayAuthorizationDataBuilder implements BuilderInterface
$requestBody['paymentMethod']['type'] = 'paywithgoogle'; $requestBody['paymentMethod']['type'] = 'paywithgoogle';
// get payment data // get payment data
if ($token) { if ($token) {
try { $requestBody['paymentMethod']['paywithgoogle.token'] = $token;
$requestBody['paymentMethod']['paywithgoogle.token'] = $token;
} catch (\Exception $exception) {
$this->adyenLogger->addAdyenDebug("exception: " . $exception->getMessage());
}
} else { } else {
$this->adyenLogger->addAdyenDebug("PaymentToken is empty"); $this->adyenLogger->addAdyenDebug("PaymentToken is empty");
} }
......
...@@ -24,48 +24,39 @@ ...@@ -24,48 +24,39 @@
namespace Adyen\Payment\Gateway\Response; namespace Adyen\Payment\Gateway\Response;
use Adyen\AdyenException;
use Adyen\Payment\Helper\Data;
use Adyen\Payment\Logger\AdyenLogger;
use Magento\Payment\Gateway\Helper\SubjectReader;
use Magento\Payment\Gateway\Response\HandlerInterface; use Magento\Payment\Gateway\Response\HandlerInterface;
use Magento\Setup\Exception;
class PaymentPosCloudHandler implements HandlerInterface class PaymentPosCloudHandler implements HandlerInterface
{ {
/** /**
* @var \Adyen\Payment\Helper\Data * @var Data
*/ */
private $adyenHelper; private $adyenHelper;
/** /**
* @var \Adyen\Payment\Logger\AdyenLogger * @var AdyenLogger
*/ */
private $adyenLogger; private $adyenLogger;
/**
* PaymentPosCloudHandler constructor.
*
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/
public function __construct( public function __construct(
\Adyen\Payment\Logger\AdyenLogger $adyenLogger, AdyenLogger $adyenLogger,
\Adyen\Payment\Helper\Data $adyenHelper Data $adyenHelper
) { ) {
$this->adyenLogger = $adyenLogger; $this->adyenLogger = $adyenLogger;
$this->adyenHelper = $adyenHelper; $this->adyenHelper = $adyenHelper;
} }
/** /**
* Handles response * {@inheritdoc}
*
* @param array $handlingSubject
* @param array $paymentResponse
* @return void
* @throws Exception
*/ */
public function handle(array $handlingSubject, array $paymentResponse) public function handle(array $handlingSubject, array $paymentResponse)
{ {
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($handlingSubject); $paymentDataObject = SubjectReader::readPayment($handlingSubject);
/** @var OrderPaymentInterface $payment */
$payment = $paymentDataObject->getPayment(); $payment = $paymentDataObject->getPayment();
// set transaction not to processing by default wait for notification // set transaction not to processing by default wait for notification
...@@ -76,10 +67,10 @@ class PaymentPosCloudHandler implements HandlerInterface ...@@ -76,10 +67,10 @@ class PaymentPosCloudHandler implements HandlerInterface
if (!empty($paymentResponse['Response']['AdditionalResponse']) if (!empty($paymentResponse['Response']['AdditionalResponse'])
) { ) {
$pairs = explode('&', $paymentResponse['Response']['AdditionalResponse']); $pairs = \explode('&', $paymentResponse['Response']['AdditionalResponse']);
foreach ($pairs as $pair) { foreach ($pairs as $pair) {
$nv = explode('=', $pair); $nv = \explode('=', $pair);
if ($nv[0] == 'recurring.recurringDetailReference') { if ($nv[0] == 'recurring.recurringDetailReference') {
$recurringDetailReference = $nv[1]; $recurringDetailReference = $nv[1];
...@@ -93,7 +84,7 @@ class PaymentPosCloudHandler implements HandlerInterface ...@@ -93,7 +84,7 @@ class PaymentPosCloudHandler implements HandlerInterface
$maskedPan = $paymentResponse['PaymentResult']['PaymentInstrumentData']['CardData']['MaskedPan']; $maskedPan = $paymentResponse['PaymentResult']['PaymentInstrumentData']['CardData']['MaskedPan'];
$expiryDate = $paymentResponse['PaymentResult']['PaymentInstrumentData']['CardData'] $expiryDate = $paymentResponse['PaymentResult']['PaymentInstrumentData']['CardData']
['SensitiveCardData']['ExpiryDate']; // 1225 ['SensitiveCardData']['ExpiryDate']; // 1225
$expiryDate = substr($expiryDate, 0, 2) . '/' . substr($expiryDate, 2, 2); $expiryDate = \substr($expiryDate, 0, 2) . '/' . \substr($expiryDate, 2, 2);
$brand = $paymentResponse['PaymentResult']['PaymentInstrumentData']['CardData']['PaymentBrand']; $brand = $paymentResponse['PaymentResult']['PaymentInstrumentData']['CardData']['PaymentBrand'];
// create additionalData so we can use the helper // create additionalData so we can use the helper
...@@ -101,7 +92,7 @@ class PaymentPosCloudHandler implements HandlerInterface ...@@ -101,7 +92,7 @@ class PaymentPosCloudHandler implements HandlerInterface
$additionalData['recurring.recurringDetailReference'] = $recurringDetailReference; $additionalData['recurring.recurringDetailReference'] = $recurringDetailReference;
$additionalData['cardBin'] = $recurringDetailReference; $additionalData['cardBin'] = $recurringDetailReference;
$additionalData['cardHolderName'] = ''; $additionalData['cardHolderName'] = '';
$additionalData['cardSummary'] = substr($maskedPan, -4); $additionalData['cardSummary'] = \substr($maskedPan, -4);
$additionalData['expiryDate'] = $expiryDate; $additionalData['expiryDate'] = $expiryDate;
$additionalData['paymentMethod'] = $brand; $additionalData['paymentMethod'] = $brand;
$additionalData['recurring.recurringDetailReference'] = $recurringDetailReference; $additionalData['recurring.recurringDetailReference'] = $recurringDetailReference;
...@@ -122,7 +113,7 @@ class PaymentPosCloudHandler implements HandlerInterface ...@@ -122,7 +113,7 @@ class PaymentPosCloudHandler implements HandlerInterface
// set transaction(payment) // set transaction(payment)
} else { } else {
$this->adyenLogger->error("Missing POS Transaction ID"); $this->adyenLogger->error("Missing POS Transaction ID");
throw new Exception("Missing POS Transaction ID"); throw new AdyenException("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
......
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