-
Notifications
You must be signed in to change notification settings - Fork 1
Fix: added #DS and taxvat to Wallet and Pix #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
contardi
wants to merge
18
commits into
PicPay:main
Choose a base branch
from
bizcommerce:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 10 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
0fa1c47
Merge pull request #5 from PicPay/main
contardi 135f24f
feat: Init 3DS implementation
janainabiz 1d7e955
fix: add taxvat to pix and wallet
janainabiz 0b7d96d
Merge branch 'main' into tds
janainabiz 15638ee
fix: save request data when transaction rollback
janainabiz 4996ff9
feat: add enrollment
janainabiz 80edd81
feat: implement 3DS authorization steps
janainabiz 6a0a0c4
Merge branch 'tds'
janainabiz 18370ad
fix: update composer version and add translation
janainabiz 2e0b5c3
fix: fix config path and not authorized validation
janainabiz bc82478
fix: improve code
janainabiz 04af259
fix: improve code
janainabiz 5c581a5
feat: code improvments
contardi a200781
fix: change param type to array
janainabiz 4d10a52
feat: set Magento as caller-origin
janainabiz 46b031c
fix: added some data to sse endpoint and fix typo
contardi 27c5833
fix: change #Ds challenge verification to POST to avoid Varnish cache
contardi d920746
fix: adjust qr code display
janainabiz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,85 @@ | ||
<?php | ||
|
||
namespace PicPay\Checkout\Controller\Tds; | ||
|
||
use Magento\Checkout\Model\Session; | ||
use Magento\Framework\App\Action\Action; | ||
use Magento\Framework\App\Action\HttpGetActionInterface; | ||
use Magento\Framework\App\CsrfAwareActionInterface; | ||
use Magento\Framework\App\Request\InvalidRequestException; | ||
use Magento\Framework\App\RequestInterface; | ||
use Magento\Framework\Controller\Result\JsonFactory; | ||
use Magento\Framework\Controller\ResultFactory; | ||
use Magento\Framework\Serialize\Serializer\Json; | ||
use Magento\Backend\App\Action\Context; | ||
use Magento\Quote\Model\QuoteRepository; | ||
|
||
class Challenge extends Action implements HttpGetActionInterface, CsrfAwareActionInterface | ||
{ | ||
/** @var Json */ | ||
protected $json; | ||
|
||
/** @var Session */ | ||
protected $checkoutSession; | ||
|
||
/** | ||
* @var JsonFactory | ||
*/ | ||
protected JsonFactory $resultJsonFactory; | ||
|
||
/** | ||
* @var QuoteRepository | ||
*/ | ||
protected $quoteRepository; | ||
|
||
public function __construct( | ||
Context $context, | ||
Session $checkoutSession, | ||
Json $json, | ||
JsonFactory $resultJsonFactory, | ||
QuoteRepository $quoteRepository | ||
) | ||
{ | ||
$this->checkoutSession = $checkoutSession; | ||
$this->json = $json; | ||
$this->resultJsonFactory = $resultJsonFactory; | ||
$this->quoteRepository = $quoteRepository; | ||
|
||
parent::__construct($context); | ||
} | ||
|
||
public function execute() | ||
{ | ||
$result = $this->resultJsonFactory->create(); | ||
|
||
$quoteId = $this->checkoutSession->getQuoteId(); | ||
|
||
if ($quoteId) { | ||
$quote = $this->quoteRepository->get($quoteId); | ||
|
||
if ($quote->getPicpayChargeId()) { | ||
contardi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
$tdsChallengeStatus = $quote->getPicpayChallengeStatus(); | ||
return $result->setData([ | ||
'challenge_status' => $tdsChallengeStatus, | ||
'charge_id' => $quote->getPicpayChargeId() | ||
]); | ||
} | ||
} | ||
|
||
return $result->setData(['error' => true, 'message' => __('No orders found for this user.')]); | ||
} | ||
|
||
public function createCsrfValidationException(RequestInterface $request): ?InvalidRequestException | ||
{ | ||
$result = $this->resultFactory->create(ResultFactory::TYPE_RAW); | ||
$result->setHttpResponseCode(403); | ||
return new InvalidRequestException( | ||
$result | ||
); | ||
} | ||
|
||
public function validateForCsrf(RequestInterface $request): ?bool | ||
{ | ||
return true; | ||
} | ||
} |
This file contains hidden or 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,102 @@ | ||
<?php | ||
|
||
namespace PicPay\Checkout\Controller\Tds; | ||
|
||
use Magento\Backend\App\Action\Context; | ||
use Magento\Framework\App\Action\Action; | ||
use Magento\Framework\App\Action\HttpPostActionInterface; | ||
use Magento\Framework\App\CsrfAwareActionInterface; | ||
use Magento\Framework\App\Request\InvalidRequestException; | ||
use Magento\Framework\App\RequestInterface; | ||
use Magento\Framework\Controller\Result\JsonFactory; | ||
use Magento\Framework\Controller\ResultFactory; | ||
use Magento\Framework\Serialize\Serializer\Json; | ||
use PicPay\Checkout\Gateway\Http\Client\Api; | ||
use PicPay\Checkout\Model\CheckoutTds; | ||
|
||
class Enrollment extends Action implements HttpPostActionInterface, CsrfAwareActionInterface | ||
{ | ||
/** | ||
* @var JsonFactory | ||
*/ | ||
protected $resultJsonFactory; | ||
|
||
/** | ||
* @var Json | ||
*/ | ||
protected $json; | ||
|
||
/** | ||
* @var Api | ||
*/ | ||
protected $api; | ||
|
||
/** | ||
* @var CheckoutTds | ||
*/ | ||
protected $tds; | ||
|
||
/** | ||
* @param Context $context | ||
* @param CheckoutTds $tds | ||
* @param JsonFactory $resultJsonFactory | ||
* @param Json $json | ||
*/ | ||
public function __construct( | ||
Context $context, | ||
CheckoutTds $tds, | ||
JsonFactory $resultJsonFactory, | ||
Json $json | ||
) { | ||
$this->resultJsonFactory = $resultJsonFactory; | ||
$this->json = $json; | ||
$this->tds = $tds; | ||
|
||
parent::__construct($context); | ||
} | ||
|
||
public function execute() | ||
{ | ||
$result = $this->resultJsonFactory->create(); | ||
|
||
try { | ||
$content = $this->getRequest()->getContent(); | ||
$bodyParams = ($content) ? $this->json->unserialize($content) : []; | ||
$response = $this->tds->runTdsRequest($bodyParams); | ||
|
||
if ($response['response']['chargeId']) { | ||
$result->setJsonData($this->json->serialize($response['response']['transactions'][0])); | ||
} | ||
|
||
$responseCode = 200; | ||
} catch (\Exception $e) { | ||
$responseCode = 500; | ||
$this->messageManager->addErrorMessage($e->getMessage()); | ||
} | ||
|
||
$result->setHttpResponseCode($responseCode); | ||
return $result; | ||
} | ||
|
||
/** | ||
* @param RequestInterface $request | ||
* @return InvalidRequestException|null | ||
*/ | ||
public function createCsrfValidationException(RequestInterface $request): ?InvalidRequestException | ||
{ | ||
$result = $this->resultFactory->create(ResultFactory::TYPE_RAW); | ||
$result->setHttpResponseCode(403); | ||
return new InvalidRequestException( | ||
$result | ||
); | ||
} | ||
|
||
/** | ||
* @param RequestInterface $request | ||
* @return bool|null | ||
*/ | ||
public function validateForCsrf(RequestInterface $request): ?bool | ||
{ | ||
return true; | ||
} | ||
} |
This file contains hidden or 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 hidden or 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,48 @@ | ||
<?php | ||
|
||
/** | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade this extension to newer | ||
* version in the future. | ||
* | ||
* @category PicPay | ||
* @package PicPay_Checkout | ||
* | ||
*/ | ||
|
||
namespace PicPay\Checkout\Gateway\Http\Client\Api; | ||
|
||
use PicPay\Checkout\Gateway\Http\Client; | ||
use Laminas\Http\Request; | ||
|
||
class Tds extends Client | ||
{ | ||
public function setup(array $data): array | ||
{ | ||
$path = $this->getEndpointPath('payments/tds_setup'); | ||
$method = Request::METHOD_POST; | ||
return $this->makeRequest($path, $method, 'payments', $data); | ||
} | ||
|
||
public function enrollment(array $data): array | ||
{ | ||
$path = $this->getEndpointPath('payments/tds_enrollment'); | ||
$method = Request::METHOD_POST; | ||
return $this->makeRequest($path, $method, 'payments', $data); | ||
} | ||
|
||
public function challengeStatus($chargeId): array | ||
{ | ||
$path = $this->getEndpointPath('payments/tds_challenge_status'); | ||
$method = Request::METHOD_GET; | ||
return $this->makeRequest($path, $method); | ||
} | ||
|
||
public function authorization($data): array | ||
{ | ||
$path = $this->getEndpointPath('payments/tds_authorization'); | ||
$method = Request::METHOD_POST; | ||
return $this->makeRequest($path, $method, 'payments', $data); | ||
} | ||
} |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.