From f02f5056bb0de7b9c3f0c9394543998c600e74dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20H=C3=B6gefjord?= Date: Wed, 24 Jul 2024 11:50:33 +0200 Subject: [PATCH 01/14] Update .distignore --- .distignore | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/.distignore b/.distignore index e06f680..d524e47 100644 --- a/.distignore +++ b/.distignore @@ -1,16 +1,34 @@ -/.git* + +/.git +/.github /.husky -/.vscode /node_modules -.distignore +/.vscode +/.wordpress-org +/tests .env +.editorconfig +.distignore .gitignore commitlint.config.js -composer.json -docker-compose.yml +Dockerfile Dockerfile-* -package-lock.json +docker-compose.phpunit.yml +docker-compose.yml +DOCKER_ENV +docker_tag +gulpfile.js +output.log package.json +package-lock.json +phpcs.ruleset.xml +phpunit-docker.xml +phpunit.xml +phpcs.xml +readme.md +README.md +readme.dev.txt README.md +renovate.json webpack.config.js -wpcron.txt +wpcron.txt \ No newline at end of file From 7c92ec9b85e03bab0210c4f46b11d737fef8229c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20H=C3=B6gefjord?= Date: Wed, 24 Jul 2024 11:50:43 +0200 Subject: [PATCH 02/14] Create build-and-deploy.yml --- .github/workflows/build-and-deploy.yml | 37 ++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/build-and-deploy.yml diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml new file mode 100644 index 0000000..230a786 --- /dev/null +++ b/.github/workflows/build-and-deploy.yml @@ -0,0 +1,37 @@ +name: Build and deploy to WordPress.org +on: + release: + types: [published] +jobs: + tag: + name: New tag + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@main + + # Install all composer dependencies for the plugin. + - name: Install Composer dependencies + uses: php-actions/composer@v6 + with: + dev: no + php_version: 7.4 + + - name: Install PNPM + uses: pnpm/action-setup@v2 + with: + run_install: true + + - name: Build Assets + run: pnpm run build + + # Deploy the plugin to WordPress.org + - name: WordPress Plugin Deploy + id: deploy + uses: 10up/action-wordpress-plugin-deploy@stable + with: + generate-zip: true + env: + SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} + SVN_USERNAME: ${{ secrets.SVN_USERNAME }} + SLUG: ledyer-checkout-for-woocommerce \ No newline at end of file From b4277585c67f0d0ae8a2fb9ce749fdc41e04b599 Mon Sep 17 00:00:00 2001 From: anyakro Date: Tue, 3 Sep 2024 16:37:51 +0200 Subject: [PATCH 03/14] Update deprecated sanitization --- classes/class-ledyer-confirmation.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/class-ledyer-confirmation.php b/classes/class-ledyer-confirmation.php index 5b0cbfe..a98061d 100644 --- a/classes/class-ledyer-confirmation.php +++ b/classes/class-ledyer-confirmation.php @@ -32,8 +32,8 @@ public function actions() { * Confirm the order in Woo */ public function confirm_order() { - $ledyer_confirm = filter_input( INPUT_GET, 'lco_confirm', FILTER_SANITIZE_URL); - $order_key = filter_input( INPUT_GET, 'key', FILTER_SANITIZE_STRING); + $ledyer_confirm = isset( $_GET['lco_confirm'] ) ? esc_url_raw( wp_unslash( $_GET['lco_confirm'] ) ) : ''; + $order_key = isset( $_GET['key'] ) ? sanitize_text_field( wp_unslash( $_GET['key'] ) ) : ''; if ( empty( $ledyer_confirm ) || empty( $order_key ) ) { return; From 43aa0938aefa6e55c4283968c3a2cb2bca3d1460 Mon Sep 17 00:00:00 2001 From: anyakro Date: Thu, 5 Sep 2024 10:48:59 +0200 Subject: [PATCH 04/14] Update with better filter solution After talk with Michael. --- classes/class-ledyer-confirmation.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/class-ledyer-confirmation.php b/classes/class-ledyer-confirmation.php index a98061d..a3046e0 100644 --- a/classes/class-ledyer-confirmation.php +++ b/classes/class-ledyer-confirmation.php @@ -32,8 +32,8 @@ public function actions() { * Confirm the order in Woo */ public function confirm_order() { - $ledyer_confirm = isset( $_GET['lco_confirm'] ) ? esc_url_raw( wp_unslash( $_GET['lco_confirm'] ) ) : ''; - $order_key = isset( $_GET['key'] ) ? sanitize_text_field( wp_unslash( $_GET['key'] ) ) : ''; + $ledyer_confirm = filter_input( INPUT_GET, 'lco_confirm', FILTER_SANITIZE_URL); + $order_key = filter_input( INPUT_GET, 'key', FILTER_SANITIZE_FULL_SPECIAL_CHARS); if ( empty( $ledyer_confirm ) || empty( $order_key ) ) { return; From 6ce1777ff0a4fa03dcaf7f4e90f956f4c08e4e05 Mon Sep 17 00:00:00 2001 From: anyakro Date: Thu, 5 Sep 2024 11:18:33 +0200 Subject: [PATCH 05/14] Fix spacing --- classes/class-ledyer-confirmation.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/class-ledyer-confirmation.php b/classes/class-ledyer-confirmation.php index a3046e0..ec86397 100644 --- a/classes/class-ledyer-confirmation.php +++ b/classes/class-ledyer-confirmation.php @@ -32,8 +32,8 @@ public function actions() { * Confirm the order in Woo */ public function confirm_order() { - $ledyer_confirm = filter_input( INPUT_GET, 'lco_confirm', FILTER_SANITIZE_URL); - $order_key = filter_input( INPUT_GET, 'key', FILTER_SANITIZE_FULL_SPECIAL_CHARS); + $ledyer_confirm = filter_input( INPUT_GET, 'lco_confirm', FILTER_SANITIZE_URL ); + $order_key = filter_input( INPUT_GET, 'key', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); if ( empty( $ledyer_confirm ) || empty( $order_key ) ) { return; From bd2dc6e80574638d8949d973ae8f83fcff42eae8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20H=C3=B6gefjord?= Date: Thu, 12 Sep 2024 09:02:04 +0200 Subject: [PATCH 06/14] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 6d06199..85ea342 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,7 @@ wp-content/themes/twenty*/ # ignore node dependency directories node_modules/ +/vendor/ # ignore log files and databases *.log From 7c41d6c90983a6a1c33d4589f17adb48c8003b5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20H=C3=B6gefjord?= Date: Thu, 12 Sep 2024 09:03:03 +0200 Subject: [PATCH 07/14] Create composer.lock --- composer.lock | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 composer.lock diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..ce49e8c --- /dev/null +++ b/composer.lock @@ -0,0 +1,18 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "ec2bc7f14e0adac7ccbe8b016e933a8d", + "packages": [], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.6.0" +} From c0d3f732de6b0fa7324f280e3019de14ca45dc73 Mon Sep 17 00:00:00 2001 From: anyakro Date: Fri, 13 Sep 2024 11:05:35 +0200 Subject: [PATCH 08/14] Set transaction id correctly --- classes/class-ledyer-lco-gateway.php | 2 +- includes/lco-functions.php | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/classes/class-ledyer-lco-gateway.php b/classes/class-ledyer-lco-gateway.php index 5680d1e..4a1785d 100644 --- a/classes/class-ledyer-lco-gateway.php +++ b/classes/class-ledyer-lco-gateway.php @@ -293,7 +293,7 @@ public function process_payment_handler( $order_id ) { $order->update_meta_data( '_wc_ledyer_session_id', $ledyer_order['id'] ); - $order->update_meta_data( '_transaction_id', $ledyer_order['orderId'] ); + $order->set_transaction_id( $ledyer_order['orderId'] ); $order->update_meta_data( '_ledyer_company_id', $ledyer_order['customer']['companyId'] ); diff --git a/includes/lco-functions.php b/includes/lco-functions.php index 327a5ab..edf72c3 100644 --- a/includes/lco-functions.php +++ b/includes/lco-functions.php @@ -199,6 +199,9 @@ function wc_ledyer_confirm_ledyer_order( $order_id ) { $payment_id = WC()->session->get( 'lco_wc_order_id' ); } + $ledyer_order = ledyer()->api->get_order_session( $payment_id ); + $order->set_transaction_id( $ledyer_order['orderId'] ); + if( null === $session_id ) { $session_id = WC()->session->get( 'lco_wc_session_id' ); } From 8181d8e785b69e9203512f606d19e2f3858883ad Mon Sep 17 00:00:00 2001 From: anyakro Date: Fri, 13 Sep 2024 13:30:42 +0200 Subject: [PATCH 09/14] Remove transaction id set too early --- classes/class-ledyer-lco-gateway.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/classes/class-ledyer-lco-gateway.php b/classes/class-ledyer-lco-gateway.php index 4a1785d..4f167de 100644 --- a/classes/class-ledyer-lco-gateway.php +++ b/classes/class-ledyer-lco-gateway.php @@ -293,8 +293,6 @@ public function process_payment_handler( $order_id ) { $order->update_meta_data( '_wc_ledyer_session_id', $ledyer_order['id'] ); - $order->set_transaction_id( $ledyer_order['orderId'] ); - $order->update_meta_data( '_ledyer_company_id', $ledyer_order['customer']['companyId'] ); $order->update_meta_data( '_ledyer_company_name', $company_name ); From 290ec9d54c57a871da79fc3fbf012224406c7e76 Mon Sep 17 00:00:00 2001 From: anyakro Date: Fri, 13 Sep 2024 13:52:14 +0200 Subject: [PATCH 10/14] Revert "Remove transaction id set too early" This reverts commit 8181d8e785b69e9203512f606d19e2f3858883ad. --- classes/class-ledyer-lco-gateway.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/classes/class-ledyer-lco-gateway.php b/classes/class-ledyer-lco-gateway.php index 4f167de..4a1785d 100644 --- a/classes/class-ledyer-lco-gateway.php +++ b/classes/class-ledyer-lco-gateway.php @@ -293,6 +293,8 @@ public function process_payment_handler( $order_id ) { $order->update_meta_data( '_wc_ledyer_session_id', $ledyer_order['id'] ); + $order->set_transaction_id( $ledyer_order['orderId'] ); + $order->update_meta_data( '_ledyer_company_id', $ledyer_order['customer']['companyId'] ); $order->update_meta_data( '_ledyer_company_name', $company_name ); From 2c69a6348930b31524fc7b7beea4bd09da5fe31e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20H=C3=B6gefjord?= Date: Wed, 25 Sep 2024 11:19:32 +0200 Subject: [PATCH 11/14] Update .distignore --- .distignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.distignore b/.distignore index d524e47..b7530d3 100644 --- a/.distignore +++ b/.distignore @@ -10,7 +10,10 @@ .editorconfig .distignore .gitignore +.nvmrc commitlint.config.js +composer.json +composer-lock.json Dockerfile Dockerfile-* docker-compose.phpunit.yml From 9e55230eb9a442cf053d740707f25ca749bc955b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20H=C3=B6gefjord?= Date: Tue, 1 Oct 2024 14:40:48 +0200 Subject: [PATCH 12/14] PHPCS --- classes/class-ledyer-main.php | 199 +++++++++++++++++++--------------- 1 file changed, 111 insertions(+), 88 deletions(-) diff --git a/classes/class-ledyer-main.php b/classes/class-ledyer-main.php index 74b942e..7deb3d9 100644 --- a/classes/class-ledyer-main.php +++ b/classes/class-ledyer-main.php @@ -25,7 +25,7 @@ class Ledyer_Checkout_For_WooCommerce { * * @var array */ - public $notices = []; + public $notices = array(); /** * Reference to credentials class. * @@ -51,21 +51,28 @@ class Ledyer_Checkout_For_WooCommerce { */ public $checkout; - const VERSION = '1.8.0'; - const SLUG = 'ledyer-checkout-for-woocommerce'; + const VERSION = '1.8.0'; + const SLUG = 'ledyer-checkout-for-woocommerce'; const SETTINGS = 'ledyer_checkout_for_woocommerce_settings'; public function actions() { - \add_action( 'plugins_loaded', [ $this, 'on_plugins_loaded' ] ); + \add_action( 'plugins_loaded', array( $this, 'on_plugins_loaded' ) ); \add_action( 'admin_init', array( $this, 'on_admin_init' ) ); - add_action( 'rest_api_init', function () { - register_rest_route( 'ledyer/v1', '/notifications/', array( - 'methods' => 'POST', - 'callback' => [ $this, 'handle_notification' ], - 'permission_callback' => '__return_true' - ) ); - } ); + add_action( + 'rest_api_init', + function () { + register_rest_route( + 'ledyer/v1', + '/notifications/', + array( + 'methods' => 'POST', + 'callback' => array( $this, 'handle_notification' ), + 'permission_callback' => '__return_true', + ) + ); + } + ); add_action( 'woocommerce_checkout_fields', @@ -78,110 +85,122 @@ public function actions() { ); add_action( 'schedule_process_notification', array( $this, 'process_notification' ), 10, 1 ); - } /** * Handles notification callbacks + * * @param $request * * @return \WP_REST_Response */ public function handle_notification( $request ) { - $request_body = json_decode( $request->get_body()); - $response = new \WP_REST_Response(); + $request_body = json_decode( $request->get_body() ); + $response = new \WP_REST_Response(); - if (json_last_error() !== JSON_ERROR_NONE) { + if ( json_last_error() !== JSON_ERROR_NONE ) { Logger::log( 'Request body isn\'t valid JSON string.' ); $response->set_status( 400 ); return $response; } $ledyer_event_type = $request_body->{'eventType'}; - $ledyer_order_id = $request_body->{'orderId'}; + $ledyer_order_id = $request_body->{'orderId'}; - if ($ledyer_event_type === NULL || $ledyer_order_id === NULL) { + if ( $ledyer_event_type === null || $ledyer_order_id === null ) { Logger::log( 'Request body doesn\'t hold orderId and eventType data.' ); $response->set_status( 400 ); return $response; } - $scheduleId = as_schedule_single_action(time() + 120, 'schedule_process_notification', array($ledyer_order_id) ); - Logger::log( 'Enqueued notification: ' . $ledyer_event_type . ", schedule-id:" . $scheduleId ); + $scheduleId = as_schedule_single_action( time() + 120, 'schedule_process_notification', array( $ledyer_order_id ) ); + Logger::log( 'Enqueued notification: ' . $ledyer_event_type . ', schedule-id:' . $scheduleId ); $response->set_status( 200 ); return $response; } public function process_notification( $ledyer_order_id ) { - Logger::log( 'process notification: ' . $ledyer_order_id); - - $orders = wc_get_orders( - array( - 'meta_query' => array( - array( - 'key' => '_wc_ledyer_order_id', - 'value' => $ledyer_order_id, - 'compare' => '=', - ) - ), - 'date_created' => '>' . ( time() - MONTH_IN_SECONDS ) - ) - ); - - $order_id = isset($orders[0]) ? $orders[0]->get_id() : null; - $order = wc_get_order( $order_id ); - - if ( !is_object( $order ) ) { - Logger::log('Could not find woo order with ledyer id: ' . $ledyer_order_id ); + Logger::log( 'process notification: ' . $ledyer_order_id ); + + $orders = wc_get_orders( + array( + 'meta_query' => array( + array( + 'key' => '_wc_ledyer_order_id', + 'value' => $ledyer_order_id, + 'compare' => '=', + ), + ), + 'date_created' => '>' . ( time() - MONTH_IN_SECONDS ), + ) + ); + + $order_id = isset( $orders[0] ) ? $orders[0]->get_id() : null; + $order = wc_get_order( $order_id ); + + if ( ! is_object( $order ) ) { + Logger::log( 'Could not find woo order with ledyer id: ' . $ledyer_order_id ); return; } $ledyer_payment_status = ledyer()->api->get_payment_status( $ledyer_order_id ); - if ( is_wp_error($ledyer_payment_status) ) { + if ( is_wp_error( $ledyer_payment_status ) ) { \Ledyer\Logger::log( 'Could not get ledyer payment status ' . $ledyer_order_id ); return; } $ackOrder = false; - switch( $ledyer_payment_status['status']) { + switch ( $ledyer_payment_status['status'] ) { case \LedyerPaymentStatus::paymentPending: - if ( !$order->has_status( array( 'on-hold', 'processing', 'completed' ) ) ) { - $note = sprintf( __( 'New payment created in Ledyer with Payment ID %1$s. %2$s', - 'ledyer-checkout-for-woocommerce' ), $ledyer_order_id, $ledyer_payment_status['note'] ); - $order->update_status('on-hold', $note); + if ( ! $order->has_status( array( 'on-hold', 'processing', 'completed' ) ) ) { + $note = sprintf( + __( + 'New payment created in Ledyer with Payment ID %1$s. %2$s', + 'ledyer-checkout-for-woocommerce' + ), + $ledyer_order_id, + $ledyer_payment_status['note'] + ); + $order->update_status( 'on-hold', $note ); $ackOrder = true; } break; case \LedyerPaymentStatus::paymentConfirmed: - if ( !$order->has_status( array( 'processing', 'completed' ) ) ) { - $note = sprintf( __( 'New payment created in Ledyer with Payment ID %1$s. %2$s', - 'ledyer-checkout-for-woocommerce' ), $ledyer_order_id, $ledyer_payment_status['note'] ); - $order->add_order_note($note); - $order->payment_complete($ledyer_order_id); + if ( ! $order->has_status( array( 'processing', 'completed' ) ) ) { + $note = sprintf( + __( + 'New payment created in Ledyer with Payment ID %1$s. %2$s', + 'ledyer-checkout-for-woocommerce' + ), + $ledyer_order_id, + $ledyer_payment_status['note'] + ); + $order->add_order_note( $note ); + $order->payment_complete( $ledyer_order_id ); $ackOrder = true; } break; case \LedyerPaymentStatus::orderCaptured: - $order->update_status('completed'); + $order->update_status( 'completed' ); break; case \LedyerPaymentStatus::orderRefunded: - $order->update_status('refunded'); + $order->update_status( 'refunded' ); break; case \LedyerPaymentStatus::orderCancelled: - $order->update_status('cancelled'); + $order->update_status( 'cancelled' ); break; } - if ($ackOrder) { + if ( $ackOrder ) { $response = ledyer()->api->acknowledge_order( $ledyer_order_id ); - if( is_wp_error( $response ) ) { - \Ledyer\Logger::log( 'Couldn\'t acknowledge order ' . $ledyer_order_id ); + if ( is_wp_error( $response ) ) { + \Ledyer\Logger::log( 'Couldn\'t acknowledge order ' . $ledyer_order_id ); return; } $ledyer_update_order = ledyer()->api->update_order_reference( $ledyer_order_id, array( 'reference' => $order->get_order_number() ) ); if ( is_wp_error( $ledyer_update_order ) ) { - \Ledyer\Logger::log( 'Couldn\'t set merchant reference ' . $order->get_order_number() ); + \Ledyer\Logger::log( 'Couldn\'t set merchant reference ' . $order->get_order_number() ); return; } } @@ -213,10 +232,13 @@ public function on_plugins_loaded() { load_plugin_textdomain( 'ledyer-checkout-for-woocommerce', false, LCO_WC_PLUGIN_NAME . '/languages' ); add_filter( 'woocommerce_payment_gateways', array( $this, 'add_gateways' ) ); - add_filter( 'plugin_action_links_' . plugin_basename( LCO_WC_MAIN_FILE ), array( - $this, - 'plugin_action_links' - ) ); + add_filter( + 'plugin_action_links_' . plugin_basename( LCO_WC_MAIN_FILE ), + array( + $this, + 'plugin_action_links', + ) + ); } /** @@ -225,29 +247,29 @@ public function on_plugins_loaded() { public function include_files() { include_once LCO_WC_PLUGIN_PATH . '/includes/lco-functions.php'; include_once LCO_WC_PLUGIN_PATH . '/includes/lco-types.php'; - include_once LCO_WC_PLUGIN_PATH . '/classes/class-ledyer-singleton.php'; - include_once LCO_WC_PLUGIN_PATH . '/classes/class-ledyer-logger.php'; - include_once LCO_WC_PLUGIN_PATH . '/classes/admin/class-ledyer-meta-box.php'; - include_once LCO_WC_PLUGIN_PATH . '/classes/requests/class-ledyer-request.php'; - include_once LCO_WC_PLUGIN_PATH . '/classes/requests/order/class-ledyer-request-order.php'; - include_once LCO_WC_PLUGIN_PATH . '/classes/requests/order/session/class-ledyer-create-order.php'; - include_once LCO_WC_PLUGIN_PATH . '/classes/requests/order/session/class-ledyer-get-order.php'; - include_once LCO_WC_PLUGIN_PATH . '/classes/requests/order/session/class-ledyer-update-order.php'; - include_once LCO_WC_PLUGIN_PATH . '/classes/requests/order/management/class-ledyer-acknowledge-order.php'; - include_once LCO_WC_PLUGIN_PATH . '/classes/requests/order/management/class-ledyer-get-order.php'; + include_once LCO_WC_PLUGIN_PATH . '/classes/class-ledyer-singleton.php'; + include_once LCO_WC_PLUGIN_PATH . '/classes/class-ledyer-logger.php'; + include_once LCO_WC_PLUGIN_PATH . '/classes/admin/class-ledyer-meta-box.php'; + include_once LCO_WC_PLUGIN_PATH . '/classes/requests/class-ledyer-request.php'; + include_once LCO_WC_PLUGIN_PATH . '/classes/requests/order/class-ledyer-request-order.php'; + include_once LCO_WC_PLUGIN_PATH . '/classes/requests/order/session/class-ledyer-create-order.php'; + include_once LCO_WC_PLUGIN_PATH . '/classes/requests/order/session/class-ledyer-get-order.php'; + include_once LCO_WC_PLUGIN_PATH . '/classes/requests/order/session/class-ledyer-update-order.php'; + include_once LCO_WC_PLUGIN_PATH . '/classes/requests/order/management/class-ledyer-acknowledge-order.php'; + include_once LCO_WC_PLUGIN_PATH . '/classes/requests/order/management/class-ledyer-get-order.php'; include_once LCO_WC_PLUGIN_PATH . '/classes/requests/order/management/class-ledyer-get-payment-status.php'; - include_once LCO_WC_PLUGIN_PATH . '/classes/requests/order/management/class-ledyer-update-order-reference.php'; - include_once LCO_WC_PLUGIN_PATH . '/classes/requests/helpers/class-ledyer-cart.php'; - include_once LCO_WC_PLUGIN_PATH . '/classes/requests/helpers/class-ledyer-woocommerce-bridge.php'; - include_once LCO_WC_PLUGIN_PATH . '/classes/class-ledyer-ajax.php'; - include_once LCO_WC_PLUGIN_PATH . '/classes/class-ledyer-api.php'; - include_once LCO_WC_PLUGIN_PATH . '/classes/class-ledyer-checkout.php'; - include_once LCO_WC_PLUGIN_PATH . '/classes/class-ledyer-confirmation.php'; - include_once LCO_WC_PLUGIN_PATH . '/classes/class-ledyer-credentials.php'; - include_once LCO_WC_PLUGIN_PATH . '/classes/class-ledyer-fields.php'; - include_once LCO_WC_PLUGIN_PATH . '/classes/class-ledyer-lco-gateway.php'; - include_once LCO_WC_PLUGIN_PATH . '/classes/class-ledyer-merchant-urls.php'; - include_once LCO_WC_PLUGIN_PATH . '/classes/class-ledyer-templates.php'; + include_once LCO_WC_PLUGIN_PATH . '/classes/requests/order/management/class-ledyer-update-order-reference.php'; + include_once LCO_WC_PLUGIN_PATH . '/classes/requests/helpers/class-ledyer-cart.php'; + include_once LCO_WC_PLUGIN_PATH . '/classes/requests/helpers/class-ledyer-woocommerce-bridge.php'; + include_once LCO_WC_PLUGIN_PATH . '/classes/class-ledyer-ajax.php'; + include_once LCO_WC_PLUGIN_PATH . '/classes/class-ledyer-api.php'; + include_once LCO_WC_PLUGIN_PATH . '/classes/class-ledyer-checkout.php'; + include_once LCO_WC_PLUGIN_PATH . '/classes/class-ledyer-confirmation.php'; + include_once LCO_WC_PLUGIN_PATH . '/classes/class-ledyer-credentials.php'; + include_once LCO_WC_PLUGIN_PATH . '/classes/class-ledyer-fields.php'; + include_once LCO_WC_PLUGIN_PATH . '/classes/class-ledyer-lco-gateway.php'; + include_once LCO_WC_PLUGIN_PATH . '/classes/class-ledyer-merchant-urls.php'; + include_once LCO_WC_PLUGIN_PATH . '/classes/class-ledyer-templates.php'; } /** @@ -279,6 +301,7 @@ public function set_settings() { /** * Get LCO setting by name + * * @param string $key * * @return mixed @@ -335,23 +358,23 @@ public function on_admin_init() { */ public function modify_checkout_fields( $checkout_fields ) { - if( ! is_checkout() ) { + if ( ! is_checkout() ) { return $checkout_fields; } - if( ! isset( WC()->session ) || empty( WC()->session->get('chosen_payment_method') ) ) { + if ( ! isset( WC()->session ) || empty( WC()->session->get( 'chosen_payment_method' ) ) ) { return $checkout_fields; } - if( 'lco' === WC()->session->get('chosen_payment_method') ) { + if ( 'lco' === WC()->session->get( 'chosen_payment_method' ) ) { foreach ( $checkout_fields['billing'] as $key => $field ) { - if( false !== stripos( $key, 'first_name' ) || false !== stripos( $key, 'last_name' ) ) { + if ( false !== stripos( $key, 'first_name' ) || false !== stripos( $key, 'last_name' ) ) { $checkout_fields['billing'][ $key ]['required'] = false; } } foreach ( $checkout_fields['shipping'] as $key => $field ) { - if( false !== stripos( $key, 'first_name' ) || false !== stripos( $key, 'last_name' ) ) { + if ( false !== stripos( $key, 'first_name' ) || false !== stripos( $key, 'last_name' ) ) { $checkout_fields['shipping'][ $key ]['required'] = false; } } From 22696edbc7a3d192546670c8144d4b13ae71aa99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20H=C3=B6gefjord?= Date: Tue, 1 Oct 2024 14:41:15 +0200 Subject: [PATCH 13/14] Version update (1.8.1) --- classes/class-ledyer-main.php | 2 +- ledyer-checkout-for-woocommerce.php | 18 +++++++++--------- readme.txt | 17 +++++++++++------ 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/classes/class-ledyer-main.php b/classes/class-ledyer-main.php index 7deb3d9..e26e376 100644 --- a/classes/class-ledyer-main.php +++ b/classes/class-ledyer-main.php @@ -51,7 +51,7 @@ class Ledyer_Checkout_For_WooCommerce { */ public $checkout; - const VERSION = '1.8.0'; + const VERSION = '1.8.1'; const SLUG = 'ledyer-checkout-for-woocommerce'; const SETTINGS = 'ledyer_checkout_for_woocommerce_settings'; diff --git a/ledyer-checkout-for-woocommerce.php b/ledyer-checkout-for-woocommerce.php index 58c39f2..45a8b3d 100644 --- a/ledyer-checkout-for-woocommerce.php +++ b/ledyer-checkout-for-woocommerce.php @@ -5,7 +5,7 @@ * Description: Ledyer Checkout payment gateway for WooCommerce. * Author: Maksimer/Ledyer * Author URI: https://www.maksimer.com/ - * Version: 1.8.0 + * Version: 1.8.1 * Text Domain: ledyer-checkout-for-woocommerce * Domain Path: /languages * @@ -39,8 +39,8 @@ * Required minimums and constants */ \define( 'LCO_WC_VERSION', Ledyer_Checkout_For_WooCommerce::VERSION ); -\define( 'LCO_WC_MIN_PHP_VER', '5.6.0' ); -\define( 'LCO_WC_MIN_WC_VER', '3.9.0' ); +\define( 'LCO_WC_MIN_PHP_VER', '7.4.0' ); +\define( 'LCO_WC_MIN_WC_VER', '5.6.0' ); \define( 'LCO_WC_MAIN_FILE', __FILE__ ); \define( 'LCO_WC_PLUGIN_NAME', dirname( plugin_basename( LCO_WC_MAIN_FILE ) ) ); \define( 'LCO_WC_PLUGIN_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) ); @@ -48,12 +48,12 @@ // Declare HPOS compatibility. add_action( - 'before_woocommerce_init', - function () { - if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) { - \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); - } - } + 'before_woocommerce_init', + function () { + if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) { + \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); + } + } ); function ledyer() { diff --git a/readme.txt b/readme.txt index 71b908c..767aa61 100644 --- a/readme.txt +++ b/readme.txt @@ -2,11 +2,16 @@ Contributors: maksimer, ledyer Tags: woocommerce, ledyer, ecommerce, e-commerce, checkout Donate link: https://ledyer.com -Requires at least: 4.0 -Tested up to: 6.3 -Requires PHP: 7.0 -WC requires at least: 4.0.0 -WC tested up to: 8.2.0 -Stable tag: 1.8.0 +Requires at least: 5.0 +Tested up to: 6.6.2 +Requires PHP: 7.4 +WC requires at least: 5.6.0 +WC tested up to: 9.3.3 +Stable tag: 1.8.1 License: GPLv3 or later License URI: http://www.gnu.org/licenses/gpl-3.0.html + +== Changelog == += 2024.10.01 - version 1.8.1 = +* Fix - Update deprecated sanitization. +* Fix - Confirm that the current Ledyer payment id is set as transaction id in WooCommerce after purchase. \ No newline at end of file From 8f271ce7b35b6630e01f88dc22fd62bff7832721 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20H=C3=B6gefjord?= Date: Tue, 1 Oct 2024 15:04:43 +0200 Subject: [PATCH 14/14] Update build-and-deploy.yml --- .github/workflows/build-and-deploy.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 230a786..d806f0e 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -17,13 +17,10 @@ jobs: dev: no php_version: 7.4 - - name: Install PNPM - uses: pnpm/action-setup@v2 - with: - run_install: true - - name: Build Assets - run: pnpm run build + run: | + npm ci + npm run build # Deploy the plugin to WordPress.org - name: WordPress Plugin Deploy