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