Skip to content

Commit

Permalink
Release 2.4.0 (#304)
Browse files Browse the repository at this point in the history
Release 2.4.0
  • Loading branch information
RafaMelazzo authored Jan 29, 2024
2 parents d0c1f29 + 628d2a1 commit f3932ae
Show file tree
Hide file tree
Showing 63 changed files with 1,294 additions and 344 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,91 @@ jobs:
-
name: Check PHP sintax
run: find . -name \*.php -exec php -l "{}" \;
phpunit:
name: PHP Unit
runs-on: ubuntu-latest
steps:
- name: Create Folder
run: ls -la && mkdir magento && cd magento && ls -la

- name: Install Magento
uses: php-actions/composer@v6
with:
php_version: 8.1
command: "create-project --repository-url=https://repo.magento.com/ magento/project-community-edition:2.4.5 ."
args: "--ignore-platform-reqs"
working_dir: /app/magento
env:
COMPOSER_AUTH: '{"http-basic": { "repo.magento.com": { "username": "${{ secrets.MAGENTO_KEY }}", "password": "${{secrets.MAGENTO_SECRET}}"}}}'

- name: Change minimum stable to Dev
uses: php-actions/composer@v6
with:
php_version: 8.1
command: "config minimum-stability dev"
working_dir: /app/magento

- name: Download Module
uses: php-actions/composer@v6
with:
php_version: 8.1
command: require pagarme/pagarme-magento2-module:dev-${{ github.head_ref }}
args: "--ignore-platform-reqs"
working_dir: /app/magento
env:
COMPOSER_AUTH: '{"http-basic": { "repo.magento.com": { "username": "${{ secrets.MAGENTO_KEY }}", "password": "${{secrets.MAGENTO_SECRET}}"}}}'

- name: Download Mockery
uses: php-actions/composer@v6
with:
php_version: 8.1
command: require mockery/mockery
args: "--ignore-platform-reqs"
working_dir: /app/magento
env:
COMPOSER_AUTH: '{"http-basic": { "repo.magento.com": { "username": "${{ secrets.MAGENTO_KEY }}", "password": "${{secrets.MAGENTO_SECRET}}"}}}'

- name: Run PHP Unit Tests
uses: php-actions/phpunit@v3
env:
XDEBUG_MODE: coverage
with:
bootstrap: "/app/magento/vendor/autoload.php"
configuration: "/app/magento/vendor/pagarme/pagarme-magento2-module/phpunit.xml"
version: 9.5.28
php_version : 8.1
php_extensions: "xdebug"

- name: Upload coverage artifact
uses: actions/upload-artifact@master
with:
name: mage-coverage-${{ github.sha }}
path: magento/vendor/pagarme/pagarme-magento2-module/clover.xml

sonar:
name: SonarCloud
runs-on: ubuntu-latest
needs: phpunit
steps:
-
name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
-
name: Download coverage artifact
uses: actions/download-artifact@master
with:
name: mage-coverage-${{ github.sha }}
path: coverage
-
name: Run Sonar
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Delete coverage artifact
uses: geekyeggo/delete-artifact@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: mage-coverage-${{ github.sha }}
11 changes: 11 additions & 0 deletions Api/TdsTokenInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Pagarme\Pagarme\Api;

interface TdsTokenInterface
{
/**
* @return string
*/
public function getToken();
}
7 changes: 2 additions & 5 deletions Block/Adminhtml/Form/Field/CreditCardPspField.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Magento\Backend\Block\Template\Context;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\View\Helper\SecureHtmlRenderer;
use Pagarme\Pagarme\Model\Account;
use Pagarme\Pagarme\Model\PagarmeConfigProvider;

Expand All @@ -20,15 +19,13 @@ class CreditCardPspField extends Field
* @param Context $context
* @param Account $account
* @param array $data
* @param SecureHtmlRenderer|null $secureRenderer
*/
public function __construct(
Context $context,
Account $account,
array $data = [],
?SecureHtmlRenderer $secureRenderer = null
array $data = []
) {
parent::__construct($context, $data, $secureRenderer);
parent::__construct($context, $data);
$this->account = $account;
}

Expand Down
7 changes: 2 additions & 5 deletions Block/Adminhtml/Form/Field/GatewayField.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Magento\Backend\Block\Template\Context;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\View\Helper\SecureHtmlRenderer;
use Pagarme\Pagarme\Model\Account;

class GatewayField extends Field
Expand All @@ -25,16 +24,14 @@ class GatewayField extends Field
* @param Account $account
* @param string $paymentMethodName
* @param array $data
* @param SecureHtmlRenderer|null $secureRenderer
*/
public function __construct(
Context $context,
Account $account,
string $paymentMethodName = '',
array $data = [],
?SecureHtmlRenderer $secureRenderer = null
array $data = []
) {
parent::__construct($context, $data, $secureRenderer);
parent::__construct($context, $data);
$this->account = $account;
$this->paymentMethodName = $paymentMethodName;
}
Expand Down
7 changes: 2 additions & 5 deletions Block/Adminhtml/Form/Field/InstallmentsNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Config\Model\ResourceModel\Config\Data\CollectionFactory;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\View\Helper\SecureHtmlRenderer;
use Pagarme\Pagarme\Model\Account;
use Pagarme\Pagarme\Model\PagarmeConfigProvider;

Expand All @@ -22,16 +21,14 @@ class InstallmentsNumber extends Field
* @param CollectionFactory $configCollectionFactory
* @param Account $account
* @param array $data
* @param SecureHtmlRenderer|null $secureRenderer
*/
public function __construct(
Context $context,
CollectionFactory $configCollectionFactory,
Account $account,
array $data = [],
?SecureHtmlRenderer $secureRenderer = null
array $data = []
) {
parent::__construct($context, $data, $secureRenderer);
parent::__construct($context, $data);
$this->configCollectionFactory = $configCollectionFactory;
$this->account = $account;
}
Expand Down
7 changes: 2 additions & 5 deletions Block/Adminhtml/Form/Field/SoftDescriptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Magento\Backend\Block\Template\Context;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\View\Helper\SecureHtmlRenderer;
use Pagarme\Pagarme\Model\Account;

class SoftDescriptor extends Field
Expand All @@ -25,16 +24,14 @@ class SoftDescriptor extends Field
* @param Account $account
* @param string $paymentMethodName
* @param array $data
* @param SecureHtmlRenderer|null $secureRenderer
*/
public function __construct(
Context $context,
Account $account,
string $paymentMethodName = '',
array $data = [],
?SecureHtmlRenderer $secureRenderer = null
array $data = []
) {
parent::__construct($context, $data, $secureRenderer);
parent::__construct($context, $data);
$this->account = $account;
$this->paymentMethodName = $paymentMethodName;
}
Expand Down
7 changes: 2 additions & 5 deletions Block/Adminhtml/Form/Fieldset/CreditCardGatewayFieldset.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Magento\Config\Block\System\Config\Form\Fieldset;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\View\Helper\Js;
use Magento\Framework\View\Helper\SecureHtmlRenderer;
use Pagarme\Pagarme\Model\Account;
use Pagarme\Pagarme\Model\PagarmeConfigProvider;

Expand All @@ -24,17 +23,15 @@ class CreditCardGatewayFieldset extends Fieldset
* @param Js $jsHelper
* @param Account $account
* @param array $data
* @param SecureHtmlRenderer|null $secureRenderer
*/
public function __construct(
Context $context,
Session $authSession,
Js $jsHelper,
Account $account,
array $data = [],
?SecureHtmlRenderer $secureRenderer = null
array $data = []
) {
parent::__construct($context, $authSession, $jsHelper, $data, $secureRenderer);
parent::__construct($context, $authSession, $jsHelper, $data);
$this->account = $account;
}

Expand Down
7 changes: 2 additions & 5 deletions Block/Adminhtml/Form/Fieldset/CustomPaymentFieldset.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Magento\Config\Block\System\Config\Form\Fieldset;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\View\Helper\Js;
use Magento\Framework\View\Helper\SecureHtmlRenderer;
use Pagarme\Pagarme\Model\Account;

class CustomPaymentFieldset extends Fieldset
Expand All @@ -29,18 +28,16 @@ class CustomPaymentFieldset extends Fieldset
* @param Account $account
* @param string $paymentMethodName
* @param array $data
* @param SecureHtmlRenderer|null $secureRenderer
*/
public function __construct(
Context $context,
Session $authSession,
Js $jsHelper,
Account $account,
string $paymentMethodName = '',
array $data = [],
?SecureHtmlRenderer $secureRenderer = null
array $data = []
) {
parent::__construct($context, $authSession, $jsHelper, $data, $secureRenderer);
parent::__construct($context, $authSession, $jsHelper, $data);
$this->account = $account;
$this->paymentMethodName = $paymentMethodName;
}
Expand Down
6 changes: 2 additions & 4 deletions Block/Adminhtml/System/Config/Form/Field/HubIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\Phrase;
use Magento\Framework\View\Helper\SecureHtmlRenderer;
use Pagarme\Core\Hub\Services\HubIntegrationService;
use Pagarme\Pagarme\Concrete\Magento2CoreSetup;
use Pagarme\Pagarme\Model\Account;
Expand All @@ -22,11 +21,10 @@ class HubIntegration extends Field
public function __construct(
Account $account,
Context $context,
array $data = [],
?SecureHtmlRenderer $secureRenderer = null
array $data = []
) {
$this->account = $account;
parent::__construct($context, $data, $secureRenderer);
parent::__construct($context, $data);
}

/**
Expand Down
25 changes: 15 additions & 10 deletions Block/Payment/Info/CreditCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
use Magento\Framework\Exception\LocalizedException;
use Magento\Payment\Block\Info\Cc;
use Pagarme\Core\Kernel\Aggregates\Charge;
use Pagarme\Core\Kernel\Aggregates\Order;
use Pagarme\Core\Kernel\Exceptions\InvalidParamException;
use Pagarme\Core\Kernel\Services\OrderService;
use Pagarme\Core\Kernel\ValueObjects\Id\OrderId;
use Pagarme\Core\Payment\Aggregates\Payments\Authentication\AuthenticationStatusEnum;
use Pagarme\Pagarme\Concrete\Magento2CoreSetup;
use Pagarme\Pagarme\Concrete\Magento2PlatformOrderDecorator;

Expand All @@ -42,14 +42,6 @@ public function getCcType()
return $this->getCcTypeName();
}

/**
* @return string
*/
public function getCardNumber()
{
return '**** **** **** ' . $this->getInfo()->getCcLast4();
}

/**
* @return string
*/
Expand Down Expand Up @@ -82,6 +74,19 @@ public function getInstallments()
return $this->getInfo()->getAdditionalInformation('cc_installments');
}

public function getThreeDSStatus()
{
$authenticationAdditionalInformation = $this->getInfo()->getAdditionalInformation('authentication');
if (empty($authenticationAdditionalInformation)) {
return '';
}

$authentication = json_decode($authenticationAdditionalInformation, true);
return AuthenticationStatusEnum::statusMessage(
$authentication['trans_status'] ?? ''
);
}

/**
* @return array
* @throws InvalidParamException
Expand Down Expand Up @@ -109,7 +114,7 @@ public function getTransactionInfo()
}

$charge = current($orderObject->getCharges());

return array_merge(
$charge->getAcquirerTidCapturedAndAutorize(),
['tid' => $this->getTid($charge)]
Expand Down
4 changes: 1 addition & 3 deletions Block/Payment/Info/Debit.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace Pagarme\Pagarme\Block\Payment\Info;

use Magento\Payment\Block\Info\Cc;

class Debit extends Cc
class Debit extends CreditCard
{

}
Loading

0 comments on commit f3932ae

Please sign in to comment.