Skip to content

Commit

Permalink
SP-767 WordPress 6.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
mwarzybok-sumoheavy committed Jan 18, 2024
1 parent 93bac98 commit e565d3f
Show file tree
Hide file tree
Showing 19 changed files with 150 additions and 20 deletions.
56 changes: 56 additions & 0 deletions BitPayLib/Blocks/class-bitpaypaymentsblocks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

declare(strict_types=1);

namespace BitPayLib\Blocks;

use Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType;
use BitPayLib\BitPayPluginSetup;
use BitPayLib\WcGatewayBitpay;

/**
* Plugin Name: BitPay Checkout for WooCommerce
* Plugin URI: https://www.bitpay.com
* Description: BitPay Checkout Plugin
* Version: 5.4.0
* Author: BitPay
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
*/
class BitPayPaymentsBlocks extends AbstractPaymentMethodType {
protected $name = WcGatewayBitpay::GATEWAY_NAME;
private ?WcGatewayBitpay $gateway;

public function initialize() {
$this->settings = get_option( 'woocommerce_bitpay_checkout_gateway_settings', array() );
$gateways = WC()->payment_gateways->payment_gateways();
$this->gateway = $gateways[ $this->name ];
}
public function is_active() {
return $this->gateway->is_available();
}

public function get_payment_method_script_handles() {
$version = BitPayPluginSetup::VERSION;
$path = plugins_url( '../../../js/bitpay_payments_blocks.js', __FILE__ );
$handle = 'bitpay-checkout-block';
$dependencies = array( 'wp-hooks' );

wp_register_script( $handle, $path, $dependencies, $version, true );

return array( 'bitpay-checkout-block' );
}

public function get_payment_method_data() {
return array(
'title' => WcGatewayBitpay::TITLE,
'description' => $this->get_setting( 'description' ),
'supports' => array_filter(
$this->gateway->supports,
array(
$this->gateway,
'supports',
)
),
);
}
}
2 changes: 1 addition & 1 deletion BitPayLib/class-bitpaycancelorder.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Plugin Name: BitPay Checkout for WooCommerce
* Plugin URI: https://www.bitpay.com
* Description: BitPay Checkout Plugin
* Version: 5.3.2
* Version: 5.4.0
* Author: BitPay
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
*/
Expand Down
2 changes: 1 addition & 1 deletion BitPayLib/class-bitpaycart.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Plugin Name: BitPay Checkout for WooCommerce
* Plugin URI: https://www.bitpay.com
* Description: BitPay Checkout Plugin
* Version: 5.3.2
* Version: 5.4.0
* Author: BitPay
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
*/
Expand Down
2 changes: 1 addition & 1 deletion BitPayLib/class-bitpaycheckouttransactions.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Plugin Name: BitPay Checkout for WooCommerce
* Plugin URI: https://www.bitpay.com
* Description: BitPay Checkout Plugin
* Version: 5.3.2
* Version: 5.4.0
* Author: BitPay
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
*/
Expand Down
2 changes: 1 addition & 1 deletion BitPayLib/class-bitpayclientfactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* Plugin Name: BitPay Checkout for WooCommerce
* Plugin URI: https://www.bitpay.com
* Description: BitPay Checkout Plugin
* Version: 5.3.2
* Version: 5.4.0
* Author: BitPay
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
*/
Expand Down
2 changes: 1 addition & 1 deletion BitPayLib/class-bitpayinvoicecreate.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* Plugin Name: BitPay Checkout for WooCommerce
* Plugin URI: https://www.bitpay.com
* Description: BitPay Checkout Plugin
* Version: 5.3.2
* Version: 5.4.0
* Author: BitPay
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
*/
Expand Down
2 changes: 1 addition & 1 deletion BitPayLib/class-bitpayipnprocess.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* Plugin Name: BitPay Checkout for WooCommerce
* Plugin URI: https://www.bitpay.com
* Description: BitPay Checkout Plugin
* Version: 5.3.2
* Version: 5.4.0
* Author: BitPay
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
*/
Expand Down
2 changes: 1 addition & 1 deletion BitPayLib/class-bitpaylogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Plugin Name: BitPay Checkout for WooCommerce
* Plugin URI: https://www.bitpay.com
* Description: BitPay Checkout Plugin
* Version: 5.3.2
* Version: 5.4.0
* Author: BitPay
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
*/
Expand Down
2 changes: 1 addition & 1 deletion BitPayLib/class-bitpaypages.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* Plugin Name: BitPay Checkout for WooCommerce
* Plugin URI: https://www.bitpay.com
* Version: 5.3.2
* Version: 5.4.0
* Author: BitPay
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
*/
Expand Down
2 changes: 1 addition & 1 deletion BitPayLib/class-bitpaypaymentsettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Plugin Name: BitPay Checkout for WooCommerce
* Plugin URI: https://www.bitpay.com
* Description: BitPay Checkout Plugin
* Version: 5.3.2
* Version: 5.4.0
* Author: BitPay
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
*/
Expand Down
33 changes: 32 additions & 1 deletion BitPayLib/class-bitpaypluginsetup.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@

