-
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.
- Adiciona salvamento de cartão utilizando a API de Zero Dollar.
- Loading branch information
Showing
19 changed files
with
1,214 additions
and
5 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,153 @@ | ||
<?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 PagBank Vault Token. | ||
* | ||
* @api | ||
*/ | ||
interface PagBankVaultTokenInterface | ||
{ | ||
/** | ||
* Constants for keys of data array. | ||
*/ | ||
public const PAGBANK_TOKEN = 'pagbank_token'; | ||
public const PUBLIC_HASH = 'public_hash'; | ||
public const CARD_BRAND = 'card_brand'; | ||
public const LAST_DIGITS = 'last_digits'; | ||
public const EXPIRATION_DATE = 'expiration_date'; | ||
public const CREATED_AT = 'created_at'; | ||
public const IS_ACTIVE = 'is_active'; | ||
public const WEBSITE_ID = 'website_id'; | ||
|
||
/** | ||
* Get PagBank Token. | ||
* | ||
* @return string|null | ||
*/ | ||
public function getPagBankToken(); | ||
|
||
/** | ||
* Set PagBank Token. | ||
* | ||
* @param string $token | ||
* @return $this | ||
*/ | ||
public function setPagBankToken($token); | ||
|
||
/** | ||
* Get Website Id. | ||
* | ||
* @return int|null | ||
*/ | ||
public function getWebsiteId(); | ||
|
||
/** | ||
* Set Website Id. | ||
* | ||
* @param int $websiteId | ||
* @return $this | ||
*/ | ||
public function setWebsiteId($websiteId); | ||
|
||
/** | ||
* Get public hash. | ||
* | ||
* @return string|null | ||
*/ | ||
public function getPublicHash(); | ||
|
||
/** | ||
* Set public hash. | ||
* | ||
* @param string $hash | ||
* @return $this | ||
*/ | ||
public function setPublicHash($hash); | ||
|
||
/** | ||
* Get card brand. | ||
* | ||
* @return string|null | ||
*/ | ||
public function getCardBrand(); | ||
|
||
/** | ||
* Set card brand. | ||
* | ||
* @param string $brand | ||
* @return $this | ||
*/ | ||
public function setCardBrand($brand); | ||
|
||
/** | ||
* Get last digits. | ||
* | ||
* @return string|null | ||
*/ | ||
public function getLastDigits(); | ||
|
||
/** | ||
* Set last digits. | ||
* | ||
* @param string $lastDigits | ||
* @return $this | ||
*/ | ||
public function setLastDigits($lastDigits); | ||
|
||
/** | ||
* Get expiration date. | ||
* | ||
* @return string|null | ||
*/ | ||
public function getExpirationDate(); | ||
|
||
/** | ||
* Set expiration date. | ||
* | ||
* @param string $expirationDate | ||
* @return $this | ||
*/ | ||
public function setExpirationDate($expirationDate); | ||
|
||
/** | ||
* Get created at. | ||
* | ||
* @return string|null | ||
*/ | ||
public function getCreatedAt(); | ||
|
||
/** | ||
* Set created at. | ||
* | ||
* @param string $createdAt | ||
* @return $this | ||
*/ | ||
public function setCreatedAt($createdAt); | ||
|
||
/** | ||
* Get is active. | ||
* | ||
* @return bool|null | ||
*/ | ||
public function getIsActive(); | ||
|
||
/** | ||
* Set is active. | ||
* | ||
* @param bool $isActive | ||
* @return $this | ||
*/ | ||
public function setIsActive($isActive); | ||
} |
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 | ||
/** | ||
* 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; | ||
|
||
/** | ||
* Interface for creating token vault from zero dollar transaction. | ||
* | ||
* @api | ||
*/ | ||
interface PagBankVaultManagementInterface | ||
{ | ||
/** | ||
* Criar token vault a partir de cartão criptografado. | ||
* | ||
* @param int $customerId | ||
* @param string $encryptedCard | ||
* @return \PagBank\PaymentMagento\Api\Data\PagBankVaultTokenInterface | ||
*/ | ||
public function createVaultToken( | ||
int $customerId, | ||
string $encryptedCard | ||
); | ||
} |
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,143 @@ | ||
<?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\Block\Customer\Vault\Cards; | ||
|
||
use Magento\Framework\View\Element\Template; | ||
use Magento\Payment\Model\CcConfig; | ||
use PagBank\PaymentMagento\Gateway\Config\Config; | ||
use PagBank\PaymentMagento\Gateway\Config\ConfigCc; | ||
use Magento\Framework\Serialize\Serializer\Json; | ||
use Magento\Framework\View\Asset\Source; | ||
|
||
/** | ||
* Class CreateForm - Block to handle credit card form. | ||
*/ | ||
class CreateForm extends Template | ||
{ | ||
/** | ||
* @var Config | ||
*/ | ||
private $config; | ||
|
||
/** | ||
* @var ConfigCc | ||
*/ | ||
private $configCc; | ||
|
||
/** | ||
* @var CcConfig | ||
*/ | ||
private $ccConfig; | ||
|
||
/** | ||
* @var Json | ||
*/ | ||
private $serializer; | ||
|
||
/** | ||
* @var Source | ||
*/ | ||
private $assetSource; | ||
|
||
/** | ||
* @param Template\Context $context | ||
* @param Config $config | ||
* @param ConfigCc $configCc | ||
* @param CcConfig $ccConfig | ||
* @param Json $serializer | ||
* @param Source $assetSource | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
Template\Context $context, | ||
Config $config, | ||
ConfigCc $configCc, | ||
CcConfig $ccConfig, | ||
Json $serializer, | ||
Source $assetSource, | ||
array $data = [] | ||
) { | ||
parent::__construct($context, $data); | ||
$this->config = $config; | ||
$this->configCc = $configCc; | ||
$this->ccConfig = $ccConfig; | ||
$this->serializer = $serializer; | ||
$this->assetSource = $assetSource; | ||
} | ||
|
||
/** | ||
* Get credit card expiration months | ||
* | ||
* @return array | ||
*/ | ||
public function getCcMonths() | ||
{ | ||
return $this->ccConfig->getCcMonths(); | ||
} | ||
|
||
/** | ||
* Get credit card expiration years | ||
* | ||
* @return array | ||
*/ | ||
public function getCcYears() | ||
{ | ||
return $this->ccConfig->getCcYears(); | ||
} | ||
|
||
/** | ||
* Get CC Available Types | ||
* | ||
* @return array | ||
*/ | ||
public function getCcAvailableTypes() | ||
{ | ||
$storeId = $this->_storeManager->getStore()->getId(); | ||
$types = $this->configCc->getCcAvailableTypes($storeId); | ||
$ccTypesMapper = $this->configCc->getCcTypesMapper($storeId); | ||
$availableTypes = array_filter(explode(',', $types)); | ||
|
||
$result = []; | ||
foreach ($availableTypes as $type) { | ||
$code = trim($type); | ||
if (isset($ccTypesMapper[$code])) { | ||
$result[$code] = $ccTypesMapper[$code]; | ||
} | ||
} | ||
|
||
return $result; | ||
} | ||
|
||
/** | ||
* Get Public Key | ||
* | ||
* @return string | ||
*/ | ||
public function getPublicKey() | ||
{ | ||
return $this->config->getMerchantGatewayPublicKey($this->_storeManager->getStore()->getId()); | ||
} | ||
|
||
/** | ||
* Get JS Form Config | ||
* | ||
* @return string | ||
*/ | ||
public function getJsFormConfig() | ||
{ | ||
$storeId = $this->_storeManager->getStore()->getId(); | ||
$config = [ | ||
'publicKey' => $this->getPublicKey(), | ||
'ccTypesMapper' => $this->configCc->getCcTypesMapper($storeId) | ||
]; | ||
return $this->serializer->serialize($config); | ||
} | ||
} |
Oops, something went wrong.