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

Commit

Permalink
Merge pull request #75 from pagseguro/desenvolvimento
Browse files Browse the repository at this point in the history
3.5.0
  • Loading branch information
s2it-moscou authored Jan 9, 2018
2 parents a21f4db + 1cb2cd8 commit 602f8ed
Show file tree
Hide file tree
Showing 14 changed files with 253 additions and 43 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
Changelog
---------
3.5.0
- Não exibe meio de pagamento transparente na tela de checkout caso o mesmo não esteja habilitado ou configurado corretamente na conta do vendedor ou aplicação do PagSeguro configurada no módulo
- Exibe na interface administrativa o estado (ativo, inativo) dos meios de pagamento do checkout transparente da conta do PagSeguro configurada no módulo


3.4.0
- Atualizada biblioteca PHP do PagSeguro para versão 3.3.0
- Fix: erro no "credit card holder phone" (não estava sendo enviado o telefone do usuário)
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ Com o módulo instalado e configurado, você pode pode oferecer o PagSeguro como
**[Licença](#licença)**<br>

## Requisitos
- [Magento](https://www.magentocommerce.com/) Community 1.9.0 até 1.9.3.4 (ainda em fase de testes nas versões 1.6.x, 1.7.x, 1.8.x)
- [PHP](http://www.php.net/) 5.4.27+, 5.5.x+, 5.6.x+ (ainda em fase de testes nas versões 7.x)
- [Magento](https://www.magentocommerce.com/) Community 1.9.0 até 1.9.3.7
- [PHP](http://www.php.net/) 5.4.27+, 5.5.x+, 5.6.x+
- [SPL](http://php.net/manual/en/book.spl.php)
- [cURL](http://php.net/manual/en/book.curl.php)
- [SimpleXML](http://php.net/manual/en/book.simplexml.php)
Expand All @@ -30,7 +30,7 @@ Com o módulo instalado e configurado, você pode pode oferecer o PagSeguro como
- Certifique-se de que não há instalação de outros módulos para o PagSeguro em seu sistema;
- Caso utilize a compilação do Magento, desative-a e limpe-a *(Sistema -> Ferramentas -> Compilação)*;
- Baixe a última versão do módulo **[nesse link](https://github.com/pagseguro/magento/raw/master/UOL_PagSeguro-3.4.0.tgz)** ou então baixe o repositório como arquivo zip através do botão do GitHub;
- Baixe a última versão do módulo **[nesse link](https://github.com/pagseguro/magento/raw/master/UOL_PagSeguro-3.5.0.tgz)** ou então baixe o repositório como arquivo zip através do botão do GitHub;
- Na área administrativa do seu Magento, acesse o menu *Sistema/System -> Magento Connect -> Magento Connect Manager*. Caso tenha uma versão anterior do módulo instalada faça a remoção agora;
- No Magento Connect Manger, dentro da seção Direct package file upload, clique em **Escolher arquivo/Choose file**, selecione o arquivo UOL_PagSeguro-x.x.x.tgz (baixado anteriormente), clique no botão de upload e acompanhe a instalação do módulo no console da página;
- Caso utilize a compilação, volte para a área administrativa do Magento, ative-a e execute-a novamente;
Expand Down
Binary file removed UOL_PagSeguro-3.4.0.tgz
Binary file not shown.
Binary file added UOL_PagSeguro-3.5.0.tgz
Binary file not shown.
20 changes: 20 additions & 0 deletions app/code/community/UOL/PagSeguro/Model/Adminhtml/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class UOL_PagSeguro_Model_Adminhtml_Config
private $logo;
private $skin;
private $version;
private $session;
private $stc;

public function __construct()
{
Expand All @@ -46,6 +48,20 @@ public function __construct()
$this->background = $skinUrl.'images/background.png';
//Set version
$this->version = Mage::helper('pagseguro')->getVersion();
if (Mage::getStoreConfig('payment/pagseguro/token') && Mage::getStoreConfig('payment/pagseguro/email')) {
try {
$this->session = \PagSeguro\Services\Session::create($this->library->getAccountCredentials())->getResult();
} catch (Exception $exception){
$this->session = null;
// TODO make a default format of exception
Mage::log('[PAGSEGURO] Error: ' . $exception->getCode() . ' - ' . $exception->getMessage());
}
}
if (Mage::getStoreConfig('payment/pagseguro/environment') === 'production') {
$this->stc = 'https://stc.pagseguro.uol.com.br/pagseguro/api/v2/checkout/pagseguro.directpayment.js';
} else {
$this->stc = 'https://stc.sandbox.pagseguro.uol.com.br/pagseguro/api/v2/checkout/pagseguro.directpayment.js?';
}
}

/**
Expand Down Expand Up @@ -82,6 +98,10 @@ public function getCommentText()
//TODO javascript na model!?
$comment = '<script src="'.$this->jquery.'"></script>';
$comment .= '<script src="'.$this->js.'"></script>';
$comment .= '<script src="'.$this->stc.'"></script>';
if ($this->session) {
$comment .= '<script>PagSeguroDirectPayment.setSessionId("' . $this->session . '")</script>';
}
$comment .= '<script src="'.$this->jsColorbox.'"></script>';
$comment .= '<script type="text/javascript">
var jQuery = jQuery.noConflict();
Expand Down
2 changes: 1 addition & 1 deletion app/code/community/UOL/PagSeguro/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ limitations under the License.
<config>
<modules>
<UOL_PagSeguro>
<version>3.4.0</version>
<version>3.5.0</version>
</UOL_PagSeguro>
</modules>
<global>
Expand Down
7 changes: 7 additions & 0 deletions app/code/community/UOL/PagSeguro/etc/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,13 @@ limitations under the License.
</pagseguro_online_debit>
</fields>
</pagseguro_payment>

<pagseguro_payments_enabled type="group" translate="label">
<label>Consultar meios de pagamentos ativos na conta PagSeguro</label>
<sort_order>900</sort_order>
<show_in_default>1</show_in_default>
<expanded>0</expanded>
</pagseguro_payments_enabled>
</fields>
</pagseguro_settings>
</groups>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
<style>
#dt_method_<?php echo $this->getMethodCode() ?> {
display: none;
}
</style>

<script>
//<![CDATA[
var pagseguro_boleto_options = jQuery('#dt_method_<?php echo $this->getMethodCode() ?>')
paymentMethods()
var BoletoOptions = false

pagseguroBoletoOptions = function (res) {
if (!BoletoOptions) {
BoletoOptions = true
if (!res['error']) {
if (res['paymentMethods']) {
if (res['paymentMethods'] && res['paymentMethods']['BOLETO'] && res['paymentMethods']['BOLETO']['options']['BOLETO']['status'] === 'AVAILABLE') {
pagseguro_boleto_options.show()
} else {
pagseguro_creditcard_dt.find('input').prop('disabled', true)
}
}
} else {
console.log(res['error'])
}
}
}
//]]>
</script>

<script type="text/javascript">
//<![CDATA[
// get value fromm one step checkout guest document to be used in pagseguro direct payment
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,55 @@
<style>
#dt_method_<?php echo $this->getMethodCode() ?> {
display: none;
}
</style>

<script>
//<![CDATA[
var pagseguro_creditcard_dt = jQuery('#dt_method_<?php echo $this->getMethodCode() ?>')
var pagseguro_credit_card_options = jQuery('#pagseguro-credit-card-options')
paymentMethods()
var CreditcardOptions = false

pagseguroCreditcardOptions = function (res) {
if (!CreditcardOptions) {
pagseguro_credit_card_options.on('click', 'a', function () {
pagseguro_credit_card_options.find('li').css('display', 'inline-flex')
pagseguro_credit_card_options.find('li.more_cc').css('display', 'none')
})
if (!res['error']) {
if (res['paymentMethods'] && res['paymentMethods']['CREDIT_CARD'] && res['paymentMethods']['CREDIT_CARD']['options']) {
var k = 0
pagseguro_credit_card_options.empty()
jQuery.each(res['paymentMethods']['CREDIT_CARD']['options'], function (i, item) {
if (item['status'] === 'AVAILABLE') {
++k
if (k > 0) {
pagseguro_creditcard_dt.show()
}
if (k <= 6) {
pagseguro_credit_card_options.append('<li style="display: inline-flex; padding: 0 3px 3px 0; margin: 0;"><img src="https://stc.pagseguro.uol.com.br' + item['images']['SMALL']['path'] + '"></li>')
if (k === 6) {
pagseguro_credit_card_options.append('<li style="display: inline-flex; padding: 0 3px 3px 0; margin: 0;" class="more_cc"><a >mais</a></li>')
}
}
if (k > 6) {
pagseguro_credit_card_options.append('<li style="display: none; padding: 0 3px 3px 0; margin: 0;"><img src="https://stc.pagseguro.uol.com.br' + item['images']['SMALL']['path'] + '"></li>')
}
}
})
if (k === 0) {
pagseguro_onlinedebit_dt.find('input').prop('disabled', true)
}
}
} else {
console.log(res['error'])
}
}
}
//]]>
</script>

<script type="text/javascript">
//<![CDATA[
// get value from one step checkout guest (if it is enabled) document to be used in pagseguro direct payment
Expand Down Expand Up @@ -53,6 +105,7 @@
<div class="pagseguro-cc-input-div">
<input class="pagseguro-cc-input required-entry" type="text" id="creditCardNum" onkeydown="creditCardMask(this)" onblur="getBrand(this)" maxlength="19">
<div class="display-none validation-advice creditCardNum-error-message">Insira um número de cartão válido</div>
<ul id="pagseguro-credit-card-options" style="padding: 4px 0;"></ul>
</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,45 @@
<style>
#dt_method_<?php echo $this->getMethodCode() ?> {
display: none;
}
</style>

<script>
//<![CDATA[
var pagseguro_onlinedebit_dt = jQuery('#dt_method_<?php echo $this->getMethodCode() ?>')
var pagseguro_online_debit_options = jQuery('#pagseguro-online-debit-options')
paymentMethods()
var OnlinedebitOptions = false

pagseguroOnlinedebitOptions = function (res) {
if (!OnlinedebitOptions) {
if (!res['error']) {
if (res['paymentMethods'] && res['paymentMethods']['ONLINE_DEBIT'] && res['paymentMethods']['ONLINE_DEBIT']['options']) {
var k = 0
pagseguro_online_debit_options.empty()
jQuery.each(res['paymentMethods']['ONLINE_DEBIT']['options'], function (i, item) {
if (item['status'] === 'AVAILABLE') {
++k
if (k > 0) {
pagseguro_onlinedebit_dt.show()
}
pagseguro_online_debit_options.append('<div><label>' +
'<input class="input-radio required-entry" type="radio" id="debitbankName" name="debitbankName" value="' + i + '" required onclick="validateDebitBankName(this)">'
+ item['displayName'] + '</label></div>')
}
})
if (k === 0) {
pagseguro_onlinedebit_dt.find('input').prop('disabled', true)
}
}
} else {
console.log(res['error'])
}
}
}
//]]>
</script>

<script type="text/javascript">
//<![CDATA[
// get value from one step checkout guest (if it is enabled) document to be used in pagseguro direct payment
Expand Down Expand Up @@ -37,7 +79,7 @@
}
//]]>
</script>

<div class="form-list" id="payment_form_<?php echo $this->getMethodCode() ?>" style="display:none;">
<input type="hidden" id="onlineDebitHash" value="" name="payment[online_debit_hash]">
<input type="hidden" id="onlineDebitBankName" value="" name="payment[online_debit_bank_name]">
Expand All @@ -63,44 +105,7 @@
</div>
<div class="input-box">
<label class="required" style="padding: 0.9em 0em 0em;"><?php echo $this->__('Selecione abaixo seu banco') ?></label>
<div style="padding: 0em 1em;">
<div>
<div>
<label>
<input class="input-radio required-entry" type="radio" id="debitbankName" name="debitbankName" value="itau"
required onclick="validateDebitBankName(this)">
Itaú
</label>
</div>
</div>
<div>
<div>
<label>
<input class="input-radio required-entry" type="radio" id="debitbankName" name="debitbankName" value="bradesco"
required onclick="validateDebitBankName(this)">
Bradesco
</label>
</div>
</div>
<div>
<div>
<label>
<input class="input-radio required-entry" type="radio" id="debitbankName" name="debitbankName" value="banrisul"
required onclick="validateDebitBankName(this)">
Banrisul
</label>
</div>
</div>
<div>
<div>
<label>
<input class="input-radio required-entry" type="radio" id="debitbankName" name="debitbankName"
value="bancodobrasil" onclick="validateDebitBankName(this)">
Banco do Brasil
</label>
</div>
</div>
</div>
<div id="pagseguro-online-debit-options" style="padding: 0em 1em;"></div>
</div>
<div class="display-none validation-advice debitbankName-error-message">Escolha um banco</div>
<div style="display: inline-block; "class="pagseguro-label-spacing pagseguro-cc-group-div">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,3 +388,63 @@ function maskDiscount(v) {

return v;
}

/**
* List payments methods enabled for account
*/
jQuery(document).ready(function () {
var open = false
jQuery('#payment_pagseguro_payments_enabled-head').click(function () {
open = true
if (open) {
var body = jQuery('#payment_pagseguro_payments_enabled')
var loading = '<p>carregando...</p>'
body.append(loading)
PagSeguroDirectPayment.getPaymentMethods({
success: function (res) {
if (!res['error']) {
body.empty()
jQuery.each(res['paymentMethods'], function (i, items) {
if (i !== 'BALANCE' && i !== 'DEPOSIT') {
if (i === 'ONLINE_DEBIT') {
body.append('<ul id="' + i + '">' +
'<li style="display: inline-block; font-weight: bold; width: 100%;">Débito On-Line:</li>' +
'<li style="display: inline-block; padding: 5px 15px;" class="none">nenhuma opção disponível</li>' +
'</ul>')
} else if (i === 'CREDIT_CARD') {
body.append('<ul id="' + i + '">' +
'<li style="display: inline-block; font-weight: bold; width: 100%;">Cartão de Crédito:</li>' +
'<li style="display: inline-block; padding: 5px 15px;" class="none">nenhuma opção disponível</li>' +
'</ul>')
} else if (i === 'BOLETO') {
body.append('<ul id="' + i + '">' +
'<li style="display: inline-block; font-weight: bold; width: 100%;">Boleto:</li>' +
'<li style="display: inline-block; padding: 5px 15px;" class="none">nenhuma opção disponível</li>' +
'</ul>')
} else {
body.append('<ul id="' + i + '">' +
'<li style="display: inline-block; font-weight: bold; width: 100%;">' + i + ':</li>' +
'<li style="display: inline-block; padding: 5px 15px;" class="none">nenhuma opção disponível</li>' +
'</ul>')
}
jQuery.each(items['options'], function (k, item) {
if (item['status'] === 'AVAILABLE') {
body.find('ul#' + i).find('.none').hide()
body.find('ul#' + i).append('<li style="display: inline-block; padding: 5px 15px;">' + item['displayName'] + '</li>')
}
})
}
})
} else {
body.empty()
body.append('<p>Erro</p>')
}
},
error: function () {
body.empty()
body.append('<p>Erro</p>')
}
})
}
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ span > input {
width: 100%;
}

.pagseguro-cc-input-div > ul {
width: 365px;
}

.pagseguro-required:after {
content: '*';
color: #df280a;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ span > input {
width: 70%;
}

.pagseguro-cc-input-div > ul {
width: 365px;
}

.pagseguro-required:after {
content: '*';
color: #df280a;
Expand Down
Loading

0 comments on commit 602f8ed

Please sign in to comment.