-
Notifications
You must be signed in to change notification settings - Fork 6
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
Showing
23 changed files
with
1,105 additions
and
56 deletions.
There are no files selected for viewing
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 | ||
/** | ||
* PagBank Payment Magento Module. | ||
* | ||
* Copyright © 2023 PagBank. All rights reserved. | ||
* | ||
* @author Bruno Elisei <brunoelisei@o2ti.com> | ||
* @license See LICENSE for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PagBank\PaymentMagento\Api\Data; | ||
|
||
/** | ||
* Interface 3ds Session. | ||
* | ||
* @api | ||
* | ||
* @since 100.0.1 | ||
*/ | ||
interface ThreeDsSessionDataInterface | ||
{ | ||
/** | ||
* Return Three Ds Session. | ||
* | ||
* @return string|null | ||
*/ | ||
public function getSessionId(); | ||
|
||
/** | ||
* Set Three Ds Session Id. | ||
* | ||
* @param string $sessionId | ||
* | ||
* @return $this | ||
*/ | ||
public function setSessionId($sessionId); | ||
|
||
/** | ||
* Return Three Ds Expires At. | ||
* | ||
* @return string|null | ||
*/ | ||
public function getExpiresAt(); | ||
|
||
/** | ||
* Set Three Ds Session Expires At. | ||
* | ||
* @param string $expiresAt | ||
* | ||
* @return $this | ||
*/ | ||
public function setExpiresAt($expiresAt); | ||
} |
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 | ||
/** | ||
* PagBank Payment Magento Module. | ||
* | ||
* Copyright © 2023 PagBank. All rights reserved. | ||
* | ||
* @author Bruno Elisei <brunoelisei@o2ti.com> | ||
* @license See LICENSE for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PagBank\PaymentMagento\Api; | ||
|
||
use PagBank\PaymentMagento\Api\Data\ThreeDsSessionDataInterface; | ||
|
||
/** | ||
* Interface for obtaining session for 3ds. | ||
* | ||
* @api | ||
*/ | ||
interface ThreeDsSessionInterface | ||
{ | ||
/** | ||
* Get 3ds Session. | ||
* | ||
* @return \PagBank\PaymentMagento\Api\Data\ThreeDsSessionDataInterface | ||
*/ | ||
public function getSession(): ThreeDsSessionDataInterface; | ||
} |
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
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,92 @@ | ||
<?php | ||
/** | ||
* PagBank Payment Magento Module. | ||
* | ||
* Copyright © 2023 PagBank. All rights reserved. | ||
* | ||
* @author Bruno Elisei <brunoelisei@o2ti.com> | ||
* @license See LICENSE for license details. | ||
*/ | ||
|
||
namespace PagBank\PaymentMagento\Gateway\Request\CreditCard; | ||
|
||
use Magento\Payment\Gateway\Data\PaymentDataObject; | ||
use Magento\Payment\Gateway\Helper\SubjectReader; | ||
use Magento\Payment\Gateway\Request\BuilderInterface; | ||
use Magento\Payment\Model\InfoInterface; | ||
use PagBank\PaymentMagento\Gateway\Request\ChargesDataRequest; | ||
use PagBank\PaymentMagento\Gateway\Request\CreditCard\PaymentCcDataRequest; | ||
|
||
/** | ||
* Class 3ds Auth Data Request - Payment structure for credit card with 3ds authentication. | ||
*/ | ||
class ThreeDsAuthDataRequest implements BuilderInterface | ||
{ | ||
/** | ||
* Authentication Method - block name. | ||
*/ | ||
public const AUTHENTICATION_METHOD = 'authentication_method'; | ||
|
||
/** | ||
* Type - Block name. | ||
*/ | ||
public const TYPE = 'type'; | ||
|
||
/** | ||
* Id - Block name. | ||
*/ | ||
public const ID = 'id'; | ||
|
||
/** | ||
* Type Value - Value. | ||
*/ | ||
public const TYPE_VALUE = 'THREEDS'; | ||
|
||
/** | ||
* Build. | ||
* | ||
* @param array $buildSubject | ||
* | ||
* @SuppressWarnings(PHPMD.StaticAccess) | ||
*/ | ||
public function build(array $buildSubject) | ||
{ | ||
$result = []; | ||
|
||
/** @var PaymentDataObject $paymentDO * */ | ||
$paymentDO = SubjectReader::readPayment($buildSubject); | ||
|
||
/** @var InfoInterface $payment * */ | ||
$payment = $paymentDO->getPayment(); | ||
|
||
$result[ChargesDataRequest::CHARGES][] = [ | ||
PaymentCcDataRequest::PAYMENT_METHOD => $this->getDataThreeDs($payment), | ||
]; | ||
|
||
return $result; | ||
} | ||
|
||
/** | ||
* Get data for 3ds. | ||
* | ||
* @param InfoInterface $payment | ||
* | ||
* @return array | ||
*/ | ||
public function getDataThreeDs($payment) | ||
{ | ||
$dataThreeDs = []; | ||
$sessionID = $payment->getAdditionalInformation('three_ds_session'); | ||
|
||
if ($sessionID) { | ||
$dataThreeDs = [ | ||
self::AUTHENTICATION_METHOD => [ | ||
self::TYPE => self::TYPE_VALUE, | ||
self::ID => $sessionID, | ||
], | ||
]; | ||
} | ||
|
||
return $dataThreeDs; | ||
} | ||
} |
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
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,63 @@ | ||
<?php | ||
/** | ||
* PagBank Payment Magento Module. | ||
* | ||
* Copyright © 2023 PagBank. All rights reserved. | ||
* | ||
* @author Bruno Elisei <brunoelisei@o2ti.com> | ||
* @license See LICENSE for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PagBank\PaymentMagento\Model\Api\Data; | ||
|
||
use PagBank\PaymentMagento\Api\Data\ThreeDsSessionDataInterface; | ||
|
||
/** | ||
* Class 3ds Session - Model data. | ||
*/ | ||
class Session implements ThreeDsSessionDataInterface | ||
{ | ||
/** | ||
* @var string $sessionId | ||
*/ | ||
protected $sessionId; | ||
|
||
/** | ||
* @var string $expiresAt | ||
*/ | ||
protected $expiresAt; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getSessionId() | ||
{ | ||
return $this->sessionId; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function setSessionId($sessionId) | ||
{ | ||
return $this->sessionId = $sessionId; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getExpiresAt() | ||
{ | ||
return $this->expiresAt; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function setExpiresAt($expiresAt) | ||
{ | ||
return $this->expiresAt = $expiresAt; | ||
} | ||
} |
Oops, something went wrong.