-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit bc96fae
Showing
26 changed files
with
1,069 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Jh\AdyenPayment\Api; | ||
|
||
use Jh\AdyenPayment\Api\Data\RedirectResponseInterface; | ||
|
||
interface AdyenRedirectInterface | ||
{ | ||
/** | ||
* @param int $orderId | ||
* @return \Jh\AdyenPayment\Api\Data\RedirectResponseInterface | ||
*/ | ||
public function execute(int $orderId): RedirectResponseInterface; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Jh\AdyenPayment\Api; | ||
|
||
use Jh\AdyenPayment\Api\Data\ResultResponseInterface; | ||
|
||
interface AdyenResultInterface | ||
{ | ||
/** | ||
* @param int $orderId | ||
* @param string $response | ||
* @param string $resultCode | ||
* @return \Jh\AdyenPayment\Api\Data\ResultResponseInterface | ||
*/ | ||
public function execute(int $orderId, string $response, string $resultCode = null): ResultResponseInterface; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Jh\AdyenPayment\Api; | ||
|
||
use Magento\Framework\Exception\LocalizedException; | ||
|
||
interface AdyenThreeDS1ProcessInterface | ||
{ | ||
/** | ||
* @param int $orderId | ||
* @param string $md | ||
* @param string $paReq | ||
* @return void | ||
* @throws LocalizedException | ||
*/ | ||
public function authorise(int $orderId, string $md, string $paReq): void; | ||
|
||
/** | ||
* @param object $payment | ||
* @param string $md | ||
* @param string $paRes | ||
* @return void | ||
*/ | ||
public function authorisePayment($payment, string $md, $paRes): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Jh\AdyenPayment\Api; | ||
|
||
use Magento\Framework\Exception\LocalizedException; | ||
|
||
interface AdyenThreeDSAbortInterface | ||
{ | ||
/** | ||
* @param int $orderId | ||
* @return void | ||
* @throws LocalizedException | ||
*/ | ||
public function abort(int $orderId): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Jh\AdyenPayment\Api\Data; | ||
|
||
interface RedirectResponseInterface | ||
{ | ||
/** | ||
* @return int | ||
*/ | ||
public function getOrderId(): int; | ||
|
||
/** | ||
* @param int $orderId | ||
* @return void | ||
*/ | ||
public function setOrderId(int $orderId): void; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getRedirectUrl(): string; | ||
|
||
/** | ||
* @param string $orderId | ||
* @return void | ||
*/ | ||
public function setRedirectUrl(string $redirectUrl): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Jh\AdyenPayment\Api\Data; | ||
|
||
interface ResultResponseInterface | ||
{ | ||
/** | ||
* @return int | ||
*/ | ||
public function getOrderId(): int; | ||
|
||
/** | ||
* @param int $orderId | ||
* @return void | ||
*/ | ||
public function setOrderId(int $orderId): void; | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getQuoteId(): int; | ||
|
||
/** | ||
* @param int $quoteId | ||
* @return void | ||
*/ | ||
public function setQuoteId(int $quoteId): void; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getResponse(): string; | ||
|
||
/** | ||
* @param string $response | ||
* @return void | ||
*/ | ||
public function setResponse(string $response): void; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getMessage(): string; | ||
|
||
/** | ||
* @param string $message | ||
* @return void | ||
*/ | ||
public function setMessage(string $message): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Jh\AdyenPayment\Gateway\Request; | ||
|
||
use Adyen\Payment\Gateway\Request\CheckoutDataBuilder as OrigCheckoutDataBuilder; | ||
use Adyen\Payment\Helper\Data; | ||
use Adyen\Payment\Model\Gender; | ||
use Magento\Store\Model\StoreManagerInterface; | ||
use Magento\Quote\Api\CartRepositoryInterface; | ||
|
||
class CheckoutDataBuilder extends OrigCheckoutDataBuilder | ||
{ | ||
private $adyenHelper; | ||
|
||
public function __construct( | ||
Data $adyenHelper, | ||
StoreManagerInterface $storeManager, | ||
CartRepositoryInterface $cartRepository, | ||
Gender $gender | ||
) { | ||
parent::__construct($adyenHelper, $storeManager, $cartRepository, $gender); | ||
|
||
$this->adyenHelper = $adyenHelper; | ||
} | ||
|
||
public function build(array $buildSubject) | ||
{ | ||
$request = parent::build($buildSubject); | ||
|
||
$customOrigin = $this->adyenHelper->getAdyenAbstractConfigData('origin_key_domain'); | ||
if ($customOrigin) { | ||
$customPath = $this->adyenHelper->getAdyenAbstractConfigData('pwa_return_path'); | ||
$path = $customPath ?? 'adyen/process/result'; | ||
$request['body']['returnUrl'] = sprintf('%s/%s', $customOrigin, $path); | ||
} | ||
|
||
return $request; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Jh\AdyenPayment\Model; | ||
|
||
use Jh\AdyenPayment\Api\Data\RedirectResponseInterface; | ||
|
||
class RedirectResponse implements RedirectResponseInterface | ||
{ | ||
private $orderId; | ||
private $redirectUrl; | ||
|
||
public function getOrderId(): int | ||
{ | ||
return $this->orderId; | ||
} | ||
|
||
public function setOrderId(int $orderId): void | ||
{ | ||
$this->orderId = $orderId; | ||
} | ||
|
||
public function getRedirectUrl(): string | ||
{ | ||
return $this->redirectUrl; | ||
} | ||
|
||
public function setRedirectUrl(string $redirectUrl): void | ||
{ | ||
$this->redirectUrl = $redirectUrl; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Jh\AdyenPayment\Model; | ||
|
||
use Jh\AdyenPayment\Api\Data\ResultResponseInterface; | ||
|
||
class ResultResponse implements ResultResponseInterface | ||
{ | ||
private $orderId; | ||
private $quoteId; | ||
private $response; | ||
private $message; | ||
|
||
public function getOrderId(): int | ||
{ | ||
return $this->orderId; | ||
} | ||
|
||
public function setOrderId(int $orderId): void | ||
{ | ||
$this->orderId = $orderId; | ||
} | ||
|
||
public function getQuoteId(): int | ||
{ | ||
return $this->quoteId; | ||
} | ||
|
||
public function setQuoteId(int $quoteId): void | ||
{ | ||
$this->quoteId = $quoteId; | ||
} | ||
|
||
public function getResponse(): string | ||
{ | ||
return $this->response; | ||
} | ||
|
||
public function setResponse(string $response): void | ||
{ | ||
$this->response = $response; | ||
} | ||
|
||
public function getMessage(): string | ||
{ | ||
return $this->message; | ||
} | ||
|
||
public function setMessage(string $message): void | ||
{ | ||
$this->message = $message; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Jh\AdyenPayment\Plugin; | ||
|
||
use Adyen\Payment\Helper\Data as Subject; | ||
|
||
class CustomOriginPlugin | ||
{ | ||
public function aroundGetOrigin(Subject $subject, callable $proceed) | ||
{ | ||
if ($customOrigin = $subject->getAdyenAbstractConfigData('origin_key_domain')) { | ||
return $customOrigin; | ||
} | ||
return $proceed(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Jh\AdyenPayment\Plugin; | ||
|
||
use Adyen\Payment\Model\AdyenOrderPaymentStatus; | ||
use Adyen\Payment\Model\Ui\AdyenCcConfigProvider; | ||
use Adyen\Payment\Model\Ui\AdyenOneclickConfigProvider; | ||
use Magento\Sales\Api\OrderRepositoryInterface; | ||
|
||
class ThreeDS1RedirectPlugin | ||
{ | ||
private $orderRepository; | ||
|
||
public function __construct(OrderRepositoryInterface $orderRepository) | ||
{ | ||
$this->orderRepository = $orderRepository; | ||
} | ||
|
||
public function afterGetOrderPaymentStatus(AdyenOrderPaymentStatus $adyenOrderPaymentStatus, $response, $orderId) | ||
{ | ||
if (!is_string($response)) { | ||
return $response; | ||
} | ||
|
||
$payment = $this->orderRepository->get($orderId)->getPayment(); | ||
|
||
if ($payment->getMethod() === AdyenCcConfigProvider::CODE || | ||
$payment->getMethod() === AdyenOneclickConfigProvider::CODE | ||
) { | ||
$response = json_decode($response, true); | ||
|
||
if (($response['threeDS2'] ?? false) === false && ($response['type'] ?? '') === 'RedirectShopper') { | ||
$additionalInformation = $payment->getAdditionalInformation(); | ||
|
||
$response = array_merge($response, [ | ||
'redirect' => [ | ||
'data' => [ | ||
'PaReq' => $additionalInformation['paRequest'] ?? null, | ||
'MD' => $additionalInformation['md'] ?? null, | ||
'TermUrl' => null | ||
], | ||
'method' => $additionalInformation['redirectMethod'] ?? 'POST', | ||
'url' => $additionalInformation['redirectUrl'] ?? null | ||
] | ||
]); | ||
} | ||
|
||
return json_encode($response); | ||
} | ||
|
||
return $response; | ||
} | ||
} |
Oops, something went wrong.