Skip to content

Commit 20a8147

Browse files
Merge pull request #385 from pagarme/develop
Release 3.2.0
2 parents 65d2c4b + 9080858 commit 20a8147

File tree

190 files changed

+4632
-6712
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

190 files changed

+4632
-6712
lines changed

.github/workflows/pr.yml

+46-1
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,65 @@ jobs:
4343
-
4444
name: Install project dependences
4545
run:
46-
php composer.phar install
46+
php composer.phar install --no-dev --ignore-platform-reqs
47+
phpunit:
48+
name: PHP Unit
49+
runs-on: ubuntu-latest
50+
steps:
51+
- name: Checkout project
52+
uses: actions/checkout@v4
53+
54+
- name: Install dependencies
55+
uses: php-actions/composer@v6
56+
57+
- name: Unit tests
58+
uses: php-actions/phpunit@v3
59+
env:
60+
XDEBUG_MODE: coverage
61+
with:
62+
configuration: "phpunit.xml"
63+
version: ${{ vars.phpunit_version }}
64+
php_version : ${{ vars.unit_tests_php_version }}
65+
php_extensions: "xdebug"
66+
coverage_clover: "coverage/clover.xml"
67+
68+
- name: Upload coverage artifact
69+
uses: actions/upload-artifact@master
70+
with:
71+
name: woo-coverage-${{ github.sha }}
72+
path: coverage/clover.xml
4773

4874
sonar:
4975
name: Sonar
5076
runs-on: ubuntu-latest
77+
needs: phpunit
5178
steps:
5279
- name: Checkout project
5380
uses: actions/checkout@v3
5481
with:
5582
fetch-depth: 0
5683

