Skip to content

Commit

Permalink
Merge pull request #179 from pagarme/release/2.2.0
Browse files Browse the repository at this point in the history
Release 2.2.0
  • Loading branch information
fabiano-mallmann authored Apr 17, 2023
2 parents 0ab4014 + 8d0f7f5 commit 58811e6
Show file tree
Hide file tree
Showing 104 changed files with 3,239 additions and 528 deletions.
6 changes: 5 additions & 1 deletion .github/data/magento2_module_install.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ VALUES ('default', 0, 'pagarme_pagarme/global/test_mode', '1'),
('default', 0, 'payment/pagarme_customer_address/number_attribute', 'street_2'),
('default', 0, 'payment/pagarme_customer_address/complement_attribute', 'street_3'),
('default', 0, 'payment/pagarme_customer_address/district_attribute', 'street_4'),
('default', 0, 'payment/pagarme_pix/expiration_qrcode', '5000'),
('default', 0, 'payment/pagarme_pix/active', '1'),
('default', 0, 'payment/pagarme_pix/title', 'Pagar.me Pix'),
('default', 0, 'payment/pagarme_pix/expiration_qrcode', '3600'),
('default', 0, 'payment/pagarme_creditcard/active', '1'),
('default', 0, 'payment/pagarme_creditcard/title', 'Pagar.me Cartao'),
('default', 0, 'payment/pagarme_creditcard/soft_description', 'Magento 2 stg'),
Expand Down Expand Up @@ -34,3 +36,5 @@ VALUES ('default', 0, 'pagarme_pagarme/global/test_mode', '1'),
('default', 0, 'payment/pagarme_billet_creditcard/title', 'Pagar.me Boleto e Cartao'),
('default', 0, 'payment/pagarme_billet_creditcard/sort_order', '1'),
('default', 0, 'payment/pagarme_multibuyer/active', '1');
('default', 0, 'payment/pagarme_voucher/title', 'Pagar.me Voucher'),
('default', 0, 'payment/pagarme_debit/title', 'Pagar.me Cartao de Debito'),
2 changes: 1 addition & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ on:
- test
- stg
- master

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:

publish:
name: Publish
runs-on: ubuntu-latest
Expand Down
20 changes: 20 additions & 0 deletions Api/RecipientInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Pagarme\Pagarme\Api;

interface RecipientInterface
{
/**
*
* @param mixed $data
* @return mixed
*/
public function saveFormData();

/**
*
* @param mixed $data
* @return string
*/
public function searchRecipient(): string;
}
130 changes: 130 additions & 0 deletions Block/Adminhtml/Marketplace/Recipient.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<?php

namespace Pagarme\Pagarme\Block\Adminhtml\Marketplace;

use Magento\Framework\Registry;
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;
use Pagarme\Pagarme\Concrete\Magento2CoreSetup;
use Magento\Customer\Model\ResourceModel\Customer\CollectionFactory as CustomerCollectionFactory;
use Pagarme\Core\Marketplace\Repositories\RecipientRepository;
use stdClass;

