diff --git a/.gitignore b/.gitignore index b5de6488..a019eed6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,12 @@ .idea/ wordpress/ -woocommerce-gateway-ebanx/travis/vendor/ .DS_Store *.log *.gz *.gz.* +cypress/videos +cypress/screenshots +node_modules +.vscode apidocs/phpdoc-cache-* +.data \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 98535eab..d48f2679 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,41 @@ language: php -php: - - '5.6' \ No newline at end of file + +env: + WOOCOMMERCE_VERSION: 3.0.7 + EBANX_ADMIN_USERNAME: ebanx + EBANX_ADMIN_PASSWORD: ebanx + EBANX_SITE_TITLE: EBANX + EBANX_SITE_EMAIL: plugin@ebanx.com + EBANX_DB: wordpress + EBANX_PASSWORD: root + +services: + - docker + +cache: + - yarn: true + - apt: true + +before_install: + - sudo service mysql stop + - sudo apt-get update + - sudo apt-key update + - sudo apt-get install -y docker-engine + - curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash + - nvm install node 7 + - nvm alias default node 7 + - npm install -g kill-port + - kill-port --port 80 + - kill-port --port 3306 + - docker run --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=${EBANX_PASSWORD} -e MYSQL_DATABASE=${EBANX_DB} -d mariadb:5 + - docker run --name ebanx-woocommerce -p 80:80 --link mysql:mysql --volume="${TRAVIS_BUILD_DIR}/woocommerce-gateway-ebanx/:/var/www/html/wp-content/plugins/woocommerce-gateway-ebanx/" -e EBANX_WC_PLUGIN_VERSION=${WOOCOMMERCE_VERSION} -e EBANX_ADMIN_USERNAME=${EBANX_ADMIN_USERNAME} -e EBANX_ADMIN_PASSWORD=${EBANX_ADMIN_PASSWORD} -e EBANX_SITE_TITLE=${EBANX_SITE_TITLE} -e EBANX_SITE_EMAIL=${EBANX_SITE_EMAIL} -d ebanx/ebanx-woocommerce + +install: + - npm install -g cypress-cli + - cypress install + - npm install + +script: + - ./wait-for-it.sh -t 300 localhost:3306 -- echo "MySQL is alive!" + - ./wait-for-it.sh -t 300 localhost:80 -- echo "Plugin is alive!" + - cypress run --record --key f54e0f8d-46b4-47a4-b331-10a8e4731c3b diff --git a/CHANGELOG.md b/CHANGELOG.md index 079e9482..890c8f5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # CHANGELOG +# 1.13.0 +* Fix - Fix for debug log when is enabled before record a log [#507](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/507) +* Fix - Fix issue to avoid some issues on refund transactions [#506](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/506) +* Fix - Changed label to Minimum Instalment (title-cased labels) [#500](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/500) +* Fix - Fixed compliance fields when country is empty [#498](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/498) +* Feature - Docker implementation and end-to-end tests for Brazil payments done [#504](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/504) + # 1.12.1 * Fix - Credit-card saving for new customers [#496](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/496) * Fix - One-click payments button in product details [#496](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/496) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a56ab544..ca7465d0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,35 +9,71 @@ Please, visit the [official plugin page on WordPress store](https://wordpress.or ## Introduction We've put together all the information you'll need on this file. Also, we always try to keep this file updated and with as much information as possible. If you want to help us with this file or with any coding issue, we would really appreciate it. :heart: -## Getting Started - -If you want to contribute to our repository the best way is to clone it and then create a symbolic link: - -1. Install [WordPress](https://codex.wordpress.org/Installing_WordPress) to your prefered location: - 1. With your terminal `cd` into your web root folder: `cd /path/to/public_html` - 2. Download the latest WordPress build: `wget https://wordpress.org/latest.tar.gz` - 3. Unzip the just downloaded file: `tar -xzvf latest.tar.gz` - 4. Delete that file since we don't need it anymore: `rm latest.tar.gz` - 5. Create the Database and a User - 6. Access `http://localhost/wordpress`(it might be different depending on the folder you've downloaded WordPress) and follow its steps. -2. Install [WooCommerce](https://docs.woocommerce.com/document/installing-uninstalling-woocommerce/). If you've configured FTP you can access WordPress Admin Dashboard and install it automatically. Otherwise, you can follow these steps: - 1. Go to the plugins folder on your WordPress: `cd /path/to/wordpress/wp-content/plugins` - 2. Download the lastest WooCommerce build: `git clone https://github.com/woocommerce/woocommerce.git` - 3. Configure it on WordPress Admin Dashboard -3. Clone this repository to your projects folder (not inside WordPress folder): `git clone https://github.com/ebanx/woocommerce-gateway-ebanx` -4. Create a symlink from the inner folder to your wordpress plugins folder: `ln -s /path/to/clone/directory/woocommerce-gateway-ebanx/woocommerce-gateway-ebanx /path/to/wordpress/wp-content/plugins/woocommerce-gateway-ebanx` -5. Let the coding begin! +## Getting Started with Docker -## Have you found a bug? +Don't you know what is Docker? [Know here](https://www.docker.com/what-docker). -You can create a new [Issue](https://github.com/ebanx/woocommerce-gateway-ebanx/issues/new) and wait for someone to fix it. Keep in mind that if you don't provide enough information no one will be able to help you. +You need to install Docker on your machine before start. [Please install the CE Edition of your OS](https://www.docker.com/community-edition). -## So you want to code... +#### Disable built-in Apache server (Mac OS only) + +``` +sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist +``` + +#### Create the containers + +After installed Docker and disabled apache, clone this repo, go to root folder and run: + +``` +docker-compose up +``` + +**The first installation may take up to 5 minutes. After that, visit `http://localhost` on your browser. We use the port 80 and 3306. So, check if you are not using these ports.** + +Every time that you want to go back to plugin development, just run `docker-compose up`. + +To run docker in background, execute `docker-compose up -d`, and `docker-compose stop` to stop the application. + +To login into Wordpress, visit `http://localhost/wp-admin/`. + +The credentials are: -If you want to code (and you are not an ebanker [yet](https://ebanx.recruiterbox.com/)) all you have to do is fork our repo create a [well named]branch from develop and make a [pull request](https://github.com/ebanx/woocommerce-gateway-ebanx/compare) to our develop. +``` +Username: ebanx +Password: ebanx +``` -## Documentation +**To change these informations, you can edit the environments on file `docker-compose.yml`.** -Documentation is in `apidocs` folder. +The defaults are: + +``` +MYSQL_DATABASE: wordpress +MYSQL_ROOT_PASSWORD: root + +WORDPRESS_DB_NAME: wordpress +WORDPRESS_DB_USER: root +WORDPRESS_DB_PASSWORD: root +WORDPRESS_DB_HOST: mysql + +EBANX_WC_PLUGIN_VERSION: 3.0.5 +EBANX_ADMIN_USERNAME: ebanx +EBANX_ADMIN_PASSWORD: ebanx +EBANX_SITE_TITLE: EBANX +EBANX_SITE_EMAIL: plugin@ebanx.com +``` + +#### What did we do here? + +The Docker installed Wordpress, MySQL, PHP, WooCommerce, create some products and pages, installed the EBANX plugin and another things. + +To know more about the Docker commands, [please read this gist](https://gist.github.com/cezarlz/cf9ecbd8be33562b16d07fc1bc04b150). + +## Have you found a bug? + +You can create a new [Issue](https://github.com/ebanx/woocommerce-gateway-ebanx/issues/new) and wait for someone to fix it. Keep in mind that if you don't provide enough information no one will be able to help you. + +## So you want to code... -To generate a new documentation, install `phpdoc` and run at root folder `phpdoc --template="clean" -d . -i "travis/*,woocommerce-gateway-ebanx/vendor/*,woocommerce-gateway-ebanx/templates/*" -t apidocs` \ No newline at end of file +If you want to code (and you are not an ebanker [yet](https://ebanx.recruiterbox.com/)) all you have to do is fork our repo create a [well named]branch from develop and make a [pull request](https://github.com/ebanx/woocommerce-gateway-ebanx/compare) to our develop. \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..a91c331f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,53 @@ +FROM php:5-apache + +MAINTAINER Cezar Luiz + +ARG WORDPRESS_DB_USER +ARG WORDPRESS_DB_PASSWORD +ARG WORDPRESS_DB_NAME +ARG WORDPRESS_DB_HOST + +# install the PHP extensions we need +RUN set -ex; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + libjpeg-dev \ + libpng12-dev \ + mysql-client \ + ; \ + rm -rf /var/lib/apt/lists/*; \ + \ + docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \ + docker-php-ext-install gd mysqli opcache pdo pdo_mysql + +RUN { \ + echo 'opcache.memory_consumption=128'; \ + echo 'opcache.interned_strings_buffer=8'; \ + echo 'opcache.max_accelerated_files=4000'; \ + echo 'opcache.revalidate_freq=2'; \ + echo 'opcache.fast_shutdown=1'; \ + echo 'opcache.enable_cli=1'; \ + } > /usr/local/etc/php/conf.d/opcache-recommended.ini + +RUN a2enmod rewrite expires + +WORKDIR /var/www/html + +# Download WP-CLI, install and configure Wordpress +RUN curl -O "https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar"; \ + chmod +x wp-cli.phar; \ + mv wp-cli.phar /usr/local/bin/wp; \ + wp --info --allow-root --debug; \ + wp core download --allow-root --force --debug; \ + wp core config --dbname=$WORDPRESS_DB_NAME --dbuser=$WORDPRESS_DB_USER --dbpass=$WORDPRESS_DB_PASSWORD --dbhost=$WORDPRESS_DB_HOST --force --allow-root --debug --skip-check --extra-php="define( 'WP_DEBUG', true );define( 'WP_DEBUG_LOG', true );define( 'FS_METHOD', 'direct' );"; + +COPY wait-for-it.sh /usr/local/bin/ +COPY entrypoint.sh /usr/local/bin/ + +RUN chmod +x /usr/local/bin/wait-for-it.sh +RUN chmod +x /usr/local/bin/entrypoint.sh + +EXPOSE 80 + +ENTRYPOINT /usr/local/bin/entrypoint.sh \ No newline at end of file diff --git a/cypress.json b/cypress.json new file mode 100644 index 00000000..80699ba0 --- /dev/null +++ b/cypress.json @@ -0,0 +1,8 @@ +{ + "env": { + "admin": "admin", + "site": "site" + }, + "projectId": "ff45ju", + "chromeWebSecurity": false +} diff --git a/cypress/integration/site/admin_spec.js b/cypress/integration/site/admin_spec.js new file mode 100644 index 00000000..e95b8474 --- /dev/null +++ b/cypress/integration/site/admin_spec.js @@ -0,0 +1,33 @@ +const defaults = require('../../lib/defaults'); + +global.ebanx = {}; +let admin = {}; + +describe('Admin', () => { + + context('Settings', () => { + before(function () { + admin = require('../../lib/admin/admin_operator')(cy); + }); + + it('Fill sandbox keys and save settings', () => { + admin + .openAdmin() + .openEbanxSettings() + .fillKeys({ + integration_key: defaults.api.integration_key, + public_key: defaults.api.public_key + }) + .saveSettings(); + }); + + it('Fill instalment number and save settings', () => { + admin + .openAdmin() + .openEbanxSettings() + .fillInstalments(defaults.admin.instalments) + .saveSettings(); + }); + }); + +}); \ No newline at end of file diff --git a/cypress/integration/site/payment_spec.js b/cypress/integration/site/payment_spec.js new file mode 100644 index 00000000..174320e3 --- /dev/null +++ b/cypress/integration/site/payment_spec.js @@ -0,0 +1,94 @@ +const Faker = require('faker'); +const CPF = require('cpf_cnpj').CPF; +const CNPJ = require('cpf_cnpj').CNPJ; +const defaults = require('../../lib/defaults'); +let site = {}; +let api = {}; +let mock = {}; + +global.ebanx = {}; + +describe('Site', () => { + + context('Brazil Payments', () => { + beforeEach(function () { + Faker.locale = 'pt_BR'; + + site = require('../../lib/site/site_operator')(cy); + api = require('../../lib/pay/api_operator')(cy); + + mock = { + firstName: Faker.name.firstName(), + lastName: Faker.name.lastName(), + company: Faker.company.companyName(), + email: Faker.internet.email(), + phone: Faker.phone.phoneNumber(), + country: Faker.address.country(), + address: Faker.address.streetAddress(), + state: Faker.address.state(), + postcode: Faker.address.zipCode('########'), + city: Faker.address.city() + }; + + mock.country = 'Brazil'; + mock.state = 'Paraná'; + mock.brazilDocument = CPF.generate(true); + mock.brazilBirthdate = '01/01/1970'; + }); + + it('Make a Boleto Payment', () => { + site.makeBoletoPayment(mock, hash => { + api.assertPaymentStatus(hash, 'PE'); + }); + }); + + it('Make a Credit Card Payment using Visa', () => { + let cc_data = { + cvv: Faker.random.number({ min: 100, max: 999 }).toString(), + due_date: `02 / ${Faker.random.number({ min: 20, max: 30 }) }`, + card_name: `${Faker.name.firstName} ${Faker.name.lastName}`, + number: defaults.site.payments.credit_card.visa + }; + + site.makeCreditCardToBrazilPayment(mock, cc_data, hash => { + api.assertPaymentStatus(hash, 'CO'); + }); + }); + + it('Make a Credit Card Payment using Visa with Instalments', () => { + let cc_data = { + cvv: Faker.random.number({ min: 100, max: 999 }).toString(), + due_date: `02 / ${Faker.random.number({ min: 20, max: 30 }) }`, + card_name: `${Faker.name.firstName} ${Faker.name.lastName}`, + number: defaults.site.payments.credit_card.visa, + instalments: Faker.random.number({ min: 2, max: 12 }).toString() + }; + + site.makeCreditCardToBrazilPayment(mock, cc_data, hash => { + api.assertPaymentStatus(hash, 'CO'); + }); + }); + + it('Make a TEF Payment using Itau', () => { + site.makeItauPayment(mock); + }); + + it('Make a TEF Payment using Bradesco', () => { + site.makeBradescoPayment(mock); + }); + + it('Make a TEF Payment using Banco do Brasil', () => { + site.makeBBPayment(mock); + }); + + it('Make a TEF Payment using Banrisul', () => { + site.makeBanrisulPayment(mock); + }); + + it('Make a EBANX Account Payment', () => { + site.makeAccountPayment(mock); + }); + + }); + +}); \ No newline at end of file diff --git a/cypress/lib/admin/admin_operator.js b/cypress/lib/admin/admin_operator.js new file mode 100644 index 00000000..b67d2a2a --- /dev/null +++ b/cypress/lib/admin/admin_operator.js @@ -0,0 +1,52 @@ +const adminOperator = (function (test) { + const _private = { + pages: { + login: require('./pages/login')(test), + settings: require('./pages/settings')(test), + } + }; + + const { login, settings } = _private.pages; + + const $public = { + openAdmin: function () { + login + .open() + .login(); + + return this; + }, + + openEbanxSettings: function () { + settings + .open(); + + return this; + }, + + fillKeys: function (keys) { + settings + .fillSandboxKeys(keys); + + return this; + }, + + fillInstalments: function (number) { + settings + .fillInstalments(number); + + return this; + }, + + saveSettings: function () { + settings + .saveSettings(); + + return this; + } + }; + + return $public; +}); + +module.exports = adminOperator; \ No newline at end of file diff --git a/cypress/lib/admin/pages/login.js b/cypress/lib/admin/pages/login.js new file mode 100644 index 00000000..de0dfc74 --- /dev/null +++ b/cypress/lib/admin/pages/login.js @@ -0,0 +1,68 @@ +const defaults = require('../../defaults'); + +const loginPage = (function (test) { + const _private = { + elements: { + buttons: { + login: '#wp-submit', + ebanxSettings: '#toplevel_page_admin-page-wc-settings-tab-checkout-section-ebanx-global a', + skipSetup: 'body.wc-setup > div > p.wc-setup-actions.step > a:nth-child(2)' + }, + fields: { + user_login: '#user_login', + user_pass: '#user_pass' + }, + containers: { + sidebar: '#adminmenuwrap' + } + } + }; + + const { buttons, fields, containers } = _private.elements; + + const $public = { + open: function () { + test + .visit(defaults.admin.host) + .get(fields.user_login, { timeout: 10000 }) + .should('be.visible') + .get(fields.user_pass, { timeout: 10000 }) + .should('be.visible'); + + return this; + }, + + login: function () { + test + .get(fields.user_login, { timeout: 10000 }) + .clear() + .type(defaults.admin.login) + .should('be.visible') + .get(fields.user_pass, { timeout: 10000 }) + .clear() + .type(defaults.admin.password) + .should('be.visible') + .get(buttons.login, { timeout: 10000 }) + .click({ force: true }) + .location() + .its('search') + .then(function (search) { + if (search === '?page=wc-setup') { + test + .get(buttons.skipSetup) + .click({ force: true }); + } + }) + .get(containers.sidebar, { timeout: 10000 }) + .should('be.visible') + .get(buttons.ebanxSettings, { timeout: 10000 }) + .should('be.visible'); + + return this; + } + }; + + return $public; +}); + +module.exports = loginPage; \ No newline at end of file diff --git a/cypress/lib/admin/pages/settings.js b/cypress/lib/admin/pages/settings.js new file mode 100644 index 00000000..1667ccb7 --- /dev/null +++ b/cypress/lib/admin/pages/settings.js @@ -0,0 +1,77 @@ +const settingsPage = (function (test) { + const _private = { + elements: { + buttons: { + ebanxSettings: '#toplevel_page_admin-page-wc-settings-tab-checkout-section-ebanx-global a', + saveSettings: '#mainform > p.submit > input.button-primary.woocommerce-save-button' + }, + fields: { + sandboxIntegrationKey: '#woocommerce_ebanx-global_sandbox_private_key', + sandboxPublickKey: '#woocommerce_ebanx-global_sandbox_public_key', + instalmentsSelect: '#woocommerce_ebanx-global_credit_card_instalments' + }, + containers: { + successMessage: '#message', + errorMessage: '#mainform > div.notice.notice-error' + } + } + }; + + const { buttons, fields, containers } = _private.elements; + + _private.fillSelect = function (field, value) { + test + .get(field, { timeout: 10000 }) + .select(value, { force: true }) + .then($select => { + $select.change(); + }) + .should('contain', value); + }; + + const $public = { + open: function () { + test + .get(buttons.ebanxSettings, { timeout: 10000 }) + .should('be.visible') + .click({ force: true }); + + return this; + }, + + fillSandboxKeys: function (keys) { + test + .get(fields.sandboxIntegrationKey, { timeout: 10000 }) + .should('be.visible') + .clear() + .type(keys.integration_key) + .get(fields.sandboxPublickKey, { timeout: 10000 }) + .should('be.visible') + .clear() + .type(keys.public_key); + + return this; + }, + + fillInstalments: function (number) { + _private.fillSelect(fields.instalmentsSelect, number); + + return this; + }, + + saveSettings: function () { + test + .get(buttons.saveSettings, { timeout: 10000 }) + .should('be.visible') + .click({ force: true }) + .get(containers.successMessage, { timeout: 10000 }) + .should('be.visible'); + + return this; + } + }; + + return $public; +}); + +module.exports = settingsPage; \ No newline at end of file diff --git a/cypress/lib/defaults.js b/cypress/lib/defaults.js new file mode 100644 index 00000000..e6590e32 --- /dev/null +++ b/cypress/lib/defaults.js @@ -0,0 +1,29 @@ +module.exports = { + site: { + host: Cypress.env('WC_PLUGIN_SITE_HOST') || 'http://localhost/shop/', + payments: { + credit_card: { + visa: '4111 1111 1111 1111', + master: '5555 5555 5555 4444', + amex: '378282246310005', + elo: '6362970000457013', + hipercard: '6062825624254001', + carnet: '5062224607440872', + discover: '6011111111111117' + } + } + }, + + admin: { + host: Cypress.env('WC_PLUGIN_ADMIN_HOST') || 'http://localhost/wp-login.php', + login: 'ebanx', + password: 'ebanx', + instalments: '12' + }, + + api: { + integration_key: 'b9fa8b1d4231889a1445e1ebfdfa2a3558ef3cc651d523eb1b12cdf8af3afc518f17b36edf5e8cfc59a8338bb9241aacd427', + public_key: 'yBy5zUmLxop5pUyKTr5CsNGRjnUkmaup8Ha9wwjU8Sg', + host: `https://sandbox.ebanx.com/ws/query` + } +}; \ No newline at end of file diff --git a/cypress/lib/pay/api_operator.js b/cypress/lib/pay/api_operator.js new file mode 100644 index 00000000..bc30dea9 --- /dev/null +++ b/cypress/lib/pay/api_operator.js @@ -0,0 +1,44 @@ +const defaults = require('../defaults'); + +const apiOperator = (function (test) { + const _private = { + getPayment: function (hash, cb) { + test + .request({ + method: 'GET', + headers: { + 'Content-Type': 'application/json' + }, + qs: { + integration_key: defaults.api.integration_key, + hash + }, + url: defaults.api.host, + timeout: 20000 + }) + .then(res => { + if (res.status != 200 || res.body.status !== 'SUCCESS') { + throw new Error(JSON.stringify(res)); + } + + if (cb) { + cb(res.body); + } + + return this; + }) + } + }; + + const $public = { + assertPaymentStatus: function (hash, status) { + _private.getPayment(hash, res => { + expect(res.payment.status).eql(status); + }); + } + }; + + return $public; +}); + +module.exports = apiOperator; \ No newline at end of file diff --git a/cypress/lib/site/pages/cart.js b/cypress/lib/site/pages/cart.js new file mode 100644 index 00000000..7152aabc --- /dev/null +++ b/cypress/lib/site/pages/cart.js @@ -0,0 +1,29 @@ +const cartPage = (function (test) { + const _private = { + elements: { + buttons: { + proceedToCheckout: '.checkout-button', + placeOrder: '#place_order' + } + } + }; + + const { buttons } = _private.elements; + + const $public = { + proceedToCheckout: function () { + test + .get(buttons.proceedToCheckout) + .should('be.visible') + .click() + .get(buttons.placeOrder) + .should('be.visible'); + + return this; + } + }; + + return $public; +}); + +module.exports = cartPage; \ No newline at end of file diff --git a/cypress/lib/site/pages/checkout.js b/cypress/lib/site/pages/checkout.js new file mode 100644 index 00000000..6b31f241 --- /dev/null +++ b/cypress/lib/site/pages/checkout.js @@ -0,0 +1,296 @@ +const utils = require('../../utils'); +const checkoutSchema = require('../schemas/checkout'); + +const checkoutPage = (function (test) { + const _private = { + elements: { + buttons: { + placeOrder: '#place_order', + boletoRadio: '.payment_method_ebanx-banking-ticket label', + ccRadio: '.payment_method_ebanx-credit-card-br > label', + tefRadio: '.payment_method_ebanx-tef > label', + itauRadio: '#ebanx-tef-payment .ebanx-label input[value="itau"]', + bradescoRadio: '#ebanx-tef-payment .ebanx-label input[value="bradesco"]', + bbRadio: '#ebanx-tef-payment .ebanx-label input[value="bancodobrasil"]', + banrisulRadio: '#ebanx-tef-payment .ebanx-label input[value="banrisul"]', + ebanxAccountRadio: '.payment_method_ebanx-account > label' + }, + containers: { + boletoBox: '.payment_box.payment_method_ebanx-banking-ticket', + tefBox: '.payment_box.payment_method_ebanx-tef', + accountBox: '.payment_box.payment_method_ebanx-account', + boletoBarCode: '.banking-ticket__barcode-code', + checkoutForm: 'form.checkout', + paymentType: '.ebanx-payment-type' + }, + fields: { + firstName: '#billing_first_name', + lastName: '#billing_last_name', + companyName: '#billing_company', + email: '#billing_email', + phone: '#billing_phone', + address: '#billing_address_1', + city: '#billing_city', + postcode: '#billing_postcode', + brazilDocument: '#ebanx_billing_brazil_document', + brazilBirthdate: '#ebanx_billing_brazil_birth_date', + country: '#billing_country', + state: '#billing_state', + hash: 'input[name="ebanx_payment_hash"]', + ccName: '#ebanx-card-holder-name', + ccNumber: '#ebanx-card-number', + ccDueDate: '#ebanx-card-expiry', + ccCVV: '#ebanx-card-cvv', + ccInstalments: '#ebanx-container-new-credit-card select.ebanx-instalments', + } + } + }; + + const { buttons, fields, containers } = _private.elements; + + _private.fillField = (value, field) => { + test + .get(field) + .should('be.visible') + // .clear() + .type(value) + .should('have.value', value); + }; + + _private.fillFirstName = function (firstName) { + this.fillField(firstName, fields.firstName); + }; + + _private.fillLastName = function (lastName) { + this.fillField(lastName, fields.lastName); + }; + + _private.fillCompany = function (companyName) { + this.fillField(companyName, fields.companyName); + }; + + _private.fillEmail = function (email) { + this.fillField(email, fields.email); + }; + + _private.fillPhone = function (phone) { + this.fillField(phone, fields.phone); + }; + + _private.fillAddress = function (address) { + this.fillField(address, fields.address); + }; + + _private.fillCity = function (city) { + this.fillField(city, fields.city); + }; + + _private.fillPostcode = function (postcode) { + this.fillField(postcode, fields.postcode); + }; + + _private.fillBrazilDocument = function (brazilDocument) { + this.fillField(brazilDocument, fields.brazilDocument); + }; + + _private.fillBrazilBirthDate = function (birthdate) { + this.fillField(birthdate, fields.brazilBirthdate); + }; + + _private.fillSelect = function (field, value) { + test + .get(field, { timeout: 10000 }) + .select(value, { force: true }) + .then($select => { + $select.change(); + }) + .should('contain', value); + }; + + _private.fillCountry = function (country) { + _private.fillSelect(fields.country, country); + }; + + _private.fillState = function (state) { + _private.fillSelect(fields.state, state); + }; + + _private.fillInstalments = function (instalments = '1') { + _private.fillSelect(fields.ccInstalments, instalments); + }; + + const $public = { + fillCheckout: function (data) { + utils + .validate(data, checkoutSchema, () => { + _private.fillCountry(data.country); + _private.fillState(data.state); + _private.fillPostcode(data.postcode); + _private.fillCity(data.city); + _private.fillAddress(data.address); + _private.fillFirstName(data.firstName); + _private.fillLastName(data.lastName); + _private.fillCompany(data.company); + _private.fillEmail(data.email); + _private.fillPhone(data.phone); + }); + }, + + fillToBrazil: function (data) { + this.fillCheckout(data); + + _private.fillBrazilDocument(data.brazilDocument); + _private.fillBrazilBirthDate(data.brazilBirthdate); + + return this; + }, + + fillBoletoGateway: function () { + test + .get(buttons.boletoRadio, { timeout: 10000 }) + .should('be.visible') + .click({ force: true }) + .get(containers.boletoBox) + .should('be.visible'); + + return this; + }, + + fillCreditCardBrazilGateway: function (cc_data) { + test + .wait(1000) + .get(buttons.ccRadio, { timeout: 10000 }) + .should('be.visible') + .click({ force: true }) + .then(() => { + _private.fillField(cc_data.number, fields.ccNumber); + _private.fillField(cc_data.due_date, fields.ccDueDate); + _private.fillField(cc_data.cvv, fields.ccCVV); + + if (cc_data.instalments) { + _private.fillInstalments(cc_data.instalments); + } + }); + + return this; + }, + + fillTef: function () { + test + .get(buttons.tefRadio, { timeout: 10000 }) + .should('be.visible') + .click({ force: true }) + .get(containers.tefBox) + .should('be.visible'); + + return this; + }, + + fillItauGateway: function () { + this.fillTef(); + + test + .get(buttons.itauRadio, { timeout: 10000 }) + .should('be.visible') + .click({ force: true }); + + return this; + }, + + fillBradescoGateway: function () { + this.fillTef(); + + test + .get(buttons.bradescoRadio, { timeout: 10000 }) + .should('be.visible') + .click({ force: true }); + + return this; + }, + + fillBBGateway: function () { + this.fillTef(); + + test + .get(buttons.bbRadio, { timeout: 10000 }) + .should('be.visible') + .click({ force: true }); + + return this; + }, + + fillBanrisulGateway: function () { + this.fillTef(); + + test + .get(buttons.banrisulRadio, { timeout: 10000 }) + .should('be.visible') + .click({ force: true }); + + return this; + }, + + fillEbanxAccountGateway: function () { + test + .get(buttons.ebanxAccountRadio, { timeout: 10000 }) + .should('be.visible') + .click({ force: true }) + .get(containers.accountBox) + .should('be.visible') + .get(buttons.ebanxAccountRadio, { timeout: 10000 }) + .should('be.visible') + .click({ force: true }); + + return this; + }, + + placeOrder: function () { + test + .get(buttons.placeOrder, { timeout: 10000 }) + .should('be.visible') + .click({ force: true }) + + return this; + }, + + extractHash: function (cb) { + return test + .get(fields.hash, { timeout: 10000 }) + .should('be.hidden') + .and('have.attr', 'value') + .then(cb); + }, + + placeOrderBoleto: function (cb) { + this.placeOrder(); + + test + .get(containers.boletoBarCode, { timeout: 10000 }) + .should('be.visible') + .and('not.to.be.empty'); + + return this.extractHash(cb); + }, + + placeOrderCreditCardBrazil: function (data, cb) { + this.placeOrder(); + + test + .get(containers.paymentType, { timeout: 10000 }) + .should('be.visible') + .and('not.to.be.empty'); + + if (data.instalments) { + test + .get(containers.paymentType, { timeout: 10000 }) + .should('contain', data.instalments); + } + + return this.extractHash(cb); + }, + }; + + return $public; +}); + +module.exports = checkoutPage; \ No newline at end of file diff --git a/cypress/lib/site/pages/home.js b/cypress/lib/site/pages/home.js new file mode 100644 index 00000000..c48a94fd --- /dev/null +++ b/cypress/lib/site/pages/home.js @@ -0,0 +1,43 @@ +const defaults = require('../../defaults'); + +const homePage = (function (test) { + const _private = { + elements: { + anchors: { + product: '.woocommerce-LoopProduct-link' + }, + buttons: { + addToCart: '.single_add_to_cart_button' + } + } + }; + + const { anchors, buttons } = _private.elements; + + const $public = { + open: function () { + test + .visit(defaults.site.host) + .get(anchors.product) + .should('be.visible'); + + return this; + }, + + openProduct: function () { + test + .get(anchors.product) + .should('be.visible') + .first() + .click() + .get(buttons.addToCart) + .should('be.visible'); + + return this; + } + }; + + return $public; +}); + +module.exports = homePage; \ No newline at end of file diff --git a/cypress/lib/site/pages/product.js b/cypress/lib/site/pages/product.js new file mode 100644 index 00000000..11406e70 --- /dev/null +++ b/cypress/lib/site/pages/product.js @@ -0,0 +1,41 @@ +const productPage = (function (test) { + const _private = { + elements: { + buttons: { + addToCart: '.single_add_to_cart_button', + viewCart: '.woocommerce-message > .button', + proceedToCheckout: '.checkout-button' + } + } + }; + + const { buttons } = _private.elements; + + const $public = { + addOpenedToCart: function () { + test + .get(buttons.addToCart) + .should('be.visible') + .click() + .get(buttons.viewCart) + .should('be.visible'); + + return this; + }, + + viewCart: function () { + test + .get(buttons.viewCart) + .should('be.visible') + .click() + .get(buttons.proceedToCheckout) + .should('be.visible'); + + return this; + } + }; + + return $public; +}); + +module.exports = productPage; \ No newline at end of file diff --git a/cypress/lib/site/pages/tef.js b/cypress/lib/site/pages/tef.js new file mode 100644 index 00000000..8d2a81ef --- /dev/null +++ b/cypress/lib/site/pages/tef.js @@ -0,0 +1,32 @@ +const tefPage = (function (test) { + const _private = { + elements: { + buttons: { + yes: '#mestre > div > div > div > a:nth-child(1)', + }, + containers: { + thankYou: '.woocommerce-thankyou-order-received' + }, + fields: { + hash: 'input[name="ebanx_payment_hash"]', + } + } + }; + + const { buttons, containers, fields } = _private.elements; + + const $public = { + fillYes: function (cb) { + test + .get(buttons.yes, { timeout: 10000 }) + .should('be.visible') + .click({ force: true }) + .get(containers.thankYou, { timeout: 10000 }) + .should('be.visible'); + } + }; + + return $public; +}); + +module.exports = tefPage; \ No newline at end of file diff --git a/cypress/lib/site/schemas/checkout.js b/cypress/lib/site/schemas/checkout.js new file mode 100644 index 00000000..ef6ff231 --- /dev/null +++ b/cypress/lib/site/schemas/checkout.js @@ -0,0 +1,15 @@ +const Joi = require('joi'); + +module.exports = Joi.object().keys({ + schema: 'Checkout', + firstName: Joi.string().min(3).max(60).required(), + lastName: Joi.string().min(3).max(60).required(), + company: Joi.string(), + email: Joi.string().email().required(), + phone: Joi.string().required(), + country: Joi.string().required(), + address: Joi.string().required(), + state: Joi.string().required(), + postcode: Joi.string().required(), + city: Joi.string().required() +}).without('schema', ['firstName', 'lastName', 'email', 'phone', 'country', 'address', 'state', 'postcode', 'city']); \ No newline at end of file diff --git a/cypress/lib/site/site_operator.js b/cypress/lib/site/site_operator.js new file mode 100644 index 00000000..6d9f46a5 --- /dev/null +++ b/cypress/lib/site/site_operator.js @@ -0,0 +1,125 @@ +const siteOperator = (function (test) { + const _private = { + pages: { + home: require('./pages/home')(test), + product: require('./pages/product')(test), + cart: require('./pages/cart')(test), + checkout: require('./pages/checkout')(test), + tef: require('./pages/tef')(test) + } + }; + + const { home, product, cart, checkout, tef } = _private.pages; + + const $public = { + makePayment: function () { + home + .open() + .openProduct(); + + product + .addOpenedToCart() + .viewCart(); + + cart + .proceedToCheckout(); + + return this; + }, + + makePaymentToBrazil: function (data) { + this.makePayment(); + + checkout.fillToBrazil(data); + + return this; + }, + + makeBoletoPayment: function (data, cb) { + this.makePaymentToBrazil(data); + + checkout + .fillBoletoGateway() + .placeOrderBoleto(cb); + + return this; + }, + + makeCreditCardToBrazilPayment: function (data, cc_data, cb) { + this.makePaymentToBrazil(data); + + checkout + .fillCreditCardBrazilGateway(cc_data) + .placeOrderCreditCardBrazil(cc_data, cb); + }, + + makeItauPayment: function (data, cb) { + this.makePaymentToBrazil(data); + + checkout + .fillItauGateway() + .placeOrder(); + + tef + .fillYes(cb); + + return this; + }, + + makeBradescoPayment: function (data, cb) { + this.makePaymentToBrazil(data); + + checkout + .fillBradescoGateway() + .placeOrder(); + + tef + .fillYes(cb); + + return this; + }, + + makeBBPayment: function (data, cb) { + this.makePaymentToBrazil(data); + + checkout + .fillBBGateway() + .placeOrder(); + + tef + .fillYes(cb); + + return this; + }, + + makeBanrisulPayment: function (data, cb) { + this.makePaymentToBrazil(data); + + checkout + .fillBanrisulGateway() + .placeOrder(); + + tef + .fillYes(cb); + + return this; + }, + + makeAccountPayment: function (data, cb) { + this.makePaymentToBrazil(data); + + checkout + .fillEbanxAccountGateway() + .placeOrder(); + + tef + .fillYes(cb); + + return this; + }, + }; + + return $public; +}); + +module.exports = siteOperator; \ No newline at end of file diff --git a/cypress/lib/utils.js b/cypress/lib/utils.js new file mode 100644 index 00000000..ad2ee75a --- /dev/null +++ b/cypress/lib/utils.js @@ -0,0 +1,13 @@ +const Joi = require('joi'); + +module.exports = { + validate: (data, schema, cb) => { + Joi.validate(data, schema, {allowUnknown: true}, (err) => { + if (err) { + throw new Error(`Invalid data to schema ${schema._inner.children[0].schema._valids._set[0]}. DETAILS: ${JSON.stringify(err.details)}`); + } + + cb(); + }); + } +}; \ No newline at end of file diff --git a/cypress/support/commands.js b/cypress/support/commands.js new file mode 100644 index 00000000..cae33ce8 --- /dev/null +++ b/cypress/support/commands.js @@ -0,0 +1,39 @@ +// *********************************************** +// This example commands.js shows you how to +// create the custom command: 'login'. +// +// The commands.js file is a great place to +// modify existing commands and create custom +// commands for use throughout your tests. +// +// You can read more about custom commands here: +// https://on.cypress.io/api/commands +// *********************************************** +// +// Cypress.addParentCommand("login", function(email, password){ +// var email = email || "joe@example.com" +// var password = password || "foobar" +// +// var log = Cypress.Log.command({ +// name: "login", +// message: [email, password], +// consoleProps: function(){ +// return { +// email: email, +// password: password +// } +// } +// }) +// +// cy +// .visit("/login", {log: false}) +// .contains("Log In", {log: false}) +// .get("#email", {log: false}).type(email, {log: false}) +// .get("#password", {log: false}).type(password, {log: false}) +// .get("button", {log: false}).click({log: false}) //this should submit the form +// .get("h1", {log: false}).contains("Dashboard", {log: false}) //we should be on the dashboard now +// .url({log: false}).should("match", /dashboard/, {log: false}) +// .then(function(){ +// log.snapshot().end() +// }) +// }) \ No newline at end of file diff --git a/cypress/support/defaults.js b/cypress/support/defaults.js new file mode 100644 index 00000000..24d28fd2 --- /dev/null +++ b/cypress/support/defaults.js @@ -0,0 +1,17 @@ +// *********************************************** +// This example defaults.js shows you how to +// customize the internal behavior of Cypress. +// +// The defaults.js file is a great place to +// override defaults used throughout all tests. +// +// *********************************************** +// +// Cypress.Server.defaults({ +// delay: 500, +// whitelist: function(xhr){} +// }) + +// Cypress.Cookies.defaults({ +// whitelist: ["session_id", "remember_token"] +// }) \ No newline at end of file diff --git a/cypress/support/index.js b/cypress/support/index.js new file mode 100644 index 00000000..30c3e0a1 --- /dev/null +++ b/cypress/support/index.js @@ -0,0 +1,23 @@ +// *********************************************************** +// This example support/index.js is processed and +// loaded automatically before your other test files. +// +// This is a great place to put global configuration and +// behavior that modifies Cypress. +// +// You can change the location of this file or turn off +// automatically serving support files with the +// 'supportFile' configuration option. +// +// You can read more here: +// https://on.cypress.io/guides/configuration#section-global +// *********************************************************** + +// Import commands.js and defaults.js +// using ES2015 syntax: +import "./commands" +import "./defaults" + +// Alternatively you can use CommonJS syntax: +// require("./commands") +// require("./defaults") diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..1557e55a --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,34 @@ +version: '3' + +services: + woo_mysql: + image: mariadb + environment: + MYSQL_DATABASE: wordpress + MYSQL_ROOT_PASSWORD: root + ports: + - 3306:3306 + volumes: + - ./.data:/var/lib/mysql + + woo_plugin: + image: ebanx/ebanx-woocommerce + build: + context: . + args: + WORDPRESS_DB_USER: root + WORDPRESS_DB_PASSWORD: root + WORDPRESS_DB_NAME: wordpress + WORDPRESS_DB_HOST: mysql + environment: + EBANX_WC_PLUGIN_VERSION: 3.0.7 + EBANX_ADMIN_USERNAME: ebanx + EBANX_ADMIN_PASSWORD: ebanx + EBANX_SITE_TITLE: EBANX + EBANX_SITE_EMAIL: plugin@ebanx.com + ports: + - 80:80 + volumes: + - ./woocommerce-gateway-ebanx/:/var/www/html/wp-content/plugins/woocommerce-gateway-ebanx/ + links: + - woo_mysql:mysql \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 00000000..fc49d943 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,76 @@ +#!/bin/sh + +set -e + +export WP_OWNER=www-data +export WP_GROUP=www-data +export WP_ROOT=/var/www/html +export WS_GROUP=www-data + +/usr/local/bin/wait-for-it.sh -t 60 mysql:3306 -- echo 'MySQL is up!' + +if ! $(wp core is-installed --allow-root); then + cd $WP_ROOT + + if [ ! -e .htaccess ]; then + cat > .htaccess <<-'EOF' + # BEGIN WordPress + + RewriteEngine On + RewriteBase / + RewriteRule ^index\.php$ - [L] + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-d + RewriteRule . /index.php [L] + + # END WordPress + EOF + chown www-data:www-data .htaccess + fi + + wp core install --url=localhost --title=$EBANX_SITE_TITLE --admin_user=$EBANX_ADMIN_USERNAME --admin_password=$EBANX_ADMIN_PASSWORD --admin_email=$EBANX_SITE_EMAIL --skip-email --allow-root --debug + + # Install and activate plugins + wp plugin install woocommerce --version=$EBANX_WC_PLUGIN_VERSION --activate --allow-root --debug + wp plugin activate woocommerce-gateway-ebanx --allow-root --debug + + # Install Pages + wp post create --post_type=page --post_title='My Account' --post_status='publish' --post_content='[woocommerce_my_account]' --allow-root --debug + wp post create --post_type=page --post_title='Cart' --post_status='publish' --post_content='[woocommerce_cart]' --allow-root --debug + wp post create --post_type=page --post_title='Checkout' --post_status='publish' --post_content='[woocommerce_checkout]' --allow-root --debug + wp post create --post_type=page --post_title='Shop' --post_status='publish' --allow-root --debug + + # Configure WooCommerce settings + wp db query 'UPDATE wp_options SET option_value="US:NY" WHERE option_name="woocommerce_default_country"' --allow-root --debug + wp db query 'UPDATE wp_options SET option_value="USD" WHERE option_name="woocommerce_currency"' --allow-root --debug + wp db query 'UPDATE wp_options SET option_value="3" WHERE option_name="woocommerce_myaccount_page_id"' --allow-root --debug + wp db query 'UPDATE wp_options SET option_value="4" WHERE option_name="woocommerce_cart_page_id"' --allow-root --debug + wp db query 'UPDATE wp_options SET option_value="5" WHERE option_name="woocommerce_checkout_page_id"' --allow-root --debug + wp db query 'UPDATE wp_options SET option_value="6" WHERE option_name="woocommerce_shop_page_id"' --allow-root --debug + + # Create a product + wp wc product create --name='Jeans' --status='publish' --regular_price='250' --user=1 --allow-root --debug + + # Configure Permalink + wp rewrite structure '/%postname%/' --hard --allow-root + + find ${WP_ROOT} -exec chown ${WP_OWNER}:${WP_GROUP} {} \; + find ${WP_ROOT} -type d -exec chmod 755 {} \; + find ${WP_ROOT} -type f -exec chmod 644 {} \; + chgrp ${WS_GROUP} ${WP_ROOT}/wp-config.php + chmod 660 ${WP_ROOT}/wp-config.php + find ${WP_ROOT}/wp-content -exec chgrp ${WS_GROUP} {} \; + find ${WP_ROOT}/wp-content -type d -exec chmod 775 {} \; + find ${WP_ROOT}/wp-content -type f -exec chmod 664 {} \; + chmod g+w ${WP_ROOT} + chown -R ${WP_OWNER}:${WP_GROUP} ${WP_ROOT}/wp-content + chown -R ${WP_OWNER}:${WP_GROUP} ${WP_ROOT}/wp-content/plugins/ + chown -R ${WP_OWNER}:${WP_GROUP} ${WP_ROOT}/wp-content/uploads/ + chown -R ${WP_OWNER}:${WP_GROUP} ${WP_ROOT}/wp-content/themes/ + + echo "EBANX: Visit http://localhost or http://localhost/wp-admin/" + echo "EBANX: Username - $EBANX_ADMIN_USERNAME" + echo "EBANX: Password - $EBANX_ADMIN_PASSWORD" +fi + +apache2-foreground \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 00000000..0d663b6e --- /dev/null +++ b/package.json @@ -0,0 +1,8 @@ +{ + "dependencies": { + "async": "^2.3.0", + "cpf_cnpj": "^0.2.0", + "faker": "^4.1.0", + "joi": "^10.3.1" + } +} diff --git a/wait-for-it.sh b/wait-for-it.sh new file mode 100755 index 00000000..eca6c3b9 --- /dev/null +++ b/wait-for-it.sh @@ -0,0 +1,161 @@ +#!/usr/bin/env bash +# Use this script to test if a given TCP host/port are available + +cmdname=$(basename $0) + +echoerr() { if [[ $QUIET -ne 1 ]]; then echo "$@" 1>&2; fi } + +usage() +{ + cat << USAGE >&2 +Usage: + $cmdname host:port [-s] [-t timeout] [-- command args] + -h HOST | --host=HOST Host or IP under test + -p PORT | --port=PORT TCP port under test + Alternatively, you specify the host and port as host:port + -s | --strict Only execute subcommand if the test succeeds + -q | --quiet Don't output any status messages + -t TIMEOUT | --timeout=TIMEOUT + Timeout in seconds, zero for no timeout + -- COMMAND ARGS Execute command with args after the test finishes +USAGE + exit 1 +} + +wait_for() +{ + if [[ $TIMEOUT -gt 0 ]]; then + echoerr "$cmdname: waiting $TIMEOUT seconds for $HOST:$PORT" + else + echoerr "$cmdname: waiting for $HOST:$PORT without a timeout" + fi + start_ts=$(date +%s) + while : + do + (echo > /dev/tcp/$HOST/$PORT) >/dev/null 2>&1 + result=$? + if [[ $result -eq 0 ]]; then + end_ts=$(date +%s) + echoerr "$cmdname: $HOST:$PORT is available after $((end_ts - start_ts)) seconds" + break + fi + sleep 1 + done + return $result +} + +wait_for_wrapper() +{ + # In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692 + if [[ $QUIET -eq 1 ]]; then + timeout $TIMEOUT $0 --quiet --child --host=$HOST --port=$PORT --timeout=$TIMEOUT & + else + timeout $TIMEOUT $0 --child --host=$HOST --port=$PORT --timeout=$TIMEOUT & + fi + PID=$! + trap "kill -INT -$PID" INT + wait $PID + RESULT=$? + if [[ $RESULT -ne 0 ]]; then + echoerr "$cmdname: timeout occurred after waiting $TIMEOUT seconds for $HOST:$PORT" + fi + return $RESULT +} + +# process arguments +while [[ $# -gt 0 ]] +do + case "$1" in + *:* ) + hostport=(${1//:/ }) + HOST=${hostport[0]} + PORT=${hostport[1]} + shift 1 + ;; + --child) + CHILD=1 + shift 1 + ;; + -q | --quiet) + QUIET=1 + shift 1 + ;; + -s | --strict) + STRICT=1 + shift 1 + ;; + -h) + HOST="$2" + if [[ $HOST == "" ]]; then break; fi + shift 2 + ;; + --host=*) + HOST="${1#*=}" + shift 1 + ;; + -p) + PORT="$2" + if [[ $PORT == "" ]]; then break; fi + shift 2 + ;; + --port=*) + PORT="${1#*=}" + shift 1 + ;; + -t) + TIMEOUT="$2" + if [[ $TIMEOUT == "" ]]; then break; fi + shift 2 + ;; + --timeout=*) + TIMEOUT="${1#*=}" + shift 1 + ;; + --) + shift + CLI="$@" + break + ;; + --help) + usage + ;; + *) + echoerr "Unknown argument: $1" + usage + ;; + esac +done + +if [[ "$HOST" == "" || "$PORT" == "" ]]; then + echoerr "Error: you need to provide a host and port to test." + usage +fi + +TIMEOUT=${TIMEOUT:-15} +STRICT=${STRICT:-0} +CHILD=${CHILD:-0} +QUIET=${QUIET:-0} + +if [[ $CHILD -gt 0 ]]; then + wait_for + RESULT=$? + exit $RESULT +else + if [[ $TIMEOUT -gt 0 ]]; then + wait_for_wrapper + RESULT=$? + else + wait_for + RESULT=$? + fi +fi + +if [[ $CLI != "" ]]; then + if [[ $RESULT -ne 0 && $STRICT -eq 1 ]]; then + echoerr "$cmdname: strict mode, refusing to execute subprocess" + exit $RESULT + fi + exec $CLI +else + exit $RESULT +fi diff --git a/woocommerce-gateway-ebanx/assets/js/checkout-fields.js b/woocommerce-gateway-ebanx/assets/js/checkout-fields.js index 3b3b8015..d4e2de3e 100644 --- a/woocommerce-gateway-ebanx/assets/js/checkout-fields.js +++ b/woocommerce-gateway-ebanx/assets/js/checkout-fields.js @@ -6,12 +6,12 @@ jQuery (function ($) { } // Masks - $(document).find(".ebanx_billing_chile_birth_date input").mask('00/00/0000'); + $(document).find(".ebanx_billing_chile_birth_date input").mask('00/00/0000'); $(document).find(".ebanx_billing_brazil_birth_date input").mask('00/00/0000'); $(document).find(".ebanx_billing_brazil_document input").mask('000.000.000-00'); $(document).find(".ebanx_billing_brazil_cnpj input").mask('00.000.000/0000-00'); - var getBillingFields = function (filter) { + var getBillingFields = function (filter) { filter = filter || ''; switch (filter) { @@ -65,10 +65,15 @@ jQuery (function ($) { $('#billing_country') .on('change',function() { + var country = this.value.toLowerCase(); + disableFields(getBillingFields()); - enableFields(getBillingFields(this.value.toLowerCase())); + + if (country) { + enableFields(getBillingFields(country)); + } - if (this.value.toLowerCase() === 'br') { + if (country === 'br') { taxes.change(); } }) diff --git a/woocommerce-gateway-ebanx/assets/js/vendor/clipboard.min.js b/woocommerce-gateway-ebanx/assets/js/vendor/clipboard.min.js old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-gateway.php b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-gateway.php index d4103e50..5bee5941 100644 --- a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-gateway.php +++ b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-gateway.php @@ -350,51 +350,64 @@ public function admin_options() */ public function process_refund($order_id, $amount = null, $reason = '') { - $order = wc_get_order($order_id); + try { + $order = wc_get_order($order_id); - $hash = get_post_meta($order->id, '_ebanx_payment_hash', true); + $hash = get_post_meta($order->id, '_ebanx_payment_hash', true); - do_action('ebanx_before_process_refund', $order, $hash); + do_action('ebanx_before_process_refund', $order, $hash); - if (!$order || is_null($amount) || !$hash) { - return false; - } + if (!$order || is_null($amount) || !$hash) { + return false; + } - $data = array( - 'hash' => $hash, - 'amount' => $amount, - 'operation' => 'request', - 'description' => $reason, - ); + if ( empty($reason) ) { + $reason = __('No reason specified.', 'woocommerce-gateway-ebanx'); + } - $config = [ - 'integrationKey' => $this->private_key, - 'testMode' => $this->is_sandbox_mode, - ]; + $data = array( + 'hash' => $hash, + 'amount' => $amount, + 'operation' => 'request', + 'description' => $reason, + ); - \Ebanx\Config::set($config); + $config = array( + 'integrationKey' => $this->private_key, + 'testMode' => $this->is_sandbox_mode, + ); - $request = \Ebanx\EBANX::doRefund($data); + \Ebanx\Config::set($config); - if ($request->status !== 'SUCCESS') { - do_action('ebanx_process_refund_error', $order, $request); + $request = \Ebanx\EBANX::doRefund($data); - return false; - } + if ($request->status !== 'SUCCESS') { + do_action('ebanx_process_refund_error', $order, $request); - $order->add_order_note(sprintf(__('EBANX: Refund requested to EBANX %s - Refund ID: %s - Reason: %s.', 'woocommerce-gateway-ebanx'), wc_price($amount), $request->refund->id, $reason)); + switch ($request->status_code) { + case 'BP-REF-7': + $message = __('The payment cannot be refunded because it is not confirmed.', 'woocommerce-gateway-ebanx'); + break; + default: + $message = $request->status_message; + } - $refunds = current(get_post_meta((int) $order_id, "_ebanx_payment_refunds")); + return new WP_Error('ebanx_process_refund_error', $message); + } - $request->refund->wc_refund = current($order->get_refunds()); + $refunds = $request->payment->refunds; - $refunds[] = $request->refund; + $order->add_order_note(sprintf(__('EBANX: Refund requested. %s - Refund ID: %s - Reason: %s.', 'woocommerce-gateway-ebanx'), wc_price($amount), $request->refund->id, $reason)); - update_post_meta($order->id, "_ebanx_payment_refunds", $refunds); + update_post_meta($order_id, '_ebanx_payment_refunds', $refunds); - do_action('ebanx_after_process_refund', $order, $request, $refunds); + do_action('ebanx_after_process_refund', $order, $request, $refunds); - return true; + return true; + } + catch (Exception $e) { + return new WP_Error('ebanx_process_refund_error', __('We could not finish processing this refund. Please try again.')); + } } /** @@ -828,8 +841,7 @@ protected function save_user_meta_fields($order) */ protected function process_response_error($request, $order) { - $code = $request->status_code; - + $code = isset($request->status_code) ? $request->status_code : 'GENERAL'; $error_message = __(sprintf('EBANX: An error occurred: %s - %s', $code, $request->status_message), 'woocommerce-gateway-ebanx'); $order->update_status('failed', $error_message); @@ -849,7 +861,7 @@ protected function process_response_error($request, $order) */ protected function process_response($request, $order) { - WC_EBANX::log("Processing response: " . print_r($request, true)); + WC_EBANX::log(sprintf(__('Processing response: %s', 'woocommerce-gateway-ebanx'), print_r($request, true))); if ($request->status == 'ERROR') { return $this->process_response_error($request, $order); diff --git a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-global-gateway.php b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-global-gateway.php index e0e8b41a..2fc60e1a 100644 --- a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-global-gateway.php +++ b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-global-gateway.php @@ -276,7 +276,7 @@ public function init_form_fields() { $currency_code = strtolower($this->merchant_currency); if ( in_array(strtoupper($currency_code), WC_EBANX_Constants::$CREDIT_CARD_CURRENCIES) ) { $fields["min_instalment_value_$currency_code"] = array( - 'title' => sprintf(__('Minimum instalment (%s)', 'woocommerce-gateway-ebanx'), strtoupper($currency_code)), + 'title' => sprintf(__('Minimum Instalment (%s)', 'woocommerce-gateway-ebanx'), strtoupper($currency_code)), 'type' => 'number', 'class' => 'ebanx-payments-option', 'placeholder' => sprintf(__('The default is %d', 'woocommerce-gateway-ebanx'), diff --git a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-tef-gateway.php b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-tef-gateway.php index 4fa0e4a3..32dcd303 100644 --- a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-tef-gateway.php +++ b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-tef-gateway.php @@ -14,6 +14,7 @@ public function __construct() $this->id = 'ebanx-tef'; $this->method_title = __('EBANX - TEF', 'woocommerce-gateway-ebanx'); + $this->api_name = 'tef'; $this->title = __('Débito Online', 'woocommerce-gateway-ebanx'); $this->description = __('Selecione o seu banco. A seguir, você será redirecionado para concluir o pagamento pelo seu internet banking.', 'woocommerce-gateway-ebanx'); diff --git a/woocommerce-gateway-ebanx/index.php b/woocommerce-gateway-ebanx/index.php new file mode 100644 index 00000000..62200328 --- /dev/null +++ b/woocommerce-gateway-ebanx/index.php @@ -0,0 +1,2 @@ +id, '_ebanx_payment_hash', true); + + printf('', $hash); + switch ($order->payment_method) { case 'ebanx-credit-card-br': WC_EBANX_Credit_Card_BR_Gateway::thankyou_page($order); diff --git a/woocommerce-gateway-ebanx/templates/ebanx-credit-card-br/payment-processing.php b/woocommerce-gateway-ebanx/templates/ebanx-credit-card-br/payment-processing.php index f69b7913..f99b4998 100644 --- a/woocommerce-gateway-ebanx/templates/ebanx-credit-card-br/payment-processing.php +++ b/woocommerce-gateway-ebanx/templates/ebanx-credit-card-br/payment-processing.php @@ -15,9 +15,9 @@

1) : ?> -

+

-

+

diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/.gitignore b/woocommerce-gateway-ebanx/vendor/ebanx-php/.gitignore old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/.travis.yml b/woocommerce-gateway-ebanx/vendor/ebanx-php/.travis.yml old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/LICENSE.md b/woocommerce-gateway-ebanx/vendor/ebanx-php/LICENSE.md old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/README.md b/woocommerce-gateway-ebanx/vendor/ebanx-php/README.md old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/VERSION b/woocommerce-gateway-ebanx/vendor/ebanx-php/VERSION old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/code_climate.sh b/woocommerce-gateway-ebanx/vendor/ebanx-php/code_climate.sh old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/codeclimate.json b/woocommerce-gateway-ebanx/vendor/ebanx-php/codeclimate.json old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/codeclimate.yml b/woocommerce-gateway-ebanx/vendor/ebanx-php/codeclimate.yml old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/composer.json b/woocommerce-gateway-ebanx/vendor/ebanx-php/composer.json old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/examples/bootstrap.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/examples/bootstrap.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/examples/cancel.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/examples/cancel.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/examples/capture.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/examples/capture.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/examples/checkout.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/examples/checkout.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/examples/direct.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/examples/direct.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/examples/document_balance.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/examples/document_balance.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/examples/exchange.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/examples/exchange.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/examples/get_bank_list.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/examples/get_bank_list.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/examples/print_html.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/examples/print_html.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/examples/query.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/examples/query.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/examples/refund.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/examples/refund.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/examples/refund_or_cancel.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/examples/refund_or_cancel.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/examples/zipcode.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/examples/zipcode.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/phpunit.xml b/woocommerce-gateway-ebanx/vendor/ebanx-php/phpunit.xml old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/phpunit_runner.sh b/woocommerce-gateway-ebanx/vendor/ebanx-php/phpunit_runner.sh old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/src/Ebanx/Command/AbstractCommand.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/src/Ebanx/Command/AbstractCommand.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/src/Ebanx/Command/BankList.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/src/Ebanx/Command/BankList.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/src/Ebanx/Command/Cancel.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/src/Ebanx/Command/Cancel.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/src/Ebanx/Command/Capture.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/src/Ebanx/Command/Capture.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/src/Ebanx/Command/DocumentBalance.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/src/Ebanx/Command/DocumentBalance.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/src/Ebanx/Command/Exchange.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/src/Ebanx/Command/Exchange.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/src/Ebanx/Command/Factory.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/src/Ebanx/Command/Factory.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/src/Ebanx/Command/PrintHtml.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/src/Ebanx/Command/PrintHtml.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/src/Ebanx/Command/Query.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/src/Ebanx/Command/Query.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/src/Ebanx/Command/Refund.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/src/Ebanx/Command/Refund.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/src/Ebanx/Command/RefundOrCancel.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/src/Ebanx/Command/RefundOrCancel.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/src/Ebanx/Command/Request/Checkout.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/src/Ebanx/Command/Request/Checkout.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/src/Ebanx/Command/Request/Direct.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/src/Ebanx/Command/Request/Direct.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/src/Ebanx/Command/Token.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/src/Ebanx/Command/Token.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/src/Ebanx/Command/Validator.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/src/Ebanx/Command/Validator.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/src/Ebanx/Command/Zipcode.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/src/Ebanx/Command/Zipcode.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/src/Ebanx/Config.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/src/Ebanx/Config.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/src/Ebanx/Ebanx.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/src/Ebanx/Ebanx.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/src/autoload.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/src/autoload.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/test/Ebanx/Command/BankListTest.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/test/Ebanx/Command/BankListTest.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/test/Ebanx/Command/CancelTest.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/test/Ebanx/Command/CancelTest.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/test/Ebanx/Command/CaptureTest.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/test/Ebanx/Command/CaptureTest.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/test/Ebanx/Command/DocumentBalance.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/test/Ebanx/Command/DocumentBalance.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/test/Ebanx/Command/ExchangeTest.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/test/Ebanx/Command/ExchangeTest.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/test/Ebanx/Command/FactoryTest.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/test/Ebanx/Command/FactoryTest.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/test/Ebanx/Command/ModifyTest.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/test/Ebanx/Command/ModifyTest.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/test/Ebanx/Command/PrintHtmlTest.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/test/Ebanx/Command/PrintHtmlTest.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/test/Ebanx/Command/QueryTest.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/test/Ebanx/Command/QueryTest.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/test/Ebanx/Command/RefundOrCancelTest.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/test/Ebanx/Command/RefundOrCancelTest.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/test/Ebanx/Command/RefundTest.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/test/Ebanx/Command/RefundTest.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/test/Ebanx/Command/Request/CheckoutTest.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/test/Ebanx/Command/Request/CheckoutTest.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/test/Ebanx/Command/Request/DirectTest.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/test/Ebanx/Command/Request/DirectTest.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/test/Ebanx/Command/TokenTest.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/test/Ebanx/Command/TokenTest.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/test/Ebanx/Command/ValidatorTest.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/test/Ebanx/Command/ValidatorTest.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/test/Ebanx/ConfigTest.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/test/Ebanx/ConfigTest.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/test/Ebanx/EbanxTest.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/test/Ebanx/EbanxTest.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/test/Mock/Http/Client.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/test/Mock/Http/Client.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/test/TestCase.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/test/TestCase.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/vendor/ebanx-php/test/bootstrap.php b/woocommerce-gateway-ebanx/vendor/ebanx-php/test/bootstrap.php old mode 100755 new mode 100644 diff --git a/woocommerce-gateway-ebanx/woocommerce-gateway-ebanx.php b/woocommerce-gateway-ebanx/woocommerce-gateway-ebanx.php index 2eec0184..6ba30bbc 100644 --- a/woocommerce-gateway-ebanx/woocommerce-gateway-ebanx.php +++ b/woocommerce-gateway-ebanx/woocommerce-gateway-ebanx.php @@ -5,7 +5,7 @@ * Description: Offer Latin American local payment methods & increase your conversion rates with the solution used by AliExpress, AirBnB and Spotify in Brazil. * Author: EBANX * Author URI: https://www.ebanx.com/business/en - * Version: 1.12.1 + * Version: 1.13.0 * License: MIT * Text Domain: woocommerce-gateway-ebanx * Domain Path: /languages @@ -584,6 +584,10 @@ public function woocommerce_missing_notice() */ public static function log($message) { + $configs = new WC_EBANX_Global_Gateway(); + + if ($configs->settings['debug_enabled'] !== 'yes') return; + if (empty(self::$log)) self::$log = new WC_Logger(); self::$log->add('woocommerce-gateway-ebanx', $message); diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 00000000..b8900870 --- /dev/null +++ b/yarn.lock @@ -0,0 +1,48 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +async@^2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/async/-/async-2.3.0.tgz#1013d1051047dd320fe24e494d5c66ecaf6147d9" + dependencies: + lodash "^4.14.0" + +cpf_cnpj@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/cpf_cnpj/-/cpf_cnpj-0.2.0.tgz#a032c19242a38e8363edce4e78bb1fbe9d664aa5" + +faker@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/faker/-/faker-4.1.0.tgz#1e45bbbecc6774b3c195fad2835109c6d748cc3f" + +hoek@4.x.x: + version "4.1.0" + resolved "https://registry.yarnpkg.com/hoek/-/hoek-4.1.0.tgz#4a4557460f69842ed463aa00628cc26d2683afa7" + +isemail@2.x.x: + version "2.2.1" + resolved "https://registry.yarnpkg.com/isemail/-/isemail-2.2.1.tgz#0353d3d9a62951080c262c2aa0a42b8ea8e9e2a6" + +items@2.x.x: + version "2.1.1" + resolved "https://registry.yarnpkg.com/items/-/items-2.1.1.tgz#8bd16d9c83b19529de5aea321acaada78364a198" + +joi@^10.3.1: + version "10.3.1" + resolved "https://registry.yarnpkg.com/joi/-/joi-10.3.1.tgz#2d22cab6eea650f02601144e51c35e2ba5ec497a" + dependencies: + hoek "4.x.x" + isemail "2.x.x" + items "2.x.x" + topo "2.x.x" + +lodash@^4.14.0: + version "4.17.4" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" + +topo@2.x.x: + version "2.0.2" + resolved "https://registry.yarnpkg.com/topo/-/topo-2.0.2.tgz#cd5615752539057c0dc0491a621c3bc6fbe1d182" + dependencies: + hoek "4.x.x"