Skip to content

Commit e8eb6fd

Browse files
authored
QDEVFE-201 (#82)
Refactor plugin for Wordpress store submission Update CI, demo store
1 parent 0f51f7b commit e8eb6fd

Some content is hidden

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

41 files changed

+510
-515
lines changed

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
WORDPRESS_HOST=
22
NGROK_TOKEN=
3-
PLUGIN_URL=https://github.com/qenta-cee/woocommerce-qcs.git
3+
PLUGIN_URL=
44
PLUGIN_VERSION=
55
WORDPRESS_ADMIN_USER=
66
WORDPRESS_ADMIN_PASS=

.github/workflows/plugin-test.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,21 @@ jobs:
99
steps:
1010
- name: Checkout
1111
uses: actions/checkout@v2
12+
- name: Setup PHP
13+
uses: shivammathur/setup-php@v2
14+
with:
15+
php-version: 7.4
16+
tools: composer
1217
- name: Get Branch Name
1318
shell: bash
1419
run: echo "::set-output name=name::$(bash docker/branchname.sh)"
1520
id: branch
1621
- name: Start NGROK
1722
shell: bash
18-
run: echo "::set-output name=host::$(timeout 1m bash docker/wordpress/ngrok.sh)"
23+
run: |
24+
NGROK_HOST=$(timeout 5m bash docker/wordpress/ngrok.sh)
25+
echo "ngrok hostname: ${NGROK_HOST}"
26+
echo "::set-output name=host::${NGROK_HOST}"
1927
id: ngrok
2028
env:
2129
NGROK_TOKEN: ${{ secrets.NGROK_TOKEN }}
@@ -31,3 +39,14 @@ jobs:
3139
env:
3240
WP_URL: ${{ steps.ngrok.outputs.host }}
3341
run: curl https://${{ steps.ngrok.outputs.host }}
42+
- name: Prepare Artifact
43+
run: |
44+
mkdir -p /tmp/artifact
45+
cp -r woocommerce-qenta-checkout-seamless composer.* /tmp/artifact/
46+
cd /tmp/artifact && composer install && rm composer.*
47+
- name: Upload Artifact
48+
id: upload_artifact
49+
uses: actions/upload-artifact@v2
50+
with:
51+
name: woocommerce-qenta-checkout-seamless
52+
path: /tmp/artifact

.github/workflows/release.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ jobs:
1212
steps:
1313
- name: Checkout
1414
uses: actions/checkout@v2
15+
- name: Setup PHP
16+
uses: shivammathur/setup-php@v2
17+
with:
18+
php-version: 7.4
19+
tools: composer
1520
- name: Install Dependencies
1621
run: composer install
1722
- name: Pack Release zip

docker/wordpress/init.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
set -e
44

5+
touch /tmp/shop.log
6+
57
# If we are in Github plugin repo CI environment
68
CI_REPO_URL=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}
79
if [[ ${CI_REPO_URL} == ${PLUGIN_URL//.git/} ]]; then
@@ -80,16 +82,21 @@ function setup_store() {
8082
wp option set woocommerce_default_country "AT"
8183
wp_set_array woocommerce_onboarding_profile skipped 1
8284
wp wc --user=admin tool run install_pages
85+
wp option update page_on_front 5
86+
wp option update show_on_front page
87+
wp option update blogdescription "QENTA Plugin DEMO"
88+
wp theme install twentytwenty --activate
89+
wp post delete 2 --force
90+
wp post delete 1 --force
8391
}
8492

8593
function print_info() {
8694
echo
8795
echo '####################################'
8896
echo
89-
echo "URL: https://${WORDPRESS_URL}"
90-
echo "Shop: https://${WORDPRESS_URL}/?post_type=product"
91-
echo "Panel: https://${WORDPRESS_URL}/wp-admin/"
92-
echo "Plugin Config: https://${WORDPRESS_URL}/wp-admin/admin.php?page=wc-settings&tab=checkout"
97+
echo "Shop: https://${WORDPRESS_URL}"
98+
echo "Admin Panel: https://${WORDPRESS_URL}/wp-admin/"
99+
echo "Plugin Config: https://${WORDPRESS_URL}/wp-admin/admin.php?page=wc-settings&tab=checkout&section=woocommerce_wcs"
93100
echo "User: ${WORDPRESS_ADMIN_USER}"
94101
echo "Password: ${WORDPRESS_ADMIN_PASS}"
95102
echo

docker/wordpress/ngrok.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
#!/bin/bash
22

3-
set -e
4-
53
which ngrok >/dev/null
64
if [[ $? == 0 ]]; then
75
NGROK_BINARY="$(which ngrok)"
86
else
97
>&2 echo "Installing NGROK"
108
cd ~/
11-
npm install ngrok
12-
NGROK_BINARY="~/node_modules/ngrok/bin/ngrok"
9+
npm install ngrok >&2
10+
NGROK_BINARY="./node_modules/ngrok/bin/ngrok"
1311
fi
1412

1513
function get_ngrok_url() {

woocommerce-qenta-checkout-seamless/assets/scripts/admin.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,9 @@ wpOnload = function () {
4646
tabPane.className = tabPane.className + ' active';
4747
});
4848
}
49-
}
49+
}
50+
51+
function goToWctPage(page) {
52+
start = "?page=qenta_transactions_page&transaction_start=" + page;
53+
window.location.href = start;
54+
}

woocommerce-qenta-checkout-seamless/classes/class-qenta-admin.php

Lines changed: 131 additions & 147 deletions
Large diffs are not rendered by default.

woocommerce-qenta-checkout-seamless/classes/class-qenta-backend-operations.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,17 @@ public function __construct( $settings ) {
8989
public function refund( $order_id = 0, $amount = 0, $reason = '' ) {
9090
global $wpdb;
9191

92-
$order_id = $_POST['order_id'];
93-
$refund_amount = $_POST['refund_amount'];
92+
$params_post = array_map( 'sanitize_text_field', $_POST );
93+
$order_id = $params_post['order_id'];
94+
$refund_amount = $params_post['refund_amount'];
9495
if ( $refund_amount <= 0 ) {
95-
$this->_logger->error( __( 'Refund amount must be greater than zero.', 'woocommerce-qenta-checkout-seamless' ) );
96+
$this->_logger->error( esc_html( __( 'Refund amount must be greater than zero.', 'woocommerce-qenta-checkout-seamless' ) ) );
9697

9798
return false;
9899
}
99100

100-
$line_item_qtys = json_decode( str_replace( '\\', "", $_POST['line_item_qtys'] ) );
101-
$line_item_totals = (array) json_decode( str_replace( '\\', "", $_POST['line_item_totals'] ) );
101+
$line_item_qtys = json_decode( str_replace( '\\', "", $params_post['line_item_qtys'] ) );
102+
$line_item_totals = (array) json_decode( str_replace( '\\', "", $params_post['line_item_totals'] ) );
102103
$refund_items = array();
103104
$total_items = 0;
104105

@@ -331,7 +332,7 @@ private function logResponseErrors( $method, $errors ) {
331332
foreach ( $errors as $error ) {
332333
$_errors[] = $error->getConsumerMessage();
333334
}
334-
$this->_logger->error( "$method : processing refund failed with error(s): " . join( '|', $_errors ) );
335+
$this->_logger->error( esc_html( "$method : processing refund failed with error(s): " . join( '|', $_errors ) ) );
335336
}
336337

337338
/**
@@ -358,7 +359,7 @@ public function transfer_fund_refund( $amount, $currency, $order_number, $woocom
358359
$refundable_sum = $wpdb->get_row( $refundable_sum );
359360

360361
if ( $refundable_sum !== null && $amount > $refundable_sum->sum ) {
361-
$this->_logger->error( __METHOD__ . ":" . __( 'The refunded amount must be less than deposited amount.', 'woocommerce-qenta-checkout-seamless' ) );
362+
$this->_logger->error( __METHOD__ . ":" . esc_html( __( 'The refunded amount must be less than deposited amount.', 'woocommerce-qenta-checkout-seamless' ) ) );
362363

363364
return false;
364365
}
@@ -506,6 +507,7 @@ public function depositreversal( $orderNumber, $paymentNumber ) {
506507
* @return array
507508
*/
508509
public function approvereversal( $orderNumber ) {
510+
$params_post = array_map( 'sanitize_text_field', $_POST );
509511
$response = $this->get_client()->approveReversal( $orderNumber );
510512
$transaction = new WC_Gateway_Qenta_Checkout_Seamless_Transaction( $this->_settings );
511513

@@ -518,8 +520,8 @@ public function approvereversal( $orderNumber ) {
518520

519521
return array( 'type' => 'error', 'message' => join( "<br>", $errors ) );
520522
} else {
521-
if( isset($_POST['id_tx'])){
522-
$transaction->update( array( 'payment_state' => 'CANCELED BY ADMIN' ), array( 'id_tx' => $_POST['id_tx'] ) );
523+
if( isset($params_post['id_tx'])){
524+
$transaction->update( array( 'payment_state' => 'CANCELED BY ADMIN' ), array( 'id_tx' => $params_post['id_tx'] ) );
523525
}
524526
return array( 'type' => 'updated', 'message' => __( 'APPROVEREVERSAL', 'woocommerce-qenta-checkout-seamless' ) );
525527
}

woocommerce-qenta-checkout-seamless/classes/class-qenta-config.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
* Please do not use the plugin if you do not agree to these terms of use!
3131
*/
3232

33-
define( 'WOOCOMMERCE_GATEWAY_WCS_NAME', 'QentaCheckoutSeamless' );
34-
define( 'WOOCOMMERCE_GATEWAY_WCS_VERSION', '2.0.2' );
33+
define( 'WOOCOMMERCE_GATEWAY_QMORE_NAME', 'QentaCheckoutSeamless' );
34+
define( 'WOOCOMMERCE_GATEWAY_QMORE_VERSION', '2.0.3' );
3535

3636
/**
3737
* Config class
@@ -205,8 +205,8 @@ public function get_plugin_version() {
205205
return QentaCEE\QMore\FrontendClient::generatePluginVersion(
206206
'woocommerce',
207207
WC()->version,
208-
WOOCOMMERCE_GATEWAY_WCS_NAME,
209-
WOOCOMMERCE_GATEWAY_WCS_VERSION
208+
WOOCOMMERCE_GATEWAY_QMORE_NAME,
209+
WOOCOMMERCE_GATEWAY_QMORE_VERSION
210210
);
211211
}
212212

0 commit comments

Comments
 (0)