# monei/7.1.3/src/Gateways/Blocks/MoneiAppleGoogleBlocksSupport.php

MONEI Payments for WooCommerce, version 7.1.3. 150 lines.

- Page: https://pluginprobe.com/plugins/monei/7.1.3/code/src/Gateways/Blocks/MoneiAppleGoogleBlocksSupport.php
- Raw: https://pluginprobe.com/plugins/monei/7.1.3/raw/src/Gateways/Blocks/MoneiAppleGoogleBlocksSupport.php
- Modified: 2026-08-25T11:57:56+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/monei/7.1.3/code/src/Gateways/Blocks/MoneiAppleGoogleBlocksSupport.php#L10-L20`.

```php
<?php

namespace Monei\Gateways\Blocks;

use Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType;
use Monei\Gateways\Abstracts\WCMoneiPaymentGateway;
use Monei\Gateways\PaymentMethods\WCGatewayMoneiAppleGoogle;
use Monei\Services\express\ExpressCheckoutAssets;

final class MoneiAppleGoogleBlocksSupport extends AbstractPaymentMethodType {

	protected $name = 'monei_apple_google';
	/** @var WCGatewayMoneiAppleGoogle */
	public WCGatewayMoneiAppleGoogle $gateway;

	/**
	 * @param WCGatewayMoneiAppleGoogle $gateway
	 */
	public function __construct( WCGatewayMoneiAppleGoogle $gateway ) {
		$this->gateway = $gateway;
	}

	public function initialize() {
		$this->settings = get_option( 'woocommerce_monei_apple_google_settings', array() );
	}

	public function is_active() {
		// Order-pay page always uses classic checkout
		if ( is_checkout_pay_page() ) {
			return false;
		}

		$id = $this->gateway->getAccountId() ?? false;

		$key = $this->gateway->getApiKey() ?? false;

		if ( ! $id || ! $key ) {
			return false;
		}

		// Hide when neither Apple nor Google is available
		if ( ! $this->gateway->isAppleAvailable() && ! $this->gateway->isGoogleAvailable() ) {
			return false;
		}

		return 'yes' === ( $this->get_setting( 'enabled' ) ?? 'no' );
	}

	public function get_payment_method_script_handles() {
		// Order-pay page uses classic checkout, not blocks
		if ( is_checkout_pay_page() ) {
			return array();
		}

		// Register and enqueue blocks checkout CSS
		wp_register_style(
			'monei-blocks-checkout',
			WC_Monei()->plugin_url() . '/public/css/monei-blocks-checkout.css',
			array(),
			WC_Monei()->version,
			'all'
		);
		wp_enqueue_style( 'monei-blocks-checkout' );

		wp_register_script( 'monei', 'https://js.monei.com/v3/monei.js', '', '3.0', true );
		wp_enqueue_script( 'monei' );

		$script_name = 'wc-monei-apple-google-blocks-integration';

		wp_register_script(
			$script_name,
			WC_Monei()->plugin_url() . '/public/js/monei-block-checkout-apple-google.min.js',
			array(
				'wc-blocks-checkout',
				'wc-blocks-registry',
				'wc-settings',
				'wp-element',
				'wp-html-entities',
				'wp-i18n',
				'monei',
			),
			WC_Monei()->version,
			true
		);

		if ( function_exists( 'wp_set_script_translations' ) ) {
			wp_set_script_translations( $script_name, 'monei', WC_Monei()->plugin_path() . '/languages' );
		}

		$handles = array( $script_name );

		// One express script serves both wallets and both blocks: WooCommerce merges
		// every active payment method's handles into `wc-cart-block-frontend` and
		// `wc-checkout-block-frontend` alike.
		$express_handle = ExpressCheckoutAssets::register_blocks_script();

		if ( '' !== $express_handle ) {
			$handles[] = $express_handle;
		}

		return $handles;
	}

	public function get_payment_method_data() {
		$supports              = $this->gateway->supports;
		$total                 = WC()->cart !== null ? WC()->cart->get_total( false ) : 0;
		$isGoogleEnabled       = $this->gateway->isGoogleAvailable();
		$isAppleEnabled        = $this->gateway->isAppleAvailable();
		$logoApple             = WC_Monei()->plugin_url() . '/public/images/apple-logo.svg';
		$logoGoogle            = WC_Monei()->plugin_url() . '/public/images/google-logo.svg';
		$payment_request_style = $this->get_setting( 'payment_request_style' ) ?? '{"height": "42"}';

		// Get separate titles with fallback to defaults
		$apple_pay_title  = $this->get_setting( 'apple_pay_title' );
		$google_pay_title = $this->get_setting( 'google_pay_title' );

		// Use specific titles if set, otherwise fall back to defaults
		$apple_pay_title  = ! empty( $apple_pay_title ) ? $apple_pay_title : __( 'Apple Pay', 'monei' );
		$google_pay_title = ! empty( $google_pay_title ) ? $google_pay_title : __( 'Google Pay', 'monei' );

		// Add test mode suffix if enabled
		if ( $this->gateway->getTestmode() ) {
			$test_suffix       = ' (' . __( 'Test Mode', 'monei' ) . ')';
			$apple_pay_title  .= $test_suffix;
			$google_pay_title .= $test_suffix;
		}

		$data = array(
			'applePayTitle'       => $apple_pay_title,
			'googlePayTitle'      => $google_pay_title,
			'description'         => $this->gateway->description === '&nbsp;' ? '' : $this->gateway->description,
			'logoGoogle'          => $isGoogleEnabled ? $logoGoogle : false,
			'logoApple'           => $isAppleEnabled ? $logoApple : false,
			'supports'            => $supports,
			// yes: test mode.
			// no:  live,
			'testMode'            => $this->gateway->getTestmode(),
			'accountId'           => $this->gateway->getAccountId() ?? false,
			'sessionId'           => WC()->session !== null ? WC()->session->get_customer_id() : '',
			'currency'            => get_woocommerce_currency(),
			'total'               => $total,
			'language'            => locale_iso_639_1_code(),
			'paymentRequestStyle' => json_decode( $payment_request_style ),
			'express'             => ExpressCheckoutAssets::get_script_data(),
		);

		return $data;
	}
}

```
