woocommerce-paypal-payments/modules/ppcp-googlepay/services.php

61 lines
1.9 KiB
PHP
Raw Normal View History

2023-08-22 08:44:32 +01:00
<?php
/**
* The Googlepay module services.
*
* @package WooCommerce\PayPalCommerce\Googlepay
*/
declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\Googlepay;
2023-08-25 16:25:20 +01:00
use Automattic\WooCommerce\Blocks\Payments\PaymentMethodTypeInterface;
2023-08-24 17:30:29 +01:00
use WooCommerce\PayPalCommerce\Button\Assets\ButtonInterface;
2023-08-25 16:25:20 +01:00
use WooCommerce\PayPalCommerce\Googlepay\Assets\BlocksPaymentMethod;
use WooCommerce\PayPalCommerce\Googlepay\Assets\Button;
2023-08-22 08:44:32 +01:00
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
return array(
2023-08-25 16:25:20 +01:00
'googlepay.button' => static function ( ContainerInterface $container ): ButtonInterface {
2023-08-22 08:44:32 +01:00
// TODO : check other statuses.
2023-08-25 16:25:20 +01:00
return new Button(
2023-08-22 08:44:32 +01:00
$container->get( 'googlepay.url' ),
2023-08-22 11:34:52 +01:00
$container->get( 'googlepay.sdk_url' ),
2023-08-22 08:44:32 +01:00
$container->get( 'ppcp.asset-version' ),
$container->get( 'session.handler' ),
$container->get( 'wcgateway.settings' ),
$container->get( 'onboarding.environment' ),
2023-08-24 17:30:29 +01:00
$container->get( 'wcgateway.settings.status' ),
2023-08-22 08:44:32 +01:00
$container->get( 'api.shop.currency' ),
$container->get( 'woocommerce.logger.woocommerce' )
);
},
2023-08-25 16:25:20 +01:00
'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 {
2023-08-22 08:44:32 +01:00
$path = realpath( __FILE__ );
if ( false === $path ) {
return '';
}
return plugins_url(
'/modules/ppcp-googlepay/',
dirname( $path, 3 ) . '/woocommerce-paypal-payments.php'
);
},
2023-08-22 11:34:52 +01:00
2023-08-25 16:25:20 +01:00
'googlepay.sdk_url' => static function ( ContainerInterface $container ): string {
2023-08-22 08:44:32 +01:00
return 'https://pay.google.com/gp/p/js/pay.js';
},
);