Plugin Directory

Changeset 3151490


Ignore:
Timestamp:
09/13/2024 05:17:44 PM (19 months ago)
Author:
ndeet
Message:

Update to version 2.7.0 from GitHub

Location:
btcpay-greenfield-for-woocommerce
Files:
46 edited
1 copied

Legend:

Unmodified
Added
Removed
  • btcpay-greenfield-for-woocommerce/tags/2.7.0/assets/js/frontend/blocks.asset.php

    r3010485 r3151490  
    1 <?php return array('dependencies' => array('wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => 'cb815af5c4b849e4861bcc4c5d20b694');
     1<?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-html-entities', 'wp-i18n'), 'version' => 'f27172b7905ad8eb456218bc4613cd3a');
  • btcpay-greenfield-for-woocommerce/tags/2.7.0/assets/js/frontend/blocks.js

    r3010485 r3151490  
    1 (()=>{"use strict";const e=window.wp.element,t=window.wp.i18n,n=window.wc.wcBlocksRegistry,i=window.wp.htmlEntities,o=(0,window.wc.wcSettings.getSetting)("btcpaygf_default_data",{}),a=(0,t.__)("Bitcoin / Lightning Network over BTCPay Server","woo-gutenberg-products-block"),c=(0,i.decodeEntities)(o.title)||a,l=()=>(0,i.decodeEntities)(o.description||""),r={name:"btcpaygf_default",label:(0,e.createElement)(t=>{const{PaymentMethodLabel:n}=t.components;return(0,e.createElement)(n,{text:c})},null),content:(0,e.createElement)(l,null),edit:(0,e.createElement)(l,null),canMakePayment:()=>!0,ariaLabel:c,supports:{features:o.supports}};(0,n.registerPaymentMethod)(r)})();
     1(()=>{"use strict";var e={20:(e,t,r)=>{var o=r(609),n=Symbol.for("react.element"),s=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),i=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};t.jsx=function(e,t,r){var o,c={},p=null,d=null;for(o in void 0!==r&&(p=""+r),void 0!==t.key&&(p=""+t.key),void 0!==t.ref&&(d=t.ref),t)s.call(t,o)&&!a.hasOwnProperty(o)&&(c[o]=t[o]);if(e&&e.defaultProps)for(o in t=e.defaultProps)void 0===c[o]&&(c[o]=t[o]);return{$$typeof:n,type:e,key:p,ref:d,props:c,_owner:i.current}}},848:(e,t,r)=>{e.exports=r(20)},609:e=>{e.exports=window.React}},t={};const r=window.wp.i18n,o=window.wc.wcBlocksRegistry,n=window.wp.htmlEntities,s=window.wc.wcSettings;var i=function r(o){var n=t[o];if(void 0!==n)return n.exports;var s=t[o]={exports:{}};return e[o](s,s.exports,r),s.exports}(848);const a=(0,s.getSetting)("btcpaygf_default_data",{}),c=(0,r.__)("Bitcoin / Lightning Network over BTCPay Server","woo-gutenberg-products-block"),p=(0,n.decodeEntities)(a.title)||c,d=()=>(0,n.decodeEntities)(a.description||""),f=e=>{const{PaymentMethodLabel:t}=e.components;return(0,i.jsx)(t,{text:p})},l={name:"btcpaygf_default",label:(0,i.jsx)(f,{}),content:(0,i.jsx)(d,{}),edit:(0,i.jsx)(d,{}),canMakePayment:()=>!0,ariaLabel:p,supports:{features:a.supports}};(0,o.registerPaymentMethod)(l)})();
  • btcpay-greenfield-for-woocommerce/tags/2.7.0/assets/js/frontend/blocksModalCheckout.js

    r3029529 r3151490  
    1 let isProcessingOrder=!1,lastExecutionTime=0;const debounceInterval=1e3;wp.data.subscribe(()=>{const e=Date.now();if(!(e-lastExecutionTime<1e3)&&wp.data.select(wc.wcBlocksData.CHECKOUT_STORE_KEY).isBeforeProcessing()&&!isProcessingOrder){isProcessingOrder=!0,lastExecutionTime=e;const t=wp.data.select(wc.wcBlocksData.PAYMENT_STORE_KEY).getState().activePaymentMethod;if(t.startsWith("btcpaygf_")){let e=blocksProcessOrder(t);return e?(blocksShowBTCPayModal(e),isProcessingOrder=!1,!1):(blocksSubmitError(BTCPayWP.textProcessingError),isProcessingOrder=!1,!1)}return!0}});const blocksProcessOrder=function(e){let t=null,o={action:"btcpaygf_modal_blocks_checkout",orderId:wp.data.select(wc.wcBlocksData.CHECKOUT_STORE_KEY).getOrderId(),paymentGateway:e,apiNonce:BTCPayWP.apiNonce};return jQuery.ajaxSetup({async:!1}),jQuery.post(wc_add_to_cart_params.ajax_url,o,(function(e){e.data.invoiceId?t=e.data:e.data?blocksSubmitError(e.data):blocksSubmitError(BTCPayWP.textProcessingError)})).fail((function(){blocksSubmitError(BTCPayWP.textProcessingError),console.error("Error on ajax request 2")})),jQuery.ajaxSetup({async:!0}),t},blocksShowBTCPayModal=function(e){void 0!==e.invoiceId&&(window.btcpay.setApiUrlPrefix(BTCPayWP.apiUrl),window.btcpay.showInvoice(e.invoiceId));let t=!1;window.btcpay.onModalReceiveMessage((function(r){if(o(r.data)){if(r.data.status)switch(r.data.status){case"complete":case"paid":t=!0,window.location=e.orderCompleteLink;break;case"expired":window.btcpay.hideFrame(),blocksSubmitError(BTCPayWP.textInvoiceExpired),console.error("Invoice expired")}}else"close"===r.data&&(!0===t&&(window.location=e.orderCompleteLink),blocksSubmitError(BTCPayWP.textModalClosed))}));const o=e=>"[object Object]"===Object.prototype.toString.call(e)},blocksSubmitError=function(e){window.wp.data.dispatch("core/notices").createErrorNotice(e,{context:"wc/checkout"}),resetCheckout()},resetCheckout=function(){wp.data.dispatch(wc.wcBlocksData.CHECKOUT_STORE_KEY).__internalSetIdle()};
     1let isProcessingOrder=!1,lastExecutionTime=0;const debounceInterval=1e3;wp.data.subscribe((()=>{const e=Date.now();if(!(e-lastExecutionTime<1e3)&&wp.data.select(wc.wcBlocksData.CHECKOUT_STORE_KEY).isBeforeProcessing()&&!isProcessingOrder){isProcessingOrder=!0,lastExecutionTime=e;const t=wp.data.select(wc.wcBlocksData.PAYMENT_STORE_KEY).getState().activePaymentMethod;if(t.startsWith("btcpaygf_")){let e=blocksProcessOrder(t);return e?(blocksShowBTCPayModal(e),isProcessingOrder=!1,!1):(blocksSubmitError(BTCPayWP.textProcessingError),isProcessingOrder=!1,!1)}return!0}}));const blocksProcessOrder=function(e){let t=null,o={action:"btcpaygf_modal_blocks_checkout",orderId:wp.data.select(wc.wcBlocksData.CHECKOUT_STORE_KEY).getOrderId(),paymentGateway:e,apiNonce:BTCPayWP.apiNonce};return jQuery.ajaxSetup({async:!1}),jQuery.post(wc_add_to_cart_params.ajax_url,o,(function(e){e.data.invoiceId?t=e.data:e.data?blocksSubmitError(e.data):blocksSubmitError(BTCPayWP.textProcessingError)})).fail((function(){blocksSubmitError(BTCPayWP.textProcessingError),console.error("Error on ajax request 2")})),jQuery.ajaxSetup({async:!0}),t},blocksShowBTCPayModal=function(e){void 0!==e.invoiceId&&(window.btcpay.setApiUrlPrefix(BTCPayWP.apiUrl),window.btcpay.showInvoice(e.invoiceId));let t=!1;window.btcpay.onModalReceiveMessage((function(a){if(o(a.data)){if(a.data.status)switch(a.data.status.toLowerCase()){case"complete":case"paid":case"processing":case"settled":t=!0,setTimeout((function(){window.location=e.orderCompleteLink}),3e3);break;case"expired":window.btcpay.hideFrame(),submitError(BTCPayWP.textInvoiceExpired);break;case"invalid":window.btcpay.hideFrame(),submitError(BTCPayWP.textInvoiceInvalid)}}else"close"===a.data&&(!0===t&&(window.location=e.orderCompleteLink),blocksSubmitError(BTCPayWP.textModalClosed))}));const o=e=>"[object Object]"===Object.prototype.toString.call(e)},blocksSubmitError=function(e){window.wp.data.dispatch("core/notices").createErrorNotice(e,{context:"wc/checkout"}),resetCheckout()},resetCheckout=function(){wp.data.dispatch(wc.wcBlocksData.CHECKOUT_STORE_KEY).__internalSetIdle()};
  • btcpay-greenfield-for-woocommerce/tags/2.7.0/assets/js/frontend/modalCheckout.js

    r3010485 r3151490  
    7474                //console.log('BTCPay modal event: status: ' + event.data.status);
    7575                if (event.data.status) {
    76                     switch (event.data.status) {
     76                    switch (event.data.status.toLowerCase()) {
    7777                        case 'complete':
    7878                        case 'paid':
     79                        case 'processing':
     80                        case 'settled':
    7981                            invoice_paid = true;
    80                             window.location = data.orderCompleteLink;
     82                            setTimeout(function() {
     83                                window.location = data.orderCompleteLink;
     84                            }, 3000);
    8185                            break;
    8286                        case 'expired':
    8387                            window.btcpay.hideFrame();
    8488                            submitError(BTCPayWP.textInvoiceExpired);
     89                            break;
     90                        case 'invalid':
     91                            window.btcpay.hideFrame();
     92                            submitError(BTCPayWP.textInvoiceInvalid);
    8593                            break;
    8694                    }
  • btcpay-greenfield-for-woocommerce/tags/2.7.0/btcpay-greenfield-for-woocommerce.php

    r3067196 r3151490  
    88 * Text Domain:     btcpay-greenfield-for-woocommerce
    99 * Domain Path:     /languages
    10  * Version:         2.6.2
     10 * Version:         2.7.0
    1111 * Requires PHP:    8.0
    12  * Tested up to:    6.5
    13  * Requires at least: 5.9
    14  * WC requires at least: 6.0
    15  * WC tested up to: 8.7
     12 * Tested up to:    6.6
     13 * Requires at least: 6.2
     14 * WC requires at least: 7.0
     15 * WC tested up to: 9.3
    1616 */
    1717
     
    2727defined( 'ABSPATH' ) || exit();
    2828
    29 define( 'BTCPAYSERVER_VERSION', '2.6.2' );
     29define( 'BTCPAYSERVER_VERSION', '2.7.0' );
    3030define( 'BTCPAYSERVER_VERSION_KEY', 'btcpay_gf_version' );
    3131define( 'BTCPAYSERVER_PLUGIN_FILE_PATH', plugin_dir_path( __FILE__ ) );
  • btcpay-greenfield-for-woocommerce/tags/2.7.0/changelog.txt

    r3064837 r3151490  
     1= 2.4.1 :: 2024-01-22 =
     2* Fix: Ensure order status is not cancelled if paid by other payment gateway.
     3* Show periodically notification to review the plugin.
     4* Updating readme.txt (fixing text, updating banner and screenshots)
     5
     6= 2.4.0 :: 2023-12-15 =
     7* Fix: Avoid error on InvoiceProcessing/InvoiceSettled event in case of paidOver property is missing.
     8* New feature: Add basic support for WooCommerce cart and checkout blocks.
     9Note: Works for default configuration; future versions will make it work with modal checkout and separate payment gateways too.
     10
    111= 2.3.1 :: 2023-10-20 =
    212* Fix: Ensure refunds text does not exceed API field limit.
  • btcpay-greenfield-for-woocommerce/tags/2.7.0/languages/btcpay-greenfield-for-woocommerce.pot

    r3067196 r3151490  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: BTCPay For Woocommerce V2 2.6.2\n"
     5"Project-Id-Version: BTCPay For Woocommerce V2 2.7.0\n"
    66"Report-Msgid-Bugs-To: https://woocommerce.com/my-account/create-a-ticket/\n"
    77"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
     
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "POT-Creation-Date: 2024-04-08T22:16:18+00:00\n"
     12"POT-Creation-Date: 2024-09-13T17:17:15+00:00\n"
    1313"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    14 "X-Generator: WP-CLI 2.10.0\n"
     14"X-Generator: WP-CLI 2.11.0\n"
    1515"language-team: LANGUAGE <EMAIL@ADDRESS>\n"
    1616"X-Domain: btcpay-greenfield-for-woocommerce\n"
     
    9090
    9191#: btcpay-greenfield-for-woocommerce.php:518
    92 #: src/Admin/GlobalSettings.php:374
     92#: src/Admin/GlobalSettings.php:381
    9393msgid "Successfully registered a new webhook on BTCPay Server."
    9494msgstr ""
    9595
    9696#: btcpay-greenfield-for-woocommerce.php:522
    97 #: src/Admin/GlobalSettings.php:378
     97#: src/Admin/GlobalSettings.php:385
    9898msgid "Could not register a new webhook on the store."
    9999msgstr ""
     
    315315
    316316#: src/Admin/GlobalSettings.php:250
     317msgid "Customer visible refunds"
     318msgstr ""
     319
     320#: src/Admin/GlobalSettings.php:253
     321msgctxt "global_settings"
     322msgid "If enabled, it will show the order refund note also to the customer and trigger an email to customer with the refund link."
     323msgstr ""
     324
     325#: src/Admin/GlobalSettings.php:257
    317326msgid "Debug Log"
    318327msgstr ""
    319328
    320 #: src/Admin/GlobalSettings.php:253
     329#: src/Admin/GlobalSettings.php:260
    321330msgctxt "global_settings"
    322331msgid "Enable logging <a href=\"%s\" class=\"button\">View Logs</a>"
    323332msgstr ""
    324333
    325 #: src/Admin/GlobalSettings.php:285
     334#: src/Admin/GlobalSettings.php:292
    326335msgid "The provided API key scope is valid for multiple stores, please make sure to create one for a single store."
    327336msgstr ""
    328337
    329 #: src/Admin/GlobalSettings.php:293
     338#: src/Admin/GlobalSettings.php:300
    330339msgid "The provided API key does not match the required permissions. Please make sure the following permissions are are given: %s"
    331340msgstr ""
    332341
    333 #: src/Admin/GlobalSettings.php:307
     342#: src/Admin/GlobalSettings.php:314
    334343msgid "Your BTCPay Server is not fully synched yet. Until fully synched the checkout will not work."
    335344msgstr ""
    336345
    337 #: src/Admin/GlobalSettings.php:316
     346#: src/Admin/GlobalSettings.php:323
    338347msgid "Your BTCPay Server version does not support refunds, please update to at least version 1.7.6 or newer."
    339348msgstr ""
    340349
    341 #: src/Admin/GlobalSettings.php:322
     350#: src/Admin/GlobalSettings.php:329
    342351msgid "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>."
    343352msgstr ""
    344353
    345 #: src/Admin/GlobalSettings.php:345
    346 #: src/Admin/GlobalSettings.php:366
     354#: src/Admin/GlobalSettings.php:352
     355#: src/Admin/GlobalSettings.php:373
    347356msgid "Successfully setup manual webhook."
    348357msgstr ""
    349358
    350 #: src/Admin/GlobalSettings.php:349
     359#: src/Admin/GlobalSettings.php:356
    351360msgid "Webhook already exists, skipping webhook creation."
    352361msgstr ""
    353362
    354 #: src/Admin/GlobalSettings.php:391
     363#: src/Admin/GlobalSettings.php:398
    355364msgid "No wallet configured on your BTCPay Server store settings. Make sure to add at least one otherwise this plugin will not work."
    356365msgstr ""
    357366
    358 #: src/Admin/GlobalSettings.php:397
     367#: src/Admin/GlobalSettings.php:404
    359368msgid "Exception loading wallet information (payment methods) from BTCPay Server: %s."
    360369msgstr ""
    361370
    362 #: src/Admin/GlobalSettings.php:406
     371#: src/Admin/GlobalSettings.php:413
    363372msgid "Error fetching data for this API key from server. Please check if the key is valid. Error: %s"
    364373msgstr ""
    365374
    366 #: src/Admin/GlobalSettings.php:423
     375#: src/Admin/GlobalSettings.php:430
    367376msgid "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."
    368377msgstr ""
     
    405414msgstr ""
    406415
    407 #: src/Gateway/AbstractGateway.php:222
     416#: src/Gateway/AbstractGateway.php:223
    408417msgid "Refund of order "
    409418msgstr ""
    410419
    411 #: src/Gateway/AbstractGateway.php:300
     420#: src/Gateway/AbstractGateway.php:307
    412421msgid "Gateway Icon:"
    413422msgstr ""
    414423
    415 #: src/Gateway/AbstractGateway.php:305
     424#: src/Gateway/AbstractGateway.php:312
    416425msgid "Upload or select icon"
    417426msgstr ""
    418427
    419 #: src/Gateway/AbstractGateway.php:311
     428#: src/Gateway/AbstractGateway.php:318
    420429msgid "Remove image"
    421430msgstr ""
    422431
    423 #: src/Gateway/AbstractGateway.php:361
     432#: src/Gateway/AbstractGateway.php:368
    424433msgid "Use this image"
    425434msgstr ""
    426435
    427 #: src/Gateway/AbstractGateway.php:362
     436#: src/Gateway/AbstractGateway.php:369
    428437msgid "Insert image"
    429438msgstr ""
    430439
    431 #: src/Gateway/AbstractGateway.php:412
     440#: src/Gateway/AbstractGateway.php:419
    432441msgctxt "js"
    433442msgid "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."
    434443msgstr ""
    435444
    436 #: src/Gateway/AbstractGateway.php:413
     445#: src/Gateway/AbstractGateway.php:420
     446msgctxt "js"
     447msgid "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."
     448msgstr ""
     449
     450#: src/Gateway/AbstractGateway.php:421
    437451msgctxt "js"
    438452msgid "Payment aborted by you. Please try again or choose a different payment method."
    439453msgstr ""
    440454
    441 #: src/Gateway/AbstractGateway.php:414
     455#: src/Gateway/AbstractGateway.php:422
    442456msgctxt "js"
    443457msgid "Error processing checkout. Please try again or choose another payment option."
    444458msgstr ""
    445459
    446 #: src/Gateway/AbstractGateway.php:496
     460#: src/Gateway/AbstractGateway.php:510
    447461msgid "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."
    448462msgstr ""
    449463
    450 #: src/Gateway/AbstractGateway.php:508
     464#: src/Gateway/AbstractGateway.php:522
    451465msgid "Invoice (partial) payment incoming (unconfirmed) after invoice was already expired."
    452466msgstr ""
    453467
    454 #: src/Gateway/AbstractGateway.php:511
     468#: src/Gateway/AbstractGateway.php:525
    455469msgid "Invoice (partial) payment incoming (unconfirmed). Waiting for settlement."
    456470msgstr ""
    457471
    458 #: src/Gateway/AbstractGateway.php:530
     472#: src/Gateway/AbstractGateway.php:544
    459473msgid "Invoice fully settled after invoice was already expired. Needs manual checking."
    460474msgstr ""
    461475
    462 #: src/Gateway/AbstractGateway.php:535
     476#: src/Gateway/AbstractGateway.php:549
    463477msgid "(Partial) payment settled but invoice not settled yet (could be more transactions incoming). Needs manual checking."
    464478msgstr ""
    465479
    466 #: src/Gateway/AbstractGateway.php:539
     480#: src/Gateway/AbstractGateway.php:553
    467481msgid "Invoice (partial) payment settled."
    468482msgstr ""
    469483
    470 #: src/Gateway/AbstractGateway.php:549
     484#: src/Gateway/AbstractGateway.php:563
    471485msgid "Invoice payment received fully with overpayment, waiting for settlement."
    472486msgstr ""
    473487
    474 #: src/Gateway/AbstractGateway.php:551
     488#: src/Gateway/AbstractGateway.php:565
    475489msgid "Invoice payment received fully, waiting for settlement."
    476490msgstr ""
    477491
    478 #: src/Gateway/AbstractGateway.php:557
     492#: src/Gateway/AbstractGateway.php:571
    479493msgid "Invoice manually marked invalid."
    480494msgstr ""
    481495
    482 #: src/Gateway/AbstractGateway.php:559
     496#: src/Gateway/AbstractGateway.php:573
    483497msgid "Invoice became invalid."
    484498msgstr ""
    485499
    486 #: src/Gateway/AbstractGateway.php:565
     500#: src/Gateway/AbstractGateway.php:579
    487501msgid "Invoice expired but was paid partially, please check."
    488502msgstr ""
    489503
    490 #: src/Gateway/AbstractGateway.php:568
     504#: src/Gateway/AbstractGateway.php:582
    491505msgid "Invoice expired."
    492506msgstr ""
    493507
    494 #: src/Gateway/AbstractGateway.php:574
     508#: src/Gateway/AbstractGateway.php:588
    495509msgid "Invoice payment settled but was overpaid."
    496510msgstr ""
    497511
    498 #: src/Gateway/AbstractGateway.php:577
     512#: src/Gateway/AbstractGateway.php:591
    499513msgid "Invoice payment settled."
    500514msgstr ""
    501515
    502 #: src/Gateway/AbstractGateway.php:620
     516#: src/Gateway/AbstractGateway.php:634
    503517msgid "BTCPay invoice manually set to invalid because customer went back to checkout and changed payment gateway."
    504518msgstr ""
  • btcpay-greenfield-for-woocommerce/tags/2.7.0/readme.txt

    r3067196 r3151490  
    33Donate link: https://btcpayserver.org/donate/
    44Tags: Bitcoin, Lightning Network, BTCPay Server, WooCommerce, payment gateway
    5 Requires at least: 5.2
    6 Tested up to: 6.5
     5Requires at least: 5.9
     6Tested up to: 6.6
    77Requires PHP: 8.0
    8 Stable tag: 2.6.2
     8Stable tag: 2.7.0
    99License: MIT
    1010License URI: https://github.com/btcpayserver/woocommerce-greenfield-plugin/blob/master/license.txt
     
    112112
    113113== Upgrade Notice ==
    114 = 2.6.2 =
    115 * Notifications fix, buttons should now work.
     114
     115
     116
     117= 2.7.0 =
     118* IMPORTANT: If you use the "Separate Payment gateways" feature, when you upgrade your BTCPay Server to version 2.0.0 or newer, you will need to reconfigure your payment gateways in WooCommerce. This is due to the new way of handling and naming payment methods in BTCPay Server.
     119* Feature: Add option to notify customers on refund order notes.
     120* Feature: BTCPay Server 2.0.0 compatibility.
     121* Fixes see changelog.
    116122
    117123== Changelog ==
     124= 2.7.0 :: 2024-09-04 =
     125* Feature: Add option to notify customers on refund order notes.
     126* Feature: BTCPay Server 2.0.0 compatibility.
     127* Fix: Make sure to not process orders if the assigned payment gateway is not one of BTCPay.
     128* Fix: Make sure payment methods are set on refunds.
     129* Fix: Wrong currency in refund comment.
     130* Fix: Deprecation warnings.
     131* Maintenance: Update NodeJS dependencies.
     132* Maintenance: Update PHP library to v2.7.0.
     133
    118134= 2.6.2 :: 2024-04-09 =
    119135* Fix: Dismissing the review notification forever, finally.
     
    133149* Add support for modal overlay for checkout blocks.
    134150
    135 = 2.4.1 :: 2024-01-22 =
    136 * Fix: Ensure order status is not cancelled if paid by other payment gateway.
    137 * Show periodically notification to review the plugin.
    138 * Updating readme.txt (fixing text, updating banner and screenshots)
    139 
    140 = 2.4.0 :: 2023-12-15 =
    141 * Fix: Avoid error on InvoiceProcessing/InvoiceSettled event in case of paidOver property is missing.
    142 * New feature: Add basic support for WooCommerce cart and checkout blocks.
    143 Note: Works for default configuration; future versions will make it work with modal checkout and separate payment gateways too.
    144 
    145151
    146152Changelog of older releases can be found [here](https://github.com/btcpayserver/woocommerce-greenfield-plugin/blob/master/changelog.txt)
  • btcpay-greenfield-for-woocommerce/tags/2.7.0/resources/js/frontend/blocksModalCheckout.js

    r3029529 r3151490  
    125125            //console.log('BTCPay modal event: status: ' + event.data.status);
    126126            if (event.data.status) {
    127                 switch (event.data.status) {
     127                switch (event.data.status.toLowerCase()) {
    128128                    case 'complete':
    129129                    case 'paid':
     130                    case 'processing':
     131                    case 'settled':
    130132                        invoice_paid = true;
    131                         window.location = data.orderCompleteLink;
     133                        setTimeout(function() {
     134                            window.location = data.orderCompleteLink;
     135                        }, 3000);
    132136                        break;
    133137                    case 'expired':
    134138                        window.btcpay.hideFrame();
    135                         blocksSubmitError(BTCPayWP.textInvoiceExpired);
    136                         console.error('Invoice expired');
     139                        submitError(BTCPayWP.textInvoiceExpired);
     140                        break;
     141                    case 'invalid':
     142                        window.btcpay.hideFrame();
     143                        submitError(BTCPayWP.textInvoiceInvalid);
    137144                        break;
    138145                }
  • btcpay-greenfield-for-woocommerce/tags/2.7.0/resources/js/frontend/modalCheckout.js

    r3010485 r3151490  
    7474                //console.log('BTCPay modal event: status: ' + event.data.status);
    7575                if (event.data.status) {
    76                     switch (event.data.status) {
     76                    switch (event.data.status.toLowerCase()) {
    7777                        case 'complete':
    7878                        case 'paid':
     79                        case 'processing':
     80                        case 'settled':
    7981                            invoice_paid = true;
    80                             window.location = data.orderCompleteLink;
     82                            setTimeout(function() {
     83                                window.location = data.orderCompleteLink;
     84                            }, 3000);
    8185                            break;
    8286                        case 'expired':
    8387                            window.btcpay.hideFrame();
    8488                            submitError(BTCPayWP.textInvoiceExpired);
     89                            break;
     90                        case 'invalid':
     91                            window.btcpay.hideFrame();
     92                            submitError(BTCPayWP.textInvoiceInvalid);
    8593                            break;
    8694                    }
  • btcpay-greenfield-for-woocommerce/tags/2.7.0/src/Admin/GlobalSettings.php

    r3064837 r3151490  
    246246                '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' ),
    247247                'id' => 'btcpay_gf_sats_mode'
     248            ],
     249            'refund_note_visible' => [
     250                'title' => __( 'Customer visible refunds', 'btcpay-greenfield-for-woocommerce' ),
     251                'type' => 'checkbox',
     252                'default' => 'no',
     253                'desc' => _x( 'If enabled, it will show the order refund note also to the customer and trigger an email to customer with the refund link.', 'global_settings', 'btcpay-greenfield-for-woocommerce' ),
     254                'id' => 'btcpay_gf_refund_note_visible'
    248255            ],
    249256            'debug' => [
  • btcpay-greenfield-for-woocommerce/tags/2.7.0/src/Gateway/AbstractGateway.php

    r3064837 r3151490  
    186186        $refundAmount = PreciseNumber::parseString($amount);
    187187        $currency = $order->get_currency();
     188        $originalCurrency = $order->get_currency();
    188189
    189190        // Check if order has invoice id.
     
    215216        $paymentMethods = $this->getPaymentMethods();
    216217        // Remove LNURL
    217         if (in_array('BTC_LNURLPAY', $paymentMethods)) {
    218             $paymentMethods = array_diff($paymentMethods, ['BTC_LNURLPAY']);
     218        if (in_array('BTC_LNURLPAY', $paymentMethods) || in_array('BTC_LNURL', $paymentMethods)) {
     219            $paymentMethods = array_diff($paymentMethods, ['BTC_LNURLPAY', 'BTC_LNURL']);
    219220        }
    220221
     
    243244                $refundMsg = "PullPayment ID: " . $pullPayment->getId() . "\n";
    244245                $refundMsg .= "Link: " . $pullPayment->getViewLink() . "\n";
    245                 $refundMsg .= "Amount: " . $amount . " " . $currency . "\n";
     246                $refundMsg .= "Amount: " . $amount . " " . $originalCurrency . "\n";
    246247                $refundMsg .= "Reason: " . $reason;
    247248                $successMsg = 'Successfully created refund: ' . $refundMsg;
     
    249250                Logger::debug($successMsg);
    250251
    251                 $order->add_order_note($successMsg);
     252                // Add public or private order note.
     253                if (get_option('btcpay_gf_refund_note_visible') === 'yes') {
     254                    $order->add_order_note($successMsg, 1);
     255                } else {
     256                    $order->add_order_note($successMsg);
     257                }
     258
    252259                // Use add_meta_data to allow for partial refunds.
    253260                $order->add_meta_data('BTCPay_refund', $refundMsg, false);
     
    411418            'isAddPaymentMethodPage' => is_add_payment_method_page() ? 'yes' : 'no',
    412419            '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' ),
     420            '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' ),
    413421            'textModalClosed' => _x( 'Payment aborted by you. Please try again or choose a different payment method.', 'js', 'btcpay-greenfield-for-woocommerce' ),
    414422            'textProcessingError' => _x( 'Error processing checkout. Please try again or choose another payment option.', 'js', 'btcpay-greenfield-for-woocommerce' ),
     
    464472                    Logger::debug(print_r($orders, true));
    465473                    wp_die('Multiple orders found for this invoiceId, aborting.');
     474                }
     475
     476                // Only continue if the order payment method contains string "btcpaygf_" to avoid processing other gateways.
     477                if (strpos($orders[0]->get_payment_method(), 'btcpaygf_') === false) {
     478                    Logger::debug('Order payment method does not contain "btcpaygf_", aborting.');
     479                    wp_send_json_success(); // return 200 OK to not mess up BTCPay queue
    466480                }
    467481
  • btcpay-greenfield-for-woocommerce/tags/2.7.0/src/Gateway/DefaultGateway.php

    r3010485 r3151490  
    6565        $btcPayPaymentGW = [];
    6666
    67         if ($this->get_option('enforce_payment_tokens') === 'yes') {
     67        // If separate gateways are enabled and payment tokens are enforced.
     68        if (get_option('btcpay_gf_separate_gateways') === 'yes' && $this->get_option('enforce_payment_tokens') === 'yes') {
    6869            $gateways = WC()->payment_gateways->payment_gateways();
    6970            /** @var  $gateway AbstractGateway */
     
    7980        }
    8081
    81         // If payment tokens are not enforced set all.
     82        // If payment tokens are not enforced or separate gateways are not enabled.
    8283        $separateGateways = \BTCPayServer\WC\Helper\GreenfieldApiHelper::supportedPaymentMethods();
    8384        foreach ($separateGateways as $sgw) {
  • btcpay-greenfield-for-woocommerce/tags/2.7.0/src/Helper/GreenfieldApiHelper.php

    r3042021 r3151490  
    2222    public $apiKey;
    2323    public $storeId;
     24    public $webhook;
    2425
    2526    // todo: need to refactor as it loads cached options if form submitted by ajax
     
    6465        if ($config) {
    6566            $client = new Store($config['url'], $config['api_key']);
    66             if (!empty($stores = $client->getStores())) {
     67            if (!empty($client->getStores())) {
    6768                return true;
    6869            } else {
  • btcpay-greenfield-for-woocommerce/tags/2.7.0/vendor/btcpayserver/btcpayserver-greenfield-php/src/Client/Invoice.php

    r3064837 r3151490  
    88use BTCPayServer\Result\InvoiceList;
    99use BTCPayServer\Result\InvoicePaymentMethod;
     10use BTCPayServer\Result\PullPayment as ResultPullPayment;
    1011use BTCPayServer\Util\PreciseNumber;
    1112
     
    160161    {
    161162        $method = 'GET';
    162         $url = $this->getApiUrl() . 'stores/' . urlencode($storeId) . '/invoices/' . urlencode($invoiceId) . '/payment-methods';
     163        $url = $this->getApiUrl() . 'stores/' . urlencode($storeId) . '/invoices/'
     164            . urlencode($invoiceId) . '/payment-methods';
    163165        $headers = $this->getRequestHeaders();
    164166        $response = $this->getHttpClient()->request($method, $url, $headers);
     
    182184    }
    183185
     186    /**
     187     * Mark an invoice status.
     188     *
     189     * @see https://docs.btcpayserver.org/API/Greenfield/v1/#operation/Invoices_MarkInvoiceStatus
     190     * @throws \JsonException
     191     */
    184192    public function markInvoiceStatus(string $storeId, string $invoiceId, string $markAs): ResultInvoice
    185193    {
    186         $url = $this->getApiUrl() . 'stores/' . urlencode(
    187             $storeId
    188         ) . '/invoices/' . urlencode($invoiceId) . '/status';
     194        $url = $this->getApiUrl() . 'stores/' . urlencode($storeId) . '/invoices/' . urlencode($invoiceId) . '/status';
    189195        $headers = $this->getRequestHeaders();
    190196        $method = 'POST';
     
    207213        }
    208214    }
     215
     216    /**
     217     * Refund an invoice.
     218     *
     219     * @see https://docs.btcpayserver.org/API/Greenfield/v1/#operation/Invoices_Refund
     220     * @throws \JsonException
     221     */
     222    public function refundInvoice(
     223        string $storeId,
     224        string $invoiceId,
     225        ?string $refundVariant = 'CurrentRate',
     226        ?string $paymentMethod = 'BTC',
     227        ?string $name = null,
     228        ?string $description = null,
     229        ?float $subtractPercentage = 0.0,
     230        ?PreciseNumber $customAmount = null,
     231        ?string $customCurrency = null
     232    ): ResultPullPayment {
     233        $url = $this->getApiUrl() . 'stores/' . urlencode($storeId) . '/invoices/' . urlencode($invoiceId) . '/refund';
     234        $headers = $this->getRequestHeaders();
     235        $method = 'POST';
     236
     237        $body = json_encode(
     238            [
     239                'name' => $name,
     240                'description' => $description,
     241                'paymentMethod' => $paymentMethod,
     242                'refundVariant' => $refundVariant,
     243                'subtractPercentage' => $subtractPercentage,
     244                'customAmount' => $customAmount?->__toString(),
     245                'customCurrency' => $customCurrency
     246            ],
     247            JSON_THROW_ON_ERROR
     248        );
     249
     250        $response = $this->getHttpClient()->request($method, $url, $headers, $body);
     251
     252        if ($response->getStatus() === 200) {
     253            return new ResultPullPayment(
     254                json_decode($response->getBody(), true, 512, JSON_THROW_ON_ERROR)
     255            );
     256        } else {
     257            throw $this->getExceptionByStatusCode($method, $url, $response);
     258        }
     259    }
    209260}
  • btcpay-greenfield-for-woocommerce/tags/2.7.0/vendor/btcpayserver/btcpayserver-greenfield-php/src/Client/PullPayment.php

    r3042021 r3151490  
    5151        ?int $startsAt,
    5252        ?int $expiresAt,
    53         array $paymentMethods
     53        array $paymentMethods,
     54        ?string $description = null
    5455    ): ResultPullPayment {
    5556        $url = $this->getApiUrl() . 'stores/' .
     
    6263            [
    6364                'name' => $name,
     65                'description' => $description,
    6466                'amount' => $amount->__toString(),
    6567                'currency' => $currency,
  • btcpay-greenfield-for-woocommerce/tags/2.7.0/vendor/btcpayserver/btcpayserver-greenfield-php/src/Client/StorePaymentMethod.php

    r3042021 r3151490  
    1616class StorePaymentMethod extends AbstractClient
    1717{
    18     public function getPaymentMethods(string $storeId): array
     18    public function getPaymentMethods(string $storeId, bool $includeConfig = false): array
    1919    {
    2020        $url = $this->getApiUrl() . 'stores/' . urlencode($storeId) . '/payment-methods';
     21        if ($includeConfig) {
     22            $url .= '?includeConfig=true';
     23        }
    2124        $headers = $this->getRequestHeaders();
    2225        $method = 'GET';
  • btcpay-greenfield-for-woocommerce/tags/2.7.0/vendor/btcpayserver/btcpayserver-greenfield-php/src/Result/ApiKey.php

    r2674285 r3151490  
    77class ApiKey extends AbstractResult
    88{
     9    public function getApiKey(): string
     10    {
     11        return $this->getData()['apiKey'];
     12    }
     13
     14    public function getLabel(): string
     15    {
     16        return $this->getData()['label'];
     17    }
     18
     19    public function getPermissions(): array
     20    {
     21        return $this->getData()['permissions'];
     22    }
    923}
  • btcpay-greenfield-for-woocommerce/tags/2.7.0/vendor/btcpayserver/btcpayserver-greenfield-php/src/Result/InvoicePaymentMethod.php

    r2674285 r3151490  
    6060    {
    6161        $data = $this->getData();
    62         return $data['networkFee'];
     62        // BTCPay 2.0.0 compatibility: networkFee was renamed to paymentMethodFee.
     63        return $data['networkFee'] ?? $data['paymentMethodFee'];
    6364    }
    6465
     
    6667    {
    6768        $data = $this->getData();
    68         return $data['paymentMethod'];
     69        // BTCPay 2.0.0 compatibility: paymentMethod was renamed to paymentMethodId.
     70        return $data['paymentMethod'] ?? $data['paymentMethodId'];
    6971    }
    7072
     
    7274    {
    7375        $data = $this->getData();
     76        // BTCPay 2.0.0 compatibility: cryptoCode was renamed to currency.
     77        if (isset($data['currency'])) {
     78            return $data['currency'];
     79        }
     80
    7481        // For future compatibility check if cryptoCode exists.
    7582        if (isset($data['cryptoCode'])) {
     
    7784        } else {
    7885            // Extract cryptoCode from paymentMethod string.
    79             $parts = explode('-', $data['paymentMethod']);
     86            $parts = explode('-', $this->getPaymentMethod());
    8087            return $parts[0];
    8188        }
  • btcpay-greenfield-for-woocommerce/tags/2.7.0/vendor/btcpayserver/btcpayserver-greenfield-php/src/Result/PullPayment.php

    r2679022 r3151490  
    1919        $data = $this->getData();
    2020        return $data['name'];
     21    }
     22
     23    public function getDescription(): string
     24    {
     25        $data = $this->getData();
     26        return $data['description'];
    2127    }
    2228
  • btcpay-greenfield-for-woocommerce/tags/2.7.0/vendor/btcpayserver/btcpayserver-greenfield-php/src/Result/StorePaymentMethodCollection.php

    r3042021 r3151490  
    1414        $r = [];
    1515        foreach ($this->getData() as $paymentMethod => $paymentMethodData) {
     16            // BTCPay 2.0 compatibility: List is not a keyed array anymore so fix it here.
     17            if (is_numeric($paymentMethod)) {
     18                $paymentMethod = $paymentMethodData['paymentMethodId'];
     19                // Extract the cryptoCode from the paymentMethodId. e.g. "BTC-CHAIN" -> "BTC"
     20                $parts = explode('-', $paymentMethod);
     21                $extractedCryptoCode = $parts[0];
     22            }
     23
    1624            // Consistency: Flatten the array to be consistent with the specific
    1725            // payment method endpoints.
    18             $paymentMethodData += $paymentMethodData['data'];
    19             unset($paymentMethodData['data']);
     26            if (isset($paymentMethodData['data'])) {
     27                $paymentMethodData += $paymentMethodData['data'];
     28                unset($paymentMethodData['data']);
     29            }
    2030
    21             if (strpos($paymentMethod, 'LightningNetwork') !== false) {
     31            // BTCPay 2.0 compatibility: Handle config data if exists.
     32            if (isset($paymentMethodData['config'])) {
     33                $paymentMethodData += $paymentMethodData['config'];
     34                unset($paymentMethodData['config']);
     35            }
     36
     37            // BTCPay 2.0 compatibility: Check for renamed LN payment method id.
     38            if (preg_match('/(LightningNetwork|-LN$)/', $paymentMethod)) {
    2239                // Consistency: Add back the cryptoCode missing on this endpoint
    2340                // results until it is there.
     
    2542                    $paymentMethodData['cryptoCode'] = str_replace('-LightningNetwork', '', $paymentMethod);
    2643                }
     44
     45                // BTCPay 2.0 compatibility: put the currency code in the cryptoCode field.
     46                if (isset($extractedCryptoCode)) {
     47                    $paymentMethodData['cryptoCode'] = $extractedCryptoCode;
     48                }
     49
    2750                $r[] = new StorePaymentMethodLightningNetwork($paymentMethodData, $paymentMethod);
    2851            } else {
     
    3255                    $paymentMethodData['cryptoCode'] = $paymentMethod;
    3356                }
     57
     58                // BTCPay 2.0 compatibility: put the currency code in the cryptoCode field.
     59                if (isset($extractedCryptoCode)) {
     60                    $paymentMethodData['cryptoCode'] = $extractedCryptoCode;
     61                }
     62
    3463                $r[] = new StorePaymentMethodOnChain($paymentMethodData, $paymentMethod);
    3564            }
  • btcpay-greenfield-for-woocommerce/tags/2.7.0/vendor/composer/installed.json

    r3064837 r3151490  
    33        {
    44            "name": "btcpayserver/btcpayserver-greenfield-php",
    5             "version": "v2.5.0",
    6             "version_normalized": "2.5.0.0",
     5            "version": "v2.7.0",
     6            "version_normalized": "2.7.0.0",
    77            "source": {
    88                "type": "git",
    99                "url": "https://github.com/btcpayserver/btcpayserver-greenfield-php.git",
    10                 "reference": "385b7f6882213e1142b58af89b24dd1495d6babc"
     10                "reference": "5e2ba7e3f585fc8e6dc068e22a0efbfdacd9c992"
    1111            },
    1212            "dist": {
    1313                "type": "zip",
    14                 "url": "https://api.github.com/repos/btcpayserver/btcpayserver-greenfield-php/zipball/385b7f6882213e1142b58af89b24dd1495d6babc",
    15                 "reference": "385b7f6882213e1142b58af89b24dd1495d6babc",
     14                "url": "https://api.github.com/repos/btcpayserver/btcpayserver-greenfield-php/zipball/5e2ba7e3f585fc8e6dc068e22a0efbfdacd9c992",
     15                "reference": "5e2ba7e3f585fc8e6dc068e22a0efbfdacd9c992",
    1616                "shasum": ""
    1717            },
     
    2929                "vlucas/phpdotenv": "^5.5"
    3030            },
    31             "time": "2024-04-03T08:35:46+00:00",
     31            "time": "2024-09-13T14:54:13+00:00",
    3232            "type": "library",
    3333            "installation-source": "dist",
     
    5454            "support": {
    5555                "issues": "https://github.com/btcpayserver/btcpayserver-greenfield-php/issues",
    56                 "source": "https://github.com/btcpayserver/btcpayserver-greenfield-php/tree/v2.5.0"
     56                "source": "https://github.com/btcpayserver/btcpayserver-greenfield-php/tree/v2.7.0"
    5757            },
    5858            "install-path": "../btcpayserver/btcpayserver-greenfield-php"
  • btcpay-greenfield-for-woocommerce/tags/2.7.0/vendor/composer/installed.php

    r3064837 r3151490  
    2121        ),
    2222        'btcpayserver/btcpayserver-greenfield-php' => array(
    23             'pretty_version' => 'v2.5.0',
    24             'version' => '2.5.0.0',
    25             'reference' => '385b7f6882213e1142b58af89b24dd1495d6babc',
     23            'pretty_version' => 'v2.7.0',
     24            'version' => '2.7.0.0',
     25            'reference' => '5e2ba7e3f585fc8e6dc068e22a0efbfdacd9c992',
    2626            'type' => 'library',
    2727            'install_path' => __DIR__ . '/../btcpayserver/btcpayserver-greenfield-php',
  • btcpay-greenfield-for-woocommerce/trunk/assets/js/frontend/blocks.asset.php

    r3010485 r3151490  
    1 <?php return array('dependencies' => array('wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => 'cb815af5c4b849e4861bcc4c5d20b694');
     1<?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-html-entities', 'wp-i18n'), 'version' => 'f27172b7905ad8eb456218bc4613cd3a');
  • btcpay-greenfield-for-woocommerce/trunk/assets/js/frontend/blocks.js

    r3010485 r3151490  
    1 (()=>{"use strict";const e=window.wp.element,t=window.wp.i18n,n=window.wc.wcBlocksRegistry,i=window.wp.htmlEntities,o=(0,window.wc.wcSettings.getSetting)("btcpaygf_default_data",{}),a=(0,t.__)("Bitcoin / Lightning Network over BTCPay Server","woo-gutenberg-products-block"),c=(0,i.decodeEntities)(o.title)||a,l=()=>(0,i.decodeEntities)(o.description||""),r={name:"btcpaygf_default",label:(0,e.createElement)(t=>{const{PaymentMethodLabel:n}=t.components;return(0,e.createElement)(n,{text:c})},null),content:(0,e.createElement)(l,null),edit:(0,e.createElement)(l,null),canMakePayment:()=>!0,ariaLabel:c,supports:{features:o.supports}};(0,n.registerPaymentMethod)(r)})();
     1(()=>{"use strict";var e={20:(e,t,r)=>{var o=r(609),n=Symbol.for("react.element"),s=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),i=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};t.jsx=function(e,t,r){var o,c={},p=null,d=null;for(o in void 0!==r&&(p=""+r),void 0!==t.key&&(p=""+t.key),void 0!==t.ref&&(d=t.ref),t)s.call(t,o)&&!a.hasOwnProperty(o)&&(c[o]=t[o]);if(e&&e.defaultProps)for(o in t=e.defaultProps)void 0===c[o]&&(c[o]=t[o]);return{$$typeof:n,type:e,key:p,ref:d,props:c,_owner:i.current}}},848:(e,t,r)=>{e.exports=r(20)},609:e=>{e.exports=window.React}},t={};const r=window.wp.i18n,o=window.wc.wcBlocksRegistry,n=window.wp.htmlEntities,s=window.wc.wcSettings;var i=function r(o){var n=t[o];if(void 0!==n)return n.exports;var s=t[o]={exports:{}};return e[o](s,s.exports,r),s.exports}(848);const a=(0,s.getSetting)("btcpaygf_default_data",{}),c=(0,r.__)("Bitcoin / Lightning Network over BTCPay Server","woo-gutenberg-products-block"),p=(0,n.decodeEntities)(a.title)||c,d=()=>(0,n.decodeEntities)(a.description||""),f=e=>{const{PaymentMethodLabel:t}=e.components;return(0,i.jsx)(t,{text:p})},l={name:"btcpaygf_default",label:(0,i.jsx)(f,{}),content:(0,i.jsx)(d,{}),edit:(0,i.jsx)(d,{}),canMakePayment:()=>!0,ariaLabel:p,supports:{features:a.supports}};(0,o.registerPaymentMethod)(l)})();
  • btcpay-greenfield-for-woocommerce/trunk/assets/js/frontend/blocksModalCheckout.js

    r3029529 r3151490  
    1 let isProcessingOrder=!1,lastExecutionTime=0;const debounceInterval=1e3;wp.data.subscribe(()=>{const e=Date.now();if(!(e-lastExecutionTime<1e3)&&wp.data.select(wc.wcBlocksData.CHECKOUT_STORE_KEY).isBeforeProcessing()&&!isProcessingOrder){isProcessingOrder=!0,lastExecutionTime=e;const t=wp.data.select(wc.wcBlocksData.PAYMENT_STORE_KEY).getState().activePaymentMethod;if(t.startsWith("btcpaygf_")){let e=blocksProcessOrder(t);return e?(blocksShowBTCPayModal(e),isProcessingOrder=!1,!1):(blocksSubmitError(BTCPayWP.textProcessingError),isProcessingOrder=!1,!1)}return!0}});const blocksProcessOrder=function(e){let t=null,o={action:"btcpaygf_modal_blocks_checkout",orderId:wp.data.select(wc.wcBlocksData.CHECKOUT_STORE_KEY).getOrderId(),paymentGateway:e,apiNonce:BTCPayWP.apiNonce};return jQuery.ajaxSetup({async:!1}),jQuery.post(wc_add_to_cart_params.ajax_url,o,(function(e){e.data.invoiceId?t=e.data:e.data?blocksSubmitError(e.data):blocksSubmitError(BTCPayWP.textProcessingError)})).fail((function(){blocksSubmitError(BTCPayWP.textProcessingError),console.error("Error on ajax request 2")})),jQuery.ajaxSetup({async:!0}),t},blocksShowBTCPayModal=function(e){void 0!==e.invoiceId&&(window.btcpay.setApiUrlPrefix(BTCPayWP.apiUrl),window.btcpay.showInvoice(e.invoiceId));let t=!1;window.btcpay.onModalReceiveMessage((function(r){if(o(r.data)){if(r.data.status)switch(r.data.status){case"complete":case"paid":t=!0,window.location=e.orderCompleteLink;break;case"expired":window.btcpay.hideFrame(),blocksSubmitError(BTCPayWP.textInvoiceExpired),console.error("Invoice expired")}}else"close"===r.data&&(!0===t&&(window.location=e.orderCompleteLink),blocksSubmitError(BTCPayWP.textModalClosed))}));const o=e=>"[object Object]"===Object.prototype.toString.call(e)},blocksSubmitError=function(e){window.wp.data.dispatch("core/notices").createErrorNotice(e,{context:"wc/checkout"}),resetCheckout()},resetCheckout=function(){wp.data.dispatch(wc.wcBlocksData.CHECKOUT_STORE_KEY).__internalSetIdle()};
     1let isProcessingOrder=!1,lastExecutionTime=0;const debounceInterval=1e3;wp.data.subscribe((()=>{const e=Date.now();if(!(e-lastExecutionTime<1e3)&&wp.data.select(wc.wcBlocksData.CHECKOUT_STORE_KEY).isBeforeProcessing()&&!isProcessingOrder){isProcessingOrder=!0,lastExecutionTime=e;const t=wp.data.select(wc.wcBlocksData.PAYMENT_STORE_KEY).getState().activePaymentMethod;if(t.startsWith("btcpaygf_")){let e=blocksProcessOrder(t);return e?(blocksShowBTCPayModal(e),isProcessingOrder=!1,!1):(blocksSubmitError(BTCPayWP.textProcessingError),isProcessingOrder=!1,!1)}return!0}}));const blocksProcessOrder=function(e){let t=null,o={action:"btcpaygf_modal_blocks_checkout",orderId:wp.data.select(wc.wcBlocksData.CHECKOUT_STORE_KEY).getOrderId(),paymentGateway:e,apiNonce:BTCPayWP.apiNonce};return jQuery.ajaxSetup({async:!1}),jQuery.post(wc_add_to_cart_params.ajax_url,o,(function(e){e.data.invoiceId?t=e.data:e.data?blocksSubmitError(e.data):blocksSubmitError(BTCPayWP.textProcessingError)})).fail((function(){blocksSubmitError(BTCPayWP.textProcessingError),console.error("Error on ajax request 2")})),jQuery.ajaxSetup({async:!0}),t},blocksShowBTCPayModal=function(e){void 0!==e.invoiceId&&(window.btcpay.setApiUrlPrefix(BTCPayWP.apiUrl),window.btcpay.showInvoice(e.invoiceId));let t=!1;window.btcpay.onModalReceiveMessage((function(a){if(o(a.data)){if(a.data.status)switch(a.data.status.toLowerCase()){case"complete":case"paid":case"processing":case"settled":t=!0,setTimeout((function(){window.location=e.orderCompleteLink}),3e3);break;case"expired":window.btcpay.hideFrame(),submitError(BTCPayWP.textInvoiceExpired);break;case"invalid":window.btcpay.hideFrame(),submitError(BTCPayWP.textInvoiceInvalid)}}else"close"===a.data&&(!0===t&&(window.location=e.orderCompleteLink),blocksSubmitError(BTCPayWP.textModalClosed))}));const o=e=>"[object Object]"===Object.prototype.toString.call(e)},blocksSubmitError=function(e){window.wp.data.dispatch("core/notices").createErrorNotice(e,{context:"wc/checkout"}),resetCheckout()},resetCheckout=function(){wp.data.dispatch(wc.wcBlocksData.CHECKOUT_STORE_KEY).__internalSetIdle()};
  • btcpay-greenfield-for-woocommerce/trunk/assets/js/frontend/modalCheckout.js

    r3010485 r3151490  
    7474                //console.log('BTCPay modal event: status: ' + event.data.status);
    7575                if (event.data.status) {
    76                     switch (event.data.status) {
     76                    switch (event.data.status.toLowerCase()) {
    7777                        case 'complete':
    7878                        case 'paid':
     79                        case 'processing':
     80                        case 'settled':
    7981                            invoice_paid = true;
    80                             window.location = data.orderCompleteLink;
     82                            setTimeout(function() {
     83                                window.location = data.orderCompleteLink;
     84                            }, 3000);
    8185                            break;
    8286                        case 'expired':
    8387                            window.btcpay.hideFrame();
    8488                            submitError(BTCPayWP.textInvoiceExpired);
     89                            break;
     90                        case 'invalid':
     91                            window.btcpay.hideFrame();
     92                            submitError(BTCPayWP.textInvoiceInvalid);
    8593                            break;
    8694                    }
  • btcpay-greenfield-for-woocommerce/trunk/btcpay-greenfield-for-woocommerce.php

    r3067196 r3151490  
    88 * Text Domain:     btcpay-greenfield-for-woocommerce
    99 * Domain Path:     /languages
    10  * Version:         2.6.2
     10 * Version:         2.7.0
    1111 * Requires PHP:    8.0
    12  * Tested up to:    6.5
    13  * Requires at least: 5.9
    14  * WC requires at least: 6.0
    15  * WC tested up to: 8.7
     12 * Tested up to:    6.6
     13 * Requires at least: 6.2
     14 * WC requires at least: 7.0
     15 * WC tested up to: 9.3
    1616 */
    1717
     
    2727defined( 'ABSPATH' ) || exit();
    2828
    29 define( 'BTCPAYSERVER_VERSION', '2.6.2' );
     29define( 'BTCPAYSERVER_VERSION', '2.7.0' );
    3030define( 'BTCPAYSERVER_VERSION_KEY', 'btcpay_gf_version' );
    3131define( 'BTCPAYSERVER_PLUGIN_FILE_PATH', plugin_dir_path( __FILE__ ) );
  • btcpay-greenfield-for-woocommerce/trunk/changelog.txt

    r3064837 r3151490  
     1= 2.4.1 :: 2024-01-22 =
     2* Fix: Ensure order status is not cancelled if paid by other payment gateway.
     3* Show periodically notification to review the plugin.
     4* Updating readme.txt (fixing text, updating banner and screenshots)
     5
     6= 2.4.0 :: 2023-12-15 =
     7* Fix: Avoid error on InvoiceProcessing/InvoiceSettled event in case of paidOver property is missing.
     8* New feature: Add basic support for WooCommerce cart and checkout blocks.
     9Note: Works for default configuration; future versions will make it work with modal checkout and separate payment gateways too.
     10
    111= 2.3.1 :: 2023-10-20 =
    212* Fix: Ensure refunds text does not exceed API field limit.
  • btcpay-greenfield-for-woocommerce/trunk/languages/btcpay-greenfield-for-woocommerce.pot

    r3067196 r3151490  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: BTCPay For Woocommerce V2 2.6.2\n"
     5"Project-Id-Version: BTCPay For Woocommerce V2 2.7.0\n"
    66"Report-Msgid-Bugs-To: https://woocommerce.com/my-account/create-a-ticket/\n"
    77"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
     
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "POT-Creation-Date: 2024-04-08T22:16:18+00:00\n"
     12"POT-Creation-Date: 2024-09-13T17:17:15+00:00\n"
    1313"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    14 "X-Generator: WP-CLI 2.10.0\n"
     14"X-Generator: WP-CLI 2.11.0\n"
    1515"language-team: LANGUAGE <EMAIL@ADDRESS>\n"
    1616"X-Domain: btcpay-greenfield-for-woocommerce\n"
     
    9090
    9191#: btcpay-greenfield-for-woocommerce.php:518
    92 #: src/Admin/GlobalSettings.php:374
     92#: src/Admin/GlobalSettings.php:381
    9393msgid "Successfully registered a new webhook on BTCPay Server."
    9494msgstr ""
    9595
    9696#: btcpay-greenfield-for-woocommerce.php:522
    97 #: src/Admin/GlobalSettings.php:378
     97#: src/Admin/GlobalSettings.php:385
    9898msgid "Could not register a new webhook on the store."
    9999msgstr ""
     
    315315
    316316#: src/Admin/GlobalSettings.php:250
     317msgid "Customer visible refunds"
     318msgstr ""
     319
     320#: src/Admin/GlobalSettings.php:253
     321msgctxt "global_settings"
     322msgid "If enabled, it will show the order refund note also to the customer and trigger an email to customer with the refund link."
     323msgstr ""
     324
     325#: src/Admin/GlobalSettings.php:257
    317326msgid "Debug Log"
    318327msgstr ""
    319328
    320 #: src/Admin/GlobalSettings.php:253
     329#: src/Admin/GlobalSettings.php:260
    321330msgctxt "global_settings"
    322331msgid "Enable logging <a href=\"%s\" class=\"button\">View Logs</a>"
    323332msgstr ""
    324333
    325 #: src/Admin/GlobalSettings.php:285
     334#: src/Admin/GlobalSettings.php:292
    326335msgid "The provided API key scope is valid for multiple stores, please make sure to create one for a single store."
    327336msgstr ""
    328337
    329 #: src/Admin/GlobalSettings.php:293
     338#: src/Admin/GlobalSettings.php:300
    330339msgid "The provided API key does not match the required permissions. Please make sure the following permissions are are given: %s"
    331340msgstr ""
    332341
    333 #: src/Admin/GlobalSettings.php:307
     342#: src/Admin/GlobalSettings.php:314
    334343msgid "Your BTCPay Server is not fully synched yet. Until fully synched the checkout will not work."
    335344msgstr ""
    336345
    337 #: src/Admin/GlobalSettings.php:316
     346#: src/Admin/GlobalSettings.php:323
    338347msgid "Your BTCPay Server version does not support refunds, please update to at least version 1.7.6 or newer."
    339348msgstr ""
    340349
    341 #: src/Admin/GlobalSettings.php:322
     350#: src/Admin/GlobalSettings.php:329
    342351msgid "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>."
    343352msgstr ""
    344353
    345 #: src/Admin/GlobalSettings.php:345
    346 #: src/Admin/GlobalSettings.php:366
     354#: src/Admin/GlobalSettings.php:352
     355#: src/Admin/GlobalSettings.php:373
    347356msgid "Successfully setup manual webhook."
    348357msgstr ""
    349358
    350 #: src/Admin/GlobalSettings.php:349
     359#: src/Admin/GlobalSettings.php:356
    351360msgid "Webhook already exists, skipping webhook creation."
    352361msgstr ""
    353362
    354 #: src/Admin/GlobalSettings.php:391
     363#: src/Admin/GlobalSettings.php:398
    355364msgid "No wallet configured on your BTCPay Server store settings. Make sure to add at least one otherwise this plugin will not work."
    356365msgstr ""
    357366
    358 #: src/Admin/GlobalSettings.php:397
     367#: src/Admin/GlobalSettings.php:404
    359368msgid "Exception loading wallet information (payment methods) from BTCPay Server: %s."
    360369msgstr ""
    361370
    362 #: src/Admin/GlobalSettings.php:406
     371#: src/Admin/GlobalSettings.php:413
    363372msgid "Error fetching data for this API key from server. Please check if the key is valid. Error: %s"
    364373msgstr ""
    365374
    366 #: src/Admin/GlobalSettings.php:423
     375#: src/Admin/GlobalSettings.php:430
    367376msgid "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."
    368377msgstr ""
     
    405414msgstr ""
    406415
    407 #: src/Gateway/AbstractGateway.php:222
     416#: src/Gateway/AbstractGateway.php:223
    408417msgid "Refund of order "
    409418msgstr ""
    410419
    411 #: src/Gateway/AbstractGateway.php:300
     420#: src/Gateway/AbstractGateway.php:307
    412421msgid "Gateway Icon:"
    413422msgstr ""
    414423
    415 #: src/Gateway/AbstractGateway.php:305
     424#: src/Gateway/AbstractGateway.php:312
    416425msgid "Upload or select icon"
    417426msgstr ""
    418427
    419 #: src/Gateway/AbstractGateway.php:311
     428#: src/Gateway/AbstractGateway.php:318
    420429msgid "Remove image"
    421430msgstr ""
    422431
    423 #: src/Gateway/AbstractGateway.php:361
     432#: src/Gateway/AbstractGateway.php:368
    424433msgid "Use this image"
    425434msgstr ""
    426435
    427 #: src/Gateway/AbstractGateway.php:362
     436#: src/Gateway/AbstractGateway.php:369
    428437msgid "Insert image"
    429438msgstr ""
    430439
    431 #: src/Gateway/AbstractGateway.php:412
     440#: src/Gateway/AbstractGateway.php:419
    432441msgctxt "js"
    433442msgid "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."
    434443msgstr ""
    435444
    436 #: src/Gateway/AbstractGateway.php:413
     445#: src/Gateway/AbstractGateway.php:420
     446msgctxt "js"
     447msgid "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."
     448msgstr ""
     449
     450#: src/Gateway/AbstractGateway.php:421
    437451msgctxt "js"
    438452msgid "Payment aborted by you. Please try again or choose a different payment method."
    439453msgstr ""
    440454
    441 #: src/Gateway/AbstractGateway.php:414
     455#: src/Gateway/AbstractGateway.php:422
    442456msgctxt "js"
    443457msgid "Error processing checkout. Please try again or choose another payment option."
    444458msgstr ""
    445459
    446 #: src/Gateway/AbstractGateway.php:496
     460#: src/Gateway/AbstractGateway.php:510
    447461msgid "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."
    448462msgstr ""
    449463
    450 #: src/Gateway/AbstractGateway.php:508
     464#: src/Gateway/AbstractGateway.php:522
    451465msgid "Invoice (partial) payment incoming (unconfirmed) after invoice was already expired."
    452466msgstr ""
    453467
    454 #: src/Gateway/AbstractGateway.php:511
     468#: src/Gateway/AbstractGateway.php:525
    455469msgid "Invoice (partial) payment incoming (unconfirmed). Waiting for settlement."
    456470msgstr ""
    457471
    458 #: src/Gateway/AbstractGateway.php:530
     472#: src/Gateway/AbstractGateway.php:544
    459473msgid "Invoice fully settled after invoice was already expired. Needs manual checking."
    460474msgstr ""
    461475
    462 #: src/Gateway/AbstractGateway.php:535
     476#: src/Gateway/AbstractGateway.php:549
    463477msgid "(Partial) payment settled but invoice not settled yet (could be more transactions incoming). Needs manual checking."
    464478msgstr ""
    465479
    466 #: src/Gateway/AbstractGateway.php:539
     480#: src/Gateway/AbstractGateway.php:553
    467481msgid "Invoice (partial) payment settled."
    468482msgstr ""
    469483
    470 #: src/Gateway/AbstractGateway.php:549
     484#: src/Gateway/AbstractGateway.php:563
    471485msgid "Invoice payment received fully with overpayment, waiting for settlement."
    472486msgstr ""
    473487
    474 #: src/Gateway/AbstractGateway.php:551
     488#: src/Gateway/AbstractGateway.php:565
    475489msgid "Invoice payment received fully, waiting for settlement."
    476490msgstr ""
    477491
    478 #: src/Gateway/AbstractGateway.php:557
     492#: src/Gateway/AbstractGateway.php:571
    479493msgid "Invoice manually marked invalid."
    480494msgstr ""
    481495
    482 #: src/Gateway/AbstractGateway.php:559
     496#: src/Gateway/AbstractGateway.php:573
    483497msgid "Invoice became invalid."
    484498msgstr ""
    485499
    486 #: src/Gateway/AbstractGateway.php:565
     500#: src/Gateway/AbstractGateway.php:579
    487501msgid "Invoice expired but was paid partially, please check."
    488502msgstr ""
    489503
    490 #: src/Gateway/AbstractGateway.php:568
     504#: src/Gateway/AbstractGateway.php:582
    491505msgid "Invoice expired."
    492506msgstr ""
    493507
    494 #: src/Gateway/AbstractGateway.php:574
     508#: src/Gateway/AbstractGateway.php:588
    495509msgid "Invoice payment settled but was overpaid."
    496510msgstr ""
    497511
    498 #: src/Gateway/AbstractGateway.php:577
     512#: src/Gateway/AbstractGateway.php:591
    499513msgid "Invoice payment settled."
    500514msgstr ""
    501515
    502 #: src/Gateway/AbstractGateway.php:620
     516#: src/Gateway/AbstractGateway.php:634
    503517msgid "BTCPay invoice manually set to invalid because customer went back to checkout and changed payment gateway."
    504518msgstr ""
  • btcpay-greenfield-for-woocommerce/trunk/readme.txt

    r3067196 r3151490  
    33Donate link: https://btcpayserver.org/donate/
    44Tags: Bitcoin, Lightning Network, BTCPay Server, WooCommerce, payment gateway
    5 Requires at least: 5.2
    6 Tested up to: 6.5
     5Requires at least: 5.9
     6Tested up to: 6.6
    77Requires PHP: 8.0
    8 Stable tag: 2.6.2
     8Stable tag: 2.7.0
    99License: MIT
    1010License URI: https://github.com/btcpayserver/woocommerce-greenfield-plugin/blob/master/license.txt
     
    112112
    113113== Upgrade Notice ==
    114 = 2.6.2 =
    115 * Notifications fix, buttons should now work.
     114
     115
     116
     117= 2.7.0 =
     118* IMPORTANT: If you use the "Separate Payment gateways" feature, when you upgrade your BTCPay Server to version 2.0.0 or newer, you will need to reconfigure your payment gateways in WooCommerce. This is due to the new way of handling and naming payment methods in BTCPay Server.
     119* Feature: Add option to notify customers on refund order notes.
     120* Feature: BTCPay Server 2.0.0 compatibility.
     121* Fixes see changelog.
    116122
    117123== Changelog ==
     124= 2.7.0 :: 2024-09-04 =
     125* Feature: Add option to notify customers on refund order notes.
     126* Feature: BTCPay Server 2.0.0 compatibility.
     127* Fix: Make sure to not process orders if the assigned payment gateway is not one of BTCPay.
     128* Fix: Make sure payment methods are set on refunds.
     129* Fix: Wrong currency in refund comment.
     130* Fix: Deprecation warnings.
     131* Maintenance: Update NodeJS dependencies.
     132* Maintenance: Update PHP library to v2.7.0.
     133
    118134= 2.6.2 :: 2024-04-09 =
    119135* Fix: Dismissing the review notification forever, finally.
     
    133149* Add support for modal overlay for checkout blocks.
    134150
    135 = 2.4.1 :: 2024-01-22 =
    136 * Fix: Ensure order status is not cancelled if paid by other payment gateway.
    137 * Show periodically notification to review the plugin.
    138 * Updating readme.txt (fixing text, updating banner and screenshots)
    139 
    140 = 2.4.0 :: 2023-12-15 =
    141 * Fix: Avoid error on InvoiceProcessing/InvoiceSettled event in case of paidOver property is missing.
    142 * New feature: Add basic support for WooCommerce cart and checkout blocks.
    143 Note: Works for default configuration; future versions will make it work with modal checkout and separate payment gateways too.
    144 
    145151
    146152Changelog of older releases can be found [here](https://github.com/btcpayserver/woocommerce-greenfield-plugin/blob/master/changelog.txt)
  • btcpay-greenfield-for-woocommerce/trunk/resources/js/frontend/blocksModalCheckout.js

    r3029529 r3151490  
    125125            //console.log('BTCPay modal event: status: ' + event.data.status);
    126126            if (event.data.status) {
    127                 switch (event.data.status) {
     127                switch (event.data.status.toLowerCase()) {
    128128                    case 'complete':
    129129                    case 'paid':
     130                    case 'processing':
     131                    case 'settled':
    130132                        invoice_paid = true;
    131                         window.location = data.orderCompleteLink;
     133                        setTimeout(function() {
     134                            window.location = data.orderCompleteLink;
     135                        }, 3000);
    132136                        break;
    133137                    case 'expired':
    134138                        window.btcpay.hideFrame();
    135                         blocksSubmitError(BTCPayWP.textInvoiceExpired);
    136                         console.error('Invoice expired');
     139                        submitError(BTCPayWP.textInvoiceExpired);
     140                        break;
     141                    case 'invalid':
     142                        window.btcpay.hideFrame();
     143                        submitError(BTCPayWP.textInvoiceInvalid);
    137144                        break;
    138145                }
  • btcpay-greenfield-for-woocommerce/trunk/resources/js/frontend/modalCheckout.js

    r3010485 r3151490  
    7474                //console.log('BTCPay modal event: status: ' + event.data.status);
    7575                if (event.data.status) {
    76                     switch (event.data.status) {
     76                    switch (event.data.status.toLowerCase()) {
    7777                        case 'complete':
    7878                        case 'paid':
     79                        case 'processing':
     80                        case 'settled':
    7981                            invoice_paid = true;
    80                             window.location = data.orderCompleteLink;
     82                            setTimeout(function() {
     83                                window.location = data.orderCompleteLink;
     84                            }, 3000);
    8185                            break;
    8286                        case 'expired':
    8387                            window.btcpay.hideFrame();
    8488                            submitError(BTCPayWP.textInvoiceExpired);
     89                            break;
     90                        case 'invalid':
     91                            window.btcpay.hideFrame();
     92                            submitError(BTCPayWP.textInvoiceInvalid);
    8593                            break;
    8694                    }
  • btcpay-greenfield-for-woocommerce/trunk/src/Admin/GlobalSettings.php

    r3064837 r3151490  
    246246                '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' ),
    247247                'id' => 'btcpay_gf_sats_mode'
     248            ],
     249            'refund_note_visible' => [
     250                'title' => __( 'Customer visible refunds', 'btcpay-greenfield-for-woocommerce' ),
     251                'type' => 'checkbox',
     252                'default' => 'no',
     253                'desc' => _x( 'If enabled, it will show the order refund note also to the customer and trigger an email to customer with the refund link.', 'global_settings', 'btcpay-greenfield-for-woocommerce' ),
     254                'id' => 'btcpay_gf_refund_note_visible'
    248255            ],
    249256            'debug' => [
  • btcpay-greenfield-for-woocommerce/trunk/src/Gateway/AbstractGateway.php

    r3064837 r3151490  
    186186        $refundAmount = PreciseNumber::parseString($amount);
    187187        $currency = $order->get_currency();
     188        $originalCurrency = $order->get_currency();
    188189
    189190        // Check if order has invoice id.
     
    215216        $paymentMethods = $this->getPaymentMethods();
    216217        // Remove LNURL
    217         if (in_array('BTC_LNURLPAY', $paymentMethods)) {
    218             $paymentMethods = array_diff($paymentMethods, ['BTC_LNURLPAY']);
     218        if (in_array('BTC_LNURLPAY', $paymentMethods) || in_array('BTC_LNURL', $paymentMethods)) {
     219            $paymentMethods = array_diff($paymentMethods, ['BTC_LNURLPAY', 'BTC_LNURL']);
    219220        }
    220221
     
    243244                $refundMsg = "PullPayment ID: " . $pullPayment->getId() . "\n";
    244245                $refundMsg .= "Link: " . $pullPayment->getViewLink() . "\n";
    245                 $refundMsg .= "Amount: " . $amount . " " . $currency . "\n";
     246                $refundMsg .= "Amount: " . $amount . " " . $originalCurrency . "\n";
    246247                $refundMsg .= "Reason: " . $reason;
    247248                $successMsg = 'Successfully created refund: ' . $refundMsg;
     
    249250                Logger::debug($successMsg);
    250251
    251                 $order->add_order_note($successMsg);
     252                // Add public or private order note.
     253                if (get_option('btcpay_gf_refund_note_visible') === 'yes') {
     254                    $order->add_order_note($successMsg, 1);
     255                } else {
     256                    $order->add_order_note($successMsg);
     257                }
     258
    252259                // Use add_meta_data to allow for partial refunds.
    253260                $order->add_meta_data('BTCPay_refund', $refundMsg, false);
     
    411418            'isAddPaymentMethodPage' => is_add_payment_method_page() ? 'yes' : 'no',
    412419            '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' ),
     420            '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' ),
    413421            'textModalClosed' => _x( 'Payment aborted by you. Please try again or choose a different payment method.', 'js', 'btcpay-greenfield-for-woocommerce' ),
    414422            'textProcessingError' => _x( 'Error processing checkout. Please try again or choose another payment option.', 'js', 'btcpay-greenfield-for-woocommerce' ),
     
    464472                    Logger::debug(print_r($orders, true));
    465473                    wp_die('Multiple orders found for this invoiceId, aborting.');
     474                }
     475
     476                // Only continue if the order payment method contains string "btcpaygf_" to avoid processing other gateways.
     477                if (strpos($orders[0]->get_payment_method(), 'btcpaygf_') === false) {
     478                    Logger::debug('Order payment method does not contain "btcpaygf_", aborting.');
     479                    wp_send_json_success(); // return 200 OK to not mess up BTCPay queue
    466480                }
    467481
  • btcpay-greenfield-for-woocommerce/trunk/src/Gateway/DefaultGateway.php

    r3010485 r3151490  
    6565        $btcPayPaymentGW = [];
    6666
    67         if ($this->get_option('enforce_payment_tokens') === 'yes') {
     67        // If separate gateways are enabled and payment tokens are enforced.
     68        if (get_option('btcpay_gf_separate_gateways') === 'yes' && $this->get_option('enforce_payment_tokens') === 'yes') {
    6869            $gateways = WC()->payment_gateways->payment_gateways();
    6970            /** @var  $gateway AbstractGateway */
     
    7980        }
    8081
    81         // If payment tokens are not enforced set all.
     82        // If payment tokens are not enforced or separate gateways are not enabled.
    8283        $separateGateways = \BTCPayServer\WC\Helper\GreenfieldApiHelper::supportedPaymentMethods();
    8384        foreach ($separateGateways as $sgw) {
  • btcpay-greenfield-for-woocommerce/trunk/src/Helper/GreenfieldApiHelper.php

    r3042021 r3151490  
    2222    public $apiKey;
    2323    public $storeId;
     24    public $webhook;
    2425
    2526    // todo: need to refactor as it loads cached options if form submitted by ajax
     
    6465        if ($config) {
    6566            $client = new Store($config['url'], $config['api_key']);
    66             if (!empty($stores = $client->getStores())) {
     67            if (!empty($client->getStores())) {
    6768                return true;
    6869            } else {
  • btcpay-greenfield-for-woocommerce/trunk/vendor/btcpayserver/btcpayserver-greenfield-php/src/Client/Invoice.php

    r3064837 r3151490  
    88use BTCPayServer\Result\InvoiceList;
    99use BTCPayServer\Result\InvoicePaymentMethod;
     10use BTCPayServer\Result\PullPayment as ResultPullPayment;
    1011use BTCPayServer\Util\PreciseNumber;
    1112
     
    160161    {
    161162        $method = 'GET';
    162         $url = $this->getApiUrl() . 'stores/' . urlencode($storeId) . '/invoices/' . urlencode($invoiceId) . '/payment-methods';
     163        $url = $this->getApiUrl() . 'stores/' . urlencode($storeId) . '/invoices/'
     164            . urlencode($invoiceId) . '/payment-methods';
    163165        $headers = $this->getRequestHeaders();
    164166        $response = $this->getHttpClient()->request($method, $url, $headers);
     
    182184    }
    183185
     186    /**
     187     * Mark an invoice status.
     188     *
     189     * @see https://docs.btcpayserver.org/API/Greenfield/v1/#operation/Invoices_MarkInvoiceStatus
     190     * @throws \JsonException
     191     */
    184192    public function markInvoiceStatus(string $storeId, string $invoiceId, string $markAs): ResultInvoice
    185193    {
    186         $url = $this->getApiUrl() . 'stores/' . urlencode(
    187             $storeId
    188         ) . '/invoices/' . urlencode($invoiceId) . '/status';
     194        $url = $this->getApiUrl() . 'stores/' . urlencode($storeId) . '/invoices/' . urlencode($invoiceId) . '/status';
    189195        $headers = $this->getRequestHeaders();
    190196        $method = 'POST';
     
    207213        }
    208214    }
     215
     216    /**
     217     * Refund an invoice.
     218     *
     219     * @see https://docs.btcpayserver.org/API/Greenfield/v1/#operation/Invoices_Refund
     220     * @throws \JsonException
     221     */
     222    public function refundInvoice(
     223        string $storeId,
     224        string $invoiceId,
     225        ?string $refundVariant = 'CurrentRate',
     226        ?string $paymentMethod = 'BTC',
     227        ?string $name = null,
     228        ?string $description = null,
     229        ?float $subtractPercentage = 0.0,
     230        ?PreciseNumber $customAmount = null,
     231        ?string $customCurrency = null
     232    ): ResultPullPayment {
     233        $url = $this->getApiUrl() . 'stores/' . urlencode($storeId) . '/invoices/' . urlencode($invoiceId) . '/refund';
     234        $headers = $this->getRequestHeaders();
     235        $method = 'POST';
     236
     237        $body = json_encode(
     238            [
     239                'name' => $name,
     240                'description' => $description,
     241                'paymentMethod' => $paymentMethod,
     242                'refundVariant' => $refundVariant,
     243                'subtractPercentage' => $subtractPercentage,
     244                'customAmount' => $customAmount?->__toString(),
     245                'customCurrency' => $customCurrency
     246            ],
     247            JSON_THROW_ON_ERROR
     248        );
     249
     250        $response = $this->getHttpClient()->request($method, $url, $headers, $body);
     251
     252        if ($response->getStatus() === 200) {
     253            return new ResultPullPayment(
     254                json_decode($response->getBody(), true, 512, JSON_THROW_ON_ERROR)
     255            );
     256        } else {
     257            throw $this->getExceptionByStatusCode($method, $url, $response);
     258        }
     259    }
    209260}
  • btcpay-greenfield-for-woocommerce/trunk/vendor/btcpayserver/btcpayserver-greenfield-php/src/Client/PullPayment.php

    r3042021 r3151490  
    5151        ?int $startsAt,
    5252        ?int $expiresAt,
    53         array $paymentMethods
     53        array $paymentMethods,
     54        ?string $description = null
    5455    ): ResultPullPayment {
    5556        $url = $this->getApiUrl() . 'stores/' .
     
    6263            [
    6364                'name' => $name,
     65                'description' => $description,
    6466                'amount' => $amount->__toString(),
    6567                'currency' => $currency,
  • btcpay-greenfield-for-woocommerce/trunk/vendor/btcpayserver/btcpayserver-greenfield-php/src/Client/StorePaymentMethod.php

    r3042021 r3151490  
    1616class StorePaymentMethod extends AbstractClient
    1717{
    18     public function getPaymentMethods(string $storeId): array
     18    public function getPaymentMethods(string $storeId, bool $includeConfig = false): array
    1919    {
    2020        $url = $this->getApiUrl() . 'stores/' . urlencode($storeId) . '/payment-methods';
     21        if ($includeConfig) {
     22            $url .= '?includeConfig=true';
     23        }
    2124        $headers = $this->getRequestHeaders();
    2225        $method = 'GET';
  • btcpay-greenfield-for-woocommerce/trunk/vendor/btcpayserver/btcpayserver-greenfield-php/src/Result/ApiKey.php

    r2674285 r3151490  
    77class ApiKey extends AbstractResult
    88{
     9    public function getApiKey(): string
     10    {
     11        return $this->getData()['apiKey'];
     12    }
     13
     14    public function getLabel(): string
     15    {
     16        return $this->getData()['label'];
     17    }
     18
     19    public function getPermissions(): array
     20    {
     21        return $this->getData()['permissions'];
     22    }
    923}
  • btcpay-greenfield-for-woocommerce/trunk/vendor/btcpayserver/btcpayserver-greenfield-php/src/Result/InvoicePaymentMethod.php

    r2674285 r3151490  
    6060    {
    6161        $data = $this->getData();
    62         return $data['networkFee'];
     62        // BTCPay 2.0.0 compatibility: networkFee was renamed to paymentMethodFee.
     63        return $data['networkFee'] ?? $data['paymentMethodFee'];
    6364    }
    6465
     
    6667    {
    6768        $data = $this->getData();
    68         return $data['paymentMethod'];
     69        // BTCPay 2.0.0 compatibility: paymentMethod was renamed to paymentMethodId.
     70        return $data['paymentMethod'] ?? $data['paymentMethodId'];
    6971    }
    7072
     
    7274    {
    7375        $data = $this->getData();
     76        // BTCPay 2.0.0 compatibility: cryptoCode was renamed to currency.
     77        if (isset($data['currency'])) {
     78            return $data['currency'];
     79        }
     80
    7481        // For future compatibility check if cryptoCode exists.
    7582        if (isset($data['cryptoCode'])) {
     
    7784        } else {
    7885            // Extract cryptoCode from paymentMethod string.
    79             $parts = explode('-', $data['paymentMethod']);
     86            $parts = explode('-', $this->getPaymentMethod());
    8087            return $parts[0];
    8188        }
  • btcpay-greenfield-for-woocommerce/trunk/vendor/btcpayserver/btcpayserver-greenfield-php/src/Result/PullPayment.php

    r2679022 r3151490  
    1919        $data = $this->getData();
    2020        return $data['name'];
     21    }
     22
     23    public function getDescription(): string
     24    {
     25        $data = $this->getData();
     26        return $data['description'];
    2127    }
    2228
  • btcpay-greenfield-for-woocommerce/trunk/vendor/btcpayserver/btcpayserver-greenfield-php/src/Result/StorePaymentMethodCollection.php

    r3042021 r3151490  
    1414        $r = [];
    1515        foreach ($this->getData() as $paymentMethod => $paymentMethodData) {
     16            // BTCPay 2.0 compatibility: List is not a keyed array anymore so fix it here.
     17            if (is_numeric($paymentMethod)) {
     18                $paymentMethod = $paymentMethodData['paymentMethodId'];
     19                // Extract the cryptoCode from the paymentMethodId. e.g. "BTC-CHAIN" -> "BTC"
     20                $parts = explode('-', $paymentMethod);
     21                $extractedCryptoCode = $parts[0];
     22            }
     23
    1624            // Consistency: Flatten the array to be consistent with the specific
    1725            // payment method endpoints.
    18             $paymentMethodData += $paymentMethodData['data'];
    19             unset($paymentMethodData['data']);
     26            if (isset($paymentMethodData['data'])) {
     27                $paymentMethodData += $paymentMethodData['data'];
     28                unset($paymentMethodData['data']);
     29            }
    2030
    21             if (strpos($paymentMethod, 'LightningNetwork') !== false) {
     31            // BTCPay 2.0 compatibility: Handle config data if exists.
     32            if (isset($paymentMethodData['config'])) {
     33                $paymentMethodData += $paymentMethodData['config'];
     34                unset($paymentMethodData['config']);
     35            }
     36
     37            // BTCPay 2.0 compatibility: Check for renamed LN payment method id.
     38            if (preg_match('/(LightningNetwork|-LN$)/', $paymentMethod)) {
    2239                // Consistency: Add back the cryptoCode missing on this endpoint
    2340                // results until it is there.
     
    2542                    $paymentMethodData['cryptoCode'] = str_replace('-LightningNetwork', '', $paymentMethod);
    2643                }
     44
     45                // BTCPay 2.0 compatibility: put the currency code in the cryptoCode field.
     46                if (isset($extractedCryptoCode)) {
     47                    $paymentMethodData['cryptoCode'] = $extractedCryptoCode;
     48                }
     49
    2750                $r[] = new StorePaymentMethodLightningNetwork($paymentMethodData, $paymentMethod);
    2851            } else {
     
    3255                    $paymentMethodData['cryptoCode'] = $paymentMethod;
    3356                }
     57
     58                // BTCPay 2.0 compatibility: put the currency code in the cryptoCode field.
     59                if (isset($extractedCryptoCode)) {
     60                    $paymentMethodData['cryptoCode'] = $extractedCryptoCode;
     61                }
     62
    3463                $r[] = new StorePaymentMethodOnChain($paymentMethodData, $paymentMethod);
    3564            }
  • btcpay-greenfield-for-woocommerce/trunk/vendor/composer/installed.json

    r3064837 r3151490  
    33        {
    44            "name": "btcpayserver/btcpayserver-greenfield-php",
    5             "version": "v2.5.0",
    6             "version_normalized": "2.5.0.0",
     5            "version": "v2.7.0",
     6            "version_normalized": "2.7.0.0",
    77            "source": {
    88                "type": "git",
    99                "url": "https://github.com/btcpayserver/btcpayserver-greenfield-php.git",
    10                 "reference": "385b7f6882213e1142b58af89b24dd1495d6babc"
     10                "reference": "5e2ba7e3f585fc8e6dc068e22a0efbfdacd9c992"
    1111            },
    1212            "dist": {
    1313                "type": "zip",
    14                 "url": "https://api.github.com/repos/btcpayserver/btcpayserver-greenfield-php/zipball/385b7f6882213e1142b58af89b24dd1495d6babc",
    15                 "reference": "385b7f6882213e1142b58af89b24dd1495d6babc",
     14                "url": "https://api.github.com/repos/btcpayserver/btcpayserver-greenfield-php/zipball/5e2ba7e3f585fc8e6dc068e22a0efbfdacd9c992",
     15                "reference": "5e2ba7e3f585fc8e6dc068e22a0efbfdacd9c992",
    1616                "shasum": ""
    1717            },
     
    2929                "vlucas/phpdotenv": "^5.5"
    3030            },
    31             "time": "2024-04-03T08:35:46+00:00",
     31            "time": "2024-09-13T14:54:13+00:00",
    3232            "type": "library",
    3333            "installation-source": "dist",
     
    5454            "support": {
    5555                "issues": "https://github.com/btcpayserver/btcpayserver-greenfield-php/issues",
    56                 "source": "https://github.com/btcpayserver/btcpayserver-greenfield-php/tree/v2.5.0"
     56                "source": "https://github.com/btcpayserver/btcpayserver-greenfield-php/tree/v2.7.0"
    5757            },
    5858            "install-path": "../btcpayserver/btcpayserver-greenfield-php"
  • btcpay-greenfield-for-woocommerce/trunk/vendor/composer/installed.php

    r3064837 r3151490  
    2121        ),
    2222        'btcpayserver/btcpayserver-greenfield-php' => array(
    23             'pretty_version' => 'v2.5.0',
    24             'version' => '2.5.0.0',
    25             'reference' => '385b7f6882213e1142b58af89b24dd1495d6babc',
     23            'pretty_version' => 'v2.7.0',
     24            'version' => '2.7.0.0',
     25            'reference' => '5e2ba7e3f585fc8e6dc068e22a0efbfdacd9c992',
    2626            'type' => 'library',
    2727            'install_path' => __DIR__ . '/../btcpayserver/btcpayserver-greenfield-php',
Note: See TracChangeset for help on using the changeset viewer.