diff --git a/.wordpress-org/banner-1544x500.png b/.wordpress-org/banner-1544x500.png index 49797cb..e400343 100644 Binary files a/.wordpress-org/banner-1544x500.png and b/.wordpress-org/banner-1544x500.png differ diff --git a/.wordpress-org/banner-772x250.png b/.wordpress-org/banner-772x250.png index 50d4871..47ffc61 100644 Binary files a/.wordpress-org/banner-772x250.png and b/.wordpress-org/banner-772x250.png differ diff --git a/.wordpress-org/screenshot-1.png b/.wordpress-org/screenshot-1.png index 690a4c5..1ae8867 100644 Binary files a/.wordpress-org/screenshot-1.png and b/.wordpress-org/screenshot-1.png differ diff --git a/.wordpress-org/screenshot-2.png b/.wordpress-org/screenshot-2.png index c1939e5..ecbba4a 100644 Binary files a/.wordpress-org/screenshot-2.png and b/.wordpress-org/screenshot-2.png differ diff --git a/.wordpress-org/screenshot-3.png b/.wordpress-org/screenshot-3.png index e2dbe38..74cfade 100644 Binary files a/.wordpress-org/screenshot-3.png and b/.wordpress-org/screenshot-3.png differ diff --git a/.wordpress-org/screenshot-4.png b/.wordpress-org/screenshot-4.png index 77da4cf..db2292b 100644 Binary files a/.wordpress-org/screenshot-4.png and b/.wordpress-org/screenshot-4.png differ diff --git a/.wordpress-org/screenshot-5.png b/.wordpress-org/screenshot-5.png index 0b9c9a3..94d612e 100644 Binary files a/.wordpress-org/screenshot-5.png and b/.wordpress-org/screenshot-5.png differ diff --git a/.wordpress-org/screenshot-6.png b/.wordpress-org/screenshot-6.png index df54392..590a1cb 100644 Binary files a/.wordpress-org/screenshot-6.png and b/.wordpress-org/screenshot-6.png differ diff --git a/btcpay-greenfield-for-woocommerce.php b/btcpay-greenfield-for-woocommerce.php index baa097d..58ec8d5 100644 --- a/btcpay-greenfield-for-woocommerce.php +++ b/btcpay-greenfield-for-woocommerce.php @@ -7,12 +7,12 @@ * Author URI: https://btcpayserver.org * Text Domain: btcpay-greenfield-for-woocommerce * Domain Path: /languages - * Version: 2.4.0 + * Version: 2.4.1 * Requires PHP: 7.4 * Tested up to: 6.4 * Requires at least: 5.2 * WC requires at least: 6.0 - * WC tested up to: 8.4 + * WC tested up to: 8.5 */ use BTCPayServer\WC\Admin\Notice; @@ -26,7 +26,7 @@ defined( 'ABSPATH' ) || exit(); -define( 'BTCPAYSERVER_VERSION', '2.4.0' ); +define( 'BTCPAYSERVER_VERSION', '2.4.1' ); define( 'BTCPAYSERVER_VERSION_KEY', 'btcpay_gf_version' ); define( 'BTCPAYSERVER_PLUGIN_FILE_PATH', plugin_dir_path( __FILE__ ) ); define( 'BTCPAYSERVER_PLUGIN_URL', plugin_dir_url(__FILE__ ) ); @@ -41,7 +41,9 @@ public function __construct() { add_action('woocommerce_thankyou_btcpaygf_default', ['BTCPayServerWCPlugin', 'orderStatusThankYouPage'], 10, 1); add_action( 'wp_ajax_btcpaygf_modal_checkout', [$this, 'processAjaxModalCheckout'] ); + add_action( 'wp_ajax_btcpaygf_notifications', [$this, 'processAjaxNotification'] ); add_action( 'wp_ajax_nopriv_btcpaygf_modal_checkout', [$this, 'processAjaxModalCheckout'] ); + add_action( 'admin_enqueue_scripts', [$this, 'enqueueAdminScripts'] ); // Run the updates. \BTCPayServer\WC\Helper\UpdateManager::processUpdates(); @@ -61,6 +63,7 @@ function ($settings) { $this->dependenciesNotification(); $this->legacyPluginNotification(); $this->notConfiguredNotification(); + $this->submitReviewNotification(); } } @@ -90,6 +93,17 @@ public function includes(): void { } } + /** + * Add scripts to admin pages. + */ + public function enqueueAdminScripts(): void { + wp_enqueue_script('btcpaygf-notifications', plugin_dir_url(__FILE__) . 'assets/js/backend/notifications.js', ['jquery'], null, true); + wp_localize_script('btcpaygf-notifications', 'BTCPayNotifications', [ + 'ajax_url' => admin_url('admin-ajax.php'), + 'nonce' => wp_create_nonce('btcpaygf-notifications-nonce') + ]); + } + public static function initPaymentGateways($gateways): array { // We always load the default gateway that covers all payment methods available on BTCPayServer. $gateways[] = DefaultGateway::class; @@ -163,6 +177,21 @@ public function legacyPluginNotification() { } } + /** + * Shows a notice on the admin dashboard to periodically ask for a review. + */ + public function submitReviewNotification() { + if (!get_transient('btcpaygf_review_dismissed')) { + $reviewMessage = sprintf( + __( 'Thank you for using BTCPay for WooCommerce! If you like the plugin, we would love if you %1$sleave us a review%2$s.', 'btcpay-greenfield-for-woocommerce' ), + '', + '' + ); + + Notice::addNotice('info', $reviewMessage, true, 'btcpay-review-notice'); + } + } + /** * Handles the AJAX callback from the GlobalSettings form. Unfortunately with namespaces it seems to not work * to have this method on the GlobalSettings class. So keeping it here for the time being. @@ -232,6 +261,13 @@ public function processAjaxModalCheckout() { } } + public function processAjaxNotification() { + check_ajax_referer('btcpaygf-notifications-nonce', 'nonce'); + // Dismiss review notice for 30 days. + set_transient('btcpaygf_review_dismissed', true, DAY_IN_SECONDS * 30); + wp_send_json_success(); + } + public static function orderStatusThankYouPage($order_id) { if (!$order = wc_get_order($order_id)) { diff --git a/languages/btcpay-greenfield-for-woocommerce.pot b/languages/btcpay-greenfield-for-woocommerce.pot index 4737cb3..6214695 100644 --- a/languages/btcpay-greenfield-for-woocommerce.pot +++ b/languages/btcpay-greenfield-for-woocommerce.pot @@ -1,17 +1,17 @@ -# Copyright (C) 2023 BTCPay Server +# Copyright (C) 2024 BTCPay Server # This file is distributed under the same license as the BTCPay For Woocommerce V2 plugin. msgid "" msgstr "" -"Project-Id-Version: BTCPay For Woocommerce V2 2.4.0\n" +"Project-Id-Version: BTCPay For Woocommerce V2 2.4.1\n" "Report-Msgid-Bugs-To: https://woocommerce.com/my-account/create-a-ticket/\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"POT-Creation-Date: 2023-12-12T15:39:41+01:00\n" +"POT-Creation-Date: 2024-01-22T21:36:35+00:00\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"X-Generator: WP-CLI 2.7.1\n" +"X-Generator: WP-CLI 2.9.0\n" "language-team: LANGUAGE \n" "X-Domain: btcpay-greenfield-for-woocommerce\n" @@ -35,65 +35,69 @@ msgstr "" msgid "https://btcpayserver.org" msgstr "" -#: btcpay-greenfield-for-woocommerce.php:122 +#: btcpay-greenfield-for-woocommerce.php:135 msgid "Plugin not configured yet, please %1$sconfigure the plugin here%2$s" msgstr "" -#: btcpay-greenfield-for-woocommerce.php:140 +#: btcpay-greenfield-for-woocommerce.php:153 msgid "Your PHP version is %s but BTCPay Greenfield Payment plugin requires version 7.4+." msgstr "" -#: btcpay-greenfield-for-woocommerce.php:146 +#: btcpay-greenfield-for-woocommerce.php:159 msgid "WooCommerce seems to be not installed. Make sure you do before you activate BTCPayServer Payment Gateway." msgstr "" -#: btcpay-greenfield-for-woocommerce.php:152 +#: btcpay-greenfield-for-woocommerce.php:165 msgid "The PHP cURL extension is not installed. Make sure it is available otherwise this plugin will not work." msgstr "" -#: btcpay-greenfield-for-woocommerce.php:162 +#: btcpay-greenfield-for-woocommerce.php:175 msgid "Seems you have the old BTCPay for WooCommerce plugin installed. While it should work it is strongly recommended to not run both versions but rely on the maintained version (BTCPay Greenfield for WooCommerce)." msgstr "" -#: btcpay-greenfield-for-woocommerce.php:336 +#: btcpay-greenfield-for-woocommerce.php:186 +msgid "Thank you for using BTCPay for WooCommerce! If you like the plugin, we would love if you %1$sleave us a review%2$s." +msgstr "" + +#: btcpay-greenfield-for-woocommerce.php:370 msgid "Settings" msgstr "" -#: btcpay-greenfield-for-woocommerce.php:338 +#: btcpay-greenfield-for-woocommerce.php:372 msgid "Debug log" msgstr "" -#: btcpay-greenfield-for-woocommerce.php:340 +#: btcpay-greenfield-for-woocommerce.php:374 msgid "Docs" msgstr "" -#: btcpay-greenfield-for-woocommerce.php:342 +#: btcpay-greenfield-for-woocommerce.php:376 msgid "Support Chat" msgstr "" -#: btcpay-greenfield-for-woocommerce.php:382 +#: btcpay-greenfield-for-woocommerce.php:416 msgid "Error on verifiying redirected API wey with stored BTCPay Server url. Aborting API wizard. Please try again or do a manual setup." msgstr "" -#: btcpay-greenfield-for-woocommerce.php:404 +#: btcpay-greenfield-for-woocommerce.php:438 msgid "Successfully received api key and store id from BTCPay Server API. Please finish setup by saving this settings form." msgstr "" -#: btcpay-greenfield-for-woocommerce.php:408 -#: src/Admin/GlobalSettings.php:362 +#: btcpay-greenfield-for-woocommerce.php:442 +#: src/Admin/GlobalSettings.php:369 msgid "Successfully registered a new webhook on BTCPay Server." msgstr "" -#: btcpay-greenfield-for-woocommerce.php:412 -#: src/Admin/GlobalSettings.php:366 +#: btcpay-greenfield-for-woocommerce.php:446 +#: src/Admin/GlobalSettings.php:373 msgid "Could not register a new webhook on the store." msgstr "" -#: btcpay-greenfield-for-woocommerce.php:421 +#: btcpay-greenfield-for-woocommerce.php:455 msgid "Please make sure you only select one store on the BTCPay API authorization page." msgstr "" -#: btcpay-greenfield-for-woocommerce.php:426 +#: btcpay-greenfield-for-woocommerce.php:460 msgid "Error processing the data from BTCPay. Please try again." msgstr "" @@ -268,88 +272,97 @@ msgid "6 confirmations on-chain" msgstr "" #: src/Admin/GlobalSettings.php:210 -msgid "Modal checkout" +msgid "Protect order status" msgstr "" #: src/Admin/GlobalSettings.php:213 msgctxt "global_settings" -msgid "Opens a modal overlay on the checkout page instead of redirecting to BTCPay Server." +msgid "Protects order status from changing if it is already \"processing\" or \"completed\". This will protect against orders getting cancelled via webhook if they were paid in the meantime with another payment gateway. Default is ON." msgstr "" #: src/Admin/GlobalSettings.php:217 -msgid "Separate Payment Gateways" +msgid "Modal checkout" msgstr "" #: src/Admin/GlobalSettings.php:220 msgctxt "global_settings" -msgid "Make all supported and enabled payment methods available as their own payment gateway. This opens new possibilities like discounts for specific payment methods. See our full guide here" +msgid "Opens a modal overlay on the checkout page instead of redirecting to BTCPay Server." msgstr "" #: src/Admin/GlobalSettings.php:224 -msgid "Send customer data to BTCPayServer" +msgid "Separate Payment Gateways" msgstr "" #: src/Admin/GlobalSettings.php:227 msgctxt "global_settings" -msgid "If you want customer email, address, etc. sent to BTCPay Server enable this option. By default for privacy and GDPR reasons this is disabled." +msgid "Make all supported and enabled payment methods available as their own payment gateway. This opens new possibilities like discounts for specific payment methods. See our full guide here" msgstr "" #: src/Admin/GlobalSettings.php:231 -msgid "Sats-Mode" +msgid "Send customer data to BTCPayServer" msgstr "" #: src/Admin/GlobalSettings.php:234 msgctxt "global_settings" -msgid "Makes Satoshis/Sats available as currency \"SAT\" (can be found in WooCommerce->Settings->General) and handles conversion to BTC before creating the invoice on BTCPay." +msgid "If you want customer email, address, etc. sent to BTCPay Server enable this option. By default for privacy and GDPR reasons this is disabled." msgstr "" #: src/Admin/GlobalSettings.php:238 -msgid "Debug Log" +msgid "Sats-Mode" msgstr "" #: src/Admin/GlobalSettings.php:241 msgctxt "global_settings" +msgid "Makes Satoshis/Sats available as currency \"SAT\" (can be found in WooCommerce->Settings->General) and handles conversion to BTC before creating the invoice on BTCPay." +msgstr "" + +#: src/Admin/GlobalSettings.php:245 +msgid "Debug Log" +msgstr "" + +#: src/Admin/GlobalSettings.php:248 +msgctxt "global_settings" msgid "Enable logging View Logs" msgstr "" -#: src/Admin/GlobalSettings.php:273 +#: src/Admin/GlobalSettings.php:280 msgid "The provided API key scope is valid for multiple stores, please make sure to create one for a single store." msgstr "" -#: src/Admin/GlobalSettings.php:281 +#: src/Admin/GlobalSettings.php:288 msgid "The provided API key does not match the required permissions. Please make sure the following permissions are are given: %s" msgstr "" -#: src/Admin/GlobalSettings.php:295 +#: src/Admin/GlobalSettings.php:302 msgid "Your BTCPay Server is not fully synched yet. Until fully synched the checkout will not work." msgstr "" -#: src/Admin/GlobalSettings.php:304 +#: src/Admin/GlobalSettings.php:311 msgid "Your BTCPay Server version does not support refunds, please update to at least version 1.7.6 or newer." msgstr "" -#: src/Admin/GlobalSettings.php:310 +#: src/Admin/GlobalSettings.php:317 msgid "Your api key does not support refunds, if you want to use that feature you need to create a new API key with permission. See our guide here." msgstr "" -#: src/Admin/GlobalSettings.php:333 -#: src/Admin/GlobalSettings.php:354 +#: src/Admin/GlobalSettings.php:340 +#: src/Admin/GlobalSettings.php:361 msgid "Successfully setup manual webhook." msgstr "" -#: src/Admin/GlobalSettings.php:337 +#: src/Admin/GlobalSettings.php:344 msgid "Webhook already exists, skipping webhook creation." msgstr "" -#: src/Admin/GlobalSettings.php:379 +#: src/Admin/GlobalSettings.php:386 msgid "No wallet configured on your BTCPay Server store settings. Make sure to add at least one otherwise this plugin will not work." msgstr "" -#: src/Admin/GlobalSettings.php:385 +#: src/Admin/GlobalSettings.php:392 msgid "Exception loading wallet information (payment methods) from BTCPay Server: %s." msgstr "" -#: src/Admin/GlobalSettings.php:394 +#: src/Admin/GlobalSettings.php:401 msgid "Error fetching data for this API key from server. Please check if the key is valid. Error: %s" msgstr "" @@ -424,59 +437,63 @@ msgctxt "js" msgid "Payment aborted by you. Please try again or choose a different payment method." msgstr "" -#: src/Gateway/AbstractGateway.php:463 +#: src/Gateway/AbstractGateway.php:466 +msgid "Webhook (%s) received from BTCPay, but the order is already processing or completed, skipping to update order status. Please manually check if everything is alright." +msgstr "" + +#: src/Gateway/AbstractGateway.php:478 msgid "Invoice (partial) payment incoming (unconfirmed) after invoice was already expired." msgstr "" -#: src/Gateway/AbstractGateway.php:466 +#: src/Gateway/AbstractGateway.php:481 msgid "Invoice (partial) payment incoming (unconfirmed). Waiting for settlement." msgstr "" -#: src/Gateway/AbstractGateway.php:485 +#: src/Gateway/AbstractGateway.php:500 msgid "Invoice fully settled after invoice was already expired. Needs manual checking." msgstr "" -#: src/Gateway/AbstractGateway.php:490 +#: src/Gateway/AbstractGateway.php:505 msgid "(Partial) payment settled but invoice not settled yet (could be more transactions incoming). Needs manual checking." msgstr "" -#: src/Gateway/AbstractGateway.php:494 +#: src/Gateway/AbstractGateway.php:509 msgid "Invoice (partial) payment settled." msgstr "" -#: src/Gateway/AbstractGateway.php:504 +#: src/Gateway/AbstractGateway.php:519 msgid "Invoice payment received fully with overpayment, waiting for settlement." msgstr "" -#: src/Gateway/AbstractGateway.php:506 +#: src/Gateway/AbstractGateway.php:521 msgid "Invoice payment received fully, waiting for settlement." msgstr "" -#: src/Gateway/AbstractGateway.php:512 +#: src/Gateway/AbstractGateway.php:527 msgid "Invoice manually marked invalid." msgstr "" -#: src/Gateway/AbstractGateway.php:514 +#: src/Gateway/AbstractGateway.php:529 msgid "Invoice became invalid." msgstr "" -#: src/Gateway/AbstractGateway.php:520 +#: src/Gateway/AbstractGateway.php:535 msgid "Invoice expired but was paid partially, please check." msgstr "" -#: src/Gateway/AbstractGateway.php:523 +#: src/Gateway/AbstractGateway.php:538 msgid "Invoice expired." msgstr "" -#: src/Gateway/AbstractGateway.php:529 +#: src/Gateway/AbstractGateway.php:544 msgid "Invoice payment settled but was overpaid." msgstr "" -#: src/Gateway/AbstractGateway.php:532 +#: src/Gateway/AbstractGateway.php:547 msgid "Invoice payment settled." msgstr "" -#: src/Gateway/AbstractGateway.php:575 +#: src/Gateway/AbstractGateway.php:590 msgid "BTCPay invoice manually set to invalid because customer went back to checkout and changed payment gateway." msgstr "" diff --git a/readme.txt b/readme.txt index e1e39af..5da0eea 100644 --- a/readme.txt +++ b/readme.txt @@ -1,11 +1,11 @@ -=== BTCPay for WooCommerce V2 === +=== BTCPay Server - Accept Bitcoin payments in WooCommerce === Contributors: ndeet, kukks, nicolasdorier Donate link: https://btcpayserver.org/donate/ -Tags: bitcoin, btcpay, BTCPay Server, btcpayserver, WooCommerce, payment gateway, accept bitcoin, bitcoin plugin, bitcoin payment processor, bitcoin e-commerce, Lightning Network, Litecoin, cryptocurrency +Tags: Bitcoin, Lightning Network, BTCPay Server, WooCommerce, payment gateway, accept Bitcoin, Cryptocurrency, Crypto Requires at least: 5.2 Tested up to: 6.4 Requires PHP: 7.4 -Stable tag: 2.4.0 +Stable tag: 2.4.1 License: MIT License URI: https://github.com/btcpayserver/woocommerce-greenfield-plugin/blob/master/license.txt @@ -15,7 +15,7 @@ BTCPay Server is a free and open-source bitcoin payment processor which allows y = Accept Bitcoin payments in your WooCommerce powered WordPress site with BTCPay Server = -BTCPay Server for WooCommerce is a revolutionary, self-hosted, open-source payment gateway to accept Bitcoin payments. Our** seamless integration** with WooCommerce allows you to connect your self-hosted [BTCPay Server](https://btcpayserver.org) and start accepting Bitcoin payments in **just a few simple steps**. +BTCPay Server for WooCommerce is a revolutionary, self-hosted, open-source payment gateway to accept Bitcoin payments. Our** seamless integration** with WooCommerce allows you to connect your self-hosted [BTCPay Server](https://btcpayserver.org) and start accepting Bitcoin payments in **[just a few simple steps](https://docs.btcpayserver.org/WooCommerce)**. = Features: = @@ -31,7 +31,7 @@ BTCPay Server for WooCommerce is a revolutionary, self-hosted, open-source payme * **Lightning Network** integrated out of the box - instant, fast and low cost payments and payouts * **Reporting and accounting** - CSV exports * **Advanced invoice managemen**t and refunding integrated in the WooCommerce UI -* **Real-time exchange price tracking **for correct payment amounts +* **Real-time exchange price tracking** for correct payment amounts * **Versatile plugin system**: * Extend functionality according to your needs * Accept payments in altcoins through various plugins @@ -103,12 +103,12 @@ You'll find extensive documentation and answers to many of your questions on [BT == Screenshots == -1. The BTCPay Server invoice. Your customers will see this at the checkout. They can pay from their wallet by scanning a QR or copy/pasting it manually into the wallet. -2. Customizable plugin interface allows store owners to adjust store statuses according to their needs. -3. Customer will see the pay with Bitcoin button at the checkout.Text can be customized. -4. Example of successfully paid invoice. -5. Example of an easy-embeddable HTML donation payment button. -6. Example of the PoS app you can launch. +1. Provides a Bitcoin / Lightning Network (and other) payment gateway on checkout. +2. Your customers can pay by scanning the QR-Code with their wallet or copy and paste the receiving address. +3. After successful payment the customers will get redirected to the order page. The order will be marked as paid automatically. +4. On the settings form you can connect to your BTCPay Server instance by just entering the URL and clicking on "Generate API Key" button. +5. You will get redirected to your BTCPay Server instance and just need to confirm the permissions of the API key. You will get redirected back to the settings form and the webhook will get set up automatically. You are ready to go. +6. On BTCPay Server you have extensive reporting and accounting features. == Upgrade Notice == = 2.4.0 = @@ -116,7 +116,12 @@ You'll find extensive documentation and answers to many of your questions on [BT == Changelog == -= 2.4.0 :: 2023-12-12 = += 2.4.1 :: 2024-01-22 = +* Fix: Ensure order status is not cancelled if paid by other payment gateway. +* Show periodically notification to review the plugin. +* Updating readme.txt (fixing text, updating banner and screenshots) + += 2.4.0 :: 2023-12-15 = * Fix: Avoid error on InvoiceProcessing/InvoiceSettled event in case of paidOver property is missing. * New feature: Add basic support for WooCommerce cart and checkout blocks. Note: Works for default configuration; future versions will make it work with modal checkout and separate payment gateways too. diff --git a/resources/js/backend/notifications.js b/resources/js/backend/notifications.js new file mode 100644 index 0000000..e5c298b --- /dev/null +++ b/resources/js/backend/notifications.js @@ -0,0 +1,12 @@ +jQuery(document).ready(function($) { + jQuery(document).on('click', '.btcpay-review-notice button.notice-dismiss', function() { + $.ajax({ + url: BTCPayNotifications.ajax_url, + type: 'post', + data: { + action: 'btcpaygf_notifications', + nonce: BTCPayNotifications.nonce + } + }); + }); +}); diff --git a/src/Admin/GlobalSettings.php b/src/Admin/GlobalSettings.php index 4727d42..e1518f2 100644 --- a/src/Admin/GlobalSettings.php +++ b/src/Admin/GlobalSettings.php @@ -206,6 +206,13 @@ public function getGlobalSettings(): array 'type' => 'order_states', 'id' => 'btcpay_gf_order_states' ], + 'protect_orders' => [ + 'title' => __( 'Protect order status', 'btcpay-greenfield-for-woocommerce' ), + 'type' => 'checkbox', + 'default' => 'yes', + 'desc' => _x( 'Protects order status from changing if it is already "processing" or "completed". This will protect against orders getting cancelled via webhook if they were paid in the meantime with another payment gateway. Default is ON.', 'global_settings', 'btcpay-greenfield-for-woocommerce' ), + 'id' => 'btcpay_gf_protect_order_status' + ], 'modal_checkout' => [ 'title' => __( 'Modal checkout', 'btcpay-greenfield-for-woocommerce' ), 'type' => 'checkbox', diff --git a/src/Admin/Notice.php b/src/Admin/Notice.php index ab5069f..1512d50 100644 --- a/src/Admin/Notice.php +++ b/src/Admin/Notice.php @@ -8,13 +8,14 @@ class Notice { /** * Adds notice to the admin UI. */ - public static function addNotice( string $level, string $message, bool $dismissible = false): void { + public static function addNotice( string $level, string $message, bool $dismissible = false, ?string $customClass = null): void { add_action( 'admin_notices', - function () use ( $level, $message, $dismissible ) { - $dismiss = $dismissible ? ' is-dismissible' : ''; + function () use ( $level, $message, $dismissible, $customClass ) { + $classes = $customClass ? ' ' . $customClass : ''; + $classes .= $dismissible ? ' is-dismissible' : ''; ?> -
+
BTCPay Server: ' . wp_kses_post( $message ) ?>
getDefaultOrderStateMappings(); } + // Check if the order is already in a final state, if so do not update it if the orders are protected. + $protectedOrders = get_option('btcpay_gf_protect_order_status', 'no'); + + if ($protectedOrders === 'yes') { + // Check if the order status is either 'processing' or 'completed' + if ($order->has_status(array('processing', 'completed'))) { + $note = sprintf( + __('Webhook (%s) received from BTCPay, but the order is already processing or completed, skipping to update order status. Please manually check if everything is alright.', 'btcpay-greenfield-for-woocommerce'), + $webhookData->type + ); + $order->add_order_note($note); + return; + } + } + switch ($webhookData->type) { case 'InvoiceReceivedPayment': if ($webhookData->afterExpiration) { diff --git a/src/Helper/UpdateManager.php b/src/Helper/UpdateManager.php index ec8ab8c..231a666 100644 --- a/src/Helper/UpdateManager.php +++ b/src/Helper/UpdateManager.php @@ -7,7 +7,8 @@ class UpdateManager { private static $updates = [ - '1.0.3' => 'update-1.0.3.php' + '1.0.3' => 'update-1.0.3.php', + '2.4.1' => 'update-2.4.1.php' ]; /** diff --git a/updates/update-2.4.1.php b/updates/update-2.4.1.php new file mode 100644 index 0000000..b5fba32 --- /dev/null +++ b/updates/update-2.4.1.php @@ -0,0 +1,12 @@ +