Skip to content
This repository has been archived by the owner on Apr 24, 2023. It is now read-only.

Commit

Permalink
Merge pull request #21 from pagseguro/desenvolvimento
Browse files Browse the repository at this point in the history
Desenvolvimento
  • Loading branch information
esilvajr authored Jan 24, 2017
2 parents 6331971 + 6d763ee commit ddd01d4
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 102 deletions.
8 changes: 0 additions & 8 deletions Block/Adminhtml/Conciliation.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
<?php
/**
* Created by PhpStorm.
* User: esilva
* Date: 12/07/16
* Time: 10:12
*/

namespace UOL\PagSeguro\Block\Adminhtml;

namespace UOL\PagSeguro\Block\Payment;

class Conciliation extends \Magento\Framework\View\Element\Template
{
public function _prepareLayout()
Expand Down
6 changes: 0 additions & 6 deletions Block/Product/View/Installments.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ class Installments extends Template
* @var \Magento\Framework\Registry
*/
protected $_coreRegistry;
/**
* @var \Magento\Framework\App\Config\ScopeConfigInterface
*/
protected $_scopeConfig;
/**
* InstallmentMethod auto-generated factory
* @var \UOL\PagSeguro\Model\Direct\InstallmentsMethod
Expand All @@ -53,11 +49,9 @@ class Installments extends Template
*/
public function __construct(
\Magento\Catalog\Block\Product\Context $context,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfigInterface,
\UOL\PagSeguro\Model\Direct\InstallmentsMethodFactory $installmentFactory
) {
$this->_coreRegistry = $context->getRegistry();
$this->_scopeConfig = $scopeConfigInterface;
$this->_installmentFactory = $installmentFactory;
parent::__construct($context);
}
Expand Down
4 changes: 2 additions & 2 deletions Controller/Adminhtml/Refund/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
namespace UOL\PagSeguro\Controller\Adminhtml\Refund;

use UOL\PagSeguro\Controller\Ajaxable;
use UOL\PagSeguro\Model\Transactions\Methods\Refund;
use UOL\PagSeguro\Model\Transactions\Methods;

/**
* Class Request
Expand All @@ -49,7 +49,7 @@ public function __construct(
*/
public function execute()
{
$refund = new Refund(
$refund = new Methods\Refund(
$this->_objectManager->create('Magento\Framework\App\Config\ScopeConfigInterface'),
$this->_objectManager->create('Magento\Framework\App\ResourceConnection'),
$this->_objectManager->create('Magento\Framework\Model\ResourceModel\Db\Context'),
Expand Down
30 changes: 0 additions & 30 deletions Controller/Direct.php

This file was deleted.

6 changes: 3 additions & 3 deletions Controller/Payment/Direct.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
* @license http://www.apache.org/licenses/LICENSE-2.0
*/

namespace UOL\PagSeguro\Controller\Direct;
namespace UOL\PagSeguro\Controller\Payment;

/**
* Class Checkout
* Class Direct
* @package UOL\PagSeguro\Controller\Payment
*/
class Payment extends \Magento\Framework\App\Action\Action
class Direct extends \Magento\Framework\App\Action\Action
{

/** @var \Magento\Framework\View\Result\PageFactory */
Expand Down
12 changes: 3 additions & 9 deletions Controller/Payment/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@
*/
class Request extends \Magento\Framework\App\Action\Action
{

/** @var \Magento\Framework\View\Result\PageFactory */
protected $_resultRedirectFactory;

/**
* @var \Magento\Checkout\Model\Session
Expand All @@ -52,14 +49,10 @@ class Request extends \Magento\Framework\App\Action\Action
* @param \Magento\Framework\App\Action\Context $context
*/
public function __construct(
\Magento\Framework\App\Action\Context $context,
\Magento\Framework\Controller\Result\RedirectFactory $resultRedirectFactory
\Magento\Framework\App\Action\Context $context
) {
parent::__construct($context);

/** @var \Magento\Framework\Controller\Result\RedirectFactory _resultPageFactory*/
$this->_resultRedirectFactory = $resultRedirectFactory;

/** @var \Magento\Checkout\Model\Session _checkoutSession */
$this->_checkoutSession = $this->_objectManager->create('\Magento\Checkout\Model\Session');

Expand All @@ -80,7 +73,7 @@ public function __construct(
public function execute()
{
try {
return $this->_resultRedirectFactory->create()->setPath($this->_payment->createPaymentRequest());
return $this->_redirect($this->_payment->createPaymentRequest());
} catch (\Exception $exception) {
/** @var \Magento\Sales\Model\Order $order */
$order = $this->_objectManager->create('\Magento\Sales\Model\Order')->load(
Expand All @@ -90,6 +83,7 @@ public function execute()
$order->addStatusToHistory('pagseguro_cancelada', null, true);
/** save order */
$order->save();

return $this->_redirect('pagseguro/payment/failure');
}
}
Expand Down
3 changes: 0 additions & 3 deletions Model/Transactions/Methods/Abandoned.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ class Abandoned extends Method
*/
public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfigInterface,
\Magento\Framework\App\ResourceConnection $resourceConnection,
\Magento\Framework\Mail\Template\TransportBuilder $transportBuilder,
\Magento\Framework\Model\ResourceModel\Db\Context $context,
\Magento\Backend\Model\Session $session,
Expand All @@ -113,8 +112,6 @@ public function __construct(
) {
/** @var \Magento\Framework\App\Config\ScopeConfigInterface _scopeConfig */
$this->_scopeConfig = $scopeConfigInterface;
/** @var \Magento\Framework\App\ResourceConnection _resource */
$this->_resource = $resourceConnection;
/** @var \Magento\Backend\Model\Session _session */
$this->_session = $session;
/** @var \Magento\Sales\Model\Order _order */
Expand Down
8 changes: 0 additions & 8 deletions Model/Transactions/Methods/Cancellation.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ class Cancellation extends Method
*/
protected $_scopeConfig;

/**
* @var \Magento\Framework\App\ResourceConnection
*/
protected $_resource;

/**
* @var \Magento\Sales\Model\ResourceModel\Grid
*/
Expand Down Expand Up @@ -94,7 +89,6 @@ class Cancellation extends Method
*/
public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfigInterface,
\Magento\Framework\App\ResourceConnection $resourceConnection,
\Magento\Framework\Model\ResourceModel\Db\Context $context,
\Magento\Backend\Model\Session $session,
\Magento\Sales\Model\Order $order,
Expand All @@ -104,8 +98,6 @@ public function __construct(
) {
/** @var \Magento\Framework\App\Config\ScopeConfigInterface _scopeConfig */
$this->_scopeConfig = $scopeConfigInterface;
/** @var \Magento\Framework\App\ResourceConnection _resource */
$this->_resource = $resourceConnection;
/** @var \Magento\Backend\Model\Session _session */
$this->_session = $session;
/** @var \Magento\Sales\Model\Order _order */
Expand Down
3 changes: 0 additions & 3 deletions Model/Transactions/Methods/Conciliation.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ class Conciliation extends Method
*/
public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfigInterface,
\Magento\Framework\App\ResourceConnection $resourceConnection,
\Magento\Framework\Model\ResourceModel\Db\Context $context,
\Magento\Backend\Model\Session $session,
\Magento\Sales\Model\Order $order,
Expand All @@ -104,8 +103,6 @@ public function __construct(
) {
/** @var \Magento\Framework\App\Config\ScopeConfigInterface _scopeConfig */
$this->_scopeConfig = $scopeConfigInterface;
/** @var \Magento\Framework\App\ResourceConnection _resource */
$this->_resource = $resourceConnection;
/** @var \Magento\Backend\Model\Session _session */
$this->_session = $session;
/** @var \Magento\Sales\Model\Order _order */
Expand Down
8 changes: 0 additions & 8 deletions Model/Transactions/Methods/Refund.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ class Refund extends Method
*/
protected $_scopeConfig;

/**
* @var \Magento\Framework\App\ResourceConnection
*/
protected $_resource;

/**
* @var \Magento\Sales\Model\ResourceModel\Grid
*/
Expand Down Expand Up @@ -94,7 +89,6 @@ class Refund extends Method
*/
public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfigInterface,
\Magento\Framework\App\ResourceConnection $resourceConnection,
\Magento\Framework\Model\ResourceModel\Db\Context $context,
\Magento\Backend\Model\Session $session,
\Magento\Sales\Model\Order $order,
Expand All @@ -104,8 +98,6 @@ public function __construct(
) {
/** @var \Magento\Framework\App\Config\ScopeConfigInterface _scopeConfig */
$this->_scopeConfig = $scopeConfigInterface;
/** @var \Magento\Framework\App\ResourceConnection _resource */
$this->_resource = $resourceConnection;
/** @var \Magento\Backend\Model\Session _session */
$this->_session = $session;
/** @var \Magento\Sales\Model\Order _order */
Expand Down
20 changes: 8 additions & 12 deletions Observer/CreatePagSeguroOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ class CreatePagSeguroOrder implements ObserverInterface
protected $_scopeConfig;

/**
* @var UOL\PagSeguro\Model\System\Config\Environment
* @var \UOL\PagSeguro\Model\System\Config\Environment
*/
protected $_environment;

/**
* Automatic generated factory class
* @var UOL\PagSeguro\Model\OrdersFactory;
* @var \UOL\PagSeguro\Model\OrdersFactory;
*/
protected $_ordersFactory;

Expand All @@ -61,15 +61,10 @@ class CreatePagSeguroOrder implements ObserverInterface
protected $_context;

/**
* @var Magento\Sales\Model\ResourceModel\Grid;
* @var \Magento\Sales\Model\ResourceModel\Grid;
*/
protected $_grid;

/**
* @var Magento\Sales\Model\ResourceModel\Grid;
*/
protected $_resource;

/**
* @param \Magento\Framework\ObjectManagerInterface $objectManager
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfigInterface
Expand All @@ -80,15 +75,13 @@ public function __construct(
\Magento\Framework\ObjectManagerInterface $objectManager,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfigInterface,
\Magento\Framework\Model\ResourceModel\Db\Context $context,
\Magento\Framework\App\ResourceConnection $resourceConnection,
\UOL\PagSeguro\Model\OrdersFactory $ordersFactory,
\UOL\PagSeguro\Model\System\Config\Environment $environmentConfig
) {
$this->_objectManager = $objectManager;
$this->_scopeConfig = $scopeConfigInterface;
$this->_environment = $environmentConfig;
$this->_ordersFactory = $ordersFactory;
$this->_resource = $resourceConnection;
// Unavaliable for DI
$this->_grid = new Grid($context, 'pagseguro_orders', 'sales_order_grid', 'order_id');
}
Expand Down Expand Up @@ -154,10 +147,13 @@ private function getEnvironmentName($environment)
private function updateSalesOrderGridEnvironment($orderId, $environment)
{
$environmentName = $this->getEnvironmentName($environment);

$resource = $this->_objectManager->create('Magento\Framework\App\ResourceConnection');

//Getting connection
$connection = $this->_resource->getConnection();
$connection = $resource->getConnection();
//Getting full table name
$tableName = $this->_resource->getTableName('sales_order_grid');
$tableName = $resource->getTableName('sales_order_grid');
//Update sales_order_grid query
$mapsDeleteQuery = "UPDATE $tableName SET environment='$environmentName' WHERE entity_id=$orderId";
$connection->query($mapsDeleteQuery);
Expand Down
10 changes: 1 addition & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,7 @@
],
"require": {
"php": "~5.5.0|~5.6.0|~7.0.0",
"pagseguro/pagseguro-php-sdk":"*"
},
"extra": {
"map": [
[
"*",
"UOL/PagSeguro"
]
]
"pagseguro/pagseguro-php-sdk": "3.*"
},
"autoload": {
"files": [
Expand Down
12 changes: 11 additions & 1 deletion view/frontend/templates/direct/payment.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@
<span id="card_total">R$ 00,00</span>
</div>
</div>
<div align="right">
Esta compra está sendo feita no Brasil <img src="<?php echo $this->getViewFileUrl('UOL_PagSeguro::images/flag-origin-country.png'); ?>">
</div>
<button class="btn-pagseguro --align-right" id="payment-credit-card">Concluir</button>
</form>
</div><!-- /.item-tab#credit-card -->
Expand Down Expand Up @@ -143,6 +146,9 @@
</label>
</div>
</div><!-- /.form-group -->
<div align="right">
Esta compra está sendo feita no Brasil <img src="<?php echo $this->getViewFileUrl('UOL_PagSeguro::images/flag-origin-country.png'); ?>">
</div>
<button class="btn-pagseguro --align-right" id="payment-debit">Concluir</button>
</form>
</div><!-- /.item-tab#debit-online -->
Expand All @@ -155,6 +161,9 @@
<input class="form-control cpf-cnpj-mask" id="document-boleto" name="document" type="text">
</div>
</div>
<div align="right">
Esta compra está sendo feita no Brasil <img src="<?php echo $this->getViewFileUrl('UOL_PagSeguro::images/flag-origin-country.png'); ?>">
</div>
<button class="btn-pagseguro --align-right" id="payment-boleto">Concluir</button>
</form>
<ul class="list-warning">
Expand Down Expand Up @@ -316,7 +325,8 @@
if (val === true) {
var $el = $el.val();
}
return $el.replace(/[/ -. ]+/g, '').trim();
$el = $el.replace(/[^0-9]+/g, '').trim();
return $el;
} catch(e) {
alert('Ops, algo deu errado! Recarregue a página');
};
Expand Down
Binary file added view/frontend/web/images/flag-origin-country.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ddd01d4

Please sign in to comment.