2023-08-22 08:44:32 +01:00
< ? php
/**
* The Googlepay module extensions .
*
* @ package WooCommerce\PayPalCommerce\Googlepay
*/
declare ( strict_types = 1 );
namespace WooCommerce\PayPalCommerce\Googlepay ;
2023-09-08 18:43:33 +01:00
use WooCommerce\PayPalCommerce\Googlepay\Helper\PropertiesDictionary ;
2023-08-22 08:44:32 +01:00
use WooCommerce\PayPalCommerce\Onboarding\State ;
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface ;
return array (
2023-08-30 11:28:18 +01: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 ;
return array_merge ( array_slice ( $array , 0 , $pos ), $new , array_slice ( $array , $pos ) );
};
return $insert_after (
$fields ,
'allow_card_button_gateway' ,
array (
2023-09-06 11:55:26 +01:00
'googlepay_button_enabled' => array (
2023-08-30 16:38:00 +01:00
'title' => __ ( 'Google Pay Button' , 'woocommerce-paypal-payments' ),
'type' => 'checkbox' ,
2023-09-11 17:42:54 +01:00
'label' => __ ( 'Enable Google Pay button' , 'woocommerce-paypal-payments' )
. '<p class="description">'
. sprintf (
// translators: %1$s and %2$s are the opening and closing of HTML <a> tag.
__ ( 'Buyers can use %1$sGoogle Pay%2$s to make payments on the web using a web browser.' , 'woocommerce-paypal-payments' ),
'<a href="https://woocommerce.com/document/woocommerce-paypal-payments/#google-pay" target="_blank">' ,
'</a>'
)
. '</p>' ,
2023-08-30 16:38:00 +01:00
'default' => 'yes' ,
'screens' => array ( State :: STATE_ONBOARDED ),
'gateway' => 'paypal' ,
'requirements' => array (),
'custom_attributes' => array (
'data-ppcp-handlers' => wp_json_encode (
array (
array (
'handler' => 'SubElementsHandler' ,
'options' => array (
'values' => array ( '1' ),
2023-09-06 11:55:26 +01:00
'elements' => array (
'#field-googlepay_button_color' ,
'#field-googlepay_button_type' ,
'#field-googlepay_button_shipping_enabled' ,
),
2023-08-30 16:38:00 +01:00
),
),
)
),
),
),
2023-09-11 17:42:54 +01:00
'googlepay_button_type' => array (
'title' => str_repeat ( ' ' , 6 ) . __ ( 'Button Label' , 'woocommerce-paypal-payments' ),
2023-08-30 16:38:00 +01:00
'type' => 'select' ,
2023-09-11 17:42:54 +01:00
'desc_tip' => true ,
'description' => __ (
'This controls the label of the Google Pay button.' ,
'woocommerce-paypal-payments'
),
2023-08-30 16:38:00 +01:00
'class' => array (),
2023-09-11 17:42:54 +01:00
'input_class' => array ( 'wc-enhanced-select' ),
'default' => 'pay' ,
'options' => PropertiesDictionary :: button_types (),
2023-08-30 16:38:00 +01:00
'screens' => array ( State :: STATE_ONBOARDED ),
'gateway' => 'paypal' ,
'requirements' => array (),
),
2023-09-11 17:42:54 +01:00
'googlepay_button_color' => array (
'title' => str_repeat ( ' ' , 6 ) . __ ( 'Button Color' , 'woocommerce-paypal-payments' ),
2023-08-30 16:38:00 +01:00
'type' => 'select' ,
2023-09-11 17:42:54 +01:00
'desc_tip' => true ,
'description' => __ (
'Google Pay payment buttons exist in two styles: dark and light. To provide contrast, use dark buttons on light backgrounds and light buttons on dark or colorful backgrounds.' ,
'woocommerce-paypal-payments'
),
'label' => '' ,
2023-08-30 16:38:00 +01:00
'input_class' => array ( 'wc-enhanced-select' ),
2023-09-11 17:42:54 +01:00
'class' => array (),
'default' => 'black' ,
'options' => PropertiesDictionary :: button_colors (),
2023-08-30 11:28:18 +01:00
'screens' => array ( State :: STATE_ONBOARDED ),
'gateway' => 'paypal' ,
'requirements' => array (),
2023-08-24 17:30:29 +01:00
),
2023-09-06 11:55:26 +01:00
'googlepay_button_shipping_enabled' => array (
'title' => str_repeat ( ' ' , 6 ) . __ ( 'Shipping Callback' , 'woocommerce-paypal-payments' ),
'type' => 'checkbox' ,
2023-09-11 17:42:54 +01:00
'desc_tip' => true ,
'description' => __ (
'Synchronizes your available shipping options with Google Pay. Enabling this may impact the buyer experience.' ,
'woocommerce-paypal-payments'
),
2023-09-06 11:55:26 +01:00
'label' => __ ( 'Enable Google Pay shipping callback' , 'woocommerce-paypal-payments' ),
'default' => 'no' ,
'screens' => array ( State :: STATE_ONBOARDED ),
'gateway' => 'paypal' ,
'requirements' => array (),
),
2023-08-30 11:28:18 +01:00
)
2023-08-24 17:30:29 +01:00
);
},
2023-08-30 11:28:18 +01:00
2023-08-22 08:44:32 +01:00
);