Compare commits

..

4 Commits

43 changed files with 1105 additions and 23676 deletions

View File

@ -16,6 +16,7 @@ behat.yml
bitbucket-pipelines.yml
bin
.circleci/config.yml
composer.json
composer.lock
dependencies.yml
DOCKER_ENV

View File

@ -8,34 +8,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v3
- name: Install Composer dependencies
uses: php-actions/composer@v6
with:
dev: no
php_version: 8.0
php_version: 7.4
php_extensions: bcmath
- name: Install WP-CLI
run: |
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Set Execute Permissions for build_i18n.sh
run: chmod +x bin/build_i18n.sh
- name: Build assets and translation files
run: |
npm install
npm run build
- name: WordPress Plugin Deploy
id: deploy
uses: 10up/action-wordpress-plugin-deploy@stable
@ -45,7 +28,6 @@ jobs:
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
SLUG: btcpay-greenfield-for-woocommerce
- name: Upload release asset
uses: actions/upload-release-asset@v1
env:

2
.gitignore vendored
View File

@ -10,4 +10,4 @@ node_modules/
/vendor/
composer.lock
/generated/
/assets/js/

Binary file not shown.

Before

Width:  |  Height:  |  Size: 223 KiB

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 106 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 93 KiB

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 158 KiB

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 93 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 112 KiB

After

Width:  |  Height:  |  Size: 710 KiB

View File

@ -1,6 +1,6 @@
FROM wordpress:6.4-php8.2
FROM wordpress:6.1-php8.2
ENV WOOCOMMERCE_VERSION 8.4.0
ENV WOOCOMMERCE_VERSION 7.3.0
# Fetch WooCommerce.
RUN apt-get update \

46
Gruntfile.js Normal file
View File

@ -0,0 +1,46 @@
module.exports = function( grunt ) {
'use strict';
// Project configuration
grunt.initConfig( {
pkg: grunt.file.readJSON( 'package.json' ),
addtextdomain: {
options: {
textdomain: 'btcpay-greenfield-for-woocommerce',
},
update_all_domains: {
options: {
updateDomains: true
},
src: [ '*.php', '**/*.php', '!\.git/**/*', '!bin/**/*', '!node_modules/**/*', '!tests/**/*' ]
}
},
makepot: {
target: {
options: {
domainPath: '/languages',
exclude: [ '\.git/*', 'bin/*', 'node_modules/*', 'tests/*' ],
mainFile: 'btcpay-greenfield-for-woocommerce.php',
potFilename: 'btcpay-greenfield-for-woocommerce.pot',
potHeaders: {
poedit: true,
'x-poedit-keywordslist': true
},
type: 'wp-plugin',
updateTimestamp: true
}
}
},
} );
grunt.loadNpmTasks( 'grunt-wp-i18n' );
grunt.registerTask( 'default', [] );
grunt.registerTask( 'i18n', ['addtextdomain', 'makepot'] );
grunt.util.linefeed = '\n';
};

View File

@ -4,9 +4,3 @@
.btcpay-connection-error {
color: red;
}
.btcpay-review-dismiss {
margin-left: 20px;
}
.btcpay-review-dismiss-forever {
margin-left: 10px;
}

View File

