Skip to content
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

Release 2.6.0 #363

Merged
merged 31 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0271d86
tests: add config tests
fabiano-mallmann Jun 24, 2024
e48d08e
tests: add config tests for googlepay
fabiano-mallmann Jun 25, 2024
66f0bdd
fix: making corporation_type field required
RafaMelazzo Jun 26, 2024
44e4fc2
refactor: add variable to date placeholder
RafaMelazzo Jun 26, 2024
d33909d
fix: making corporation_type field required #350
RafaMelazzo Jun 26, 2024
eba62b3
feat: add pagarme account id to google pay fields
RafaMelazzo Jul 2, 2024
d895791
fix: hide google pay options when not active
RafaMelazzo Jul 2, 2024
cf63778
feat: add pagarme account id to googlepay #351
RafaMelazzo Jul 5, 2024
895061e
improve: allow integration in the default scope
RafaMelazzo Jul 8, 2024
7ac92fa
fix: integration behaviour
RafaMelazzo Jul 16, 2024
3c48319
feat: remove integration from db when marking 'use default' option
RafaMelazzo Jul 17, 2024
fdfea64
fix: sonar issue
RafaMelazzo Jul 17, 2024
4a4101c
improve: allow integration in the default scope #352
RafaMelazzo Jul 23, 2024
ecd9875
feat: add mask to card number fields on checkout
RafaMelazzo Jul 25, 2024
df308f8
fix: sonarcloud issues
RafaMelazzo Jul 25, 2024
4842eb1
fix: token card number
RafaMelazzo Jul 29, 2024
a0a024b
refactor: added mask to listener
RafaMelazzo Aug 1, 2024
a86540a
feat: add mask to card number fields on checkout #354
RafaMelazzo Aug 1, 2024
728b78e
fix: core develop
RafaMelazzo Aug 2, 2024
03968b8
fix: core develop #355
RafaMelazzo Aug 2, 2024
0fa08fa
handle empty card brands configuration
robsoned Aug 13, 2024
d983011
update return type in RecipientInterface createKycLink method
robsoned Aug 13, 2024
376bbd9
fix: handle empty card brands configuration #357
fabiano-mallmann Aug 21, 2024
ef5c2aa
fix: update return type in RecipientInterface createKycLink method #359
fabiano-mallmann Aug 21, 2024
2350b3e
Release 2.5.0
fabiano-mallmann Sep 5, 2024
22beafd
fix: when credit card data is empty
fabiano-mallmann Sep 5, 2024
c204af3
fix: code smell
fabiano-mallmann Sep 5, 2024
4f06cea
refact: split in two functions
fabiano-mallmann Sep 5, 2024
5f2f057
fix: when credit card data is empty #361
fabiano-mallmann Sep 5, 2024
83c2229
release: 2.6.0
fabiano-mallmann Sep 11, 2024
6293e3f
Release 2.6.0 #362
fabiano-mallmann Sep 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Api/RecipientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function searchRecipient(): string;

/**
* @param string $id
* @return KycLinkResponseInterface
* @return Pagarme\Pagarme\Api\KycLinkResponseInterface
*/
public function createKycLink(string $id);
}
77 changes: 47 additions & 30 deletions Block/Adminhtml/System/Config/Form/Field/HubIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use Exception;
use Magento\Backend\Block\Template\Context;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\Phrase;
use Pagarme\Core\Hub\Services\HubIntegrationService;
use Pagarme\Pagarme\Concrete\Magento2CoreSetup;
use Pagarme\Pagarme\Model\Account;
Expand All @@ -18,12 +18,16 @@ class HubIntegration extends Field
*/
private $account;

protected $scopeConfig;

public function __construct(
Account $account,
ScopeConfigInterface $scopeConfig,
Context $context,
array $data = []
) {
$this->account = $account;
$this->scopeConfig = $scopeConfig;
parent::__construct($context, $data);
}

Expand All @@ -32,31 +36,46 @@ public function __construct(
* @return string
* @throws Exception
*/
protected function _renderValue(AbstractElement $element)
protected function _renderValue(AbstractElement $element): string
{
Magento2CoreSetup::bootstrap();

$installId = Magento2CoreSetup::getModuleConfiguration()
->getHubInstallId();

$hubUrl = $this->getHubUrl($installId);
$buttonText = $this->getButtonText($installId);
$installId = Magento2CoreSetup::getModuleConfiguration()->getHubInstallId();
$installIdValue = !empty($installId) ? $installId->getValue() : '';
$defaultInstallId = $this->scopeConfig->getValue(
'pagarme_pagarme/hub/install_id',
ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
0
);
$defaultInstallId = $defaultInstallId ?? '';

$html = '<td class="value">';
$html = sprintf(
'<td class="value" data-pagarme-integration-scope="%s">',
$installIdValue === $defaultInstallId ? 'default' : 'scope'
);
$html .= $this->_getElementHtml($element);

$hidden = ' hidden';

$html .= sprintf(
'<a id="pagarme-hub-button" href="%s">%s</a>',
$hubUrl,
$buttonText
'<a href="%s" id="pagarme-integrate-button" class="pagarme-integration-button%s">%s</a>',
$this->getBaseIntegrateUrl(),
$installId ? $hidden : '',
__("Integrate With Pagar.me")
);

$html .= sprintf(
'<a href="%s" id="pagarme-view-integration-button" class="pagarme-integration-button%s">%s</a>',
$this->getHubUrl($installId),
$installId ? '' : $hidden,
__("View Integration")
);

if ($this->account->hasMerchantAndAccountIds()) {
$dashUrl = $this->account->getDashUrl();
$html .= sprintf(
'<a id="pagarme-dash-button" href="%s" target="_blank">%s</a>',
$dashUrl,
'<a href="%s" target="_blank" id="pagarme-dash-button" class="pagarme-integration-button%s">%s</a>',
$this->account->getDashUrl(),
$installId ? '' : $hidden,
__('Access Pagar.me Dash')
);
}
Expand All @@ -66,16 +85,6 @@ protected function _renderValue(AbstractElement $element)
return $html;
}

/**
* @param $installId
* @return Phrase
*/
private function getButtonText($installId): Phrase
{
return $installId
? __("View Integration") : __("Integrate With Pagar.me");
}

/**
* @param $installId
* @return string
Expand All @@ -97,12 +106,20 @@ private function getBaseIntegrateUrl(): string
$this->getPublicAppKey()
);

$params = sprintf(
'?redirect=%swebsite/%s/&install_token/%s',
$this->getRedirectUrl(),
Magento2CoreSetup::getCurrentStoreId(),
$this->getInstallToken()
);
if($this->getRequest()->getParam('website') !== null) {
$params = sprintf(
'?redirect=%swebsite/%s/&install_token/%s',
$this->getRedirectUrl(),
Magento2CoreSetup::getCurrentStoreId(),
$this->getInstallToken()
);
} else {
$params = sprintf(
'?redirect=%s&install_token/%s',
$this->getRedirectUrl(),
$this->getInstallToken()
);
}

return $baseUrl . $params;
}
Expand Down
41 changes: 26 additions & 15 deletions Block/Payment/Info/BaseCardInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,34 @@ abstract class BaseCardInfo extends Cc

/**
* @return array
*/
public function getTransactionInfo()
{
$charge = $this->getLastCharge();
if ($charge->getLastTransaction()->getCardData() == null) {
return [];
}
$lastFourDigitsWithDots = sprintf(
"**** **** **** %s",
$charge->getLastTransaction()->getCardData()->getLastFourDigits()->getValue()
);
return array_merge(
$charge->getAcquirerTidCapturedAndAuthorize(),
['tid' => $charge->getLastTransaction()->getAcquirerTid() ?? ""],
['cardBrand' => $charge->getLastTransaction()->getCardData()->getBrand()->getName() ?? ""],
['installments' => $this->getInfo()->getAdditionalInformation('cc_installments') ?? ""],
['lastFour' => $lastFourDigitsWithDots],
['acquirerMessage' => $charge->getLastTransaction()->getAcquirerMessage() ?? ""]
);
}

/**
* @return mixed|array|Charge
* @throws InvalidParamException
* @throws LocalizedException
* @throws Exception
*/
public function getTransactionInfo()
private function getLastCharge()
{
Magento2CoreSetup::bootstrap();
$orderService = new OrderService();
Expand All @@ -40,21 +63,9 @@ public function getTransactionInfo()
return [];
}

$charge = current($orderObject->getCharges());
$lastFourDigitsWithDots = sprintf(
"**** **** **** %s",
$charge->getLastTransaction()->getCardData()->getLastFourDigits()->getValue()
);
return array_merge(
$charge->getAcquirerTidCapturedAndAuthorize(),
['tid' => $charge->getLastTransaction()->getAcquirerTid() ?? ""],
['cardBrand' => $charge->getLastTransaction()->getCardData()->getBrand()->getName() ?? ""],
['installments' => $this->getInfo()->getAdditionalInformation('cc_installments') ?? ""],
['lastFour' => $lastFourDigitsWithDots],
['acquirerMessage' => $charge->getLastTransaction()->getAcquirerMessage() ?? ""]
);
return current($orderObject->getCharges());
}

/**
* @param mixed $orderService
* @param mixed $pagarmeId
Expand Down
Loading
Loading