Plugin Directory

Changeset 2963669


Ignore:
Timestamp:
09/06/2023 01:49:53 PM (3 years ago)
Author:
ndeet
Message:

Update to version 2.3.0 from GitHub

Location:
btcpay-greenfield-for-woocommerce
Files:
2 added
16 edited
1 copied

Legend:

Unmodified
Added
Removed
  • btcpay-greenfield-for-woocommerce/tags/2.3.0/btcpay-greenfield-for-woocommerce.php

    r2956798 r2963669  
    88 * Text Domain:     btcpay-greenfield-for-woocommerce
    99 * Domain Path:     /languages
    10  * Version:         2.2.3
     10 * Version:         2.3.0
    1111 * Requires PHP:    7.4
    1212 * Tested up to:    6.3
     
    2727defined( 'ABSPATH' ) || exit();
    2828
    29 define( 'BTCPAYSERVER_VERSION', '2.2.3' );
     29define( 'BTCPAYSERVER_VERSION', '2.3.0' );
    3030define( 'BTCPAYSERVER_VERSION_KEY', 'btcpay_gf_version' );
    3131define( 'BTCPAYSERVER_PLUGIN_FILE_PATH', plugin_dir_path( __FILE__ ) );
     
    422422add_filter( 'woocommerce_payment_gateways', [ 'BTCPayServerWCPlugin', 'initPaymentGateways' ] );
    423423add_action( 'plugins_loaded', 'init_btcpay_greenfield', 0 );
     424
     425// Mark support for HPOS / COT.
     426add_action( 'before_woocommerce_init', function() {
     427    if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
     428        \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
     429    }
     430} );
  • btcpay-greenfield-for-woocommerce/tags/2.3.0/readme.txt

    r2956798 r2963669  
    66Tested up to: 6.3
    77Requires PHP: 7.4
    8 Stable tag: 2.2.3
     8Stable tag: 2.3.0
    99License: MIT
    1010License URI: https://github.com/btcpayserver/woocommerce-greenfield-plugin/blob/master/license.txt
     
    105105== Changelog ==
    106106
     107= 2.3.0 :: 2023-09-06 =
     108* Support for high performance order storage (HPOS)
     109
     110Note: 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.
     111
    107112= 2.2.3 :: 2023-08-22 =
    108113* Automatically create webhook after redirect.
     
    128133If you do NOT use refunds. You do NOT need to do anything, your existing API key and setup will continue to work as before.
    129134
    130 = 1.1.5 :: 2023-03-08 =
    131 * Fix: fix error when plugins override delete_transient function not returning boolean value
    132 
    133 = 1.1.4 :: 2023-01-20 =
    134 (redo deployment because of broken build pipe)
    135 * Fix: fixed error on thank you page for separate payment methods.
    136 * Dev: updating Docker to latest WP and WC versions.
    137 * Dev: switch Github action for checkout to v3.
    138 
    139 = 1.1.3 :: 2023-01-20 =
    140 * Fix: fixed error on thank you page for separate payment methods.
    141 * Dev: updating Docker to latest WP and WC versions.
    142 * Dev: switch Github action for checkout to v3.
    143 
    144 = 1.1.2 :: 2022-12-09 =
    145 * Fix existing invoice check, wrongly marking invoice invalid on some use cases.
    146 * Add check for cURL PHP extension.
    147 * Make sure generated gateways exist on filesystem.
    148 
    149 = 1.1.1 :: 2022-09-12 =
    150 * Update missing metadata
    151 
    152 = 1.1.0 :: 2022-09-12 =
    153 * Feature: Sats-Mode, currency SAT for Satoshis/Sats now available.
    154 * Settings, adding more links to docs.
    155 
    156 = 1.0.3 :: 2022-08-17 =
    157 * New order state: Payment received after invoice has been expired.
    158 * Order metadata restructure, also list multiple payments separated.
    159 * Add plugin action links for settings, logs, docs, support.
    160 * Show notice when BTCPay Server is not fully synched yet.
    161 * Add BTCPay Server info to debug log.
    162 * Update Readme with development instructions.
    163 * Docker: Update to latest WP and WC versions.
    164 * Pin BTCPay Server PHP library stable version.
    165 
    166 = 1.0.2 :: 2022-04-08 =
    167 * Fix plugin meta docblock version update, pump version once more.
    168 
    169 = 1.0.1 :: 2022-04-08 =
    170 * Fix bug if the custom uploaded payment gateway icon is deleted from filesystem.
    171 * Added information about Tor proxy for Umbrel and other self-hosted nodes to BTCPay settings page.
    172 
    173 = 1.0.0 :: 2022-03-27 =
    174 * Reflect stability with release 1.0.0.
    175 * 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).
    176 * Added plugin loader singleton.
    177 * Added missing docs link to separate payment gateways feature.
    178 * Added checkbox to enable/disable gateway from within gateway settings.
    179 * Updated README.md
    180 
    181 = 0.2.5 :: 2022-03-13 =
    182 *  Load media library and JS only on payment gateway settings page.
    183 
    184 = 0.2.4 :: 2022-03-04 =
    185 * Fix possible problem with CamelCased headers on PHP-FPM and/or Nginx.
    186 * Do not log hitting the cache on debug log to avoid clutter.
    187 
    188 = 0.2.3 :: 2022-02-28 =
    189 * Adding irrelevant GitHub workflow files to .distignore.
    190 * Updating installation instructions with new material.
    191 
    192 = 0.2.2 :: 2022-02-28 =
    193 * Fix fatal error, make sure is_plugin_active() is available.
    194 
    195 = 0.2.1 :: 2022-02-21 =
    196 * Replace SVG by PNG logo to avoid scaling it on themes without proper CSS rules for payment gateway icons.
    197 
    198 = 0.2.0 :: 2022-02-18 =
    199 * Fix Cash on delivery, Bank transfer gateways missing after plugin activation.
    200 
    201 = 0.1.10 :: 2022-02-15 =
    202 * Make sure custom endpoint works without nice url enabled.
    203 * Better description for setting.
    204 * Update translation strings.
    205 
    206 = 0.1.9 :: 2022-02-08 =
    207 * Make sure custom endpoint works by flushing rewrite rules on plugin activation.
    208 * Replacing usage of WC_Admin_Settings::addMessage() with our own.
    209 
    210 = 0.1.1 :: 2022-01-13 =
    211 * Admin notice if legacy plugin is installed
    212 * Admin notice on missing WooCommerce / PHP version lower 7.4
    213 * Minor changes metadata / readme.txt
    214 
    215 = 0.1.0 :: 2022-01-13 =
    216 * First public release for testing.
     135Changelog of older releases can be found [here](https://github.com/btcpayserver/woocommerce-greenfield-plugin/blob/master/changelog.txt)
  • btcpay-greenfield-for-woocommerce/tags/2.3.0/src/Admin/GlobalSettings.php

    r2954869 r2963669  
    6565
    6666        // Check setup status and prepare output.
     67        $storedApiKey = get_option('btcpay_gf_api_key');
     68        $storedStoreId = get_option('btcpay_gf_store_id');
     69        $storedUrl = get_option('btcpay_gf_url');
     70
    6771        $setupStatus = '';
    68         if ($this->apiHelper->configured) {
     72        if ($storedUrl && $storedStoreId && $storedApiKey) {
    6973            $setupStatus = '<p class="btcpay-connection-success">' . _x('BTCPay Server connected.', 'global_settings', 'btcpay-greenfield-for-woocommerce') . '</p>';
    7074        } else {
     
    8084        }
    8185
    82         if ($this->apiHelper->webhookIsSetup()) {
     86        // Todo: check why $this->apiHelper->webhookIsSetup() is cached, also others above.
     87        if (!empty($webhookConfig['secret'])) {
    8388            $whStatus = '<p class="btcpay-connection-success">' . _x('Webhook setup automatically.', 'global_settings', 'btcpay-greenfield-for-woocommerce') . ' ID: ' . $whId . '</p>';
    8489        } else {
  • btcpay-greenfield-for-woocommerce/tags/2.3.0/src/Gateway/AbstractGateway.php

    r2892604 r2963669  
    112112        // Check for existing invoice and redirect instead.
    113113        if ( $this->validInvoiceExists( $orderId ) ) {
    114             $existingInvoiceId = get_post_meta( $orderId, 'BTCPay_id', true );
     114            $existingInvoiceId = $order->get_meta( 'BTCPay_id' );
    115115            Logger::debug( 'Found existing BTCPay Server invoice and redirecting to it. Invoice id: ' . $existingInvoiceId );
    116116
     
    547547    protected function validInvoiceExists( int $orderId ): bool {
    548548        // Check order metadata for BTCPay_id.
    549         if ( $invoiceId = get_post_meta( $orderId, 'BTCPay_id', true ) ) {
     549        $order = wc_get_order($orderId);
     550        if ( $invoiceId = $order->get_meta( 'BTCPay_id' ) ) {
    550551            // Validate the order status on BTCPay server.
    551552            $client = new Invoice( $this->apiHelper->url, $this->apiHelper->apiKey );
    552553            try {
    553554                Logger::debug( 'Trying to fetch existing invoice from BTCPay Server.' );
    554                 $invoice       = $client->getInvoice( $this->apiHelper->storeId, $invoiceId );
     555                $invoice = $client->getInvoice( $this->apiHelper->storeId, $invoiceId );
    555556                $invalidStates = [ 'Expired', 'Invalid' ];
    556557                if ( in_array( $invoice->getData()['status'], $invalidStates ) ) {
     
    614615                    $paymentMethodName = $payment->getPaymentMethod();
    615616                    // Update order meta data with payment methods and transactions.
    616                     update_post_meta( $order->get_id(), "BTCPay_{$paymentMethodName}_total_paid", $payment->getTotalPaid() ?? '' );
    617                     update_post_meta( $order->get_id(), "BTCPay_{$paymentMethodName}_total_amount", $payment->getAmount() ?? '' );
    618                     update_post_meta( $order->get_id(), "BTCPay_{$paymentMethodName}_total_due", $payment->getDue() ?? '' );
    619                     update_post_meta( $order->get_id(), "BTCPay_{$paymentMethodName}_total_fee", $payment->getNetworkFee() ?? '' );
    620                     update_post_meta( $order->get_id(), "BTCPay_{$paymentMethodName}_rate", $payment->getRate() ?? '' );
     617                    $order->update_meta_data( "BTCPay_{$paymentMethodName}_total_paid", $payment->getTotalPaid() ?? '' );
     618                    $order->update_meta_data( "BTCPay_{$paymentMethodName}_total_amount", $payment->getAmount() ?? '' );
     619                    $order->update_meta_data( "BTCPay_{$paymentMethodName}_total_due", $payment->getDue() ?? '' );
     620                    $order->update_meta_data( "BTCPay_{$paymentMethodName}_total_fee", $payment->getNetworkFee() ?? '' );
     621                    $order->update_meta_data( "BTCPay_{$paymentMethodName}_rate", $payment->getRate() ?? '' );
    621622                    if ((float) $payment->getRate() > 0.0) {
    622623                        $formattedRate = number_format((float) $payment->getRate(), wc_get_price_decimals(), wc_get_price_decimal_separator(), wc_get_price_thousand_separator());
    623                         update_post_meta( $order->get_id(), "BTCPay_{$paymentMethodName}_rateFormatted", $formattedRate );
     624                        $order->update_meta_data( "BTCPay_{$paymentMethodName}_rateFormatted", $formattedRate );
    624625                    }
    625626
    626627                    // For each actual payment make a separate entry to make sense of it.
    627628                    foreach ($payment->getPayments() as $index => $trx) {
    628                         update_post_meta( $order->get_id(), "BTCPay_{$paymentMethodName}_{$index}_id", $trx->getTransactionId() ?? '' );
    629                         update_post_meta( $order->get_id(), "BTCPay_{$paymentMethodName}_{$index}_timestamp", $trx->getReceivedTimestamp() ?? '' );
    630                         update_post_meta( $order->get_id(), "BTCPay_{$paymentMethodName}_{$index}_destination", $trx->getDestination() ?? '' );
    631                         update_post_meta( $order->get_id(), "BTCPay_{$paymentMethodName}_{$index}_amount", $trx->getValue() ?? '' );
    632                         update_post_meta( $order->get_id(), "BTCPay_{$paymentMethodName}_{$index}_status", $trx->getStatus() ?? '' );
    633                         update_post_meta( $order->get_id(), "BTCPay_{$paymentMethodName}_{$index}_networkFee", $trx->getFee() ?? '' );
     629                        $order->update_meta_data( "BTCPay_{$paymentMethodName}_{$index}_id", $trx->getTransactionId() ?? '' );
     630                        $order->update_meta_data( "BTCPay_{$paymentMethodName}_{$index}_timestamp", $trx->getReceivedTimestamp() ?? '' );
     631                        $order->update_meta_data( "BTCPay_{$paymentMethodName}_{$index}_destination", $trx->getDestination() ?? '' );
     632                        $order->update_meta_data( "BTCPay_{$paymentMethodName}_{$index}_amount", $trx->getValue() ?? '' );
     633                        $order->update_meta_data( "BTCPay_{$paymentMethodName}_{$index}_status", $trx->getStatus() ?? '' );
     634                        $order->update_meta_data( "BTCPay_{$paymentMethodName}_{$index}_networkFee", $trx->getFee() ?? '' );
    634635                    }
     636
     637                    // Save the order.
     638                    $order->save();
    635639                }
    636640            }
     
    767771    protected function updateOrderMetadata( int $orderId, \BTCPayServer\Result\Invoice $invoice ) {
    768772        // Store relevant BTCPay invoice data.
    769         update_post_meta( $orderId, 'BTCPay_redirect', $invoice->getData()['checkoutLink'] );
    770         update_post_meta( $orderId, 'BTCPay_id', $invoice->getData()['id'] );
     773        $order = wc_get_order($orderId);
     774        $order->update_meta_data( 'BTCPay_redirect', $invoice->getData()['checkoutLink'] );
     775        $order->update_meta_data( 'BTCPay_id', $invoice->getData()['id'] );
     776        $order->save();
    771777    }
    772778
  • btcpay-greenfield-for-woocommerce/tags/2.3.0/src/Helper/GreenfieldApiHelper.php

    r2956798 r2963669  
    2323    public $storeId;
    2424
    25     // todo: perf static instance
     25    // todo: need to refactor as it loads cached options if form submitted by ajax
    2626    public function __construct() {
    2727        if ($config = self::getConfig()) {
  • btcpay-greenfield-for-woocommerce/tags/2.3.0/vendor/autoload.php

    r2956798 r2963669  
    2323require_once __DIR__ . '/composer/autoload_real.php';
    2424
    25 return ComposerAutoloaderInitfd933f855e2b3e9fc705a8e1da981a27::getLoader();
     25return ComposerAutoloaderInitd14bfa940f72714486b6878ba7d4cb9e::getLoader();
  • btcpay-greenfield-for-woocommerce/tags/2.3.0/vendor/composer/autoload_real.php

    r2956798 r2963669  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInitfd933f855e2b3e9fc705a8e1da981a27
     5class ComposerAutoloaderInitd14bfa940f72714486b6878ba7d4cb9e
    66{
    77    private static $loader;
     
    2525        require __DIR__ . '/platform_check.php';
    2626
    27         spl_autoload_register(array('ComposerAutoloaderInitfd933f855e2b3e9fc705a8e1da981a27', 'loadClassLoader'), true, true);
     27        spl_autoload_register(array('ComposerAutoloaderInitd14bfa940f72714486b6878ba7d4cb9e', 'loadClassLoader'), true, true);
    2828        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
    29         spl_autoload_unregister(array('ComposerAutoloaderInitfd933f855e2b3e9fc705a8e1da981a27', 'loadClassLoader'));
     29        spl_autoload_unregister(array('ComposerAutoloaderInitd14bfa940f72714486b6878ba7d4cb9e', 'loadClassLoader'));
    3030
    3131        require __DIR__ . '/autoload_static.php';
    32         call_user_func(\Composer\Autoload\ComposerStaticInitfd933f855e2b3e9fc705a8e1da981a27::getInitializer($loader));
     32        call_user_func(\Composer\Autoload\ComposerStaticInitd14bfa940f72714486b6878ba7d4cb9e::getInitializer($loader));
    3333
    3434        $loader->register(true);
  • btcpay-greenfield-for-woocommerce/tags/2.3.0/vendor/composer/autoload_static.php

    r2956798 r2963669  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInitfd933f855e2b3e9fc705a8e1da981a27
     7class ComposerStaticInitd14bfa940f72714486b6878ba7d4cb9e
    88{
    99    public static $prefixLengthsPsr4 = array (
     
    3333    {
    3434        return \Closure::bind(function () use ($loader) {
    35             $loader->prefixLengthsPsr4 = ComposerStaticInitfd933f855e2b3e9fc705a8e1da981a27::$prefixLengthsPsr4;
    36             $loader->prefixDirsPsr4 = ComposerStaticInitfd933f855e2b3e9fc705a8e1da981a27::$prefixDirsPsr4;
    37             $loader->classMap = ComposerStaticInitfd933f855e2b3e9fc705a8e1da981a27::$classMap;
     35            $loader->prefixLengthsPsr4 = ComposerStaticInitd14bfa940f72714486b6878ba7d4cb9e::$prefixLengthsPsr4;
     36            $loader->prefixDirsPsr4 = ComposerStaticInitd14bfa940f72714486b6878ba7d4cb9e::$prefixDirsPsr4;
     37            $loader->classMap = ComposerStaticInitd14bfa940f72714486b6878ba7d4cb9e::$classMap;
    3838
    3939        }, null, ClassLoader::class);
  • btcpay-greenfield-for-woocommerce/trunk/btcpay-greenfield-for-woocommerce.php

    r2956798 r2963669  
    88 * Text Domain:     btcpay-greenfield-for-woocommerce
    99 * Domain Path:     /languages
    10  * Version:         2.2.3
     10 * Version:         2.3.0
    1111 * Requires PHP:    7.4
    1212 * Tested up to:    6.3
     
    2727defined( 'ABSPATH' ) || exit();
    2828
    29 define( 'BTCPAYSERVER_VERSION', '2.2.3' );
     29define( 'BTCPAYSERVER_VERSION', '2.3.0' );
    3030define( 'BTCPAYSERVER_VERSION_KEY', 'btcpay_gf_version' );
    3131define( 'BTCPAYSERVER_PLUGIN_FILE_PATH', plugin_dir_path( __FILE__ ) );
     
    422422add_filter( 'woocommerce_payment_gateways', [ 'BTCPayServerWCPlugin', 'initPaymentGateways' ] );
    423423add_action( 'plugins_loaded', 'init_btcpay_greenfield', 0 );
     424
     425// Mark support for HPOS / COT.
     426add_action( 'before_woocommerce_init', function() {
     427    if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
     428        \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
     429    }
     430} );
  • btcpay-greenfield-for-woocommerce/trunk/readme.txt

    r2956798 r2963669  
    66Tested up to: 6.3
    77Requires PHP: 7.4
    8 Stable tag: 2.2.3
     8Stable tag: 2.3.0
    99License: MIT
    1010License URI: https://github.com/btcpayserver/woocommerce-greenfield-plugin/blob/master/license.txt
     
    105105== Changelog ==
    106106
     107= 2.3.0 :: 2023-09-06 =
     108* Support for high performance order storage (HPOS)
     109
     110Note: 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.
     111
    107112= 2.2.3 :: 2023-08-22 =
    108113* Automatically create webhook after redirect.
     
    128133If you do NOT use refunds. You do NOT need to do anything, your existing API key and setup will continue to work as before.
    129134
    130 = 1.1.5 :: 2023-03-08 =
    131 * Fix: fix error when plugins override delete_transient function not returning boolean value
    132 
    133 = 1.1.4 :: 2023-01-20 =
    134 (redo deployment because of broken build pipe)
    135 * Fix: fixed error on thank you page for separate payment methods.
    136 * Dev: updating Docker to latest WP and WC versions.
    137 * Dev: switch Github action for checkout to v3.
    138 
    139 = 1.1.3 :: 2023-01-20 =
    140 * Fix: fixed error on thank you page for separate payment methods.
    141 * Dev: updating Docker to latest WP and WC versions.
    142 * Dev: switch Github action for checkout to v3.
    143 
    144 = 1.1.2 :: 2022-12-09 =
    145 * Fix existing invoice check, wrongly marking invoice invalid on some use cases.
    146 * Add check for cURL PHP extension.
    147 * Make sure generated gateways exist on filesystem.
    148 
    149 = 1.1.1 :: 2022-09-12 =
    150 * Update missing metadata
    151 
    152 = 1.1.0 :: 2022-09-12 =
    153 * Feature: Sats-Mode, currency SAT for Satoshis/Sats now available.
    154 * Settings, adding more links to docs.
    155 
    156 = 1.0.3 :: 2022-08-17 =
    157 * New order state: Payment received after invoice has been expired.
    158 * Order metadata restructure, also list multiple payments separated.
    159 * Add plugin action links for settings, logs, docs, support.
    160 * Show notice when BTCPay Server is not fully synched yet.
    161 * Add BTCPay Server info to debug log.
    162 * Update Readme with development instructions.
    163 * Docker: Update to latest WP and WC versions.
    164 * Pin BTCPay Server PHP library stable version.
    165 
    166 = 1.0.2 :: 2022-04-08 =
    167 * Fix plugin meta docblock version update, pump version once more.
    168 
    169 = 1.0.1 :: 2022-04-08 =
    170 * Fix bug if the custom uploaded payment gateway icon is deleted from filesystem.
    171 * Added information about Tor proxy for Umbrel and other self-hosted nodes to BTCPay settings page.
    172 
    173 = 1.0.0 :: 2022-03-27 =
    174 * Reflect stability with release 1.0.0.
    175 * 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).
    176 * Added plugin loader singleton.
    177 * Added missing docs link to separate payment gateways feature.
    178 * Added checkbox to enable/disable gateway from within gateway settings.
    179 * Updated README.md
    180 
    181 = 0.2.5 :: 2022-03-13 =
    182 *  Load media library and JS only on payment gateway settings page.
    183 
    184 = 0.2.4 :: 2022-03-04 =
    185 * Fix possible problem with CamelCased headers on PHP-FPM and/or Nginx.
    186 * Do not log hitting the cache on debug log to avoid clutter.
    187 
    188 = 0.2.3 :: 2022-02-28 =
    189 * Adding irrelevant GitHub workflow files to .distignore.
    190 * Updating installation instructions with new material.
    191 
    192 = 0.2.2 :: 2022-02-28 =
    193 * Fix fatal error, make sure is_plugin_active() is available.
    194 
    195 = 0.2.1 :: 2022-02-21 =
    196 * Replace SVG by PNG logo to avoid scaling it on themes without proper CSS rules for payment gateway icons.
    197 
    198 = 0.2.0 :: 2022-02-18 =
    199 * Fix Cash on delivery, Bank transfer gateways missing after plugin activation.
    200 
    201 = 0.1.10 :: 2022-02-15 =
    202 * Make sure custom endpoint works without nice url enabled.
    203 * Better description for setting.
    204 * Update translation strings.
    205 
    206 = 0.1.9 :: 2022-02-08 =
    207 * Make sure custom endpoint works by flushing rewrite rules on plugin activation.
    208 * Replacing usage of WC_Admin_Settings::addMessage() with our own.
    209 
    210 = 0.1.1 :: 2022-01-13 =
    211 * Admin notice if legacy plugin is installed
    212 * Admin notice on missing WooCommerce / PHP version lower 7.4
    213 * Minor changes metadata / readme.txt
    214 
    215 = 0.1.0 :: 2022-01-13 =
    216 * First public release for testing.
     135Changelog of older releases can be found [here](https://github.com/btcpayserver/woocommerce-greenfield-plugin/blob/master/changelog.txt)
  • btcpay-greenfield-for-woocommerce/trunk/src/Admin/GlobalSettings.php

    r2954869 r2963669  
    6565
    6666        // Check setup status and prepare output.
     67        $storedApiKey = get_option('btcpay_gf_api_key');
     68        $storedStoreId = get_option('btcpay_gf_store_id');
     69        $storedUrl = get_option('btcpay_gf_url');
     70
    6771        $setupStatus = '';
    68         if ($this->apiHelper->configured) {
     72        if ($storedUrl && $storedStoreId && $storedApiKey) {
    6973            $setupStatus = '<p class="btcpay-connection-success">' . _x('BTCPay Server connected.', 'global_settings', 'btcpay-greenfield-for-woocommerce') . '</p>';
    7074        } else {
     
    8084        }
    8185
    82         if ($this->apiHelper->webhookIsSetup()) {
     86        // Todo: check why $this->apiHelper->webhookIsSetup() is cached, also others above.
     87        if (!empty($webhookConfig['secret'])) {
    8388            $whStatus = '<p class="btcpay-connection-success">' . _x('Webhook setup automatically.', 'global_settings', 'btcpay-greenfield-for-woocommerce') . ' ID: ' . $whId . '</p>';
    8489        } else {
  • btcpay-greenfield-for-woocommerce/trunk/src/Gateway/AbstractGateway.php

    r2892604 r2963669  
    112112        // Check for existing invoice and redirect instead.
    113113        if ( $this->validInvoiceExists( $orderId ) ) {
    114             $existingInvoiceId = get_post_meta( $orderId, 'BTCPay_id', true );
     114            $existingInvoiceId = $order->get_meta( 'BTCPay_id' );
    115115            Logger::debug( 'Found existing BTCPay Server invoice and redirecting to it. Invoice id: ' . $existingInvoiceId );
    116116
     
    547547    protected function validInvoiceExists( int $orderId ): bool {
    548548        // Check order metadata for BTCPay_id.
    549         if ( $invoiceId = get_post_meta( $orderId, 'BTCPay_id', true ) ) {
     549        $order = wc_get_order($orderId);
     550        if ( $invoiceId = $order->get_meta( 'BTCPay_id' ) ) {
    550551            // Validate the order status on BTCPay server.
    551552            $client = new Invoice( $this->apiHelper->url, $this->apiHelper->apiKey );
    552553            try {
    553554                Logger::debug( 'Trying to fetch existing invoice from BTCPay Server.' );
    554                 $invoice       = $client->getInvoice( $this->apiHelper->storeId, $invoiceId );
     555                $invoice = $client->getInvoice( $this->apiHelper->storeId, $invoiceId );
    555556                $invalidStates = [ 'Expired', 'Invalid' ];
    556557                if ( in_array( $invoice->getData()['status'], $invalidStates ) ) {
     
    614615                    $paymentMethodName = $payment->getPaymentMethod();
    615616                    // Update order meta data with payment methods and transactions.
    616                     update_post_meta( $order->get_id(), "BTCPay_{$paymentMethodName}_total_paid", $payment->getTotalPaid() ?? '' );
    617                     update_post_meta( $order->get_id(), "BTCPay_{$paymentMethodName}_total_amount", $payment->getAmount() ?? '' );
    618                     update_post_meta( $order->get_id(), "BTCPay_{$paymentMethodName}_total_due", $payment->getDue() ?? '' );
    619                     update_post_meta( $order->get_id(), "BTCPay_{$paymentMethodName}_total_fee", $payment->getNetworkFee() ?? '' );
    620                     update_post_meta( $order->get_id(), "BTCPay_{$paymentMethodName}_rate", $payment->getRate() ?? '' );
     617                    $order->update_meta_data( "BTCPay_{$paymentMethodName}_total_paid", $payment->getTotalPaid() ?? '' );
     618                    $order->update_meta_data( "BTCPay_{$paymentMethodName}_total_amount", $payment->getAmount() ?? '' );
     619                    $order->update_meta_data( "BTCPay_{$paymentMethodName}_total_due", $payment->getDue() ?? '' );
     620                    $order->update_meta_data( "BTCPay_{$paymentMethodName}_total_fee", $payment->getNetworkFee() ?? '' );
     621                    $order->update_meta_data( "BTCPay_{$paymentMethodName}_rate", $payment->getRate() ?? '' );
    621622                    if ((float) $payment->getRate() > 0.0) {
    622623                        $formattedRate = number_format((float) $payment->getRate(), wc_get_price_decimals(), wc_get_price_decimal_separator(), wc_get_price_thousand_separator());
    623                         update_post_meta( $order->get_id(), "BTCPay_{$paymentMethodName}_rateFormatted", $formattedRate );
     624                        $order->update_meta_data( "BTCPay_{$paymentMethodName}_rateFormatted", $formattedRate );
    624625                    }
    625626
    626627                    // For each actual payment make a separate entry to make sense of it.
    627628                    foreach ($payment->getPayments() as $index => $trx) {
    628                         update_post_meta( $order->get_id(), "BTCPay_{$paymentMethodName}_{$index}_id", $trx->getTransactionId() ?? '' );
    629                         update_post_meta( $order->get_id(), "BTCPay_{$paymentMethodName}_{$index}_timestamp", $trx->getReceivedTimestamp() ?? '' );
    630                         update_post_meta( $order->get_id(), "BTCPay_{$paymentMethodName}_{$index}_destination", $trx->getDestination() ?? '' );
    631                         update_post_meta( $order->get_id(), "BTCPay_{$paymentMethodName}_{$index}_amount", $trx->getValue() ?? '' );
    632                         update_post_meta( $order->get_id(), "BTCPay_{$paymentMethodName}_{$index}_status", $trx->getStatus() ?? '' );
    633                         update_post_meta( $order->get_id(), "BTCPay_{$paymentMethodName}_{$index}_networkFee", $trx->getFee() ?? '' );
     629                        $order->update_meta_data( "BTCPay_{$paymentMethodName}_{$index}_id", $trx->getTransactionId() ?? '' );
     630                        $order->update_meta_data( "BTCPay_{$paymentMethodName}_{$index}_timestamp", $trx->getReceivedTimestamp() ?? '' );
     631                        $order->update_meta_data( "BTCPay_{$paymentMethodName}_{$index}_destination", $trx->getDestination() ?? '' );
     632                        $order->update_meta_data( "BTCPay_{$paymentMethodName}_{$index}_amount", $trx->getValue() ?? '' );
     633                        $order->update_meta_data( "BTCPay_{$paymentMethodName}_{$index}_status", $trx->getStatus() ?? '' );
     634                        $order->update_meta_data( "BTCPay_{$paymentMethodName}_{$index}_networkFee", $trx->getFee() ?? '' );
    634635                    }
     636
     637                    // Save the order.
     638                    $order->save();
    635639                }
    636640            }
     
    767771    protected function updateOrderMetadata( int $orderId, \BTCPayServer\Result\Invoice $invoice ) {
    768772        // Store relevant BTCPay invoice data.
    769         update_post_meta( $orderId, 'BTCPay_redirect', $invoice->getData()['checkoutLink'] );
    770         update_post_meta( $orderId, 'BTCPay_id', $invoice->getData()['id'] );
     773        $order = wc_get_order($orderId);
     774        $order->update_meta_data( 'BTCPay_redirect', $invoice->getData()['checkoutLink'] );
     775        $order->update_meta_data( 'BTCPay_id', $invoice->getData()['id'] );
     776        $order->save();
    771777    }
    772778
  • btcpay-greenfield-for-woocommerce/trunk/src/Helper/GreenfieldApiHelper.php

    r2956798 r2963669  
    2323    public $storeId;
    2424
    25     // todo: perf static instance
     25    // todo: need to refactor as it loads cached options if form submitted by ajax
    2626    public function __construct() {
    2727        if ($config = self::getConfig()) {
  • btcpay-greenfield-for-woocommerce/trunk/vendor/autoload.php

    r2956798 r2963669  
    2323require_once __DIR__ . '/composer/autoload_real.php';
    2424
    25 return ComposerAutoloaderInitfd933f855e2b3e9fc705a8e1da981a27::getLoader();
     25return ComposerAutoloaderInitd14bfa940f72714486b6878ba7d4cb9e::getLoader();
  • btcpay-greenfield-for-woocommerce/trunk/vendor/composer/autoload_real.php

    r2956798 r2963669  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInitfd933f855e2b3e9fc705a8e1da981a27
     5class ComposerAutoloaderInitd14bfa940f72714486b6878ba7d4cb9e
    66{
    77    private static $loader;
     
    2525        require __DIR__ . '/platform_check.php';
    2626
    27         spl_autoload_register(array('ComposerAutoloaderInitfd933f855e2b3e9fc705a8e1da981a27', 'loadClassLoader'), true, true);
     27        spl_autoload_register(array('ComposerAutoloaderInitd14bfa940f72714486b6878ba7d4cb9e', 'loadClassLoader'), true, true);
    2828        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
    29         spl_autoload_unregister(array('ComposerAutoloaderInitfd933f855e2b3e9fc705a8e1da981a27', 'loadClassLoader'));
     29        spl_autoload_unregister(array('ComposerAutoloaderInitd14bfa940f72714486b6878ba7d4cb9e', 'loadClassLoader'));
    3030
    3131        require __DIR__ . '/autoload_static.php';
    32         call_user_func(\Composer\Autoload\ComposerStaticInitfd933f855e2b3e9fc705a8e1da981a27::getInitializer($loader));
     32        call_user_func(\Composer\Autoload\ComposerStaticInitd14bfa940f72714486b6878ba7d4cb9e::getInitializer($loader));
    3333
    3434        $loader->register(true);
  • btcpay-greenfield-for-woocommerce/trunk/vendor/composer/autoload_static.php

    r2956798 r2963669  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInitfd933f855e2b3e9fc705a8e1da981a27
     7class ComposerStaticInitd14bfa940f72714486b6878ba7d4cb9e
    88{
    99    public static $prefixLengthsPsr4 = array (
     
    3333    {
    3434        return \Closure::bind(function () use ($loader) {
    35             $loader->prefixLengthsPsr4 = ComposerStaticInitfd933f855e2b3e9fc705a8e1da981a27::$prefixLengthsPsr4;
    36             $loader->prefixDirsPsr4 = ComposerStaticInitfd933f855e2b3e9fc705a8e1da981a27::$prefixDirsPsr4;
    37             $loader->classMap = ComposerStaticInitfd933f855e2b3e9fc705a8e1da981a27::$classMap;
     35            $loader->prefixLengthsPsr4 = ComposerStaticInitd14bfa940f72714486b6878ba7d4cb9e::$prefixLengthsPsr4;
     36            $loader->prefixDirsPsr4 = ComposerStaticInitd14bfa940f72714486b6878ba7d4cb9e::$prefixDirsPsr4;
     37            $loader->classMap = ComposerStaticInitd14bfa940f72714486b6878ba7d4cb9e::$classMap;
    3838
    3939        }, null, ClassLoader::class);
Note: See TracChangeset for help on using the changeset viewer.