84+
- name: Download coverage artifact
85+
uses: actions/download-artifact@master
86+
with:
87+
name: woo-coverage-${{ github.sha }}
88+
path: coverage
89+
5790
- name: Run Sonar
5891
uses: sonarsource/sonarcloud-github-action@master
5992
env:
6093
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6194
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
95+
with:
96+
args: >
97+
-Dsonar.php.coverage.reportPaths=coverage/clover.xml
98+
-Dsonar.coverage.exclusions=tests/**,assets/**,templates/**,woo-pagarme-payments.php
99+
-Dsonar.tests=tests/
100+
-Dsonar.sources=src,assets,templates,woo-pagarme-payments.php
101+
102+
- name: Delete coverage artifact
103+
uses: geekyeggo/delete-artifact@v4
104+
with:
105+
token: ${{ secrets.GITHUB_TOKEN }}
106+
name: woo-coverage-${{ github.sha }}
62107

.gitignore

+14
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,17 @@
55
node_modules/
66
.idea/
77
.vscode/
8+
.phpunit.result.cache
9+
.phpunit.cache/
10+
vendor/antecedent/
11+
vendor/bin/
12+
vendor/brain/
13+
vendor/composer/autoload_files.php
14+
vendor/hamcrest/
15+
vendor/mockery/
16+
vendor/myclabs/
17+
vendor/nikic/
18+
vendor/phar-io/
19+
vendor/phpunit/
20+
vendor/sebastian/
21+
vendor/theseer/

assets/javascripts/admin/pagarme_settings.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@
33
( function ($) {
44
$('.wc_gateways').on(
55
'click',
6-
'.wc-payment-gateway-method-toggle-enabled',
6+
'.wc-payment-gateway-method-toggle-enabled, .pagarme-toggle-payment-subscription',
77
function () {
88
const $link = $(this),
9-
$row = $link.closest('tr'),
10-
$toggle = $link.find('.woocommerce-input-toggle');
9+
$row = $link.closest('tr'),
10+
$toggle = $link.find('.woocommerce-input-toggle');
11+
12+
let action = 'woocommerce_toggle_gateway_enabled';
13+
if ($link.attr('class') === 'pagarme-toggle-payment-subscription') {
14+
action = 'pagarme_toggle_payment_subscription';
15+
}
1116

1217
const data = {
13-
action: 'woocommerce_toggle_gateway_enabled',
18+
action: action,
1419
security: pagarme_settings.nonces.gateway_toggle,
1520
gateway_id: $row.data('gateway_id'),
1621
};

assets/javascripts/front/checkout/model/payment.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ jQuery(function ($) {
55
globalThis.wc_pagarme_checkout = wc_pagarme_checkout;
66
$.jMaskGlobals.watchDataMask = true;
77
wc_pagarme_checkout.validate = function () {
8-
const checkedPayment = $('form .payment_methods input[name="payment_method"]:checked').val();
8+
const checkedPayment = $('form .payment_methods input[name="payment_method"]:checked')?.val();
9+
if (!checkedPayment) {
10+
return true;
11+
}
912
const requiredFields = $('#shipping_number:visible, input[data-required=true]:visible,' +
1013
'select[data-required=true]:visible,' +
1114
`.wc_payment_method.payment_method_${checkedPayment} [data-pagarmecheckout-element="brand-input"]`);

assets/javascripts/front/checkout/model/payment/card.js

+34-12
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
/* globals wc_pagarme_checkout */
2-
2+
/*jshint esversion: 8 */
33
let pagarmeCard = {
44
limitTokenize: 10,
55
tokenExpirationAttribute: 'data-pagarmecheckout-expiration',
66
cardNumberTarget: 'input[data-element="pagarme-card-number"]',
77
brandTarget: 'input[data-pagarmecheckout-element="brand-input"]',
88
valueTarget: 'input[data-pagarmecheckout-element="order-value"]',
99
installmentsTarget: '[data-pagarme-component="installments"]',
10+
installmentsInfoTarget: '[data-pagarme-component="installments-info"]',
1011
mundiCdn: 'https://cdn.mundipagg.com/assets/images/logos/brands/png/',
1112
tokenElement: '[data-pagarmecheckout-element="token"]',
1213
fieldsetCardElements: 'fieldset[data-pagarmecheckout="card"]',
@@ -36,7 +37,18 @@ let pagarmeCard = {
3637
return jQuery('.wc_payment_method.payment_method_' + value);
3738
},
3839
isPagarmePayment: function () {
39-
return jQuery('form .payment_methods input[name="payment_method"]:checked').val().indexOf('pagarme');
40+
let paymentSelected = jQuery('form .payment_methods input[name="payment_method"]:checked');
41+
if(paymentSelected.length <= 0) {
42+
return false;
43+
}
44+
paymentSelected = paymentSelected.val();
45+
if(!paymentSelected) {
46+
return false;
47+
}
48+
if(paymentSelected.indexOf('pagarme') == '-1') {
49+
return false;
50+
}
51+
return paymentSelected.indexOf('pagarme');
4052
},
4153
keyEventHandlerCard: function (event) {
4254
this.clearToken(event);
@@ -244,22 +256,26 @@ let pagarmeCard = {
244256
if (!elem) {
245257
return false;
246258
}
247-
let brand = elem.closest('fieldset').find(this.brandTarget).val();
259+
const brand = elem.closest('fieldset').find(this.brandTarget).val();
248260
let total = elem.closest('fieldset').find(this.valueTarget).val();
249261
if (total) {
250262
total = pagarmeCard.formatValue(total);
251263
}
252-
let cardForm = elem.closest("fieldset");
253-
let select = cardForm.find(this.installmentsTarget);
254-
if (!total)
264+
const cardForm = elem.closest("fieldset");
265+
const select = cardForm.find(this.installmentsTarget);
266+
const info = cardForm.find(this.installmentsInfoTarget);
267+
if (!total) {
255268
total = cartTotal;
269+
}
256270
if ((!total) ||
257271
(select.data("type") === 2 && !brand) ||
258-
(select.data("type") === 1 && elem.data('element') !== "order-value"))
272+
(select.data("type") === 1 && elem.data('element') !== "order-value")
273+
) {
259274
return false;
260-
let storageName = btoa(brand + total);
275+
}
276+
const storageName = btoa(brand + total);
261277
sessionStorage.removeItem(storageName);
262-
let storage = sessionStorage.getItem(storageName);
278+
const storage = sessionStorage.getItem(storageName);
263279
if (storage) {
264280
select.html(storage);
265281
} else {
@@ -272,7 +288,7 @@ let pagarmeCard = {
272288
}
273289
});
274290
ajax.done(function (response) {
275-
pagarmeCard._done(select, storageName, cardForm, response);
291+
pagarmeCard._done(select, info, storageName, cardForm, JSON.parse(response));
276292
});
277293
ajax.fail(function () {
278294
pagarmeCard._fail(cardForm);
@@ -282,8 +298,14 @@ let pagarmeCard = {
282298
return true;
283299
},
284300

285-
_done: function (select, storageName, event, response) {
286-
select.html(response);
301+
_done: function (select, info, storageName, event, response) {
302+
if (info.length) {
303+
info.addClass('pagarme-hidden');
304+
if(response.installmentsConfig > 1) {
305+
info.removeClass('pagarme-hidden');
306+
}
307+
}
308+
select.html(response.optionsHtml);
287309
sessionStorage.setItem(storageName, response);
288310
this.removeLoader(event);
289311
},

assets/stylesheets/admin/style.css

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
background-color: #007cba;
44
}
55

6+
.pagarme-toggle-payment-subscription:focus {
7+
box-shadow: none;
8+
}
9+
610
.form-table td p.pagarme-hub-desintegration {
711
margin: 0;
812
font-style: italic;

assets/stylesheets/front/style.css

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
.pagarme-hidden {
2+
display: none!important;
3+
}
4+
15
#wcmp-checkout-errors {
26
display: none;
37
}
@@ -67,6 +71,13 @@
6771
pointer-events: none;
6872
}
6973

74+
#payment .payment_methods li[class*="pagarme"] .payment_box .pagarme-installments-info {
75+
display: block;
76+
margin: 0 .75em .25em;
77+
font-size: .9em;
78+
font-style: italic;
79+
}
80+
7081
.woocommerce-order .woocommerce-message .pagarme-response p:last-child {
7182
margin-bottom: 0;
7283
}
@@ -132,7 +143,7 @@
132143

133144
/* sm */
134145
/* @media (min-width: 576px) {
135-
146+
136147
} */
137148

138149
/* md */
@@ -151,10 +162,10 @@
151162

152163
/* xl */
153164
/* @media (min-width: 1200px) {
154-
165+
155166
} */
156167

157168
/* xxl */
158169
/* @media (min-width: 1400px) {
159-
170+
160171
} */

composer.json

+13-2
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,27 @@
22
"name": "pagarme/woocommerce-pagarme-payments",
33
"description": "Pagar.me module for Woocommerce",
44
"type": "wordpress-plugin",
5-
"version": "3.1.9",
5+
"version": "3.2.0",
66
"license": "GPL",
77
"autoload": {
88
"psr-4": {
99
"Woocommerce\\Pagarme\\": "src/"
1010
}
1111
},
12+
"autoload-dev": {
13+
"psr-4": {
14+
"Woocommerce\\Pagarme\\Tests\\": "tests/"
15+
}
16+
},
1217
"require": {
1318
"mashape/unirest-php": "^3.0",
1419
"pagarme/ecommerce-module-core": "2.3.*",
15-
"psr/log": "1.1.4"
20+
"psr/log": "1.1.4",
21+
"monolog/monolog": "<2"
22+
},
23+
"require-dev": {
24+
"mockery/mockery": "1.6.*",
25+
"phpunit/phpunit": "10.5.*",
26+
"brain/monkey": "2.*"
1627
}
1728
}

