mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Handle continuation mode in blocks
This commit is contained in:
parent
b0a0eea752
commit
493933a1c1
6 changed files with 107 additions and 12 deletions
|
@ -10,6 +10,7 @@ declare(strict_types=1);
|
|||
namespace WooCommerce\PayPalCommerce\Blocks;
|
||||
|
||||
use Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry;
|
||||
use WooCommerce\PayPalCommerce\Button\Assets\SmartButton;
|
||||
use WooCommerce\PayPalCommerce\Vendor\Dhii\Container\ServiceProvider;
|
||||
use WooCommerce\PayPalCommerce\Vendor\Dhii\Modular\Module\ModuleInterface;
|
||||
use WooCommerce\PayPalCommerce\Vendor\Interop\Container\ServiceProviderInterface;
|
||||
|
@ -40,6 +41,21 @@ class BlocksModule implements ModuleInterface {
|
|||
$payment_method_registry->register( $c->get( 'blocks.method' ) );
|
||||
}
|
||||
);
|
||||
|
||||
woocommerce_store_api_register_payment_requirements(
|
||||
array(
|
||||
'data_callback' => function() use ( $c ): array {
|
||||
$smart_button = $c->get( 'button.smart-button' );
|
||||
assert( $smart_button instanceof SmartButton );
|
||||
|
||||
if ( isset( $smart_button->script_data()['continuation'] ) ) {
|
||||
return array( 'ppcp_continuation' );
|
||||
}
|
||||
|
||||
return array();
|
||||
},
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue