woocommerce-paypal-payments/modules/ppcp-googlepay/services.php
2023-09-01 11:32:26 +01:00

67 lines
2.1 KiB
PHP

<?php
/**
* The Googlepay module services.
*
* @package WooCommerce\PayPalCommerce\Googlepay
*/
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\BlocksPaymentMethod;
use WooCommerce\PayPalCommerce\Googlepay\Assets\Button;
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
return array(
'googlepay.eligible' => static function ( ContainerInterface $container ): bool {
// TODO : add handlers.
return true;
},
'googlepay.available' => static function ( ContainerInterface $container ): bool {
// TODO : add handlers.
return true;
},
'googlepay.button' => static function ( ContainerInterface $container ): ButtonInterface {
return new Button(
$container->get( 'googlepay.url' ),
$container->get( 'googlepay.sdk_url' ),
$container->get( 'ppcp.asset-version' ),
$container->get( 'session.handler' ),
$container->get( 'wcgateway.settings' ),
$container->get( 'onboarding.environment' ),
$container->get( 'wcgateway.settings.status' ),
$container->get( 'api.shop.currency' ),
$container->get( 'woocommerce.logger.woocommerce' )
);
},
'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 '';
}
return plugins_url(
'/modules/ppcp-googlepay/',
dirname( $path, 3 ) . '/woocommerce-paypal-payments.php'
);
},
'googlepay.sdk_url' => static function ( ContainerInterface $container ): string {
return 'https://pay.google.com/gp/p/js/pay.js';
},
);