class Recipient extends Template
{

private $customerCollection;

/**
* @var RecipientRepository
*/
private $recipientRepository;

/**
* @var Registry
*/
private $coreRegistry;


/**
* @var array
*/
private $sellers = [];

/**
* @var stdClass
*/
private $recipient = null;


/**
* Link constructor.
* @param Context $context
*/
public function __construct(
Context $context,
Registry $registry,
CustomerCollectionFactory $customerCollectionFactory
) {
$this->coreRegistry = $registry;
$this->customerCollection = $customerCollectionFactory->create();
$this->recipientRepository = new RecipientRepository();

Magento2CoreSetup::bootstrap();
parent::__construct($context, []);

$recipientData = $this->coreRegistry->registry('recipient_data');
if (!empty($recipientData)) {
$this->recipient = json_decode($recipientData);
$this->recipient->recipient->externalId = $this->recipient->externalId;
$this->recipient->recipient->localId = $this->recipient->localId;
$this->recipient = $this->recipient->recipient;
}

$sellerData = $this->coreRegistry->registry('sellers');
if (!empty($sellerData)) {
$this->sellers = $this->buildSellerData($sellerData);
}
}

private function buildSellerData($serializedSellerData)
{
$sellerData = unserialize($serializedSellerData);
$entityIds = [];

foreach ($sellerData as $seller) {
$sellerId = $seller->getSellerId();

$recipient = $this->recipientRepository->findBySellerId($sellerId);

if (!empty($recipient)) {
continue;
}

$entityIds[] = $sellerId;
}

$customers = $this->customerCollection
->addAttributeToSelect('*')
->addFieldToFilter('entity_id', array('in' => $entityIds))
->getData();

return $customers;
}

public function getEditRecipient()
{
if (empty($this->recipient)) {
return "";
}

return json_encode($this->recipient);
}

public function getRecipientId()
{
if (is_null($this->recipient)) {
return '';
}

return $this->recipient->id;
}

public function getLocalId()
{
if (is_null($this->recipient)) {
return '';
}

return $this->recipient->localId;
}

public function getSellers()
{
if (is_null($this->sellers)) {
return [];
}

return $this->sellers;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Pagarme\Pagarme\Block\Adminhtml\Form\Field;
namespace Pagarme\Pagarme\Block\Adminhtml\System\Config\Form\Field;

use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Pagarme\Pagarme\Block\Adminhtml\Form\Field;
namespace Pagarme\Pagarme\Block\Adminhtml\System\Config\Form\Field;

use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;
Expand Down Expand Up @@ -28,10 +28,12 @@ protected function _renderValue(AbstractElement $element)
$html .= $this->_getElementHtml($element);

$html .= sprintf(
'<p
'<a
id="botao-hub"
href="%s"
hub-url="%s"
button-text="%s"></p>',
button-text="%s"></a>',
$hubUrl,
$hubUrl,
$buttonText
);
Expand Down Expand Up @@ -99,5 +101,4 @@ private function getInstallToken()

return $installToken->getValue();
}

}
43 changes: 43 additions & 0 deletions Block/Adminhtml/System/Config/Form/Field/MarketplaceMessage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace Pagarme\Pagarme\Block\Adminhtml\System\Config\Form\Field;

use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\Module\Manager as ModuleManager;

class MarketplaceMessage extends Field
{
/**
* @var ModuleManager
*/
protected $moduleManager;

public function __construct(ModuleManager $moduleManager)
{
$this->moduleManager = $moduleManager;
}


/**
* @param AbstractElement $element
* @return string
*/
public function render(AbstractElement $element)
{
$html = "";
if(!$this->moduleManager->isEnabled("Webkul_Marketplace")){
$html = __(<<<MSG
<p class='message message-notification'>
You need to activate the
<a href='https://store.webkul.com/magento2-multi-vendor-marketplace.html' target='_blank'>
Webkul Marketplace
</a>
extension.
</p>
MSG);
}
return $html;
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Pagarme\Pagarme\Block\Adminhtml\Form\Field;
namespace Pagarme\Pagarme\Block\Adminhtml\System\Config\Form\Field;

use Magento\Framework\Data\Form\Element\AbstractElement;
use Pagarme\Core\Kernel\Services\VersionService;
Expand Down
36 changes: 36 additions & 0 deletions Block/Adminhtml/System/Config/Form/Field/SearchRecipient.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace Pagarme\Pagarme\Block\Adminhtml\System\Config\Form\Field;

use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;

class SearchRecipient extends Field
{

protected function _renderValue(AbstractElement $element): string
{
$html = '<td class="value">';
$html .= $this->_getElementHtml($element);
$html .= '<p>Pagar.me recipient id that represents your marketplace</p>';
$html .= '</td>';
$html .= '<td>';
$html .= sprintf(
'<button type="button" class="action-basic" api-url="%s" id="pagarme-get-info" data-action="">
<span>%s</span>
</button>',
$this->getSearchUrl(),
__('Get info')
);
$html .= '</td>';

return $html;
}

protected function getSearchUrl(): string
{
return $this->getBaseUrl() . 'rest/V1/pagarme/marketplace/recipient/searchRecipient';
}


}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Pagarme\Pagarme\Block\Adminhtml\System\Config\Fieldset;
namespace Pagarme\Pagarme\Block\Adminhtml\System\Config\Form\Fieldset;

use Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @link https://pagar.me
*/

namespace Pagarme\Pagarme\Block\Adminhtml\System\Config\Fieldset;
namespace Pagarme\Pagarme\Block\Adminhtml\System\Config\Form\Fieldset;


use Magento\Config\Block\System\Config\Form\Fieldset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @link https://pagar.me
*/

namespace Pagarme\Pagarme\Block\Adminhtml\System\Config\Fieldset;
namespace Pagarme\Pagarme\Block\Adminhtml\System\Config\Form\Fieldset;

use Magento\Config\Block\System\Config\Form\Fieldset;

Expand Down
Loading

0 comments on commit 58811e6

Please sign in to comment.