Skip to content

Commit

Permalink
QMP-67 (#59)
Browse files Browse the repository at this point in the history
## New Payment Methods
* Invoice and Installments via AfterPay
* Crypto Payments via Salamantex

## Fixes
* Security fix for guzzlehttp

## Refactoring
* Update Test Mode configurations
* Remove outdated payment methods
* Update parameter documentations
* Update translations
* Update eps, bank selection is now on the eps site

## CI/Dev
* Dockerize Magento2
* Automate plugin installation
* Automate shop configuration
* Add German language pack

* Add automated installation, Docker

* Install local plugin or via repo url

* Remove non3d-test mode, add new test data

* Remove autodeposit option and set to false always

* Remove mobiledetect, hardcoded displayMode
displayMode = redirect
layout = DESKTOP

* Remove InvoiceB2B

* Remove Skrill

* Remove Moneta

* Remove Trustpay

* Remove Trustly

* Remove Ekonto

* Remove Poli

* Remove Paybox

* Remove Bancontact

* Remove Quick

* Remove Epay

* Remove MOTO

* Remove Giropay

* Remove Maestro

* Remove Masterpass

* Remove Tatrapay

* Remove Voucher

* Remove Ideal

* Remove Ratepay

* Remove Installment (payolution)

* Set default to send billing, shipping for all PM..
unless specified differently in Payment Model

Set default autodeposit false

* Add AfterPay

* Add Crypto (Salamantex)

* Force AfterpPay additional data
remove default of sending additional data

* EPS modifications

* Update shop init script

* Clear Cart after successful payment

* Remove unused logos

* Chores

* Bump version to 2.1.0

* Dependencies security update

* Fix minicart clear after payment

* Add docker instructions
  • Loading branch information
HMKnapp authored May 20, 2022
1 parent 29410a0 commit 04e7f7b
Show file tree
Hide file tree
Showing 75 changed files with 1,316 additions and 3,622 deletions.
94 changes: 94 additions & 0 deletions .docker/magento2/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
FROM php:7-apache

# set PATH for composer binaries
ENV PATH="~/.composer/vendor/bin:${PATH}"

# reduce APT noise
ENV DEBIAN_FRONTEND=noninteractive

# use proper shell
SHELL ["/bin/bash", "-c"]

# to avoid all too common aborts because of debian repo timeouts
RUN echo 'APT::Acquire::Retries "30";' > /etc/apt/apt.conf.d/80-retries

# upgrade package list and default packages
RUN apt-get -qq update
RUN apt-get -qq upgrade

# install npm nodesource repo
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -

# install dependencies aand tools
RUN apt-get -qq install git unzip vim mariadb-client zip jq nodejs

# install php extension dependencies
RUN apt-get -qq install libmemcached-dev libzip-dev zlib1g-dev libpng-dev libjpeg-dev libfreetype6-dev libwebp-dev libonig-dev libtidy-dev libicu-dev libxml2-dev libxslt-dev

# clean up to reduce docker image size
RUN apt-get -qq autoremove

# install PHP extensions required
RUN bash -c "pecl install xdebug memcached &> /dev/null"
RUN docker-php-ext-configure gd --with-jpeg --with-freetype --with-webp
RUN docker-php-ext-install -j64 intl sockets soap gd mbstring mysqli pdo pdo_mysql tidy bcmath xsl zip
RUN docker-php-ext-enable intl sockets xsl zip memcached xdebug gd mbstring mysqli pdo pdo_mysql tidy bcmath

# enable apache modules
RUN a2enmod rewrite headers ext_filter expires

# create self-signed cert and enable SSL on apache
RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/ssl-cert-snakeoil.key -out /etc/ssl/certs/ssl-cert-snakeoil.pem -subj "/C=AT/ST=Vienna/L=Vienna/O=Security/OU=Development/CN=example.com"
RUN a2ensite default-ssl
RUN a2enmod ssl

# get composer binary from composer docker image
COPY --from=composer /usr/bin/composer /usr/bin/composer

# add user and dir for executing composer
RUN useradd -u 431 -r -g www-data -s /sbin/nologin -c "magento user" magento

# set permissions for magento user
RUN mkdir -p /home/magento && chown -R magento:www-data /home/magento /etc/ssl /var/www

# install ngrok
COPY --from=ngrok/ngrok:debian /bin/ngrok /usr/bin/ngrok

# magento is greedy
RUN echo memory_limit=4G > /usr/local/etc/php/conf.d/give_me_more_memory__give_me_MOOOORE.ini

# continue as user for correct permissions
USER magento

# clone magento2 base and sample data
# checkout all branches to have them in the image to speed up checkout in entrypoint
RUN git clone https://github.com/magento/magento2 /var/www/magento2
RUN cd /var/www/magento2 && for BRANCH in $(git branch -a | grep remotes | grep -v HEAD | grep -v master); do git branch --track "${BRANCH#remotes/origin/}" "${BRANCH}"; done
RUN git clone https://github.com/magento/magento2-sample-data /var/www/magento2/magento2-sample-data
RUN cd /var/www/magento2/magento2-sample-data && for BRANCH in $(git branch -a | grep remotes | grep -v HEAD | grep -v master); do git branch --track "${BRANCH#remotes/origin/}" "${BRANCH}"; done

# copy entrypoint script
COPY init.sh /usr/local/bin/init.sh

# copy plugin fetch script
COPY get_plugin.sh /usr/local/bin/get_plugin.sh

# copy ngrok script
COPY ngrok.sh /usr/local/bin/ngrok.sh

# copy plugin
RUN mkdir /tmp/plugin
COPY . /tmp/plugin/

# make scripts executable
USER root
RUN chmod +x /usr/local/bin/*.sh

WORKDIR /var/www/html
USER magento

# override default entrypoin with ours
ENTRYPOINT [ "init.sh" ]

EXPOSE 80
EXPOSE 443
178 changes: 178 additions & 0 deletions .docker/magento2/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
#!/bin/bash

set -e

trap exit SIGTERM
touch /tmp/shop.log

# If we are in Github plugin repo CI environment
CI_REPO_URL=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}
if [[ ${CI_REPO_URL} == ${PLUGIN_URL//.git/} ]]; then
PLUGIN_VERSION=${GITHUB_SHA}
CI='true'
fi

if [[ -z ${MAGENTO2_BASEURL} ]]; then
echo "MAGENTO2_BASEURL not specified."
if [[ -n ${NGROK_TOKEN} ]]; then
echo "Launching ngrok to get temporary URL"
MAGENTO2_BASEURL=$(ngrok.sh ${NGROK_TOKEN})
else
echo "No NGROK_TOKEN specified. Using localhost as URL"
MAGENTO2_BASEURL=localhost
fi
fi

echo "Waiting for DB host ${MAGENTO2_DB_HOST}"

while ! mysqladmin ping -h"${MAGENTO2_DB_HOST}" --silent; do
sleep 10
done

function create_db() {
echo "Creating Database"
}

function install_core() {
echo "Install Core"
composer install
}

function switch_version() {
echo "Switchting to Magento2 ${MAGENTO2_VERSION}"
cd /var/www/magento2
git fetch --all
git checkout ${MAGENTO2_VERSION} || echo "Invalid MAGENTO2_VERSION specified"
rm -r /var/www/html
ln -s /var/www/magento2/pub /var/www/html
}

function install_sample_data() {
echo "Installing Sample Data"
cd /var/www/magento2/magento2-sample-data
git fetch --all
git checkout ${MAGENTO2_VERSION}
cd ..
php -f magento2-sample-data/dev/tools/build-sample-data.php -- --ce-source="/var/www/magento2/"
bin/magento cache:clean
bin/magento setup:upgrade
}

function install_language_pack() {
echo "Installing German Language Pack"
cd /var/www/magento2
composer require splendidinternet/mage2-locale-de-de
bin/magento config:set general/locale/code de_DE
bin/magento config:set general/country/default at
}

function install_plugin() {
echo "Installing Extension"
local PLUGIN_DIR=/tmp/plugin/
if [[ -n ${PLUGIN_URL} && ${PLUGIN_URL} != 'local' ]]; then
PLUGIN_DIR=$(mktemp -d)
if [[ -z ${PLUGIN_VERSION} || ${PLUGIN_VERSION} == 'latest' ]]; then
git clone -b ${PLUGIN_VERSION} ${PLUGIN_URL} ${PLUGIN_DIR}
else
git clone ${PLUGIN_URL} ${PLUGIN_DIR}
fi
fi
cd /var/www/magento2
composer config minimum-stability dev
composer config repositories.qenta path ${PLUGIN_DIR}
composer require qenta/magento2-qcp
bin/magento cache:clean
bin/magento setup:upgrade

(sleep 10; bin/magento cache:flush >&/dev/null)&
}

function run_periodic_flush() {
local INTERVAL=${1:-60}
while sleep ${INTERVAL}; do bin/magento cache:clean >& /dev/null & done &
}

function setup_store() {
bin/magento setup:install \
--admin-firstname=QENTA \
--admin-lastname=Admin \
--admin-email=${MAGENTO2_ADMIN_EMAIL} \
--admin-user=${MAGENTO2_ADMIN_USER} \
--admin-password=${MAGENTO2_ADMIN_PASS} \
--base-url=https://${MAGENTO2_BASEURL} \
--db-host=magento2_db_qcp \
--db-name=$MAGENTO2_DB_NAME \
--db-user=$MAGENTO2_DB_USER \
--db-password=$MAGENTO2_DB_PASS \
--db-prefix=qcp \
--currency=EUR \
--timezone=Europe/Vienna \
--language=de_DE \
--elasticsearch-host=magento2_elasticsearch_qcp \
--backend-frontname=admin_qenta
bin/magento cron:run
bin/magento setup:upgrade
}

function print_info() {
echo
echo '####################################'
echo
echo "Shop: https://${MAGENTO2_BASEURL}"
echo "Admin Panel: https://${MAGENTO2_BASEURL}/admin_qenta/"
echo "User: ${MAGENTO2_ADMIN_USER}"
echo "Password: ${MAGENTO2_ADMIN_PASS}"
echo
echo '####################################'
echo
}

function _log() {
echo "${@}" >> /tmp/shop.log
}

if [[ -e wp-config.php ]]; then
echo "Shop detected. Skipping installations"
MAGENTO2_BASEURL=$(echo "BLABLABLA")
else
switch_version ${MAGENTO2_VERSION}
_log "Magento2 version set to: ${MAGENTO2_VERSION}"

install_core
_log "Shop installed"

setup_store
_log "store set up"

install_language_pack
_log "installed 3rd party language pack de_DE"

install_sample_data
_log "Sample data installed"

if [[ -n ${PLUGIN_URL} ]]; then
install_plugin
_log "plugin installed"
fi
if [[ -n ${OVERRIDE_api_uri} ]]; then
change_api_uri "${OVERRIDE_api_uri}" &&
_log "changed API URL to ${OVERRIDE_api_uri}" &&
_api_uri_changed=true
fi
fi
if [[ ${CI} != 'true' ]]; then
(sleep 1; print_info) &
fi

run_periodic_flush 3m

_log "url=https://${MAGENTO2_BASEURL}"
_log "ready"

echo "ready" > /tmp/debug.log

mkdir -p /var/www/magento2/log
touch /var/www/magento2/log/exception.log

apache2-foreground "$@" &
tail -f /var/www/magento2/log/exception.log
38 changes: 38 additions & 0 deletions .docker/magento2/ngrok.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

set -e

which ngrok >/dev/null
if [[ $? == 0 ]]; then
NGROK_BINARY="$(which ngrok)"
else
>&2 echo "Installing NGROK"
cd ~/
npm install ngrok
NGROK_BINARY="~/node_modules/ngrok/bin/ngrok"
fi

function get_ngrok_url() {
curl --fail -s localhost:4040/api/tunnels | jq -r .tunnels\[0\].public_url | sed 's/^http:/https:/'
}

function wait_for_ngrok() {
while [[ -z ${RESPONSE} || ${RESPONSE} == 'null' ]]; do
RESPONSE=$(get_ngrok_url)
sleep 1;
done
}

[[ ${1} ]] && NGROK_TOKEN=${1}

if [[ -z ${NGROK_TOKEN} ]]; then
echo 'NGROK token missing. Set NGROK_TOKEN env' >&2
exit 1
fi

${NGROK_BINARY} authtoken ${NGROK_TOKEN} >&/dev/null
${NGROK_BINARY} http https://localhost:443 >&/dev/null &
wait_for_ngrok
NGROK_URL=$(get_ngrok_url)
NGROK_HOST=$(sed 's,^https\?://,,' <<< ${NGROK_URL})
echo ${NGROK_HOST}
17 changes: 17 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
MAGENTO2_BASEURL=
MAGENTO2_VERSION=2.4.3
NGROK_TOKEN=
DEFAULT_COUNTRY_CODE=
PLUGIN_URL=
PLUGIN_VERSION=
MAGENTO2_ADMIN_USER=
MAGENTO2_ADMIN_PASS=
MAGENTO2_ADMIN_EMAIL=
MAGENTO2_DB_NAME=
MAGENTO2_DB_USER=
MAGENTO2_DB_PASS=
MAGENTO2_DB_ROOTPASS=
MAGENTO2_LOCALE=
MAGENTO2_TITLE=
PORT_HTTP=
PORT_SSL=
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### Prerequisites

- [ ] I have my [server set up correctly](https://guides.wirecard.com/shop_plugins:wcp:magento2:installation).
- [ ] I am using a [supported version of Magento 2](https://guides.wirecard.com/shop_plugins:wcp:magento2:start).
- [ ] I have my [server set up correctly](https://guides.qenta.com/plugins/magento2-installation-page/).
- [ ] I am using a supported version of Magento 2.

### Versions

Expand Down
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
.idea/
composer.phar
composer.lock
composer.phar
vendor
.env
28 changes: 2 additions & 26 deletions Block/Adminhtml/Fundtransfer/Edit/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,11 @@ protected function _prepareForm()
'options' => array(
'' => $this->_dataHelper->__('Please select the fund transfer type'),
'existingorder' => $this->_dataHelper->__('Existing order'),
'moneta' => 'moneta.ru',
'sepa-ct' => 'SEPA-CT',
'skrillwallet' => 'Skrill Digital Wallet'
'sepa-ct' => 'SEPA-CT'
),
]);

$fieldNoteFmt = sprintf('<a href="https://guides.wirecard.com/doku.php%%s" target="_blank" class="docref">%s</a>',
$fieldNoteFmt = sprintf('<a href="https://guides.qenta.com/plugins/" target="_blank" class="docref">%s</a>',
$this->_dataHelper->__('See documentation'));

$fieldset->addField('currency', 'select', [
Expand Down Expand Up @@ -205,12 +203,6 @@ protected function _prepareForm()
));


/* skrillwallet fields */
$fieldsetExistingOrder = $form->addFieldset('fields-skrillwallet',
array(
'legend' => $this->_dataHelper->__('Skrill Digital Wallet data'),
'class' => 'transferfund-fieldset'
));
$fieldsetExistingOrder->addField('consumerEmail', 'text', array(
'name' => 'consumerEmail',
'label' => $this->_dataHelper->__('Consumer e-mail address'),
Expand All @@ -220,22 +212,6 @@ protected function _prepareForm()
'note' => sprintf($fieldNoteFmt, '/request_parameters#consumer_billing_data')
));


/* moneta.ru fields */
$fieldsetExistingOrder = $form->addFieldset('fields-moneta',
array(
'legend' => $this->_dataHelper->__('moneta.ru data'),
'class' => 'transferfund-fieldset'
));
$fieldsetExistingOrder->addField('consumerWalletId', 'text', array(
'name' => 'consumerWalletId',
'label' => $this->_dataHelper->__('Consumer wallet ID'),
'class' => 'required-entry fundtransfer-required',
'required' => true,
'style' => 'width: 400px',
'note' => sprintf($fieldNoteFmt, '/back-end_operations:functional_wcp_wcs:transaction-based_operations:transferfund#fund_transfer_typemoneta')
));

$form->setValues(['currency' => 'EUR']);

/** @var \Magento\Framework\DataObject $dataObject */
Expand Down
Loading

0 comments on commit 04e7f7b

Please sign in to comment.