-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #179 from pagarme/release/2.2.0
Release 2.2.0
- Loading branch information
Showing
104 changed files
with
3,239 additions
and
528 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
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
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,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; | ||
} |
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,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; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...k/Adminhtml/Form/Field/HubEnvironment.php → ...stem/Config/Form/Field/HubEnvironment.php
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
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
43 changes: 43 additions & 0 deletions
43
Block/Adminhtml/System/Config/Form/Field/MarketplaceMessage.php
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,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; | ||
} | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
Block/Adminhtml/Form/Field/ModuleVersion.php → ...ystem/Config/Form/Field/ModuleVersion.php
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
36 changes: 36 additions & 0 deletions
36
Block/Adminhtml/System/Config/Form/Field/SearchRecipient.php
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,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'; | ||
} | ||
|
||
|
||
} |
2 changes: 1 addition & 1 deletion
2
.../System/Config/Fieldset/CycleDiscount.php → ...em/Config/Form/Fieldset/CycleDiscount.php
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
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
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
Oops, something went wrong.