From 17fd6886ffc9ec95ea4f89a40a8ccec1103ba02d Mon Sep 17 00:00:00 2001 From: Emili Castells Guasch Date: Tue, 21 May 2024 15:52:41 +0200 Subject: [PATCH] Add gateway features support --- .../resources/js/advanced-card-checkout-block.js | 3 ++- .../ppcp-blocks/src/AdvancedCardPaymentMethod.php | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/modules/ppcp-blocks/resources/js/advanced-card-checkout-block.js b/modules/ppcp-blocks/resources/js/advanced-card-checkout-block.js index 923c88da8..9ddf3a6b1 100644 --- a/modules/ppcp-blocks/resources/js/advanced-card-checkout-block.js +++ b/modules/ppcp-blocks/resources/js/advanced-card-checkout-block.js @@ -12,6 +12,7 @@ registerPaymentMethod({ canMakePayment: () => {return true}, supports: { showSavedCards: true, - showSaveOption: true + showSaveOption: true, + features: config.supports } }) diff --git a/modules/ppcp-blocks/src/AdvancedCardPaymentMethod.php b/modules/ppcp-blocks/src/AdvancedCardPaymentMethod.php index 57b9d5b9a..d85555040 100644 --- a/modules/ppcp-blocks/src/AdvancedCardPaymentMethod.php +++ b/modules/ppcp-blocks/src/AdvancedCardPaymentMethod.php @@ -13,6 +13,9 @@ use Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodTyp use WooCommerce\PayPalCommerce\Button\Assets\SmartButtonInterface; use WooCommerce\PayPalCommerce\WcGateway\Gateway\CreditCardGateway; +/** + * Class AdvancedCardPaymentMethod + */ class AdvancedCardPaymentMethod extends AbstractPaymentMethodType { /** * The URL of this module. @@ -42,6 +45,14 @@ class AdvancedCardPaymentMethod extends AbstractPaymentMethodType { */ private $smart_button; + /** + * AdvancedCardPaymentMethod constructor. + * + * @param string $module_url The URL of this module. + * @param string $version The assets version. + * @param CreditCardGateway $gateway Credit card gateway. + * @param SmartButtonInterface|callable $smart_button The smart button script loading handler. + */ public function __construct( string $module_url, string $version, @@ -55,6 +66,9 @@ class AdvancedCardPaymentMethod extends AbstractPaymentMethodType { $this->smart_button = $smart_button; } + /** + * {@inheritDoc} + */ public function initialize() {} /** @@ -90,6 +104,7 @@ class AdvancedCardPaymentMethod extends AbstractPaymentMethodType { 'title' => $this->gateway->title, 'description' => $this->gateway->description, 'scriptData' => $script_data, + 'supports' => $this->gateway->supports, ); }