-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from mwarzybok-sumoheavy/feature/SP-761
SP-767 WordPress 6.4.2
- Loading branch information
Showing
19 changed files
with
150 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
) | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -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. | ||
|
@@ -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() ); | ||
} | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -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 ); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters