Add GooglePay module

This commit is contained in:
Pedro Silva 2023-08-22 08:44:32 +01:00
parent 0e97af9122
commit e87ab7362c
No known key found for this signature in database
GPG key ID: E2EE20C0669D24B3
21 changed files with 3137 additions and 17 deletions

View file

@ -0,0 +1,77 @@
<?php
/**
* The Googlepay module.
*
* @package WooCommerce\PayPalCommerce\Googlepay
*/
declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\Googlepay;
use WooCommerce\PayPalCommerce\Button\Assets\SmartButtonInterface;
use WooCommerce\PayPalCommerce\Googlepay\Assets\ButtonInterface;
use WooCommerce\PayPalCommerce\Onboarding\Environment;
use WooCommerce\PayPalCommerce\Vendor\Dhii\Container\ServiceProvider;
use WooCommerce\PayPalCommerce\Vendor\Dhii\Modular\Module\ModuleInterface;
use WooCommerce\PayPalCommerce\Vendor\Interop\Container\ServiceProviderInterface;
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
/**
* Class GooglepayModule
*/
class GooglepayModule implements ModuleInterface {
/**
* {@inheritDoc}
*/
public function setup(): ServiceProviderInterface {
return new ServiceProvider(
require __DIR__ . '/../services.php',
require __DIR__ . '/../extensions.php'
);
}
/**
* {@inheritDoc}
*/
public function run( ContainerInterface $c ): void {
add_action(
'wp',
static function () use ( $c ) {
if ( is_admin() ) {
return;
}
$button = $c->get( 'googlepay.button' );
/**
* The Button.
*
* @var ButtonInterface $button
*/
$button->render_buttons();
}
);
add_action(
'wp_enqueue_scripts',
static function () use ( $c ) {
$button = $c->get( 'googlepay.button' );
assert( $button instanceof ButtonInterface );
if ( $button->should_load_script() ) {
$button->enqueue();
}
}
);
}
/**
* Returns the key for the module.
*
* @return string|void
*/
public function getKey() {
}
}