Skip to content

Commit e565d3f

Browse files
SP-767 WordPress 6.4.2
1 parent 93bac98 commit e565d3f

19 files changed

+150
-20
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace BitPayLib\Blocks;
6+
7+
use Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType;
8+
use BitPayLib\BitPayPluginSetup;
9+
use BitPayLib\WcGatewayBitpay;
10+
11+
/**
12+
* Plugin Name: BitPay Checkout for WooCommerce
13+
* Plugin URI: https://www.bitpay.com
14+
* Description: BitPay Checkout Plugin
15+
* Version: 5.4.0
16+
* Author: BitPay
17+
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
18+
*/
19+
class BitPayPaymentsBlocks extends AbstractPaymentMethodType {
20+
protected $name = WcGatewayBitpay::GATEWAY_NAME;
21+
private ?WcGatewayBitpay $gateway;
22+
23+
public function initialize() {
24+
$this->settings = get_option( 'woocommerce_bitpay_checkout_gateway_settings', array() );
25+
$gateways = WC()->payment_gateways->payment_gateways();
26+
$this->gateway = $gateways[ $this->name ];
27+
}
28+
public function is_active() {
29+
return $this->gateway->is_available();
30+
}
31+
32+
public function get_payment_method_script_handles() {
33+
$version = BitPayPluginSetup::VERSION;
34+
$path = plugins_url( '../../../js/bitpay_payments_blocks.js', __FILE__ );
35+
$handle = 'bitpay-checkout-block';
36+
$dependencies = array( 'wp-hooks' );
37+
38+
wp_register_script( $handle, $path, $dependencies, $version, true );
39+
40+
return array( 'bitpay-checkout-block' );
41+
}
42+
43+
public function get_payment_method_data() {
44+
return array(
45+
'title' => WcGatewayBitpay::TITLE,
46+
'description' => $this->get_setting( 'description' ),
47+
'supports' => array_filter(
48+
$this->gateway->supports,
49+
array(
50+
$this->gateway,
51+
'supports',
52+
)
53+
),
54+
);
55+
}
56+
}

BitPayLib/class-bitpaycancelorder.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Plugin Name: BitPay Checkout for WooCommerce
99
* Plugin URI: https://www.bitpay.com
1010
* Description: BitPay Checkout Plugin
11-
* Version: 5.3.2
11+
* Version: 5.4.0
1212
* Author: BitPay
1313
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
1414
*/

BitPayLib/class-bitpaycart.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Plugin Name: BitPay Checkout for WooCommerce
99
* Plugin URI: https://www.bitpay.com
1010
* Description: BitPay Checkout Plugin
11-
* Version: 5.3.2
11+
* Version: 5.4.0
1212
* Author: BitPay
1313
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
1414
*/

BitPayLib/class-bitpaycheckouttransactions.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Plugin Name: BitPay Checkout for WooCommerce
1212
* Plugin URI: https://www.bitpay.com
1313
* Description: BitPay Checkout Plugin
14-
* Version: 5.3.2
14+
* Version: 5.4.0
1515
* Author: BitPay
1616
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
1717
*/

BitPayLib/class-bitpayclientfactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Plugin Name: BitPay Checkout for WooCommerce
1414
* Plugin URI: https://www.bitpay.com
1515
* Description: BitPay Checkout Plugin
16-
* Version: 5.3.2
16+
* Version: 5.4.0
1717
* Author: BitPay
1818
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
1919
*/

BitPayLib/class-bitpayinvoicecreate.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Plugin Name: BitPay Checkout for WooCommerce
1414
* Plugin URI: https://www.bitpay.com
1515
* Description: BitPay Checkout Plugin
16-
* Version: 5.3.2
16+
* Version: 5.4.0
1717
* Author: BitPay
1818
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
1919
*/

BitPayLib/class-bitpayipnprocess.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Plugin Name: BitPay Checkout for WooCommerce
1414
* Plugin URI: https://www.bitpay.com
1515
* Description: BitPay Checkout Plugin
16-
* Version: 5.3.2
16+
* Version: 5.4.0
1717
* Author: BitPay
1818
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
1919
*/

BitPayLib/class-bitpaylogger.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Plugin Name: BitPay Checkout for WooCommerce
99
* Plugin URI: https://www.bitpay.com
1010
* Description: BitPay Checkout Plugin
11-
* Version: 5.3.2
11+
* Version: 5.4.0
1212
* Author: BitPay
1313
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
1414
*/

BitPayLib/class-bitpaypages.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/**
88
* Plugin Name: BitPay Checkout for WooCommerce
99
* Plugin URI: https://www.bitpay.com
10-
* Version: 5.3.2
10+
* Version: 5.4.0
1111
* Author: BitPay
1212
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
1313
*/

BitPayLib/class-bitpaypaymentsettings.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Plugin Name: BitPay Checkout for WooCommerce
99
* Plugin URI: https://www.bitpay.com
1010
* Description: BitPay Checkout Plugin
11-
* Version: 5.3.2
11+
* Version: 5.4.0
1212
* Author: BitPay
1313
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
1414
*/

BitPayLib/class-bitpaypluginsetup.php

+32-1
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,21 @@
44

55
namespace BitPayLib;
66

7+
use BitPayLib\Blocks\BitPayPaymentsBlocks;
78
use WP_REST_Request;
89

910
/**
1011
* Plugin Name: BitPay Checkout for WooCommerce
1112
* Plugin URI: https://www.bitpay.com
1213
* Description: BitPay Checkout Plugin
13-
* Version: 5.3.2
14+
* Version: 5.4.0
1415
* Author: BitPay
1516
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
1617
*/
1718
class BitPayPluginSetup {
1819

20+
public const VERSION = '5.4.0';
21+
1922
private BitPayIpnProcess $bitpay_ipn_process;
2023
private BitPayCancelOrder $bitpay_cancel_order;
2124
private BitPayPaymentSettings $bitpay_payment_settings;
@@ -51,6 +54,7 @@ public function execute(): void {
5154
add_action( 'woocommerce_thankyou', array( $this, 'bitpay_checkout_custom_message' ) );
5255
add_filter( 'woocommerce_payment_gateways', array( $this, 'wc_bitpay_checkout_add_to_gateways' ) );
5356
add_filter( 'woocommerce_order_button_html', array( $this, 'bitpay_checkout_replace_order_button_html' ), 10, 2 );
57+
add_action( 'woocommerce_blocks_loaded', array( $this, 'register_payment_block' ) );
5458

5559
// http://<host>/wp-json/bitpay/ipn/status url.
5660
// http://<host>/wp-json/bitpay/cartfix/restore url.
@@ -194,4 +198,31 @@ private function validate_woo_commerce(): array {
194198

195199
return array();
196200
}
201+
202+
public function register_payment_block(): void {
203+
add_action(
204+
'woocommerce_blocks_payment_method_type_registration',
205+
function ( \Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) {
206+
$container = \Automattic\WooCommerce\Blocks\Package::container();
207+
208+
$container->register(
209+
BitPayPaymentsBlocks::class,
210+
function () {
211+
return new BitPayPaymentsBlocks();
212+
}
213+
);
214+
$payment_method_registry->register(
215+
$container->get( BitPayPaymentsBlocks::class )
216+
);
217+
},
218+
5
219+
);
220+
221+
add_action(
222+
'woocommerce_blocks_payment_method_type_registration',
223+
function ( $registry ) {
224+
$registry->register( new BitPayPaymentsBlocks() );
225+
}
226+
);
227+
}
197228
}

BitPayLib/class-wcgatewaybitpay.php

+15-5
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,20 @@
88
* Plugin Name: BitPay Checkout for WooCommerce
99
* Plugin URI: https://www.bitpay.com
1010
* Description: BitPay Checkout Plugin
11-
* Version: 5.3.2
11+
* Version: 5.4.0
1212
* Author: BitPay
1313
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
1414
*/
1515
class WcGatewayBitpay extends \WC_Payment_Gateway {
1616

1717
public const IGNORE_STATUS_VALUE = 'bitpay-ignore';
18+
public const GATEWAY_NAME = 'bitpay_checkout_gateway';
19+
public const TITLE = 'BitPay';
20+
1821
private string $instructions;
1922

2023
public function __construct() {
21-
$this->id = 'bitpay_checkout_gateway';
24+
$this->id = self::GATEWAY_NAME;
2225
$this->icon = $this->get_icon_on_payment_page();
2326

2427
$this->has_fields = true;
@@ -33,16 +36,23 @@ public function __construct() {
3336
$this->init_form_fields();
3437
$this->init_settings();
3538

36-
$this->title = 'BitPay';
39+
$this->title = self::TITLE;
3740
$this->description = $this->get_option( 'description' ) . '<br>';
3841
$this->instructions = $this->get_option( 'instructions', $this->description );
3942

4043
add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
4144
add_action( 'woocommerce_email_before_order_table', array( $this, 'email_instructions' ), 10, 3 );
42-
wp_enqueue_script( 'bitpay_wc_gateway', plugins_url( '../../js/wc_gateway_bitpay.js', __FILE__ ), null, 1, false );
45+
wp_enqueue_script( 'jquery' );
46+
wp_enqueue_script(
47+
'bitpay_wc_gateway',
48+
plugins_url( '../../js/wc_gateway_bitpay.js', __FILE__ ),
49+
null,
50+
1,
51+
false
52+
);
4353
}
4454
public function email_instructions( $order, $sent_to_admin, $plain_text = false ) {
45-
if ( $this->instructions && ! $sent_to_admin && 'bitpay_checkout_gateway' === $order->get_payment_method() && $order->has_status( 'processing' ) ) {
55+
if ( $this->instructions && ! $sent_to_admin && self::GATEWAY_NAME === $order->get_payment_method() && $order->has_status( 'processing' ) ) {
4656
echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
4757
}
4858
}

BitPayLib/trait-wpdbhelper.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Plugin Name: BitPay Checkout for WooCommerce
1111
* Plugin URI: https://www.bitpay.com
1212
* Description: BitPay Checkout Plugin
13-
* Version: 5.3.2
13+
* Version: 5.4.0
1414
* Author: BitPay
1515
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
1616
*/

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
# 5.4.0
6+
* Added compatibility with Checkout Blocks
7+
* Tested compatibility with WordPress 6.4.2
8+
59
# 5.3.2
610
* Fix typo "completed" for BitPay available statuses
711
* Checking if there is a cart before triggering empty_cart() method

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Visit the [Releases](https://github.com/bitpay/bitpay-checkout-for-woocommerce/r
2626

2727
**BitPay Support:**
2828

29-
* Last Cart Version Tested: Wordpress 6.2.2
29+
* Last Cart Version Tested: Wordpress 6.4.2
3030
* [GitHub Issues](https://github.com/bitpay/bitpay-checkout-for-woocommerce/issues)
3131
* [Support](https://support.bitpay.com/hc/en-us)
3232

index.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: BitPay Checkout for WooCommerce
44
* Plugin URI: https://www.bitpay.com
55
* Description: BitPay Checkout Plugin
6-
* Version: 5.3.2
6+
* Version: 5.4.0
77
* Author: BitPay
88
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
99
*/

js/bitpay_payments_blocks.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const settings = window.wc.wcSettings.getSetting( 'bitpay_checkout_gateway_data', {} )
2+
const label = window.wp.htmlEntities.decodeEntities( settings.title ) || 'BitPay';
3+
const content = () => {
4+
return window.wp.htmlEntities.decodeEntities( settings.description || '' );
5+
};
6+
7+
/**
8+
* BitPay payment method config object.
9+
*/
10+
const BitPay = {
11+
name: "bitpay_checkout_gateway",
12+
label: label,
13+
content: Object( window.wp.element.createElement )( content, null ),
14+
edit: Object( window.wp.element.createElement )( content, null ),
15+
canMakePayment: () => true,
16+
ariaLabel: label,
17+
supports: {
18+
features: settings.supports
19+
},
20+
};
21+
22+
window.wc.wcBlocksRegistry.registerPaymentMethod( BitPay )

readme.txt

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
Contributors: bitpay
33
Tags: bitcoin, ether, ripple, bitcoin cash, ERC20, payments, bitpay, cryptocurrency, payment gateway
44
Requires at least: 6.0
5-
Tested up to: 6.2.2
5+
Tested up to: 6.4.2
66
Requires PHP: 8.0
77
Recommended PHP: 8.0
8-
Stable tag: 5.3.2
8+
Stable tag: 5.4.0
99
License: MIT License (MIT)
1010
License URI: https://github.com/bitpay/bitpay-checkout-for-woocommerce/blob/master/LICENSE
1111

@@ -111,6 +111,10 @@ You can contact our support team via the following form https://bitpay.com/reque
111111

112112
== Changelog ==
113113

114+
= 5.4.0 =
115+
* Added compatibility with Checkout Blocks
116+
* Tested compatibility with WordPress 6.4.2
117+
114118
= 5.3.2 =
115119
* Fix typo "completed" for BitPay available statuses
116120
* Checking if there is a cart before triggering empty_cart() method

scoper.inc.php

+3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ static function (string $filePath, string $prefix, string $contents): string {
4040
'WC_Order',
4141
'WP_REST_Request',
4242
'WC_Admin_Settings',
43+
'Automattic\WooCommerce\Blocks\Package',
44+
'Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry',
45+
'Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType',
4346
'wpdb'
4447
],
4548
'exclude-functions' => [],

0 commit comments

Comments
 (0)