Add block support in GooglePay

This commit is contained in:
Pedro Silva 2023-08-25 16:25:20 +01:00
parent eff390f564
commit 6a205d1413
No known key found for this signature in database
GPG key ID: E2EE20C0669D24B3
8 changed files with 232 additions and 19 deletions

View file

@ -9,17 +9,19 @@ declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\Googlepay;
use Automattic\WooCommerce\Blocks\Payments\PaymentMethodTypeInterface;
use WooCommerce\PayPalCommerce\Button\Assets\ButtonInterface;
use WooCommerce\PayPalCommerce\Googlepay\Assets\GooglepayButton;
use WooCommerce\PayPalCommerce\Googlepay\Assets\BlocksPaymentMethod;
use WooCommerce\PayPalCommerce\Googlepay\Assets\Button;
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
return array(
// TODO.
'googlepay.button' => static function ( ContainerInterface $container ): ButtonInterface {
'googlepay.button' => static function ( ContainerInterface $container ): ButtonInterface {
// TODO : check other statuses.
return new GooglepayButton(
return new Button(
$container->get( 'googlepay.url' ),
$container->get( 'googlepay.sdk_url' ),
$container->get( 'ppcp.asset-version' ),
@ -32,7 +34,17 @@ return array(
);
},
'googlepay.url' => static function ( ContainerInterface $container ): string {
'googlepay.blocks-payment-method' => static function ( ContainerInterface $container ): PaymentMethodTypeInterface {
return new BlocksPaymentMethod(
'ppcp-googlepay',
$container->get( 'googlepay.url' ),
$container->get( 'ppcp.asset-version' ),
$container->get( 'googlepay.button' ),
$container->get( 'blocks.method' )
);
},
'googlepay.url' => static function ( ContainerInterface $container ): string {
$path = realpath( __FILE__ );
if ( false === $path ) {
return '';
@ -43,7 +55,7 @@ return array(
);
},
'googlepay.sdk_url' => static function ( ContainerInterface $container ): string {
'googlepay.sdk_url' => static function ( ContainerInterface $container ): string {
return 'https://pay.google.com/gp/p/js/pay.js';
},