namespace BitPayLib;

use BitPayLib\Blocks\BitPayPaymentsBlocks;
use WP_REST_Request;

/**
* Plugin Name: BitPay Checkout for WooCommerce
* Plugin URI: https://www.bitpay.com
* Description: BitPay Checkout Plugin
* Version: 5.3.2
* Version: 5.4.0
* Author: BitPay
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
*/
class BitPayPluginSetup {

public const VERSION = '5.4.0';

private BitPayIpnProcess $bitpay_ipn_process;
private BitPayCancelOrder $bitpay_cancel_order;
private BitPayPaymentSettings $bitpay_payment_settings;
Expand Down Expand Up @@ -51,6 +54,7 @@ public function execute(): void {
add_action( 'woocommerce_thankyou', array( $this, 'bitpay_checkout_custom_message' ) );
add_filter( 'woocommerce_payment_gateways', array( $this, 'wc_bitpay_checkout_add_to_gateways' ) );
add_filter( 'woocommerce_order_button_html', array( $this, 'bitpay_checkout_replace_order_button_html' ), 10, 2 );
add_action( 'woocommerce_blocks_loaded', array( $this, 'register_payment_block' ) );

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

return array();
}

public function register_payment_block(): void {
add_action(
'woocommerce_blocks_payment_method_type_registration',
function ( \Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) {
$container = \Automattic\WooCommerce\Blocks\Package::container();

$container->register(
BitPayPaymentsBlocks::class,
function () {
return new BitPayPaymentsBlocks();
}
);
$payment_method_registry->register(
$container->get( BitPayPaymentsBlocks::class )
);
},
5
);

add_action(
'woocommerce_blocks_payment_method_type_registration',
function ( $registry ) {
$registry->register( new BitPayPaymentsBlocks() );
}
);
}
}
20 changes: 15 additions & 5 deletions BitPayLib/class-wcgatewaybitpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@
* Plugin Name: BitPay Checkout for WooCommerce
* Plugin URI: https://www.bitpay.com
* Description: BitPay Checkout Plugin
* Version: 5.3.2
* Version: 5.4.0
* Author: BitPay
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
*/
class WcGatewayBitpay extends \WC_Payment_Gateway {

public const IGNORE_STATUS_VALUE = 'bitpay-ignore';
public const GATEWAY_NAME = 'bitpay_checkout_gateway';
public const TITLE = 'BitPay';

private string $instructions;

public function __construct() {
$this->id = 'bitpay_checkout_gateway';
$this->id = self::GATEWAY_NAME;
$this->icon = $this->get_icon_on_payment_page();

$this->has_fields = true;
Expand All @@ -33,16 +36,23 @@ public function __construct() {
$this->init_form_fields();
$this->init_settings();

$this->title = 'BitPay';
$this->title = self::TITLE;
$this->description = $this->get_option( 'description' ) . '<br>';
$this->instructions = $this->get_option( 'instructions', $this->description );

add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
add_action( 'woocommerce_email_before_order_table', array( $this, 'email_instructions' ), 10, 3 );
wp_enqueue_script( 'bitpay_wc_gateway', plugins_url( '../../js/wc_gateway_bitpay.js', __FILE__ ), null, 1, false );
wp_enqueue_script( 'jquery' );
wp_enqueue_script(
'bitpay_wc_gateway',
plugins_url( '../../js/wc_gateway_bitpay.js', __FILE__ ),
null,
1,
false
);
}
public function email_instructions( $order, $sent_to_admin, $plain_text = false ) {
if ( $this->instructions && ! $sent_to_admin && 'bitpay_checkout_gateway' === $order->get_payment_method() && $order->has_status( 'processing' ) ) {
if ( $this->instructions && ! $sent_to_admin && self::GATEWAY_NAME === $order->get_payment_method() && $order->has_status( 'processing' ) ) {
echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
}
}
Expand Down
2 changes: 1 addition & 1 deletion BitPayLib/trait-wpdbhelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Plugin Name: BitPay Checkout for WooCommerce
* Plugin URI: https://www.bitpay.com
* Description: BitPay Checkout Plugin
* Version: 5.3.2
* Version: 5.4.0
* Author: BitPay
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
*/
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

# 5.4.0
* Added compatibility with Checkout Blocks
* Tested compatibility with WordPress 6.4.2

# 5.3.2
* Fix typo "completed" for BitPay available statuses
* Checking if there is a cart before triggering empty_cart() method
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Visit the [Releases](https://github.com/bitpay/bitpay-checkout-for-woocommerce/r

**BitPay Support:**

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

Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: BitPay Checkout for WooCommerce
* Plugin URI: https://www.bitpay.com
* Description: BitPay Checkout Plugin
* Version: 5.3.2
* Version: 5.4.0
* Author: BitPay
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
*/
Expand Down
22 changes: 22 additions & 0 deletions js/bitpay_payments_blocks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const settings = window.wc.wcSettings.getSetting( 'bitpay_checkout_gateway_data', {} )
const label = window.wp.htmlEntities.decodeEntities( settings.title ) || 'BitPay';
const content = () => {
return window.wp.htmlEntities.decodeEntities( settings.description || '' );
};

/**
* BitPay payment method config object.
*/
const BitPay = {
name: "bitpay_checkout_gateway",
label: label,
content: Object( window.wp.element.createElement )( content, null ),
edit: Object( window.wp.element.createElement )( content, null ),
canMakePayment: () => true,
ariaLabel: label,
supports: {
features: settings.supports
},
};

window.wc.wcBlocksRegistry.registerPaymentMethod( BitPay )
8 changes: 6 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
Contributors: bitpay
Tags: bitcoin, ether, ripple, bitcoin cash, ERC20, payments, bitpay, cryptocurrency, payment gateway
Requires at least: 6.0
Tested up to: 6.2.2
Tested up to: 6.4.2
Requires PHP: 8.0
Recommended PHP: 8.0
Stable tag: 5.3.2
Stable tag: 5.4.0
License: MIT License (MIT)
License URI: https://github.com/bitpay/bitpay-checkout-for-woocommerce/blob/master/LICENSE

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

== Changelog ==

= 5.4.0 =
* Added compatibility with Checkout Blocks
* Tested compatibility with WordPress 6.4.2

= 5.3.2 =
* Fix typo "completed" for BitPay available statuses
* Checking if there is a cart before triggering empty_cart() method
Expand Down
3 changes: 3 additions & 0 deletions scoper.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ static function (string $filePath, string $prefix, string $contents): string {
'WC_Order',
'WP_REST_Request',
'WC_Admin_Settings',
'Automattic\WooCommerce\Blocks\Package',
'Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry',
'Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType',
'wpdb'
],
'exclude-functions' => [],
Expand Down

0 comments on commit e565d3f

Please sign in to comment.