constants.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function wc_pagarme_define($name, $value)
1212

1313
wc_pagarme_define('WCMP_SLUG', 'woo-pagarme-payments');
1414
wc_pagarme_define('WCMP_PREFIX', 'pagarme');
15-
wc_pagarme_define('WCMP_VERSION', '3.1.9');
15+
wc_pagarme_define('WCMP_VERSION', '3.2.0');
1616
wc_pagarme_define('WCMP_ROOT_PATH', dirname(__FILE__) . '/');
1717
wc_pagarme_define('WCMP_ROOT_SRC', WCMP_ROOT_PATH . 'src/');
1818
wc_pagarme_define('WCMP_ROOT_FILE', WCMP_ROOT_PATH . WCMP_SLUG . '.php');

docs/README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,6 @@ Se você está interessado em contribuir para o desenvolvimento deste projeto, f
3939

4040
## Contribuidores
4141

42-
| ![eduardobattisti avatar](https://avatars.githubusercontent.com/u/56602897?s=60&v=4)<br/> [eduardobattisti](https://github.com/eduardobattisti) |
43-
|----------------------------------------------------------------------------------------------------------------------------------|
42+
| ![eduardobattisti avatar](https://avatars.githubusercontent.com/u/56602897?s=60&v=4) | ![tiagopapile avatar](https://avatars.githubusercontent.com/u/82596706?s=60&v=4) |
43+
|--------------------------------------------------------------------------------------|----------------------------------------------------------------------------------|
44+
| [eduardobattisti](https://github.com/eduardobattisti) | [tiagopapile](https://github.com/tiagopapile) |
1.36 KB
Binary file not shown.

languages/woo-pagarme-payments-pt_BR.po

+38-2
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ msgstr ""
55
"Project-Id-Version: WooCommerce Pagar.me Payments 1.0\n"
66
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/woo-pagarme-payments\n"
77
"POT-Creation-Date: 2018-06-22 13:58-0300\n"
8-
"PO-Revision-Date: 2023-11-17 16:02-0300\n"
8+
"PO-Revision-Date: 2024-01-19 11:54-0300\n"
99
"Last-Translator: Pagar.me\n"
1010
"Language-Team: \n"
1111
"Language: pt_BR\n"
1212
"MIME-Version: 1.0\n"
1313
"Content-Type: text/plain; charset=UTF-8\n"
1414
"Content-Transfer-Encoding: 8bit\n"
1515
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
16-
"X-Generator: Poedit 3.4.1\n"
16+
"X-Generator: Poedit 3.4.2\n"
1717
"X-Poedit-SourceCharset: UTF-8\n"
1818
"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noop:1,2;_c;_nc:1,2;_x:1,2c;_ex:1,2c;"
1919
"_nx:4c,1,2;_nx_noop:4c,1,2\n"
@@ -1266,3 +1266,39 @@ msgstr "Acessar o Dash da Pagar.me"
12661266

12671267
msgid "If your Pagar.me Antifraud is active, orders will fail."
12681268
msgstr "Se o seu Antifraude Pagar.me estiver ativo, os pedidos irão falhar."
1269+
1270+
msgid "Active for subscription"
1271+
msgstr "Ativo para assinatura"
1272+
1273+
msgid "Enable credit card for subscription"
1274+
msgstr "Habilita cartão de crédito para assinatura"
1275+
1276+
msgid "Activates credit card payment method for subscriptions."
1277+
msgstr "Ativa o método de pagamento de cartão de crédito para assinaturas."
1278+
1279+
msgid "Enable Pix for subscription"
1280+
msgstr "Habilita Pix para assinatura"
1281+
1282+
msgid "Activates Pix payment method for subscriptions."
1283+
msgstr "Ativa o método de pagamento de Pix para assinaturas."
1284+
1285+
msgid "Enable billet for subscription"
1286+
msgstr "Habilita boleto para assinatura"
1287+
1288+
msgid "Activates billet payment method for subscriptions."
1289+
msgstr "Ativa o método de pagamento de boleto para assinaturas."
1290+
1291+
msgid "Allow installments for subscription"
1292+
msgstr "Permitir parcelamento para assinatura"
1293+
1294+
msgid "Enable installments for subscription"
1295+
msgstr "Habilita parcelamento para assinatura"
1296+
1297+
msgid "Activates credit card installments for subscriptions."
1298+
msgstr "Ativa parcelamento de cartão de crédito para assinaturas."
1299+
1300+
msgid "Works only for monthly and yearly subscriptions."
1301+
msgstr "Funciona apenas para assinaturas mensais e anuais."
1302+
1303+
msgid "Your cart has one or more daily or weekly subscription products, which do not allow installments."
1304+
msgstr "Seu carrinho possui um ou mais produtos de assinatura diário ou semanal, que não permitem parcelamentos."

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "woo-pagarme-payments",
3-
"version": "3.1.9",
3+
"version": "3.2.0",
44
"description": "Pagar.me module for Woocommerce",
55
"main": "woo-pagarme-payments.php",
66
"dependencies": {},

0 commit comments

Comments
 (0)