woocommerce-paypal-payments/modules/ppcp-applepay/extensions.php

134 lines
5.2 KiB
PHP
Raw Normal View History

<?php
/**
* The Applepay module extensions.
*
* @package WooCommerce\PayPalCommerce\Applepay
*/
declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\Applepay;
2023-09-05 09:14:20 +02:00
use WooCommerce\PayPalCommerce\Applepay\Assets\PropertiesDictionary;
use WooCommerce\PayPalCommerce\Onboarding\State;
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
return array(
2023-09-08 16:58:32 +02:00
'wcgateway.settings.fields' => function ( ContainerInterface $container, array $fields ): array {
$insert_after = function ( array $array, string $key, array $new ): array {
$keys = array_keys( $array );
$index = array_search( $key, $keys, true );
$pos = false === $index ? count( $array ) : $index + 1;
2023-09-05 09:14:20 +02:00
2023-09-08 16:58:32 +02:00
return array_merge( array_slice( $array, 0, $pos ), $new, array_slice( $array, $pos ) );
2023-09-05 09:14:20 +02:00
};
return $insert_after(
$fields,
'allow_card_button_gateway',
array(
2023-09-08 16:58:32 +02:00
'applepay_button_enabled' => array(
'title' => __( 'Apple Pay Button', 'woocommerce-paypal-payments' ),
'type' => 'checkbox',
2023-09-12 14:07:30 +02:00
'label' => __( 'Enable Apple Pay button', 'woocommerce-paypal-payments' )
. '<p class="description">'
. sprintf(
// translators: %1$s and %2$s are the opening and closing of HTML <a> tag.
2023-09-12 15:35:32 +02:00
__( 'Buyers can use %1$sApple Pay%2$s to make payments on the web using the Safari web browser or an iOS device.', 'woocommerce-paypal-payments' ),
2023-09-12 14:07:30 +02:00
'<a href="https://woocommerce.com/document/woocommerce-paypal-payments/#apple-pay" target="_blank">',
'</a>'
)
. '</p>',
2023-09-08 16:58:32 +02:00
'default' => 'yes',
'screens' => array( State::STATE_ONBOARDED ),
'gateway' => 'paypal',
'requirements' => array(),
2023-09-05 09:14:20 +02:00
'custom_attributes' => array(
'data-ppcp-handlers' => wp_json_encode(
array(
array(
'handler' => 'SubElementsHandler',
'options' => array(
2023-09-08 16:58:32 +02:00
'values' => array( '1' ),
2023-09-10 11:41:14 +02:00
'elements' => array( '#field-applepay_sandbox_validation_file', '#field-applepay_live_validation_file', '#field-applepay_button_color', '#field-applepay_button_type', '#field-applepay_button_language' ),
2023-09-05 09:14:20 +02:00
),
),
)
),
),
),
2023-09-08 16:58:32 +02:00
'applepay_live_validation_file' => array(
'title' => __( 'Apple Pay Live Validation File', 'woocommerce-paypal-payments' ),
'type' => 'text',
2023-09-05 09:14:20 +02:00
'desc_tip' => true,
2023-09-08 16:58:32 +02:00
'description' => __( 'Paste here the validation file content', 'woocommerce-paypal-payments' ),
'default' => null,
'screens' => array( State::STATE_ONBOARDED ),
'gateway' => 'paypal',
2023-09-05 09:14:20 +02:00
'requirements' => array(),
),
'applepay_sandbox_validation_file' => array(
2023-09-08 16:58:32 +02:00
'title' => __( 'Apple Pay Sandbox Validation File', 'woocommerce-paypal-payments' ),
'type' => 'text',
'desc_tip' => true,
'description' => __( 'Paste here the validation file content', 'woocommerce-paypal-payments' ),
'default' => null,
'screens' => array( State::STATE_ONBOARDED ),
'gateway' => 'paypal',
2023-09-05 09:14:20 +02:00
'requirements' => array(),
),
2023-09-12 14:07:30 +02:00
'applepay_button_type' => array(
2023-09-12 15:35:32 +02:00
'title' => str_repeat( '&nbsp;', 6 ) . __( 'Button Label', 'woocommerce-paypal-payments' ),
2023-09-08 16:58:32 +02:00
'type' => 'select',
2023-09-12 14:07:30 +02:00
'desc_tip' => true,
'description' => __(
'This controls the label of the Apple Pay button.',
'woocommerce-paypal-payments'
),
2023-09-08 16:58:32 +02:00
'class' => array(),
2023-09-12 14:07:30 +02:00
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'pay',
'options' => PropertiesDictionary::button_types(),
2023-09-08 16:58:32 +02:00
'screens' => array( State::STATE_ONBOARDED ),
'gateway' => 'paypal',
2023-09-05 09:14:20 +02:00
'requirements' => array(),
),
2023-09-12 14:07:30 +02:00
'applepay_button_color' => array(
'title' => str_repeat( '&nbsp;', 6 ) . __( 'Button Color', 'woocommerce-paypal-payments' ),
2023-09-08 16:58:32 +02:00
'type' => 'select',
2023-09-12 14:07:30 +02:00
'desc_tip' => true,
'description' => __(
2023-09-12 15:35:32 +02:00
'The Apple Pay Button may appear as a black button with white lettering, white button with black lettering, or a white button with black lettering and a black outline.',
2023-09-12 14:07:30 +02:00
'woocommerce-paypal-payments'
),
'label' => '',
2023-09-08 16:58:32 +02:00
'input_class' => array( 'wc-enhanced-select' ),
2023-09-12 14:07:30 +02:00
'class' => array(),
'default' => 'black',
'options' => PropertiesDictionary::button_colors(),
2023-09-08 16:58:32 +02:00
'screens' => array( State::STATE_ONBOARDED ),
'gateway' => 'paypal',
2023-09-05 09:14:20 +02:00
'requirements' => array(),
),
2023-09-08 16:58:32 +02:00
'applepay_button_language' => array(
'title' => str_repeat( '&nbsp;', 6 ) . __( 'Button Language', 'woocommerce-paypal-payments' ),
'type' => 'select',
2023-09-12 14:07:30 +02:00
'desc_tip' => true,
'description' => __(
2023-09-12 15:35:32 +02:00
'The language and region used for the displayed Apple Pay button. The default value is the current language and region setting in a browser.',
2023-09-12 14:07:30 +02:00
'woocommerce-paypal-payments'
),
2023-09-08 16:58:32 +02:00
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'en',
'options' => PropertiesDictionary::button_languages(),
'screens' => array( State::STATE_ONBOARDED ),
'gateway' => 'paypal',
2023-09-05 09:14:20 +02:00
'requirements' => array(),
),
)
);
},
);