@ -1,11 +0,0 @@
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/2000/svg" height="64" width="64" version="1.1"
x="0px" y="0px"
viewBox="0 0 64 64"
xml:space="preserve"
xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">
<g transform="translate(0.00630876,-0.00301984)">
<path fill="#f7931a" d="m63.033,39.744c-4.274,17.143-21.637,27.576-38.782,23.301-17.138-4.274-27.571-21.638-23.295-38.78,4.272-17.145,21.635-27.579,38.775-23.305,17.144,4.274,27.576,21.64,23.302,38.784z"/>
<path fill="#FFF" d="m46.103,27.444c0.637-4.258-2.605-6.547-7.038-8.074l1.438-5.768-3.511-0.875-1.4,5.616c-0.923-0.23-1.871-0.447-2.813-0.662l1.41-5.653-3.509-0.875-1.439,5.766c-0.764-0.174-1.514-0.346-2.242-0.527l0.004-0.018-4.842-1.209-0.934,3.75s2.605,0.597,2.55,0.634c1.422,0.355,1.679,1.296,1.636,2.042l-1.638,6.571c0.098,0.025,0.225,0.061,0.365,0.117-0.117-0.029-0.242-0.061-0.371-0.092l-2.296,9.205c-0.174,0.432-0.615,1.08-1.609,0.834,0.035,0.051-2.552-0.637-2.552-0.637l-1.743,4.019,4.569,1.139c0.85,0.213,1.683,0.436,2.503,0.646l-1.453,5.834,3.507,0.875,1.439-5.772c0.958,0.26,1.888,0.5,2.798,0.726l-1.434,5.745,3.511,0.875,1.453-5.823c5.987,1.133,10.489,0.676,12.384-4.739,1.527-4.36-0.076-6.875-3.226-8.515,2.294-0.529,4.022-2.038,4.483-5.155zm-8.022,11.249c-1.085,4.36-8.426,2.003-10.806,1.412l1.928-7.729c2.38,0.594,10.012,1.77,8.878,6.317zm1.086-11.312c-0.99,3.966-7.1,1.951-9.082,1.457l1.748-7.01c1.982,0.494,8.365,1.416,7.334,5.553z"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -5,10 +5,6 @@ jQuery(document).ready(function($) {
if (url.protocol !== 'https:' && url.protocol !== 'http:') {
return false;
}
if (url.hostname.endsWith('.local')) {
alert('You entered a .local domain which only works on your local network. Please make sure your BTCPay Server is reachable on the internet if you want to use it in production. Check the tooltip for this field for more information. Aborting.');
return false;
}
} catch (e) {
console.error(e);
return false;

View File

@ -73,24 +73,16 @@ jQuery(function ($) {
//console.log('BTCPay modal event: invoiceId: ' + event.data.invoiceId);
//console.log('BTCPay modal event: status: ' + event.data.status);
if (event.data.status) {
switch (event.data.status.toLowerCase()) {
switch (event.data.status) {
case 'complete':
case 'paid':
case 'processing':
case 'settled':
invoice_paid = true;
setTimeout(function() {
window.location = data.orderCompleteLink;
}, 3000);
window.location = data.orderCompleteLink;
break;
case 'expired':
window.btcpay.hideFrame();
submitError(BTCPayWP.textInvoiceExpired);
break;
case 'invalid':
window.btcpay.hideFrame();
submitError(BTCPayWP.textInvoiceInvalid);
break;
}
}
} else { // handle event.data "loaded" "closed"
@ -184,16 +176,12 @@ jQuery(function ($) {
var selected_gateway = $('form[name="checkout"] input[name="payment_method"]:checked').val();
unblockElement('.woocommerce-checkout-payment');
if (!selected_gateway) {
return;
}
// Always unbind first to prevent duplicate handlers.
checkout_form.off('checkout_place_order', submitOrder);
if (selected_gateway.startsWith('btcpaygf_')) {
// Bind our custom event handler to the checkout button.
checkout_form.on('checkout_place_order', submitOrder);
} else {
// Unbind custom event handlers.
checkout_form.off('checkout_place_order', submitOrder);
}
}

View File

@ -1,28 +0,0 @@
#!/usr/bin/env bash
# Check for required version.
WPCLI_VERSION=`wp cli version | cut -f2 -d' '`
if [ ${WPCLI_VERSION:0:1} -lt "2" -o ${WPCLI_VERSION:0:1} -eq "2" -a ${WPCLI_VERSION:2:1} -lt "1" ]; then
echo WP-CLI version 2.1.0 or greater is required to make JSON translation files
exit
fi
# HELPERS.
GREEN='\033[0;32m'
GREY='\033[0;38m'
NC='\033[0m' # No Color
UNDERLINE_START='\e[4m'
UNDERLINE_STOP='\e[0m'
# Substitute JS source references with build references.
for T in `find languages -name "*.pot"`
do
echo -e "\n${GREY}${UNDERLINE_START}Fixing references for: ${T}${UNDERLINE_STOP}${NC}"
sed \
-e 's/ resources\/js\/frontend\/[^:]*:/ assets\/frontend\/blocks.js:/gp' \
$T | uniq > $T-build
rm $T
mv $T-build $T
echo -e "${GREEN}Done${NC}"
done

View File

@ -7,27 +7,25 @@
* Author URI: https://btcpayserver.org
* Text Domain: btcpay-greenfield-for-woocommerce
* Domain Path: /languages
* Version: 2.8.0
* Requires PHP: 8.0
* Tested up to: 6.9
* Requires at least: 6.2
* Requires Plugins: woocommerce
* WC requires at least: 7.0
* WC tested up to: 10.7
* Version: 2.2.0
* Requires PHP: 7.4
* Tested up to: 6.3
* Requires at least: 5.2
* WC requires at least: 6.0
* WC tested up to: 8.0
*/
use BTCPayServer\WC\Admin\Notice;
use BTCPayServer\WC\Gateway\DefaultGateway;
use BTCPayServer\WC\Gateway\SeparateGateways;
use BTCPayServer\WC\Helper\GreenfieldApiAuthorization;
use BTCPayServer\WC\Helper\GreenfieldApiWebhook;
use BTCPayServer\WC\Helper\SatsMode;
use BTCPayServer\WC\Helper\GreenfieldApiHelper;
use BTCPayServer\WC\Helper\Logger;
defined( 'ABSPATH' ) || exit();
define( 'BTCPAYSERVER_VERSION', '2.8.0' );
define( 'BTCPAYSERVER_VERSION', '2.2.0' );
define( 'BTCPAYSERVER_VERSION_KEY', 'btcpay_gf_version' );
define( 'BTCPAYSERVER_PLUGIN_FILE_PATH', plugin_dir_path( __FILE__ ) );
define( 'BTCPAYSERVER_PLUGIN_URL', plugin_dir_url(__FILE__ ) );
@ -40,14 +38,9 @@ class BTCPayServerWCPlugin {
public function __construct() {
$this->includes();
add_action( 'woocommerce_thankyou_btcpaygf_default', ['BTCPayServerWCPlugin', 'orderStatusThankYouPage'], 10, 1);
add_action( 'woocommerce_order_details_after_order_table', ['BTCPayServerWCPlugin', 'orderDetailsCheckoutLink'], 10, 1);
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'] );
add_action( 'wp_ajax_btcpaygf_modal_blocks_checkout', [$this, 'processAjaxModalBlocksCheckout'] );
add_action( 'wp_ajax_nopriv_btcpaygf_modal_blocks_checkout', [$this, 'processAjaxModalBlocksCheckout'] );
// Run the updates.
\BTCPayServer\WC\Helper\UpdateManager::processUpdates();
@ -67,7 +60,6 @@ class BTCPayServerWCPlugin {
$this->dependenciesNotification();
$this->legacyPluginNotification();
$this->notConfiguredNotification();
$this->submitReviewNotification();
}
}
@ -97,18 +89,6 @@ class BTCPayServerWCPlugin {
}
}
/**
* Add scripts to admin pages.
*/
public function enqueueAdminScripts(): void {
wp_register_script('btcpaygf-notifications', plugin_dir_url(__FILE__) . 'assets/js/backend/notifications.js', ['jquery'], BTCPAYSERVER_VERSION);
wp_enqueue_script('btcpaygf-notifications');
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;
@ -154,8 +134,8 @@ class BTCPayServerWCPlugin {
*/
public function dependenciesNotification() {
// Check PHP version.
if ( version_compare( PHP_VERSION, '8.0', '<' ) ) {
$versionMessage = sprintf( __( 'Your PHP version is %s but BTCPay Greenfield Payment plugin requires version 8.0+.', 'btcpay-greenfield-for-woocommerce' ), PHP_VERSION );
if ( version_compare( PHP_VERSION, '7.4', '<' ) ) {
$versionMessage = sprintf( __( 'Your PHP version is %s but BTCPay Greenfield Payment plugin requires version 7.4+.', 'btcpay-greenfield-for-woocommerce' ), PHP_VERSION );
Notice::addNotice('error', $versionMessage);
}
@ -182,25 +162,6 @@ class BTCPayServerWCPlugin {
}
}
/**
* Shows a notice on the admin dashboard to periodically ask for a review.
*/
public function submitReviewNotification() {
if (!get_option('btcpay_gf_review_dismissed_forever') && !get_transient('btcpay_gf_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. %3$sRemind me later%4$s %5$sStop reminding me forever!%6$s', 'btcpay-greenfield-for-woocommerce' ),
'<a href="https://wordpress.org/support/plugin/btcpay-greenfield-for-woocommerce/reviews/?filter=5#new-post" target="_blank">',
'</a>',
'<button class="btcpay-review-dismiss">',
'</button>',
'<button class="btcpay-review-dismiss-forever">',
'</button>'
);
Notice::addNotice('info', $reviewMessage, false, '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.
@ -246,14 +207,13 @@ class BTCPayServerWCPlugin {
}
/**
* Handles the modal AJAX callback from the checkout page.
* Handles the AJAX callback from the Payment Request on the checkout page.
*/
public function processAjaxModalCheckout() {
Logger::debug('Entering ' . __METHOD__);
Logger::debug('$_POST: ' . print_r($_POST, true));
$nonce = sanitize_text_field($_POST['apiNonce']);
$nonce = $_POST['apiNonce'];
if ( ! wp_verify_nonce( $nonce, 'btcpay-nonce' ) ) {
wp_die('Unauthorized!', '', ['response' => 401]);
}
@ -271,81 +231,6 @@ class BTCPayServerWCPlugin {
}
}
/**
* Handles the modal AJAX callback on the blocks checkout page.
*/
public function processAjaxModalBlocksCheckout() {
Logger::debug('Entering ' . __METHOD__);
Logger::debug('$_POST: ' . print_r($_POST, true));
$nonce = sanitize_text_field($_POST['apiNonce']);
if ( ! wp_verify_nonce( $nonce, 'btcpay-nonce' ) ) {
wp_die('Unauthorized!', '', ['response' => 401]);
}
if ( get_option('btcpay_gf_modal_checkout') !== 'yes' ) {
wp_die('Modal checkout mode not enabled.', '', ['response' => 400]);
}
$selectedPaymentGateway = sanitize_text_field($_POST['paymentGateway']);
$orderId = sanitize_text_field($_POST['orderId']);
$order = wc_get_order($orderId);
if ($order) {
$orderPaymentMethod = $order->get_payment_method();
if (empty($orderPaymentMethod) || $orderPaymentMethod !== $selectedPaymentGateway) {
$order->set_payment_method($selectedPaymentGateway);
$order->save();
}
$payment_gateways = \WC_Payment_Gateways::instance();
if ($payment_gateway = $payment_gateways->payment_gateways()[$selectedPaymentGateway]) {
// Run the process_payment() method.
$result = $payment_gateway->process_payment($order->get_id());
if (isset($result['result']) && $result['result'] === 'success') {
wp_send_json_success($result);
} else {
wp_send_json_error($result);
}
} else {
wp_send_json_error('Payment gateway not found.');
}
} else {
wp_send_json_error('Order not found, stopped processing.');
}
wp_die();
}
/**
* Handles the AJAX callback to dismiss review notification.
*/
public function processAjaxNotification() {
if ( ! check_ajax_referer( 'btcpaygf-notifications-nonce', 'nonce' ) ) {
wp_die( 'Unauthorized!', '', [ 'response' => 401 ] );
}
$dismissForever = filter_var($_POST['dismiss_forever'], FILTER_VALIDATE_BOOL);
if ($dismissForever) {
update_option('btcpay_gf_review_dismissed_forever', true);
} else {
// Dismiss review notice for 30 days.
set_transient('btcpay_gf_review_dismissed', true, DAY_IN_SECONDS * 30);
}
wp_send_json_success();
}
/**
* Displays the payment status on the thank you page.
*/
public static function orderStatusThankYouPage($order_id)
{
if (!$order = wc_get_order($order_id)) {
@ -376,117 +261,14 @@ class BTCPayServerWCPlugin {
break;
}
$checkoutLink = self::getCheckoutLink($order);
echo "
<section class='woocommerce-order-payment-status'>
<h2 class='woocommerce-order-payment-status-title'>{$title}</h2>
<p><strong>{$statusDesc}</strong></p>
{$checkoutLink}
</section>
";
}
/**
* Displays the BTCPay checkout link on the customer order details page (My Account).
*/
public static function orderDetailsCheckoutLink($order)
{
if (!$order instanceof \WC_Order) {
return;
}
$payment_method = (string) $order->get_payment_method();
if (strpos($payment_method, 'btcpaygf_') !== 0) {
return;
}
$checkoutLink = self::getCheckoutLink($order);
$refundLinks = self::getRefundLinks($order);
if ($checkoutLink === '' && $refundLinks === '') {
return;
}
$title = _x('Payment information', 'btcpay-greenfield-for-woocommerce');
echo "
<section class='woocommerce-order-payment-status'>
<h2 class='woocommerce-order-payment-status-title'>{$title}</h2>
{$checkoutLink}
{$refundLinks}
</section>
";
}
/**
* Returns the BTCPay checkout link HTML for unpaid orders.
*/
private static function getCheckoutLink(\WC_Order $order): string
{
$url = $order->get_meta('BTCPay_redirect');
if (empty($url)) {
return '';
}
$label = esc_html_x('BTCPay Invoice:', 'btcpay-greenfield-for-woocommerce');
$escapedUrl = esc_url($url);
return "<p>{$label} <a href='{$escapedUrl}' target='_blank' rel='noreferrer'>{$escapedUrl}</a></p>";
}
/**
* Returns refund link(s) HTML if the refund visibility setting is enabled.
*/
private static function getRefundLinks(\WC_Order $order): string
{
if (get_option('btcpay_gf_refund_note_visible') !== 'yes') {
return '';
}
$refunds = $order->get_meta('BTCPay_refund', false);
if (empty($refunds)) {
return '';
}
$html = '';
$label = esc_html_x('Refund:', 'btcpay-greenfield-for-woocommerce');
foreach ($refunds as $refund) {
$value = $refund->value;
if (preg_match('/Link:\s*(.+)/i', $value, $matches)) {
$url = esc_url(trim($matches[1]));
if (!empty($url)) {
$html .= "<p>{$label} <a href='{$url}' target='_blank' rel='noreferrer'>{$url}</a></p>";
}
}
}
return $html;
}
/**
* Register WooCommerce Blocks support.
*/
public static function blocksSupport() {
if ( class_exists( '\Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType' ) ) {
add_action(
'woocommerce_blocks_payment_method_type_registration',
function( \Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) {
$payment_method_registry->register(new \BTCPayServer\WC\Blocks\DefaultGatewayBlocks());
if (get_option('btcpay_gf_separate_gateways') === 'yes') {
if ($separateGateways = \BTCPayServer\WC\Helper\GreenfieldApiHelper::supportedPaymentMethods()) {
foreach ($separateGateways as $gw) {
$gatewayId = 'btcpaygf_' . strtolower($gw['symbol']);
$payment_method_registry->register(
new \BTCPayServer\WC\Blocks\SeparateGatewayBlocks($gatewayId)
);
}
}
}
}
);
}
}
/**
* Gets the main plugin loader instance.
*
@ -520,6 +302,7 @@ add_action('init', function() {
flush_rewrite_rules(false);
update_option('btcpaygf_permalinks_flushed', 1);
}
});
// Action links on plugin overview.
@ -573,20 +356,9 @@ add_action( 'template_redirect', function() {
$btcPaySettingsUrl = admin_url('admin.php?page=wc-settings&tab=btcpay_settings');
$rawData = file_get_contents('php://input');
Logger::debug('Redirect payload: ' . print_r($rawData, true));
$data = json_decode( $rawData, true );
// Check if the payload api key comes from the actually requested server. Abort if not.
$storedUrl = get_option('btcpay_gf_url');
if (!GreenfieldApiHelper::checkApiKeyWorks($storedUrl, sanitize_text_field($_POST['apiKey']))) {
$messageAbort = __('Error on verifiying redirected API wey with stored BTCPay Server url. Aborting API wizard. Please try again or do a manual setup.', 'btcpay-greenfield-for-woocommerce');
Logger::debug($messageAbort);
Notice::addNotice('error', $messageAbort);
wp_redirect($btcPaySettingsUrl);
}
// Data does get submitted with url-encoded payload, so parse $_POST here.
// Seems data does get submitted with url-encoded payload, so parse $_POST here.
if (!empty($_POST)) {
$data['apiKey'] = sanitize_html_class($_POST['apiKey'] ?? null);
if (is_array($_POST['permissions'])) {
@ -603,20 +375,6 @@ add_action( 'template_redirect', function() {
update_option('btcpay_gf_store_id', $apiData->getStoreID());
update_option('btcpay_gf_connection_details', 'yes');
Notice::addNotice('success', __('Successfully received api key and store id from BTCPay Server API. Please finish setup by saving this settings form.', 'btcpay-greenfield-for-woocommerce'));
// Register a webhook.
if (GreenfieldApiWebhook::registerWebhook($storedUrl, $apiData->getApiKey(), $apiData->getStoreID())) {
$messageWebhookSuccess = __( 'Successfully registered a new webhook on BTCPay Server.', 'btcpay-greenfield-for-woocommerce' );
Notice::addNotice('success', $messageWebhookSuccess, true );
Logger::debug( $messageWebhookSuccess );
} else {
$messageWebhookError = __( 'Could not register a new webhook on the store.', 'btcpay-greenfield-for-woocommerce' );
Notice::addNotice('error', $messageWebhookError );
Logger::debug($messageWebhookError, true);
// Cleanup existing conf.
delete_option('btcpay_gf_webhook');
}
wp_redirect($btcPaySettingsUrl);
} else {
Notice::addNotice('error', __('Please make sure you only select one store on the BTCPay API authorization page.', 'btcpay-greenfield-for-woocommerce'));
@ -637,85 +395,3 @@ register_activation_hook( __FILE__, function() {
// Initialize payment gateways and plugin.
add_filter( 'woocommerce_payment_gateways', [ 'BTCPayServerWCPlugin', 'initPaymentGateways' ] );
add_action( 'plugins_loaded', 'init_btcpay_greenfield', 0 );
// Mark support for HPOS / COT.
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 );
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'cart_checkout_blocks', __FILE__, true );
}
} );
// Register WooCommerce Blocks integration.
add_action( 'woocommerce_blocks_loaded', [ 'BTCPayServerWCPlugin', 'blocksSupport' ] );
// Render BTCPay / Lightning icons in a dedicated column on the orders list.
function btcpaygf_render_order_list_icons( $order ): string {
if ( ! $order instanceof \WC_Abstract_Order ) {
return '';
}
$payment_method = (string) $order->get_payment_method();
if ( strpos( $payment_method, 'btcpaygf_' ) !== 0 ) {
return '';
}
$bitcoin_icon = '<img src="' . esc_url( BTCPAYSERVER_PLUGIN_URL . 'assets/images/bitcoin.svg' ) . '" alt="Bitcoin" title="Bitcoin" style="width:16px;height:16px;vertical-align:middle;" />';
$btcpay_icon = '<img src="' . esc_url( BTCPAYSERVER_PLUGIN_URL . 'assets/images/btcpay-logo.svg' ) . '" alt="BTCPay" title="BTCPay" style="width:16px;height:16px;vertical-align:middle;" />';
$ln_paid = $order->get_meta( 'BTCPay_BTC-LN_total_paid' );
$btc_paid = $order->get_meta( 'BTCPay_BTC_total_amount' );
$redirect = (string) $order->get_meta( 'BTCPay_redirect' );
$invoice_link = '';
if ( $redirect !== '' ) {
$invoice_url = str_replace( '/i/', '/invoices/', $redirect );
$receipt_svg = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:middle;"><path d="M4 2v20l3-2 3 2 3-2 3 2 3-2 3 2V2l-3 2-3-2-3 2-3-2-3 2-3-2z"/><path d="M8 9h8"/><path d="M8 13h8"/><path d="M8 17h5"/></svg>';
$invoice_link = ' <a href="' . esc_url( $invoice_url ) . '" target="_blank" rel="noopener noreferrer" title="' . esc_attr__( 'Open BTCPay invoice', 'btcpay-greenfield-for-woocommerce' ) . '" style="text-decoration:none;color:inherit;">' . $receipt_svg . '</a>';
}
if ( $ln_paid !== '' && (float) $ln_paid > 0 ) {
return $btcpay_icon . ' ' . $bitcoin_icon . ' <span title="Lightning Network">⚡</span>' . $invoice_link;
}
if ( $btc_paid !== '' ) {
return $btcpay_icon . ' ' . $bitcoin_icon . $invoice_link;
}
return $btcpay_icon . $invoice_link;
}
// Insert a column right after "status" on both HPOS and legacy screens.
function btcpaygf_insert_icon_column( array $columns ): array {
$new = [];
foreach ( $columns as $key => $label ) {
$new[ $key ] = $label;
if ( 'order_status' === $key || 'status' === $key ) {
$new['btcpaygf_icons'] = __( 'BTCPay', 'btcpay-greenfield-for-woocommerce' );
}
}
if ( ! isset( $new['btcpaygf_icons'] ) ) {
$new['btcpaygf_icons'] = __( 'BTCPay', 'btcpay-greenfield-for-woocommerce' );
}
return $new;
}
// HPOS orders list.
add_filter( 'woocommerce_shop_order_list_table_columns', 'btcpaygf_insert_icon_column' );
add_action( 'woocommerce_shop_order_list_table_custom_column', function( $column, $order ) {
if ( 'btcpaygf_icons' === $column ) {
echo btcpaygf_render_order_list_icons( $order );
}
}, 10, 2 );
// Legacy (post-based) orders list.
add_filter( 'manage_edit-shop_order_columns', 'btcpaygf_insert_icon_column' );
add_action( 'manage_shop_order_posts_custom_column', function( $column, $post_id ) {
if ( 'btcpaygf_icons' !== $column ) {
return;
}
$order = wc_get_order( $post_id );
if ( $order ) {
echo btcpaygf_render_order_list_icons( $order );
}
}, 10, 2 );

View File

@ -1,182 +0,0 @@
Find current version release changelog in readme.txt
Changelog for older versions:
= 2.7.5 :: 2026-04-13 =
* Fix: Refunds: remove XMR from payment methods to not break refunds
* Fix: Blocks checkout: Improve blocks checkout detection
* Fix: Blocks checkout: Allow re-trigger on abort
* Fix: Blocks checkout: Ensure customer data form validation can't get skipped
= 2.7.4 :: 2026-03-26 =
* Fix: Make sure modal checkout event handler does not get attached multiple times
* Maintenance: Update NodeJS and dependencies to v20
= 2.7.3 :: 2026-03-23 =
* Fix: Add warnings and docs on changing order status mapping of "paid" payment status
* Fix: Fix deprecation warnings of dynamic properties
* Maintenance: Add more debug logging for refunds
= 2.7.2 :: 2025-04-10 =
* Feature: Make icons visible on woocommerce blocks too
* Fix: Fix deprecation warnings of dynamic properties
* Fix: Formatting in readme.txt
= 2.7.1 :: 2024-11-22 =
* Fix: Update PHP library to v2.8.1 to fix a compatibility issue with refunds on BTCPay 2.0
= 2.7.0 :: 2024-09-04 =
* Feature: Add option to notify customers on refund order notes.
* Feature: BTCPay Server 2.0.0 compatibility.
* Fix: Make sure to not process orders if the assigned payment gateway is not one of BTCPay.
* Fix: Make sure payment methods are set on refunds.
* Fix: Wrong currency in refund comment.
* Fix: Deprecation warnings.
* Maintenance: Update NodeJS dependencies.
* Maintenance: Update PHP library to v2.7.0.
= 2.6.2 :: 2024-04-09 =
* Fix: Dismissing the review notification forever, finally.
= 2.6.1 :: 2024-04-04 =
* Fix: Error when processing full amount refunds.
* Fix: Show warning when bcmath extension is missing.
* Make it possible to dismiss the review notification forever.
= 2.6.0 :: 2024-02-27 =
* Update PHP BTCPay library to 2.3.0, minimum PHP version 8.0.
* Show warning when .local domain is used for BTCPay Server URL.
* Change BTCPay Server URL placeholder to official demo server.
= 2.5.0 :: 2024-01-31 =
* Fix: Formatting in readme.txt
* Add support for modal overlay for checkout blocks.
= 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.
= 2.3.1 :: 2023-10-20 =
* Fix: Ensure refunds text does not exceed API field limit.
= 2.3.0 :: 2023-09-06 =
* Support for high performance order storage (HPOS)
Note: This is opt-in but brings performance improvements. Follow instructions [here](https://github.com/woocommerce/woocommerce/wiki/High-Performance-Order-Storage-Upgrade-Recipe-Book#how-to-enable-hpos) if you want to use it.
= 2.2.3 :: 2023-08-22 =
* Automatically create webhook after redirect.
= 2.2.2 :: 2023-08-22 =
* Fix edgecase JS error on payment method selection.
= 2.2.1 :: 2023-08-17 =
* Add tooltip with webhook callback information
= 2.2.0 :: 2023-08-17 =
* Refactor settings UI and allow manual webhook secret entry. This allows 3rd party integrators limit their API keys scope and not include the webhook permission.
= 2.1.0 :: 2023-04-03 =
* New feature: Modal / Overlay checkout mode (no redirect to BTCPay Server)
= 2.0.0 :: 2023-03-20 =
* New feature: Add support for refunds.
Note: If you are upgrading from a version < 2.0 and you want to use refunds (via pull payments) you need to create a new API key with the "Create non-approved pull payments" which is available from BTCPay Server version 1.7.6.
See this link for more information: https://docs.btcpayserver.org/WooCommerce/#create-a-new-api-key
If you do NOT use refunds. You do NOT need to do anything, your existing API key and setup will continue to work as before.
= 1.1.5 :: 2023-03-08 =
* Fix: fix error when plugins override delete_transient function not returning boolean value
= 1.1.4 :: 2023-01-20 =
(redo deployment because of broken build pipe)
* Fix: fixed error on thank you page for separate payment methods.
* Dev: updating Docker to latest WP and WC versions.
* Dev: switch Github action for checkout to v3.
= 1.1.3 :: 2023-01-20 =
* Fix: fixed error on thank you page for separate payment methods.
* Dev: updating Docker to latest WP and WC versions.
* Dev: switch Github action for checkout to v3.
= 1.1.2 :: 2022-12-09 =
* Fix existing invoice check, wrongly marking invoice invalid on some use cases.
* Add check for cURL PHP extension.
* Make sure generated gateways exist on filesystem.
= 1.1.1 :: 2022-09-12 =
* Update missing metadata
= 1.1.0 :: 2022-09-12 =
* Feature: Sats-Mode, currency SAT for Satoshis/Sats now available.
* Settings, adding more links to docs.
= 1.0.3 :: 2022-08-17 =
* New order state: Payment received after invoice has been expired.
* Order metadata restructure, also list multiple payments separated.
* Add plugin action links for settings, logs, docs, support.
* Show notice when BTCPay Server is not fully synched yet.
* Add BTCPay Server info to debug log.
* Update Readme with development instructions.
* Docker: Update to latest WP and WC versions.
* Pin BTCPay Server PHP library stable version.
= 1.0.2 :: 2022-04-08 =
* Fix plugin meta docblock version update, pump version once more.
= 1.0.1 :: 2022-04-08 =
* Fix bug if the custom uploaded payment gateway icon is deleted from filesystem.
* Added information about Tor proxy for Umbrel and other self-hosted nodes to BTCPay settings page.
= 1.0.0 :: 2022-03-27 =
* Reflect stability with release 1.0.0.
* Create a new invoice (and mark the old invalid) if the user uses browser back button and changes the payment method (relevant for separate payment gateway feature).
* Added plugin loader singleton.
* Added missing docs link to separate payment gateways feature.
* Added checkbox to enable/disable gateway from within gateway settings.
* Updated README.md
= 0.2.5 :: 2022-03-13 =
* Load media library and JS only on payment gateway settings page.
= 0.2.4 :: 2022-03-04 =
* Fix possible problem with CamelCased headers on PHP-FPM and/or Nginx.
* Do not log hitting the cache on debug log to avoid clutter.
= 0.2.3 :: 2022-02-28 =
* Adding irrelevant GitHub workflow files to .distignore.
* Updating installation instructions with new material.
= 0.2.2 :: 2022-02-28 =
* Fix fatal error, make sure is_plugin_active() is available.
= 0.2.1 :: 2022-02-21 =
* Replace SVG by PNG logo to avoid scaling it on themes without proper CSS rules for payment gateway icons.
= 0.2.0 :: 2022-02-18 =
* Fix Cash on delivery, Bank transfer gateways missing after plugin activation.
= 0.1.10 :: 2022-02-15 =
* Make sure custom endpoint works without nice url enabled.
* Better description for setting.
* Update translation strings.
= 0.1.9 :: 2022-02-08 =
* Make sure custom endpoint works by flushing rewrite rules on plugin activation.
* Replacing usage of WC_Admin_Settings::addMessage() with our own.
= 0.1.1 :: 2022-01-13 =
* Admin notice if legacy plugin is installed
* Admin notice on missing WooCommerce / PHP version lower 7.4
* Minor changes metadata / readme.txt
= 0.1.0 :: 2022-01-13 =
* First public release for testing.

View File

@ -14,6 +14,6 @@
}
],
"require": {
"btcpayserver/btcpayserver-greenfield-php": "^2.0.0"
"btcpayserver/btcpayserver-greenfield-php": "^1.0.0"
}
}

View File

@ -5,7 +5,7 @@ services:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: no
restart: always
environment:
MYSQL_ROOT_PASSWORD: rootpress
MYSQL_DATABASE: wordpress
@ -21,7 +21,7 @@ services:
- ./:/var/www/html/wp-content/plugins/btcpay-greenfield-for-woocommerce
ports:
- "8821:80"
restart: no
restart: always
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: wordpress

View File

@ -1,18 +1,17 @@
# Copyright (C) 2026 BTCPay Server
# Copyright (C) 2022 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.7.5\n"
"Report-Msgid-Bugs-To: https://woocommerce.com/my-account/create-a-ticket/\n"
"Project-Id-Version: BTCPay For Woocommerce V2 0.1.10\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/btcpay-greenfield-for-woocommerce\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2026-04-20T09:58:11+00:00\n"
"POT-Creation-Date: 2022-02-15T11:29:35+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.7.1\n"
"language-team: LANGUAGE <EMAIL@ADDRESS>\n"
"X-Generator: WP-CLI 2.6.0\n"
"X-Domain: btcpay-greenfield-for-woocommerce\n"
#. Plugin Name of the plugin
@ -35,501 +34,272 @@ msgstr ""
msgid "https://btcpayserver.org"
msgstr ""
#: btcpay-greenfield-for-woocommerce.php:139
#: btcpay-greenfield-for-woocommerce.php:95
msgid "Plugin not configured yet, please %1$sconfigure the plugin here%2$s"
msgstr ""
#: btcpay-greenfield-for-woocommerce.php:157
msgid "Your PHP version is %s but BTCPay Greenfield Payment plugin requires version 8.0+."
#: btcpay-greenfield-for-woocommerce.php:113
msgid "Your PHP version is %s but BTCPay Greenfield Payment plugin requires version 7.4+."
msgstr ""
#: btcpay-greenfield-for-woocommerce.php:163
#: btcpay-greenfield-for-woocommerce.php:119
msgid "WooCommerce seems to be not installed. Make sure you do before you activate BTCPayServer Payment Gateway."
msgstr ""
#: btcpay-greenfield-for-woocommerce.php:169
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:179
#: btcpay-greenfield-for-woocommerce.php:130
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:190
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. %3$sRemind me later%4$s %5$sStop reminding me forever!%6$s"
#: btcpay-greenfield-for-woocommerce.php:274
msgid "Successfully received api key and store id from BTCPay Server API."
msgstr ""
#: btcpay-greenfield-for-woocommerce.php:458
msgid "Settings"
msgstr ""
#: btcpay-greenfield-for-woocommerce.php:460
msgid "Debug log"
msgstr ""
#: btcpay-greenfield-for-woocommerce.php:462
msgid "Docs"
msgstr ""
#: btcpay-greenfield-for-woocommerce.php:464
msgid "Support Chat"
msgstr ""
#: btcpay-greenfield-for-woocommerce.php:504
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:526
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:530
#: src/Admin/GlobalSettings.php:391
msgid "Successfully registered a new webhook on BTCPay Server."
msgstr ""
#: btcpay-greenfield-for-woocommerce.php:534
#: src/Admin/GlobalSettings.php:395
msgid "Could not register a new webhook on the store."
msgstr ""
#: btcpay-greenfield-for-woocommerce.php:543
#: btcpay-greenfield-for-woocommerce.php:277
msgid "Please make sure you only select one store on the BTCPay API authorization page."
msgstr ""
#: btcpay-greenfield-for-woocommerce.php:548
#: btcpay-greenfield-for-woocommerce.php:282
msgid "Error processing the data from BTCPay. Please try again."
msgstr ""
#: btcpay-greenfield-for-woocommerce.php:595
msgid "Open BTCPay invoice"
#: generated/BTCPay_GF_BTC.php:25
#: generated/BTCPay_GF_BTC_LightningNetwork.php:26
msgid "Token type"
msgstr ""
#: btcpay-greenfield-for-woocommerce.php:615
#: btcpay-greenfield-for-woocommerce.php:619
msgid "BTCPay"
#: generated/BTCPay_GF_BTC.php:32
#: generated/BTCPay_GF_BTC_LightningNetwork.php:33
msgid "Tokens of type promotion will not have a FIAT (USD, EUR, ..) exchange rate but counted as 1 per item quantity. See <a target=\"_blank\" href=\"https://docs.btcpayserver.org/FAQ/Integrations/#token-types\">here</a> for more details."
msgstr ""
#: src/Admin/GlobalSettings.php:24
msgid "BTCPay Settings"
msgstr ""
#: src/Admin/GlobalSettings.php:48
msgid "Warning: Changing this from the default \"On hold\" while \"Protect order status\" is enabled is not recommended as it could have unintended side effects. <a href=\"https://docs.btcpayserver.org/FAQ/Integrations/#overriding-the-paid-payment-status\" target=\"_blank\">Learn more</a>."
msgstr ""
#: src/Admin/GlobalSettings.php:58
msgid "The PHP bcmath extension is not installed. Make sure it is available otherwise the \"Sats-Mode\" will not work."
msgstr ""
#: src/Admin/GlobalSettings.php:67
msgctxt "global_settings"
msgid "BTCPay Server Payments settings"
msgid "BTCPay Server Payments Settings"
msgstr ""
#: src/Admin/GlobalSettings.php:88
#: src/Admin/GlobalSettings.php:64
msgctxt "global_settings"
msgid "BTCPay Server connected."
msgid "This plugin version is %s and your PHP version is %s. If you need assistance, please come on our chat <a href=\"https://chat.btcpayserver.org\" target=\"_blank\">https://chat.btcpayserver.org</a>. Thank you for using BTCPay!"
msgstr ""
#: src/Admin/GlobalSettings.php:90
msgctxt "global_settings"
msgid "Not connected. Please use the setup wizard above or check advanced settings to manually enter connection settings."
msgstr ""
#: src/Admin/GlobalSettings.php:103
msgctxt "global_settings"
msgid "Webhook setup automatically."
msgstr ""
#: src/Admin/GlobalSettings.php:105
msgctxt "global_settings"
msgid "No webhook setup, yet."
msgstr ""
#: src/Admin/GlobalSettings.php:109
msgctxt "global_settings"
msgid "Webhook setup manually with webhook secret."
msgstr ""
#: src/Admin/GlobalSettings.php:115
msgctxt "global_settings"
msgid "Connection settings"
msgstr ""
#: src/Admin/GlobalSettings.php:121
msgctxt "global_settings"
msgid "This plugin version is %s and your PHP version is %s. Check out our <a href=\"https://docs.btcpayserver.org/WooCommerce/\" target=\"_blank\">installation instructions</a>. If you need assistance, please come on our <a href=\"https://chat.btcpayserver.org\" target=\"_blank\">chat</a>. Thank you for using BTCPay!"
msgstr ""
#: src/Admin/GlobalSettings.php:125
#: src/Admin/GlobalSettings.php:68
msgctxt "global_settings"
msgid "BTCPay Server URL"
msgstr ""
#: src/Admin/GlobalSettings.php:131
#: src/Admin/GlobalSettings.php:74
msgctxt "global_settings"
msgid "URL/host to your BTCPay Server instance. Note: if you use a self hosted node like Umbrel, RaspiBlitz, myNode, etc. you will have to make sure your node is reachable from the internet. You can do that through <a href=\"https://docs.btcpayserver.org/Deployment/ReverseProxyToTor/\" target=\"_blank\">Tor</a>, <a href=\"https://docs.btcpayserver.org/Docker/cloudflare-tunnel/\" target=\"_blank\">Cloudflare</a> or <a href=\"https://docs.btcpayserver.org/Deployment/ReverseSSHtunnel/\" target=\"_blank\">SSH (advanced)</a>."
msgid "Url to your BTCPay Server instance."
msgstr ""
#: src/Admin/GlobalSettings.php:132
#: src/Admin/GlobalSettings.php:75
msgctxt "global_settings"
msgid "https://mainnet.demo.btcpayserver.org"
msgid "e.g. https://btcpayserver.example.com"
msgstr ""
#: src/Admin/GlobalSettings.php:137
msgctxt "global_settings"
msgid "Setup wizard"
msgstr ""
#: src/Admin/GlobalSettings.php:143
msgctxt "global_settings"
msgid "Setup status"
msgstr ""
#: src/Admin/GlobalSettings.php:149
msgid "Advanced settings"
msgstr ""
#: src/Admin/GlobalSettings.php:152
msgctxt "global_settings"
msgid "Show all connection settings / manual setup."
msgstr ""
#: src/Admin/GlobalSettings.php:156
#: src/Admin/GlobalSettings.php:80
msgctxt "global_settings"
msgid "BTCPay API Key"
msgstr ""
#: src/Admin/GlobalSettings.php:158
#: src/Admin/GlobalSettings.php:82
msgctxt "global_settings"
msgid "Your BTCPay API Key. If you do not have any yet use the setup wizard above."
msgid "Your BTCPay API Key. If you do not have any yet <a href=\"#\" class=\"btcpay-api-key-link\" target=\"_blank\">click here to generate API keys.</a>"
msgstr ""
#: src/Admin/GlobalSettings.php:163
#: src/Admin/GlobalSettings.php:87
msgctxt "global_settings"
msgid "Store ID"
msgstr ""
#: src/Admin/GlobalSettings.php:165
#: src/Admin/GlobalSettings.php:89
msgctxt "global_settings"
msgid "Your BTCPay Store ID. You can find it on the store settings page on your BTCPay Server."
msgstr ""
#: src/Admin/GlobalSettings.php:170
msgctxt "global_settings"
msgid "Webhook secret (optional)"
msgstr ""
#: src/Admin/GlobalSettings.php:172
msgctxt "global_settings"
msgid "If left empty an webhook will created automatically on save. Only fill out if you know the webhook secret and the webhook was created manually on BTCPay Server."
msgstr ""
#: src/Admin/GlobalSettings.php:173
msgctxt "global_settings"
msgid "The BTCPay webhook endpoint can be reached here: "
msgstr ""
#: src/Admin/GlobalSettings.php:178
msgctxt "global_settings"
msgid "Webhook status"
msgstr ""
#: src/Admin/GlobalSettings.php:189
msgctxt "global_settings"
msgid "General settings"
msgstr ""
#: src/Admin/GlobalSettings.php:201
#: src/Admin/GlobalSettings.php:97
msgctxt "global_settings"
msgid "You will be redirected to BTCPay to complete your purchase."
msgstr ""
#: src/Admin/GlobalSettings.php:208
#: src/Admin/GlobalSettings.php:104
msgctxt "global_settings"
msgid "An invoice becomes settled after the payment has this many confirmations..."
msgstr ""
#: src/Admin/GlobalSettings.php:210
#: src/Admin/GlobalSettings.php:106
msgctxt "global_settings"
msgid "Keep BTCPay Server store level configuration"
msgstr ""
#: src/Admin/GlobalSettings.php:211
#: src/Admin/GlobalSettings.php:107
msgctxt "global_settings"
msgid "0 confirmation on-chain"
msgstr ""
#: src/Admin/GlobalSettings.php:212
#: src/Admin/GlobalSettings.php:108
msgctxt "global_settings"
msgid "1 confirmation on-chain"
msgstr ""
#: src/Admin/GlobalSettings.php:213
#: src/Admin/GlobalSettings.php:109
msgctxt "global_settings"
msgid "2 confirmations on-chain"
msgstr ""
#: src/Admin/GlobalSettings.php:214
#: src/Admin/GlobalSettings.php:110
msgctxt "global_settings"
msgid "6 confirmations on-chain"
msgstr ""
#: src/Admin/GlobalSettings.php:225
msgid "Protect order status"
msgstr ""
#: src/Admin/GlobalSettings.php:228
msgctxt "global_settings"
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:232
msgid "Modal checkout"
msgstr ""
#: src/Admin/GlobalSettings.php:235
msgctxt "global_settings"
msgid "Opens a modal overlay on the checkout page instead of redirecting to BTCPay Server."
msgstr ""
#: src/Admin/GlobalSettings.php:239
#: src/Admin/GlobalSettings.php:121
msgid "Separate Payment Gateways"
msgstr ""
#: src/Admin/GlobalSettings.php:242
#: src/Admin/GlobalSettings.php:124
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 <a href=\"https://docs.btcpayserver.org/FAQ/Integrations/#how-to-configure-additional-token-support-separate-payment-gateways\" target=\"_blank\">full guide here</a>"
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 <a href=\"todo-input-link-here\" target=\"_blank\">full guide here</a>"
msgstr ""
#: src/Admin/GlobalSettings.php:246
#: src/Admin/GlobalSettings.php:128
msgid "Send customer data to BTCPayServer"
msgstr ""
#: src/Admin/GlobalSettings.php:249
#: src/Admin/GlobalSettings.php:131
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."
msgstr ""
#: src/Admin/GlobalSettings.php:253
msgid "Sats-Mode"
msgstr ""
#: src/Admin/GlobalSettings.php:256
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:260
msgid "Customer visible refunds"
msgstr ""
#: src/Admin/GlobalSettings.php:263
msgctxt "global_settings"
msgid "If enabled, it will show the order refund note also to the customer and trigger an email to customer with the refund link."
msgstr ""
#: src/Admin/GlobalSettings.php:267
#: src/Admin/GlobalSettings.php:135
msgid "Debug Log"
msgstr ""
#: src/Admin/GlobalSettings.php:270
#: src/Admin/GlobalSettings.php:138
msgctxt "global_settings"
msgid "Enable logging <a href=\"%s\" class=\"button\">View Logs</a>"
msgstr ""
#: src/Admin/GlobalSettings.php:302
#: src/Admin/GlobalSettings.php:192
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:310
#: src/Admin/GlobalSettings.php:200
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:324
msgid "Your BTCPay Server is not fully synched yet. Until fully synched the checkout will not work."
#: src/Admin/GlobalSettings.php:211
msgid "Reusing existing webhook."
msgstr ""
#: src/Admin/GlobalSettings.php:333
msgid "Your BTCPay Server version does not support refunds, please update to at least version 1.7.6 or newer."
#: src/Admin/GlobalSettings.php:217
msgid "Successfully registered a new webhook on BTCPay Server."
msgstr ""
#: src/Admin/GlobalSettings.php:339
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 <a href=\"https://docs.btcpayserver.org/WooCommerce/#create-a-new-api-key\" target=\"_blank\" rel=\"noreferrer\">here</a>."
#: src/Admin/GlobalSettings.php:221
msgid "Could not register a new webhook on the store."
msgstr ""
#: src/Admin/GlobalSettings.php:362
#: src/Admin/GlobalSettings.php:383
msgid "Successfully setup manual webhook."
msgstr ""
#: src/Admin/GlobalSettings.php:366
msgid "Webhook already exists, skipping webhook creation."
msgstr ""
#: src/Admin/GlobalSettings.php:408
#: src/Admin/GlobalSettings.php:231
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:414
msgid "Exception loading wallet information (payment methods) from BTCPay Server: %s."
msgstr ""
#: src/Admin/GlobalSettings.php:423
#: src/Admin/GlobalSettings.php:241
msgid "Error fetching data for this API key from server. Please check if the key is valid. Error: %s"
msgstr ""
#: src/Admin/GlobalSettings.php:440
msgid "The PHP bcmath extension is not installed. Make sure it is available otherwise the \"Sats-Mode\" will not work. Disabled Sats-Mode until requirements are met."
msgstr ""
#: src/Gateway/AbstractGateway.php:28
#: src/Gateway/AbstractGateway.php:25
#: src/Gateway/DefaultGateway.php:19
msgid "Proceed to BTCPay"
msgstr ""
#: src/Gateway/AbstractGateway.php:60
msgid "Use this image"
msgstr ""
#: src/Gateway/AbstractGateway.php:61
msgid "Enabled/Disabled"
msgid "Insert image"
msgstr ""
#: src/Gateway/AbstractGateway.php:63
msgid "Enable this payment gateway."
msgstr ""
#: src/Gateway/AbstractGateway.php:69
#: src/Gateway/AbstractGateway.php:67
#: src/Helper/SettingsHelper.php:12
msgid "Title"
msgstr ""
#: src/Gateway/AbstractGateway.php:71
#: src/Gateway/AbstractGateway.php:69
#: src/Helper/SettingsHelper.php:14
msgid "Controls the name of this payment method as displayed to the customer during checkout."
msgstr ""
#: src/Gateway/AbstractGateway.php:76
#: src/Gateway/AbstractGateway.php:74
#: src/Helper/SettingsHelper.php:19
msgid "Customer Message"
msgstr ""
#: src/Gateway/AbstractGateway.php:78
#: src/Gateway/AbstractGateway.php:76
#: src/Helper/SettingsHelper.php:21
msgid "Message to explain how the customer will be paying for the purchase."
msgstr ""
#: src/Gateway/AbstractGateway.php:95
#: src/Gateway/AbstractGateway.php:93
msgid "Can't process order. Please contact us if the problem persists."
msgstr ""
#: src/Gateway/AbstractGateway.php:215
msgid "Refund of order "
msgstr ""
#: src/Gateway/AbstractGateway.php:303
#: src/Gateway/AbstractGateway.php:160
msgid "Gateway Icon:"
msgstr ""
#: src/Gateway/AbstractGateway.php:308
#: src/Gateway/AbstractGateway.php:165
msgid "Upload or select icon"
msgstr ""
#: src/Gateway/AbstractGateway.php:314
#: src/Gateway/AbstractGateway.php:171
msgid "Remove image"
msgstr ""
#: src/Gateway/AbstractGateway.php:364
msgid "Use this image"
#: src/Gateway/AbstractGateway.php:268
msgid "Invoice payment received after invoice was already expired."
msgstr ""
#: src/Gateway/AbstractGateway.php:365
msgid "Insert image"
#: src/Gateway/AbstractGateway.php:272
msgid "Invoice (partial) payment received. Waiting for full payment."
msgstr ""
#: src/Gateway/AbstractGateway.php:437
msgctxt "js"
msgid "The invoice expired. Please try again, choose a different payment method or contact us if you paid but the payment did not confirm in time."
msgstr ""
#: src/Gateway/AbstractGateway.php:438
msgctxt "js"
msgid "The invoice is invalid. Please try again, choose a different payment method or contact us if you paid but the payment did not confirm in time."
msgstr ""
#: src/Gateway/AbstractGateway.php:439
msgctxt "js"
msgid "Payment aborted by you. Please try again or choose a different payment method."
msgstr ""
#: src/Gateway/AbstractGateway.php:440
msgctxt "js"
msgid "Error processing checkout. Please try again or choose another payment option."
msgstr ""
#: src/Gateway/AbstractGateway.php:441
msgctxt "js"
msgid "Processing…"
msgstr ""
#: src/Gateway/AbstractGateway.php:529
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:541
msgid "Invoice (partial) payment incoming (unconfirmed) after invoice was already expired."
msgstr ""
#: src/Gateway/AbstractGateway.php:544
msgid "Invoice (partial) payment incoming (unconfirmed). Waiting for settlement."
msgstr ""
#: src/Gateway/AbstractGateway.php:563
msgid "Invoice fully settled after invoice was already expired. Needs manual checking."
msgstr ""
#: src/Gateway/AbstractGateway.php:568
msgid "(Partial) payment settled but invoice not settled yet (could be more transactions incoming). Needs manual checking."
msgstr ""
#: src/Gateway/AbstractGateway.php:572
msgid "Invoice (partial) payment settled."
msgstr ""
#: src/Gateway/AbstractGateway.php:582
#: src/Gateway/AbstractGateway.php:282
msgid "Invoice payment received fully with overpayment, waiting for settlement."
msgstr ""
#: src/Gateway/AbstractGateway.php:584
#: src/Gateway/AbstractGateway.php:284
msgid "Invoice payment received fully, waiting for settlement."
msgstr ""
#: src/Gateway/AbstractGateway.php:590
#: src/Gateway/AbstractGateway.php:290
msgid "Invoice manually marked invalid."
msgstr ""
#: src/Gateway/AbstractGateway.php:592
#: src/Gateway/AbstractGateway.php:292
msgid "Invoice became invalid."
msgstr ""
#: src/Gateway/AbstractGateway.php:598
#: src/Gateway/AbstractGateway.php:298
msgid "Invoice expired but was paid partially, please check."
msgstr ""
#: src/Gateway/AbstractGateway.php:601
#: src/Gateway/AbstractGateway.php:301
msgid "Invoice expired."
msgstr ""
#: src/Gateway/AbstractGateway.php:607
#: src/Gateway/AbstractGateway.php:307
msgid "Invoice payment settled but was overpaid."
msgstr ""
#: src/Gateway/AbstractGateway.php:610
#: src/Gateway/AbstractGateway.php:310
msgid "Invoice payment settled."
msgstr ""
#: src/Gateway/AbstractGateway.php:654
msgid "BTCPay invoice manually set to invalid because customer went back to checkout and changed payment gateway."
msgstr ""
#: src/Gateway/DefaultGateway.php:22
msgid "BTCPay default gateway supporting all available tokens on your BTCPay store."
msgstr ""
@ -546,52 +316,47 @@ msgstr ""
msgid "This will override the default btcpay payment method (defaults to all supported by BTCPay Server) and enforce to tokens of type \"payment\". This is useful if you have enabled separate payment gateways and want full control on what is available on BTCPay Server payment page."
msgstr ""
#: src/Helper/OrderStates.php:36
#: src/Helper/OrderStates.php:34
msgctxt "global_settings"
msgid "New"
msgstr ""
#: src/Helper/OrderStates.php:37
#: src/Helper/OrderStates.php:35
msgctxt "global_settings"
msgid "Paid (unconfirmed)"
msgid "Paid"
msgstr ""
#: src/Helper/OrderStates.php:38
#: src/Helper/OrderStates.php:36
msgctxt "global_settings"
msgid "Settled"
msgstr ""
#: src/Helper/OrderStates.php:39
#: src/Helper/OrderStates.php:37
msgctxt "global_settings"
msgid "Settled (paid over)"
msgstr ""
#: src/Helper/OrderStates.php:40
#: src/Helper/OrderStates.php:38
msgctxt "global_settings"
msgid "Invalid"
msgstr ""
#: src/Helper/OrderStates.php:41
#: src/Helper/OrderStates.php:39
msgctxt "global_settings"
msgid "Expired"
msgstr ""
#: src/Helper/OrderStates.php:42
#: src/Helper/OrderStates.php:40
msgctxt "global_settings"
msgid "Expired with partial payment"
msgstr ""
#: src/Helper/OrderStates.php:43
msgctxt "global_settings"
msgid "Expired (paid late)"
msgstr ""
#: src/Helper/OrderStates.php:53
#: src/Helper/OrderStates.php:50
msgctxt "global_settings"
msgid "- no mapping / defaults -"
msgstr ""
#: src/Helper/OrderStates.php:93
#: src/Helper/OrderStates.php:90
msgctxt "global_settings"
msgid "By keeping default behavior for the \"Settled\" status you make sure that WooCommerce handles orders of virtual and downloadable products only properly and set those orders to \"complete\" instead of \"processing\" like for orders containing physical products."
msgstr ""
@ -599,7 +364,3 @@ msgstr ""
#: src/Helper/SettingsHelper.php:15
msgid "BTCPay (Bitcoin, Lightning Network, ...)"
msgstr ""
#: assets/frontend/blocks.js:58
msgid "Bitcoin / Lightning Network over BTCPay Server"
msgstr ""

22593
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,22 +1,16 @@
{
"name": "btcpay-greenfield-for-woocommerce",
"version": "0.1.0",
"author": "BTCPay Server Team",
"license": "MIT",
"devDependencies": {
"@woocommerce/dependency-extraction-webpack-plugin": "^4.0.0",
"@wordpress/scripts": "^31.7.0",
"copy-webpack-plugin": "^12.0.2",
"cross-env": "^7.0.3",
"webpack-cli": "^5.1.4"
"main": "Gruntfile.js",
"author": "BTCPay Server",
"scripts" : {
"build" : "grunt default" ,
"i18n" : "grunt i18n"
},
"scripts": {
"start": "wp-scripts start",
"build": "wp-scripts build && npm run i18n:build",
"i18n": "npm run i18n:build",
"i18n:build": "npm run i18n:pot && ./bin/build_i18n.sh",
"i18n:pot": "wp i18n make-pot --exclude=\"node_modules/,languages/,assets/\" --headers='{\"Report-Msgid-Bugs-To\":\"https://woocommerce.com/my-account/create-a-ticket/\", \"language-team\":\"LANGUAGE <EMAIL@ADDRESS>\"}' . languages/btcpay-greenfield-for-woocommerce.pot",
"i18n:json": "wp i18n make-json languages --no-purge",
"check-engines": "wp-scripts check-engines"
"devDependencies": {
"grunt": "~0.4.5",
"grunt-wp-i18n": "~0.5.0",
"grunt-wp-readme-to-markdown": "~1.0.0"
}
}

View File

@ -1,11 +1,11 @@
=== BTCPay Server - Accept Bitcoin payments in WooCommerce ===
=== BTCPay for WooCommerce V2 ===
Contributors: ndeet, kukks, nicolasdorier
Donate link: https://btcpayserver.org/donate/
Tags: Bitcoin, Lightning Network, BTCPay Server, WooCommerce, payment gateway
Requires at least: 5.9
Tested up to: 6.9
Requires PHP: 8.0
Stable tag: 2.8.0
Tags: bitcoin, btcpay, BTCPay Server, btcpayserver, WooCommerce, payment gateway, accept bitcoin, bitcoin plugin, bitcoin payment processor, bitcoin e-commerce, Lightning Network, Litecoin, cryptocurrency
Requires at least: 5.2
Tested up to: 6.3
Requires PHP: 7.4
Stable tag: 2.2.0
License: MIT
License URI: https://github.com/btcpayserver/woocommerce-greenfield-plugin/blob/master/license.txt
@ -13,42 +13,36 @@ BTCPay Server is a free and open-source bitcoin payment processor which allows y
== Description ==
= Accept Bitcoin payments in your WooCommerce powered WordPress site with BTCPay Server =
BTCPay Server is a free and open-source cryptocurrency payment processor which allows you to receive payments in Bitcoin and altcoins directly, with no fees, transaction cost or a middleman.
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)**.
BTCPay Server is a non-custodial invoicing system which eliminates the involvement of a third-party. Payments with BTCPay WooCommerce Plugin go directly to your wallet, which increases the privacy and security. Your private keys are never uploaded to the server. There is no address re-use since each invoice generates a new address deriving from your xPub key.
= Features: =
You can run BTCPay as a self-hosted solution on your own server, or use a third-party host.
* **Zero fees**: Enjoy a payment gateway with no fees. Yes, really!
* **Fully automated system**: BTCPay takes care of payments, invoice management and refunds automatically.
* **Display Bitcoin QR code at checkout**: Enhance customer experience with an easy and secure payment option.
* **No middlemen or KYC**:
* Direct, P2P payments (going directly to your wallet)
* Say goodbye to intermediaries and tedious paperwork
* Transaction information is only shared between you and your customer
* **Self-hosted infrastructure**: Maintain full control over your payment gateway.
* **Direct wallet payments**: Be your own bank with a self-custodial service.
* **Lightning Network** integrated out of the box - instant, fast and low cost payments and payouts
* **Reporting and accounting** - CSV exports
* **Advanced invoice management** and refunding integrated in the WooCommerce UI
* **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
* **Elegant checkout design**: Compatible with all Bitcoin wallets and enhanced with your store's logo and branding for a unique UX.
* **Point-of-sale** integration - Accept payments in your physical shops
* **Multilingual ready**: Serve a global audience right out of the box.
* **Top-notch privacy and security**: Protect your and your customers' data.
* **Community-driven support**: Get responsive assistance from our dedicated community ([Mattermost](http://chat.btcpayserver.org) or [Telegram](https://t.me/btcpayserver)).
* Extensive [documentation](https://docs.btcpayserver.org/WooCommerce) and [video](https://www.youtube.com/c/btcpayserver) tutorials
The non-profit [BTCPay Server Foundation ](https://foundation.btcpayserver.org)is committed to keeping this powerful payment gateway free forever. Our mission is to enable anyone to accept bitcoin regardless of financial, technical, social or political barriers.
The self-hosted solution allows you not only to attach an unlimited number of stores and use the Lightning Network but also become the payment processor for others.
* Direct, peer-to-peer Bitcoin and altcoin payments
* No transaction fees (other than mining fees by cryptocurrency network itself)
* No processing fees
* No middleman
* No KYC
* User has complete control over private keys
* Enhanced privacy (no address re-use, no IP leaks to third parties)
* Enhanced security
* Self-hosted
* SegWit, Taproot support
* Lightning Network support (LND, c-lightning and Eclair)
* Altcoin support
* Attach unlimited stores, process payments for friends
* Easy-embeddable Payment buttons
* Point of Sale app
== Installation ==
This plugin requires WooCommerce. Please make sure you have WooCommerce installed.
<img src="https://github.com/btcpayserver/btcpayserver-doc/blob/master/img/BTCPayWooCommerceInfoggraphic.png" alt="Infographic" />
To integrate BTCPay Server into an existing WooCommerce store, follow the steps below or check our official [installation instructions](https://docs.btcpayserver.org/WooCommerce/).
### 1. Deploy BTCPay Server (optional) ###
@ -101,30 +95,112 @@ You'll find extensive documentation and answers to many of your questions on [BT
== Screenshots ==
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.8.0 =
* Feature: On customer order details show link to BTCPay invoice checkout page to see receipt or retry payment in case of interruption
* Feature: On customer order details show link refunds (setting "Customer visible refunds" needs to be enabled)
* Feature: Make separate payment gateways work for WooCommerce blocks checkout
* Feature: Add column to order overview with icons for BTCPay, Bitcoin and LN payments and link to the invoice on BTCPay
Note: None of those features introduce breaking changes, you should be safe to upgrade.
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.
== Changelog ==
= 2.2.0 :: 2023-08-17 =
* Refactor settings UI and allow manual webhook secret entry
= 2.8.0 :: 2026-04-20 =
* Feature: On customer order details show link to BTCPay invoice checkout page to see receipt or retry payment in case of interruption
* Feature: On customer order details show link refunds (setting "Customer visible refunds" needs to be enabled)
* Feature: Make separate payment gateways work for WooCommerce blocks checkout
* Feature: Add column to order overview with icons for BTCPay, Bitcoin and LN payments and link to the invoice on BTCPay
= 2.1.0 :: 2023-04-03 =
* New feature: Modal / Overlay checkout mode (no redirect to BTCPay Server)
= 2.0.0 :: 2023-03-20 =
* New feature: Add support for refunds.
Changelog of older releases can be found [here](https://github.com/btcpayserver/woocommerce-greenfield-plugin/blob/master/changelog.txt)
Note: If you are upgrading from a version < 2.0 and you want to use refunds (via pull payments) you need to create a new API key with the "Create non-approved pull payments" which is available from BTCPay Server version 1.7.6.
See this link for more information: https://docs.btcpayserver.org/WooCommerce/#create-a-new-api-key
If you do NOT use refunds. You do NOT need to do anything, your existing API key and setup will continue to work as before.
= 1.1.5 :: 2023-03-08 =
* Fix: fix error when plugins override delete_transient function not returning boolean value
= 1.1.4 :: 2023-01-20 =
(redo deployment because of broken build pipe)
* Fix: fixed error on thank you page for separate payment methods.
* Dev: updating Docker to latest WP and WC versions.
* Dev: switch Github action for checkout to v3.
= 1.1.3 :: 2023-01-20 =
* Fix: fixed error on thank you page for separate payment methods.
* Dev: updating Docker to latest WP and WC versions.
* Dev: switch Github action for checkout to v3.
= 1.1.2 :: 2022-12-09 =
* Fix existing invoice check, wrongly marking invoice invalid on some use cases.
* Add check for cURL PHP extension.
* Make sure generated gateways exist on filesystem.
= 1.1.1 :: 2022-09-12 =
* Update missing metadata
= 1.1.0 :: 2022-09-12 =
* Feature: Sats-Mode, currency SAT for Satoshis/Sats now available.
* Settings, adding more links to docs.
= 1.0.3 :: 2022-08-17 =
* New order state: Payment received after invoice has been expired.
* Order metadata restructure, also list multiple payments separated.
* Add plugin action links for settings, logs, docs, support.
* Show notice when BTCPay Server is not fully synched yet.
* Add BTCPay Server info to debug log.
* Update Readme with development instructions.
* Docker: Update to latest WP and WC versions.
* Pin BTCPay Server PHP library stable version.
= 1.0.2 :: 2022-04-08 =
* Fix plugin meta docblock version update, pump version once more.
= 1.0.1 :: 2022-04-08 =
* Fix bug if the custom uploaded payment gateway icon is deleted from filesystem.
* Added information about Tor proxy for Umbrel and other self-hosted nodes to BTCPay settings page.
= 1.0.0 :: 2022-03-27 =
* Reflect stability with release 1.0.0.
* Create a new invoice (and mark the old invalid) if the user uses browser back button and changes the payment method (relevant for separate payment gateway feature).
* Added plugin loader singleton.
* Added missing docs link to separate payment gateways feature.
* Added checkbox to enable/disable gateway from within gateway settings.
* Updated README.md
= 0.2.5 :: 2022-03-13 =
* Load media library and JS only on payment gateway settings page.
= 0.2.4 :: 2022-03-04 =
* Fix possible problem with CamelCased headers on PHP-FPM and/or Nginx.
* Do not log hitting the cache on debug log to avoid clutter.
= 0.2.3 :: 2022-02-28 =
* Adding irrelevant GitHub workflow files to .distignore.
* Updating installation instructions with new material.
= 0.2.2 :: 2022-02-28 =
* Fix fatal error, make sure is_plugin_active() is available.
= 0.2.1 :: 2022-02-21 =
* Replace SVG by PNG logo to avoid scaling it on themes without proper CSS rules for payment gateway icons.
= 0.2.0 :: 2022-02-18 =
* Fix Cash on delivery, Bank transfer gateways missing after plugin activation.
= 0.1.10 :: 2022-02-15 =
* Make sure custom endpoint works without nice url enabled.
* Better description for setting.
* Update translation strings.
= 0.1.9 :: 2022-02-08 =
* Make sure custom endpoint works by flushing rewrite rules on plugin activation.
* Replacing usage of WC_Admin_Settings::addMessage() with our own.
= 0.1.1 :: 2022-01-13 =
* Admin notice if legacy plugin is installed
* Admin notice on missing WooCommerce / PHP version lower 7.4
* Minor changes metadata / readme.txt
= 0.1.0 :: 2022-01-13 =
* First public release for testing.

View File

@ -1,31 +0,0 @@
jQuery(document).ready(function($) {
jQuery(document).on('click', '.btcpay-review-notice button.btcpay-review-dismiss', function(e) {
e.preventDefault();
$.ajax({
url: BTCPayNotifications.ajax_url,
type: 'post',
data: {
action: 'btcpaygf_notifications',
nonce: BTCPayNotifications.nonce
},
success: function(data) {
jQuery('.btcpay-review-notice').remove();
}
});
});
jQuery(document).on('click', '.btcpay-review-notice button.btcpay-review-dismiss-forever', function(e) {
e.preventDefault();
$.ajax({
url: BTCPayNotifications.ajax_url,
type: 'post',
data: {
action: 'btcpaygf_notifications',
nonce: BTCPayNotifications.nonce,
dismiss_forever: true
},
success: function(data) {
jQuery('.btcpay-review-notice').remove();
}
});
});
});

View File

@ -1,23 +0,0 @@
jQuery(document).ready(function($) {
var processingSelect = $('select[name="btcpay_gf_order_states[Processing]"]');
var protectOrdersCheckbox = $('#btcpay_gf_protect_order_status');
var defaultValue = 'wc-on-hold';
var warningId = 'btcpay-processing-state-warning';
function updateWarning() {
$('#' + warningId).remove();
if (protectOrdersCheckbox.is(':checked') && processingSelect.val() !== defaultValue) {
var warning = '<div id="' + warningId + '" class="btcpay-processing-warning" style="color: #d63638; margin-top: 5px;">' +
BTCPayOrderStatesWarning.warningText +
'</div>';
processingSelect.after(warning);
}
}
processingSelect.on('change', updateWarning);
protectOrdersCheckbox.on('change', updateWarning);
// Check on page load.
updateWarning();
});

View File

@ -1,226 +0,0 @@
// Add debouncing to avoid infinite loop.
let isProcessingOrder = false;
let lastExecutionTime = 0;
const debounceInterval = 1000;
let invoiceCreatedForOrder = null;
let originalButtonText = null;
const setButtonProcessing = function (processing) {
const textEl = document.querySelector('.wc-block-components-checkout-place-order-button__text');
if (!textEl) return;
if (processing) {
originalButtonText = textEl.textContent;
textEl.textContent = BTCPayWP.textProcessingButton || 'Processing…';
} else if (originalButtonText) {
textEl.textContent = originalButtonText;
originalButtonText = null;
}
};
/**
* Subscribe to the checkout store and listen to place order button event,
* which changes emits the isBeforeProcessing() event.
*/
wp.data.subscribe(() => {
const now = Date.now();
// Check if the function was executed recently.
if (now - lastExecutionTime < debounceInterval) {
return;
}
const isBeforeProcessing = wp.data.select(wc.wcBlocksData.CHECKOUT_STORE_KEY).isBeforeProcessing();
// Check the payment method on placing the order.
if (isBeforeProcessing && !isProcessingOrder) {
//console.log('Checkout is before processing. Run your custom code here.');
isProcessingOrder = true; // Set the flag to avoid re-triggering.
lastExecutionTime = now; // Update the last execution time.
const store = wp.data.select(wc.wcBlocksData.PAYMENT_STORE_KEY);
const currentState = store.getState();
const activePM = currentState.activePaymentMethod;
//console.log('current payment method:');
//console.log(activePM);
if (activePM.startsWith('btcpaygf_')) {
//console.log('BTCPay is selected');
setButtonProcessing(true);
// Check for validation errors before proceeding.
// This ensures required fields (address, email, etc.) are filled in.
const validationStore = wp.data.select(wc.wcBlocksData.VALIDATION_STORE_KEY);
if (validationStore && validationStore.hasValidationErrors()) {
// Make all validation errors visible to the user.
wp.data.dispatch(wc.wcBlocksData.VALIDATION_STORE_KEY).showAllValidationErrors();
isProcessingOrder = false;
return;
}
// Make sure the order exists and invoice is created.
let responseData = blocksProcessOrder(activePM);
//console.log(responseData);
if (responseData) {
//console.log('got response: ');
//console.log(responseData);
// Reset checkout to idle to prevent WooCommerce blocks from also
// sending its own REST checkout request (which would call
// process_payment a second time and create a duplicate invoice).
resetCheckout();
blocksShowBTCPayModal(responseData);
// Keep isProcessingOrder = true while modal is open to prevent duplicate invoices.
return false;
} else {
blocksSubmitError(BTCPayWP.textProcessingError);
isProcessingOrder = false;
return false;
}
}
return true;
}
});
/**
* Trigger ajax request to create order object and assign an invoice id.
*/
const blocksProcessOrder = function (paymentGateway) {
//console.log('Triggered processOrderBlocks()');
let responseData = null;
// Block the UI.
//blockElement('.woocommerce-checkout-payment');
const checkout = wp.data.select(wc.wcBlocksData.CHECKOUT_STORE_KEY);
const orderId = checkout.getOrderId();
// Prevent duplicate invoice creation for the same order.
if (orderId && orderId === invoiceCreatedForOrder) {
return null;
}
// Prepare form data.
let data = {
'action': 'btcpaygf_modal_blocks_checkout',
'orderId': orderId,
'paymentGateway': paymentGateway,
'apiNonce': BTCPayWP.apiNonce,
};
//console.log(data);
// We need to make sure the order processing worked before returning from this function.
jQuery.ajaxSetup({async: false});
jQuery.post(wc_add_to_cart_params.ajax_url, data, function (response) {
//console.log('Received response when processing order: ');
//console.log(response);
if (response.data.invoiceId) {
invoiceCreatedForOrder = orderId;
responseData = response.data;
} else {
///unblockElement('.woocommerce-checkout-payment');
// Show errors.
if (response.data) {
blocksSubmitError(response.data);
} else {
blocksSubmitError(BTCPayWP.textProcessingError); // eslint-disable-line max-len
}
}
}).fail(function () {
///unblockElement('.woocommerce-checkout-payment');
blocksSubmitError(BTCPayWP.textProcessingError);
console.error('Error on ajax request 2');
});
// Reenable async.
jQuery.ajaxSetup({async: true});
return responseData;
};
/**
* Show the BTCPay modal and listen to events sent by BTCPay server.
*/
const blocksShowBTCPayModal = function (data) {
//console.log('Triggered blocksShowBTCPModal()');
if (data.invoiceId !== undefined) {
window.btcpay.setApiUrlPrefix(BTCPayWP.apiUrl);
window.btcpay.onModalWillEnter(function () {
setButtonProcessing(false);
});
window.btcpay.showInvoice(data.invoiceId);
}
let invoice_paid = false;
window.btcpay.onModalReceiveMessage(function (event) {
if (isObject(event.data)) {
//console.log('BTCPay modal event: invoiceId: ' + event.data.invoiceId);
//console.log('BTCPay modal event: status: ' + event.data.status);
if (event.data.status) {
switch (event.data.status.toLowerCase()) {
case 'complete':
case 'paid':
case 'processing':
case 'settled':
invoice_paid = true;
setTimeout(function() {
window.location = data.orderCompleteLink;
}, 3000);
break;
case 'expired':
window.btcpay.hideFrame();
isProcessingOrder = false;
invoiceCreatedForOrder = null;
blocksSubmitError(BTCPayWP.textInvoiceExpired);
break;
case 'invalid':
window.btcpay.hideFrame();
isProcessingOrder = false;
invoiceCreatedForOrder = null;
blocksSubmitError(BTCPayWP.textInvoiceInvalid);
break;
}
}
} else { // handle event.data "loaded" "closed"
if (event.data === 'close') {
if (invoice_paid === true) {
window.location = data.orderCompleteLink;
}
isProcessingOrder = false;
invoiceCreatedForOrder = null;
blocksSubmitError(BTCPayWP.textModalClosed);
}
}
});
const isObject = obj => {
return Object.prototype.toString.call(obj) === '[object Object]'
}
}
/**
* Show errors on the checkout page.
*
* @param error_message
*/
const blocksSubmitError = function (error_message) {
setButtonProcessing(false);
window.wp.data.dispatch( 'core/notices' )
.createErrorNotice(
error_message,
{ context: 'wc/checkout' }
);
resetCheckout();
};
/**
* Reset the checkout store to reenable the place order button.
*/
const resetCheckout = function () {
wp.data.dispatch( wc.wcBlocksData.CHECKOUT_STORE_KEY ).__internalSetIdle();
}

View File

@ -1,66 +0,0 @@
import { __ } from '@wordpress/i18n';
import { registerPaymentMethod } from '@woocommerce/blocks-registry';
import { decodeEntities } from '@wordpress/html-entities';
import { getSetting } from '@woocommerce/settings';
const makeContent = ( settings ) => () => {
return decodeEntities( settings.description || '' );
};
const makeLabel = ( settings, labelText ) => ( props ) => {
const { PaymentMethodLabel } = props.components;
const icon = settings.icon || '';
return (
<div className="btcpay-payment-method-label">
{ icon && (
<img
src={ icon }
alt="BTCPay Bitcoin payment icon"
className="btcpay-payment-icon"
style={ {
width: '50px',
marginRight: '10px',
verticalAlign: 'middle'
} }
/>
) }
<PaymentMethodLabel text={ labelText } />
</div>
);
};
const registerBTCPayGateway = ( name, defaultTitle ) => {
const settings = getSetting( `${ name }_data`, {} );
if ( ! settings || Object.keys( settings ).length === 0 ) {
return;
}
const label = decodeEntities( settings.title ) || defaultTitle;
const Content = makeContent( settings );
const Label = makeLabel( settings, label );
registerPaymentMethod( {
name: name,
label: <Label />,
content: <Content />,
edit: <Content />,
canMakePayment: () => true,
ariaLabel: label,
supports: {
features: settings.supports,
},
} );
};
registerBTCPayGateway(
'btcpaygf_default',
__( 'Bitcoin / Lightning Network over BTCPay Server', 'btcpay-greenfield-for-woocommerce' )
);
const paymentMethodData = getSetting( 'paymentMethodData', {} );
Object.keys( paymentMethodData ).forEach( ( name ) => {
if ( name.startsWith( 'btcpaygf_' ) && name !== 'btcpaygf_default' ) {
registerBTCPayGateway( name, name );
}
} );

View File

@ -29,7 +29,7 @@ class GlobalSettings extends \WC_Settings_Page {
if (is_admin()) {
// Register and include JS.
wp_register_script('btcpay_gf_global_settings', BTCPAYSERVER_PLUGIN_URL . 'assets/js/backend/apiKeyRedirect.js', ['jquery'], BTCPAYSERVER_VERSION);
wp_register_script('btcpay_gf_global_settings', BTCPAYSERVER_PLUGIN_URL . 'assets/js/apiKeyRedirect.js', ['jquery'], BTCPAYSERVER_VERSION);
wp_enqueue_script('btcpay_gf_global_settings');
wp_localize_script( 'btcpay_gf_global_settings',
'BTCPayGlobalSettings',
@ -39,25 +39,10 @@ class GlobalSettings extends \WC_Settings_Page {
]
);
// Order states warning script.
wp_register_script('btcpay_gf_order_states_warning', BTCPAYSERVER_PLUGIN_URL . 'assets/js/backend/orderStatesWarning.js', ['jquery'], BTCPAYSERVER_VERSION);
wp_enqueue_script('btcpay_gf_order_states_warning');
wp_localize_script('btcpay_gf_order_states_warning',
'BTCPayOrderStatesWarning',
[
'warningText' => __('Warning: Changing this from the default "On hold" while "Protect order status" is enabled is not recommended as it could have unintended side effects. <a href="https://docs.btcpayserver.org/FAQ/Integrations/#overriding-the-paid-payment-status" target="_blank">Learn more</a>.', 'btcpay-greenfield-for-woocommerce'),
]
);
// Register and include CSS.
wp_register_style( 'btcpay_gf_admin_styles', BTCPAYSERVER_PLUGIN_URL . 'assets/css/admin.css', array(), BTCPAYSERVER_VERSION );
wp_enqueue_style( 'btcpay_gf_admin_styles' );
// Check if PHP bcmath is available.
if ( ! function_exists('bcdiv') ) {
$bcmathMessage = __('The PHP bcmath extension is not installed. Make sure it is available otherwise the "Sats-Mode" will not work.', 'btcpay-greenfield-for-woocommerce');
Notice::addNotice('error', $bcmathMessage);
}
}
parent::__construct();
}
@ -79,12 +64,8 @@ class GlobalSettings extends \WC_Settings_Page {
Logger::debug('Entering Global Settings form.');
// Check setup status and prepare output.
$storedApiKey = get_option('btcpay_gf_api_key');
$storedStoreId = get_option('btcpay_gf_store_id');
$storedUrl = get_option('btcpay_gf_url');
$setupStatus = '';
if ($storedUrl && $storedStoreId && $storedApiKey) {
if ($this->apiHelper->configured) {
$setupStatus = '<p class="btcpay-connection-success">' . _x('BTCPay Server connected.', 'global_settings', 'btcpay-greenfield-for-woocommerce') . '</p>';
} else {
$setupStatus = '<p class="btcpay-connection-error">' . _x('Not connected. Please use the setup wizard above or check advanced settings to manually enter connection settings.', 'global_settings', 'btcpay-greenfield-for-woocommerce') . '</p>';
@ -98,8 +79,7 @@ class GlobalSettings extends \WC_Settings_Page {
$whId = $webhookConfig['id'];
}
// Todo: check why $this->apiHelper->webhookIsSetup() is cached, also others above.
if (!empty($webhookConfig['secret'])) {
if ($this->apiHelper->webhookIsSetup()) {
$whStatus = '<p class="btcpay-connection-success">' . _x('Webhook setup automatically.', 'global_settings', 'btcpay-greenfield-for-woocommerce') . ' ID: ' . $whId . '</p>';
} else {
$whStatus = '<p class="btcpay-connection-error">' . _x('No webhook setup, yet.', 'global_settings', 'btcpay-greenfield-for-woocommerce') . '</p>';
@ -129,7 +109,7 @@ class GlobalSettings extends \WC_Settings_Page {
),
'type' => 'text',
'desc' => esc_html_x( 'URL/host to your BTCPay Server instance. Note: if you use a self hosted node like Umbrel, RaspiBlitz, myNode, etc. you will have to make sure your node is reachable from the internet. You can do that through <a href="https://docs.btcpayserver.org/Deployment/ReverseProxyToTor/" target="_blank">Tor</a>, <a href="https://docs.btcpayserver.org/Docker/cloudflare-tunnel/" target="_blank">Cloudflare</a> or <a href="https://docs.btcpayserver.org/Deployment/ReverseSSHtunnel/" target="_blank">SSH (advanced)</a>.', 'global_settings', 'btcpay-greenfield-for-woocommerce' ),
'placeholder' => esc_attr_x( 'https://mainnet.demo.btcpayserver.org', 'global_settings', 'btcpay-greenfield-for-woocommerce' ),
'placeholder' => esc_attr_x( 'e.g. https://btcpayserver.example.com', 'global_settings', 'btcpay-greenfield-for-woocommerce' ),
'desc_tip' => true,
'id' => 'btcpay_gf_url'
],
@ -170,7 +150,6 @@ class GlobalSettings extends \WC_Settings_Page {
'title' => esc_html_x( 'Webhook secret (optional)', 'global_settings','btcpay-greenfield-for-woocommerce' ),
'type' => 'text',
'desc' => _x( 'If left empty an webhook will created automatically on save. Only fill out if you know the webhook secret and the webhook was created manually on BTCPay Server.', 'global_settings', 'btcpay-greenfield-for-woocommerce' ),
'desc_tip' => _x( 'The BTCPay webhook endpoint can be reached here: ' . site_url() . '/wc-api/btcpaygf_default/', 'global_settings', 'btcpay-greenfield-for-woocommerce' ),
'default' => '',
'id' => 'btcpay_gf_whsecret'
],
@ -221,13 +200,6 @@ class GlobalSettings extends \WC_Settings_Page {
'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',
@ -256,13 +228,6 @@ class GlobalSettings extends \WC_Settings_Page {
'desc' => _x( '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.', 'global_settings', 'btcpay-greenfield-for-woocommerce' ),
'id' => 'btcpay_gf_sats_mode'
],
'refund_note_visible' => [
'title' => __( 'Customer visible refunds', 'btcpay-greenfield-for-woocommerce' ),
'type' => 'checkbox',
'default' => 'no',
'desc' => _x( 'If enabled, it will show the order refund note also to the customer, trigger an email to customer with the refund link, and display refund links on the customer order details page.', 'global_settings', 'btcpay-greenfield-for-woocommerce' ),
'id' => 'btcpay_gf_refund_note_visible'
],
'debug' => [
'title' => __( 'Debug Log', 'btcpay-greenfield-for-woocommerce' ),
'type' => 'checkbox',
@ -433,14 +398,6 @@ class GlobalSettings extends \WC_Settings_Page {
Logger::debug($messageNotConnecting);
}
// If Sats-Mode enabled but bcmath missing show notice and delete the setting.
$satsMode = sanitize_text_field( $_POST['btcpay_gf_sats_mode'] ?? '' );
if ( $satsMode && ! function_exists('bcdiv') ) {
unset($_POST['btcpay_gf_sats_mode']);
$bcmathMessage = __('The PHP bcmath extension is not installed. Make sure it is available otherwise the "Sats-Mode" will not work. Disabled Sats-Mode until requirements are met.', 'btcpay-greenfield-for-woocommerce');
Notice::addNotice('error', $bcmathMessage);
}
parent::save();
// Purge separate payment methods cache.

View File

@ -8,14 +8,13 @@ class Notice {
/**
* Adds notice to the admin UI.
*/
public static function addNotice( string $level, string $message, bool $dismissible = false, ?string $customClass = null): void {
public static function addNotice( string $level, string $message, bool $dismissible = false): void {
add_action(
'admin_notices',
function () use ( $level, $message, $dismissible, $customClass ) {
$classes = $customClass ? ' ' . $customClass : '';
$classes .= $dismissible ? ' is-dismissible' : '';
function () use ( $level, $message, $dismissible ) {
$dismiss = $dismissible ? ' is-dismissible' : '';
?>
<div class="notice notice-<?php echo esc_attr( $level ) . esc_attr( $classes ); ?>" style="padding:12px 12px">
<div class="notice notice-<?php echo esc_attr( $level ) . esc_attr( $dismiss ); ?>" style="padding:12px 12px">
<?php echo '<strong>BTCPay Server:</strong> ' . wp_kses_post( $message ) ?>
</div>
<?php

View File

@ -1,85 +0,0 @@
<?php
namespace BTCPayServer\WC\Blocks;
use Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType;
use BTCPayServer\WC\Gateway\AbstractGateway;
use BTCPayServer\WC\Gateway\DefaultGateway;
/**
* BTCPay Default Gateway Payments Blocks integration
*
* @since 2.4.0
*/
final class DefaultGatewayBlocks extends AbstractPaymentMethodType {
/**
* The gateway instance.
*/
private $gateway;
/**
* Payment method name/id/slug.
*/
protected $name = 'btcpaygf_default';
/**
* Initializes the payment method type.
*/
public function initialize(): void {
$this->settings = get_option( 'woocommerce_btcpaygf_default_settings', [] );
$gateways = \WC()->payment_gateways->payment_gateways();
$this->gateway = $gateways[$this->name];
}
/**
* Returns if this payment method should be active. If false, the scripts will not be enqueued.
*/
public function is_active(): bool {
return $this->gateway->is_available();
}
/**
* Returns an array of scripts/handles to be registered for this payment method.
*/
public function get_payment_method_script_handles(): array {
$script_url = BTCPAYSERVER_PLUGIN_URL . 'assets/js/frontend/blocks.js';
$script_asset_path = BTCPAYSERVER_PLUGIN_FILE_PATH . 'assets/js/frontend/blocks.asset.php';
$script_asset = file_exists( $script_asset_path )
? require( $script_asset_path )
: array(
'dependencies' => array(),
'version' => BTCPAYSERVER_VERSION
);
wp_register_script(
'btcpay-gateway-blocks',
$script_url,
$script_asset[ 'dependencies' ],
$script_asset[ 'version' ],
true
);
if ( function_exists( 'wp_set_script_translations' ) ) {
wp_set_script_translations(
'btcpay-gateway-blocks',
'btcpay-greenfield-for-woocommerce',
BTCPAYSERVER_PLUGIN_FILE_PATH . 'languages/'
);
}
return [ 'btcpay-gateway-blocks' ];
}
/**
* Returns an array of key=>value pairs of data made available to the payment methods script.
*/
public function get_payment_method_data(): array {
return [
'title' => $this->get_setting( 'title' ),
'description' => $this->get_setting( 'description' ),
'supports' => array_filter( $this->gateway->supports, [ $this->gateway, 'supports' ] ),
'icon' => $this->gateway->getIcon()
];
}
}

View File

@ -1,66 +0,0 @@
<?php
namespace BTCPayServer\WC\Blocks;
use Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType;
final class SeparateGatewayBlocks extends AbstractPaymentMethodType {
private $gateway;
private string $gatewayId;
public function __construct( string $gatewayId ) {
$this->gatewayId = $gatewayId;
$this->name = $gatewayId;
}
public function initialize(): void {
$this->settings = get_option( 'woocommerce_' . $this->gatewayId . '_settings', [] );
$gateways = \WC()->payment_gateways->payment_gateways();
$this->gateway = $gateways[ $this->gatewayId ] ?? null;
}
public function is_active(): bool {
return $this->gateway && $this->gateway->is_available();
}
public function get_payment_method_script_handles(): array {
$script_url = BTCPAYSERVER_PLUGIN_URL . 'assets/js/frontend/blocks.js';
$script_asset_path = BTCPAYSERVER_PLUGIN_FILE_PATH . 'assets/js/frontend/blocks.asset.php';
$script_asset = file_exists( $script_asset_path )
? require( $script_asset_path )
: array(
'dependencies' => array(),
'version' => BTCPAYSERVER_VERSION
);
wp_register_script(
'btcpay-gateway-blocks',
$script_url,
$script_asset[ 'dependencies' ],
$script_asset[ 'version' ],
true
);
if ( function_exists( 'wp_set_script_translations' ) ) {
wp_set_script_translations(
'btcpay-gateway-blocks',
'btcpay-greenfield-for-woocommerce',
BTCPAYSERVER_PLUGIN_FILE_PATH . 'languages/'
);
}
return [ 'btcpay-gateway-blocks' ];
}
public function get_payment_method_data(): array {
return [
'title' => $this->get_setting( 'title' ),
'description' => $this->get_setting( 'description' ),
'supports' => $this->gateway
? array_filter( $this->gateway->supports, [ $this->gateway, 'supports' ] )
: [ 'products' ],
'icon' => $this->gateway ? $this->gateway->getIcon() : '',
];
}
}

View File

@ -18,8 +18,6 @@ abstract class AbstractGateway extends \WC_Payment_Gateway {
public $tokenType;
public $primaryPaymentMethod;
protected $apiHelper;
protected $debug_php_version;
protected $debug_plugin_version;
public function __construct() {
// General gateway setup.
@ -103,35 +101,25 @@ abstract class AbstractGateway extends \WC_Payment_Gateway {
throw new \Exception( $message );
}
// Check if the order is a modal payment.
if (isset($_POST['action'])) {
$action = wc_clean( wp_unslash( $_POST['action'] ) );
if ( in_array($action, ['btcpaygf_modal_checkout', 'btcpaygf_modal_blocks_checkout']) ) {
if ( $action === 'btcpaygf_modal_checkout' ) {
Logger::debug( 'process_payment called via modal checkout.' );
}
}
// Determine if modal checkout is enabled.
$isModal = false;
if ( get_option('btcpay_gf_modal_checkout') === 'yes' ) {
$isModal = true;
}
// Check for existing invoice and redirect instead.
if ( $this->validInvoiceExists( $orderId ) ) {
$existingInvoiceId = $order->get_meta( 'BTCPay_id' );
$existingInvoiceId = get_post_meta( $orderId, 'BTCPay_id', true );
Logger::debug( 'Found existing BTCPay Server invoice and redirecting to it. Invoice id: ' . $existingInvoiceId );
$response = [
return [
'result' => 'success',
'redirect' => $this->apiHelper->getInvoiceRedirectUrl( $existingInvoiceId ),
'invoiceId' => $existingInvoiceId,
'orderCompleteLink' => $order->get_checkout_order_received_url(),
];
if (!$isModal) {
$response['redirect'] = $this->apiHelper->getInvoiceRedirectUrl( $existingInvoiceId );
}
return $response;
}
// Create an invoice.
@ -148,17 +136,12 @@ abstract class AbstractGateway extends \WC_Payment_Gateway {
$url = str_replace($this->apiHelper->url, $_SERVER['SERVER_NAME'], $url);
} */
$response = [
return [
'result' => 'success',
'redirect' => $url,
'invoiceId' => $invoice->getData()['id'],
'orderCompleteLink' => $order->get_checkout_order_received_url(),
];
if (!$isModal) {
$response['redirect'] = $url;
}
return $response;
}
}
@ -187,8 +170,6 @@ abstract class AbstractGateway extends \WC_Payment_Gateway {
$order = wc_get_order($order_id);
$refundAmount = PreciseNumber::parseString($amount);
$currency = $order->get_currency();
$originalCurrency = $order->get_currency();
$orignalPaymentMethod = $order->get_payment_method();
// Check if order has invoice id.
if (!$invoiceId = $order->get_meta('BTCPay_id')) {
@ -197,6 +178,13 @@ abstract class AbstractGateway extends \WC_Payment_Gateway {
return new \WP_Error('1', $errNoBtcpayId);
}
// Make sure the refund amount is not greater than the invoice amount.
if ($amount > $order->get_remaining_refund_amount()) {
$errAmount = __METHOD__ . ': the refund amount can not exceed the order amount, aborting.';
Logger::debug($errAmount);
return new \WP_Error('1', $errAmount);
}
// Create the payout on BTCPay Server.
// Handle Sats-mode.
if ($currency === 'SAT') {
@ -207,17 +195,10 @@ abstract class AbstractGateway extends \WC_Payment_Gateway {
// Get payment methods.
$paymentMethods = $this->getPaymentMethods();
// Remove unsupported payment methods for refunds.
$unsupportedPaymentMethods = ['BTC_LNURLPAY', 'BTC_LNURL', 'XMR_CHAIN'];
$paymentMethods = array_diff($paymentMethods, $unsupportedPaymentMethods);
// Refund name is limited for 50 chars, but we do not have description field available until php lib v3 is out.
$refundName = __('Refund of order ', 'btcpay-greenfield-for-woocommerce') . $order->get_order_number() . '; ' . $reason;
$refundName = substr($refundName, 0, 50);
// Log for debugging.
Logger::debug( 'Refund: Order payment method: ' . $orignalPaymentMethod );
Logger::debug( 'Refund: Available payment methods: ' . print_r($paymentMethods, true) );
// Remove LNURL
if (in_array('BTC_LNURLPAY', $paymentMethods)) {
$paymentMethods = array_diff($paymentMethods, ['BTC_LNURLPAY']);
}
// Create the payout.
try {
@ -225,7 +206,7 @@ abstract class AbstractGateway extends \WC_Payment_Gateway {
// todo: add reason to description with upcoming php lib v3
$pullPayment = $client->createPullPayment(
$this->apiHelper->storeId,
$refundName,
__('Refund for order no.: ', 'btcpay-greenfield-for-woocommerce') . $order->get_order_number() . ' reason: ' . $reason,
$refundAmount,
$currency,
null,
@ -239,19 +220,13 @@ abstract class AbstractGateway extends \WC_Payment_Gateway {
if (!empty($pullPayment)) {
$refundMsg = "PullPayment ID: " . $pullPayment->getId() . "\n";
$refundMsg .= "Link: " . $pullPayment->getViewLink() . "\n";
$refundMsg .= "Amount: " . $amount . " " . $originalCurrency . "\n";
$refundMsg .= "Amount: " . $amount . " " . $currency . "\n";
$refundMsg .= "Reason: " . $reason;
$successMsg = 'Successfully created refund: ' . $refundMsg;
Logger::debug($successMsg);
// Add public or private order note.
if (get_option('btcpay_gf_refund_note_visible') === 'yes') {
$order->add_order_note($successMsg, 1);
} else {
$order->add_order_note($successMsg);
}
$order->add_order_note($successMsg);
// Use add_meta_data to allow for partial refunds.
$order->add_meta_data('BTCPay_refund', $refundMsg, false);
$order->save();
@ -352,7 +327,7 @@ abstract class AbstractGateway extends \WC_Payment_Gateway {
wp_enqueue_media();
wp_register_script(
'btcpay_gf_abstract_gateway',
BTCPAYSERVER_PLUGIN_URL . 'assets/js/backend/gatewayIconMedia.js',
BTCPAYSERVER_PLUGIN_URL . 'assets/js/gatewayIconMedia.js',
['jquery'],
BTCPAYSERVER_VERSION
);
@ -381,67 +356,31 @@ abstract class AbstractGateway extends \WC_Payment_Gateway {
// Load BTCPay modal JS.
wp_enqueue_script( 'btcpay_gf_modal_js', $this->apiHelper->url . '/modal/btcpay.js', [], BTCPAYSERVER_VERSION );
// Check if the checkout page uses the new woocommerce blocks.
$isBlockCheckout = false;
// 1. Try WooCommerce utility (handles block themes with DB-customized templates + page content).
if ( class_exists( '\Automattic\WooCommerce\Blocks\Utils\CartCheckoutUtils' )
&& method_exists( '\Automattic\WooCommerce\Blocks\Utils\CartCheckoutUtils', 'is_checkout_block_default' ) ) {
$isBlockCheckout = \Automattic\WooCommerce\Blocks\Utils\CartCheckoutUtils::is_checkout_block_default();
}
// 2. Fallback: directly check the checkout page content for the block.
if ( ! $isBlockCheckout ) {
$checkoutPageId = wc_get_page_id( 'checkout' );
$isBlockCheckout = $checkoutPageId && has_block( 'woocommerce/checkout', $checkoutPageId );
}
// 3. Block themes with WooCommerce Blocks always use block-based checkout via templates,
// even if the checkout page content doesn't contain the block directly and the
// template hasn't been customized (saved to DB). The WC utility misses this case.
if ( ! $isBlockCheckout && function_exists( 'wp_is_block_theme' ) && wp_is_block_theme()
&& class_exists( '\Automattic\WooCommerce\Blocks\Package' ) ) {
$isBlockCheckout = true;
}
if ($isBlockCheckout) {
$scriptName = 'btcpay_gf_modal_blocks_checkout';
$scriptFile = BTCPAYSERVER_PLUGIN_URL . 'assets/js/frontend/blocksModalCheckout.js';
} else {
$scriptName = 'btcpay_gf_modal_checkout';
$scriptFile = BTCPAYSERVER_PLUGIN_URL . 'assets/js/frontend/modalCheckout.js';
}
// Register modal script.
$scriptDeps = [ 'jquery', 'wp-data' ];
if ($isBlockCheckout) {
$scriptDeps[] = 'wc-blocks-data-store';
}
wp_register_script(
$scriptName,
$scriptFile,
$scriptDeps,
'btcpay_gf_modal_checkout',
BTCPAYSERVER_PLUGIN_URL . 'assets/js/modalCheckout.js',
[ 'jquery' ],
BTCPAYSERVER_VERSION,
true
);
// Pass object BTCPayWP to be available on the frontend.
wp_localize_script( $scriptName, 'BTCPayWP', [
'modalEnabled' => get_option( 'btcpay_gf_modal_checkout' ) === 'yes',
'debugEnabled' => get_option( 'btcpay_gf_debug' ) === 'yes',
wp_localize_script( 'btcpay_gf_modal_checkout', 'BTCPayWP', [
'modalEnabled' => get_option('btcpay_gf_modal_checkout') === 'yes',
'debugEnabled' => get_option('btcpay_gf_debug') === 'yes',
'url' => admin_url( 'admin-ajax.php' ),
'apiUrl' => $this->apiHelper->url,
'apiNonce' => wp_create_nonce( 'btcpay-nonce' ),
'isChangePaymentPage' => isset( $_GET['change_payment_method'] ) ? 'yes' : 'no',
'isPayForOrderPage' => is_wc_endpoint_url( 'order-pay' ) ? 'yes' : 'no',
'isAddPaymentMethodPage' => is_add_payment_method_page() ? 'yes' : 'no',
'textInvoiceExpired' => _x( 'The invoice expired. Please try again, choose a different payment method or contact us if you paid but the payment did not confirm in time.', 'js', 'btcpay-greenfield-for-woocommerce' ),
'textInvoiceInvalid' => _x( 'The invoice is invalid. Please try again, choose a different payment method or contact us if you paid but the payment did not confirm in time.', 'js', 'btcpay-greenfield-for-woocommerce' ),
'textModalClosed' => _x( 'Payment aborted by you. Please try again or choose a different payment method.', 'js', 'btcpay-greenfield-for-woocommerce' ),
'textProcessingError' => _x( 'Error processing checkout. Please try again or choose another payment option.', 'js', 'btcpay-greenfield-for-woocommerce' ),
'textProcessingButton' => _x( 'Processing…', 'js', 'btcpay-greenfield-for-woocommerce' ),
'textInvoiceExpired' => _x('The invoice expired. Please try again, choose a different payment method or contact us if you paid but the payment did not confirm in time.', 'js', 'btcpay-greenfield-for-woocommerce'),
'textModalClosed' => _x('Payment aborted by you. Please try again or choose a different payment method.', 'js', 'btcpay-greenfield-for-woocommerce'),
] );
// Add the registered modal blocks script to frontend.
wp_enqueue_script( $scriptName );
// Add the registered modal script to frontend.
wp_enqueue_script( 'btcpay_gf_modal_checkout' );
}
/**
@ -492,12 +431,6 @@ abstract class AbstractGateway extends \WC_Payment_Gateway {
wp_die('Multiple orders found for this invoiceId, aborting.');
}
// Only continue if the order payment method contains string "btcpaygf_" to avoid processing other gateways.
if (strpos($orders[0]->get_payment_method(), 'btcpaygf_') === false) {
Logger::debug('Order payment method does not contain "btcpaygf_", aborting.');
wp_send_json_success(); // return 200 OK to not mess up BTCPay queue
}
$this->processOrderStatus($orders[0], $postData);
} catch (\Throwable $e) {
@ -519,21 +452,6 @@ abstract class AbstractGateway extends \WC_Payment_Gateway {
$configuredOrderStates = (new OrderStates())->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) {
@ -578,7 +496,7 @@ abstract class AbstractGateway extends \WC_Payment_Gateway {
break;
case 'InvoiceProcessing': // The invoice is paid in full.
$this->updateWCOrderStatus($order, $configuredOrderStates[OrderStates::PROCESSING]);
if (isset($webhookData->overPaid) && $webhookData->overPaid) {
if ($webhookData->overPaid) {
$order->add_order_note(__('Invoice payment received fully with overpayment, waiting for settlement.', 'btcpay-greenfield-for-woocommerce'));
} else {
$order->add_order_note(__('Invoice payment received fully, waiting for settlement.', 'btcpay-greenfield-for-woocommerce'));
@ -603,7 +521,7 @@ abstract class AbstractGateway extends \WC_Payment_Gateway {
break;
case 'InvoiceSettled':
$order->payment_complete();
if (isset($webhookData->overPaid) && $webhookData->overPaid) {
if ($webhookData->overPaid) {
$order->add_order_note(__('Invoice payment settled but was overpaid.', 'btcpay-greenfield-for-woocommerce'));
$this->updateWCOrderStatus($order, $configuredOrderStates[OrderStates::SETTLED_PAID_OVER]);
} else {
@ -613,6 +531,7 @@ abstract class AbstractGateway extends \WC_Payment_Gateway {
// Store payment data (exchange rate, address).
$this->updateWCOrderPayments($order);
break;
}
}
@ -627,13 +546,12 @@ abstract class AbstractGateway extends \WC_Payment_Gateway {
*/
protected function validInvoiceExists( int $orderId ): bool {
// Check order metadata for BTCPay_id.
$order = wc_get_order($orderId);
if ( $invoiceId = $order->get_meta( 'BTCPay_id' ) ) {
if ( $invoiceId = get_post_meta( $orderId, 'BTCPay_id', true ) ) {
// Validate the order status on BTCPay server.
$client = new Invoice( $this->apiHelper->url, $this->apiHelper->apiKey );
try {
Logger::debug( 'Trying to fetch existing invoice from BTCPay Server.' );
$invoice = $client->getInvoice( $this->apiHelper->storeId, $invoiceId );
$invoice = $client->getInvoice( $this->apiHelper->storeId, $invoiceId );
$invalidStates = [ 'Expired', 'Invalid' ];
if ( in_array( $invoice->getData()['status'], $invalidStates ) ) {
return false;
@ -645,7 +563,6 @@ abstract class AbstractGateway extends \WC_Payment_Gateway {
sort($pmInvoice);
$pm = $this->getPaymentMethods();
sort($pm);
Logger::debug( 'validInvoiceExists: pmInvoice: ' . print_r($pmInvoice, true) . ' pm: ' . print_r($pm, true) . ' match: ' . ($pm === $pmInvoice ? 'yes' : 'no') );
if ($pm === $pmInvoice) {
return true;
}
@ -696,28 +613,25 @@ abstract class AbstractGateway extends \WC_Payment_Gateway {
if ((float) $payment->getPaymentMethodPaid() > 0.0) {
$paymentMethodName = $payment->getPaymentMethod();
// Update order meta data with payment methods and transactions.
$order->update_meta_data( "BTCPay_{$paymentMethodName}_total_paid", $payment->getTotalPaid() ?? '' );
$order->update_meta_data( "BTCPay_{$paymentMethodName}_total_amount", $payment->getAmount() ?? '' );
$order->update_meta_data( "BTCPay_{$paymentMethodName}_total_due", $payment->getDue() ?? '' );
$order->update_meta_data( "BTCPay_{$paymentMethodName}_total_fee", $payment->getNetworkFee() ?? '' );
$order->update_meta_data( "BTCPay_{$paymentMethodName}_rate", $payment->getRate() ?? '' );
update_post_meta( $order->get_id(), "BTCPay_{$paymentMethodName}_total_paid", $payment->getTotalPaid() ?? '' );
update_post_meta( $order->get_id(), "BTCPay_{$paymentMethodName}_total_amount", $payment->getAmount() ?? '' );
update_post_meta( $order->get_id(), "BTCPay_{$paymentMethodName}_total_due", $payment->getDue() ?? '' );
update_post_meta( $order->get_id(), "BTCPay_{$paymentMethodName}_total_fee", $payment->getNetworkFee() ?? '' );
update_post_meta( $order->get_id(), "BTCPay_{$paymentMethodName}_rate", $payment->getRate() ?? '' );
if ((float) $payment->getRate() > 0.0) {
$formattedRate = number_format((float) $payment->getRate(), wc_get_price_decimals(), wc_get_price_decimal_separator(), wc_get_price_thousand_separator());
$order->update_meta_data( "BTCPay_{$paymentMethodName}_rateFormatted", $formattedRate );
update_post_meta( $order->get_id(), "BTCPay_{$paymentMethodName}_rateFormatted", $formattedRate );
}
// For each actual payment make a separate entry to make sense of it.
foreach ($payment->getPayments() as $index => $trx) {
$order->update_meta_data( "BTCPay_{$paymentMethodName}_{$index}_id", $trx->getTransactionId() ?? '' );
$order->update_meta_data( "BTCPay_{$paymentMethodName}_{$index}_timestamp", $trx->getReceivedTimestamp() ?? '' );
$order->update_meta_data( "BTCPay_{$paymentMethodName}_{$index}_destination", $trx->getDestination() ?? '' );
$order->update_meta_data( "BTCPay_{$paymentMethodName}_{$index}_amount", $trx->getValue() ?? '' );
$order->update_meta_data( "BTCPay_{$paymentMethodName}_{$index}_status", $trx->getStatus() ?? '' );
$order->update_meta_data( "BTCPay_{$paymentMethodName}_{$index}_networkFee", $trx->getFee() ?? '' );
update_post_meta( $order->get_id(), "BTCPay_{$paymentMethodName}_{$index}_id", $trx->getTransactionId() ?? '' );
update_post_meta( $order->get_id(), "BTCPay_{$paymentMethodName}_{$index}_timestamp", $trx->getReceivedTimestamp() ?? '' );
update_post_meta( $order->get_id(), "BTCPay_{$paymentMethodName}_{$index}_destination", $trx->getDestination() ?? '' );
update_post_meta( $order->get_id(), "BTCPay_{$paymentMethodName}_{$index}_amount", $trx->getValue() ?? '' );
update_post_meta( $order->get_id(), "BTCPay_{$paymentMethodName}_{$index}_status", $trx->getStatus() ?? '' );
update_post_meta( $order->get_id(), "BTCPay_{$paymentMethodName}_{$index}_networkFee", $trx->getFee() ?? '' );
}
// Save the order.
$order->save();
}
}
} catch (\Throwable $e) {
@ -747,9 +661,6 @@ abstract class AbstractGateway extends \WC_Payment_Gateway {
// POS metadata.
$metadata['posData'] = $this->preparePosMetadata( $order );
// Add orderUrl to make order id clickable and leading to the order edit page.
$metadata['orderUrl'] = $order->get_edit_order_url();
// Checkout options.
$checkoutOptions = new InvoiceCheckoutOptions();
$redirectUrl = $this->get_return_url( $order );
@ -855,10 +766,8 @@ abstract class AbstractGateway extends \WC_Payment_Gateway {
*/
protected function updateOrderMetadata( int $orderId, \BTCPayServer\Result\Invoice $invoice ) {
// Store relevant BTCPay invoice data.
$order = wc_get_order($orderId);
$order->update_meta_data( 'BTCPay_redirect', $invoice->getData()['checkoutLink'] );
$order->update_meta_data( 'BTCPay_id', $invoice->getData()['id'] );
$order->save();
update_post_meta( $orderId, 'BTCPay_redirect', $invoice->getData()['checkoutLink'] );
update_post_meta( $orderId, 'BTCPay_id', $invoice->getData()['id'] );
}
/**

View File

@ -9,16 +9,16 @@ class DefaultGateway extends AbstractGateway {
public function __construct() {
// Set the id first.
$this->id = 'btcpaygf_default';
$this->id = 'btcpaygf_default';
// Call parent constructor.
parent::__construct();
// todo: maybe make the button text configurable via settings.
// General gateway setup.
$this->order_button_text = __('Proceed to BTCPay', 'btcpay-greenfield-for-woocommerce');
$this->order_button_text = __('Proceed to BTCPay', 'btcpay-greenfield-for-woocommerce');
// Admin facing title and description.
$this->method_title = 'BTCPay (default)';
$this->method_title = 'BTCPay (default)';
$this->method_description = __('BTCPay default gateway supporting all available tokens on your BTCPay store.', 'btcpay-greenfield-for-woocommerce');
// Actions.
@ -64,8 +64,7 @@ class DefaultGateway extends AbstractGateway {
$btcPayPaymentGW = [];
// If separate gateways are enabled and payment tokens are enforced.
if (get_option('btcpay_gf_separate_gateways') === 'yes' && $this->get_option('enforce_payment_tokens') === 'yes') {
if ($this->get_option('enforce_payment_tokens') === 'yes') {
$gateways = WC()->payment_gateways->payment_gateways();
/** @var $gateway AbstractGateway */
foreach ($gateways as $id => $gateway) {
@ -79,7 +78,7 @@ class DefaultGateway extends AbstractGateway {
return $btcPayPaymentGW;
}
// If payment tokens are not enforced or separate gateways are not enabled.
// If payment tokens are not enforced set all.
$separateGateways = \BTCPayServer\WC\Helper\GreenfieldApiHelper::supportedPaymentMethods();
foreach ($separateGateways as $sgw) {
$btcPayPaymentGW[] = $sgw['symbol'];

View File

@ -92,7 +92,7 @@ class SeparateGateways {
// Set cache for written files to avoid doing it every request, no expiration (will be cleared elsewhere)
if ($writtenFiles > 0) {
set_transient( self::PM_GENERATED_CACHE_KEY, $gateways,0 );
Logger::debug("Successfully wrote {$writtenFiles} to filesystem.");
Logger::debug("Successfully wrote ${writtenFiles} to filesystem.");
}
}

View File

@ -21,9 +21,8 @@ class GreenfieldApiHelper {
public $url;
public $apiKey;
public $storeId;
public $webhook;
// todo: need to refactor as it loads cached options if form submitted by ajax
// todo: perf static instance
public function __construct() {
if ($config = self::getConfig()) {
$this->url = $config['url'];
@ -52,26 +51,14 @@ class GreenfieldApiHelper {
}
}
public static function checkApiKeyWorks(?string $url = null, ?string $apiKey = null): bool {
$config = [];
if ($url && $apiKey) {
$config['url'] = $url;
$config['api_key'] = $apiKey;
} else {
$config = self::getConfig();
}
if ($config) {
public static function checkApiConnection(): bool {
if ($config = self::getConfig()) {
// todo: replace with server info endpoint.
$client = new Store($config['url'], $config['api_key']);
if (!empty($client->getStores())) {
if (!empty($stores = $client->getStores())) {
return true;
} else {
Logger::debug('Could not fetch stores from BTCPay Server with the given API key.');
return false;
}
}
return false;
}
@ -200,7 +187,7 @@ class GreenfieldApiHelper {
$client = new Invoice($config['url'], $config['api_key']);
try {
$invoice = $client->getInvoice($config['store_id'], $invoiceId);
return $invoice->isSettled();
return $invoice->isFullyPaid() || $invoice->isPaidLate();
} catch (\Throwable $e) {
Logger::debug('Exception while checking if invoice settled '. $invoiceId . ': ' . $e->getMessage());
}

View File

@ -34,7 +34,7 @@ class OrderStates {
public function getOrderStateLabels(): array {
return [
self::NEW => _x('New', 'global_settings', 'btcpay-greenfield-for-woocommerce'),
self::PROCESSING => _x('Paid (unconfirmed)', 'global_settings', 'btcpay-greenfield-for-woocommerce'),
self::PROCESSING => _x('Paid', 'global_settings', 'btcpay-greenfield-for-woocommerce'),
self::SETTLED => _x('Settled', 'global_settings', 'btcpay-greenfield-for-woocommerce'),
self::SETTLED_PAID_OVER => _x('Settled (paid over)', 'global_settings', 'btcpay-greenfield-for-woocommerce'),
self::INVALID => _x('Invalid', 'global_settings', 'btcpay-greenfield-for-woocommerce'),

View File

@ -7,8 +7,7 @@ use BTCPayServer\WC\Admin\Notice;
class UpdateManager {
private static $updates = [
'1.0.3' => 'update-1.0.3.php',
'2.4.1' => 'update-2.4.1.php'
'1.0.3' => 'update-1.0.3.php'
];
/**

View File

@ -1,12 +0,0 @@
<?php
/**
* Update 2.4.1
*/
/**
* Set new option to protect wc-processing and wc-completed orders by default.
*/
\BTCPayServer\WC\Helper\Logger::debug('Update 2.4.1: Starting ...', true);
update_option('btcpay_gf_protect_order_status', 'yes');
\BTCPayServer\WC\Helper\Logger::debug('Update 2.4.1: Finished.', true);

View File

@ -1,58 +0,0 @@
const defaultConfig = require('@wordpress/scripts/config/webpack.config');
const WooCommerceDependencyExtractionWebpackPlugin = require('@woocommerce/dependency-extraction-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('path');
const wcDepMap = {
'@woocommerce/blocks-registry': ['wc', 'wcBlocksRegistry'],
'@woocommerce/settings' : ['wc', 'wcSettings']
};
const wcHandleMap = {
'@woocommerce/blocks-registry': 'wc-blocks-registry',
'@woocommerce/settings' : 'wc-settings'
};
const requestToExternal = (request) => {
if (wcDepMap[request]) {
return wcDepMap[request];
}
};
const requestToHandle = (request) => {
if (wcHandleMap[request]) {
return wcHandleMap[request];
}
};
// Export configuration.
module.exports = {
...defaultConfig,
entry: {
'frontend/blocks': '/resources/js/frontend/index.js'
},
output: {
path: path.resolve( __dirname, 'assets/js' ),
filename: '[name].js',
},
plugins: [
...defaultConfig.plugins.filter(
(plugin) =>
plugin.constructor.name !== 'DependencyExtractionWebpackPlugin'
),
new WooCommerceDependencyExtractionWebpackPlugin({
requestToExternal,
requestToHandle
}),
new CopyWebpackPlugin({
patterns: [
{ from: 'resources/js/frontend/modalCheckout.js', to: 'frontend/', info: { minimized: true } },
{ from: 'resources/js/frontend/blocksModalCheckout.js', to: 'frontend/', info: { minimized: false } },
{ from: 'resources/js/backend/gatewayIconMedia.js', to: 'backend/', info: { minimized: true } },
{ from: 'resources/js/backend/apiKeyRedirect.js', to: 'backend/', info: { minimized: true } },
{ from: 'resources/js/backend/notifications.js', to: 'backend/', info: { minimized: true } },
{ from: 'resources/js/backend/orderStatesWarning.js', to: 'backend/', info: { minimized: true } }
]
})
]
};