2024-02-06 12:01:38 +00:00
< ? php
/**
* The Axo module extensions .
*
* @ package WooCommerce\PayPalCommerce\Axo
*/
declare ( strict_types = 1 );
namespace WooCommerce\PayPalCommerce\Axo ;
2024-02-08 14:37:56 +00:00
use WooCommerce\PayPalCommerce\Axo\Helper\PropertiesDictionary ;
use WooCommerce\PayPalCommerce\Onboarding\State ;
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface ;
use WooCommerce\PayPalCommerce\WcGateway\Helper\DisplayManager ;
2024-02-06 12:01:38 +00:00
return array (
2024-02-08 14:37:56 +00: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 ) );
};
$display_manager = $container -> get ( 'wcgateway.display-manager' );
assert ( $display_manager instanceof DisplayManager );
2024-04-10 15:51:19 +01:00
$module_url = $container -> get ( 'axo.url' );
2024-02-08 14:37:56 +00:00
// Standard Payments tab fields.
return $insert_after (
$fields ,
2024-03-01 15:05:17 +00:00
'vault_enabled_dcc' ,
2024-02-08 14:37:56 +00:00
array (
2024-04-11 18:07:20 +01:00
'axo_heading' => array (
2024-04-10 15:51:19 +01:00
'heading' => __ ( 'Fastlane' , 'woocommerce-paypal-payments' ),
'type' => 'ppcp-heading' ,
'description' => wp_kses_post (
sprintf (
// translators: %1$s and %2$s is a link tag.
__ (
'Offer an accelerated checkout experience that recognizes guest shoppers and autofills their details so they can pay in seconds.' ,
'woocommerce-paypal-payments'
),
' < a
rel = " noreferrer noopener "
href = " https://woo.com/document/woocommerce-paypal-payments/#vaulting-a-card "
> ' ,
'</a>'
)
),
'screens' => array (
State :: STATE_ONBOARDED ,
),
2024-04-29 15:42:54 +02:00
'requirements' => array ( 'dcc' , 'axo' ),
'gateway' => array ( 'dcc' , 'axo' ),
2024-04-10 15:51:19 +01:00
),
2024-04-11 18:07:20 +01:00
'axo_enabled' => array (
2024-02-08 14:37:56 +00:00
'title' => __ ( 'Fastlane' , 'woocommerce-paypal-payments' ),
2024-04-10 15:51:19 +01:00
'title_html' => sprintf (
'<img src="%sassets/images/fastlane.png" alt="%s" style="max-width: 150px; max-height: 45px;" />' ,
$module_url ,
__ ( 'Fastlane' , 'woocommerce-paypal-payments' )
),
2024-02-08 14:37:56 +00:00
'type' => 'checkbox' ,
2024-04-10 15:51:19 +01:00
'label' => __ ( 'Enable Fastlane by PayPal' , 'woocommerce-paypal-payments' )
2024-02-08 14:37:56 +00:00
. '<p class="description">'
2024-04-10 15:51:19 +01:00
. __ ( 'Help accelerate checkout for guests with PayPal\'s autofill solution.' , 'woocommerce-paypal-payments' )
2024-02-08 14:37:56 +00:00
. '</p>' ,
'default' => 'yes' ,
'screens' => array ( State :: STATE_ONBOARDED ),
2024-04-29 15:42:54 +02:00
'gateway' => array ( 'dcc' , 'axo' ),
'requirements' => array ( 'axo' ),
2024-02-08 14:37:56 +00:00
'custom_attributes' => array (
'data-ppcp-display' => wp_json_encode (
array (
$display_manager
-> rule ()
-> condition_element ( 'axo_enabled' , '1' )
-> action_visible ( 'axo_gateway_title' )
2024-04-11 17:14:22 +01:00
-> action_visible ( 'axo_privacy' )
2024-05-02 14:39:23 +02:00
-> action_visible ( 'axo_name_on_card' )
2024-04-11 17:14:22 +01:00
-> action_visible ( 'axo_style_heading' )
2024-02-16 15:04:36 +00:00
-> action_class ( 'axo_enabled' , 'active' )
2024-02-08 14:37:56 +00:00
-> to_array (),
2024-04-10 15:51:19 +01:00
$display_manager
-> rule ()
2024-04-15 18:08:53 +01:00
-> condition_element ( 'axo_enabled' , '1' )
2024-04-10 15:51:19 +01:00
-> condition_js_variable ( 'ppcpAxoShowStyles' , true )
-> action_visible ( 'axo_style_root_heading' )
-> action_visible ( 'axo_style_root_bg_color' )
-> action_visible ( 'axo_style_root_error_color' )
-> action_visible ( 'axo_style_root_font_family' )
2024-05-01 14:54:59 +02:00
-> action_visible ( 'axo_style_root_text_color_base' )
2024-04-10 15:51:19 +01:00
-> action_visible ( 'axo_style_root_font_size_base' )
-> action_visible ( 'axo_style_root_padding' )
-> action_visible ( 'axo_style_root_primary_color' )
-> action_visible ( 'axo_style_input_heading' )
-> action_visible ( 'axo_style_input_bg_color' )
-> action_visible ( 'axo_style_input_border_radius' )
-> action_visible ( 'axo_style_input_border_color' )
2024-04-11 17:14:22 +01:00
-> action_visible ( 'axo_style_input_border_width' )
-> action_visible ( 'axo_style_input_text_color_base' )
-> action_visible ( 'axo_style_input_focus_border_color' )
2024-04-10 15:51:19 +01:00
-> to_array (),
2024-02-08 14:37:56 +00:00
)
),
),
2024-04-11 18:07:20 +01:00
'classes' => array ( 'ppcp-valign-label-middle' , 'ppcp-align-label-center' ),
2024-02-08 14:37:56 +00:00
),
2024-04-11 18:07:20 +01:00
'axo_gateway_title' => array (
2024-02-08 14:37:56 +00:00
'title' => __ ( 'Gateway Title' , 'woocommerce-paypal-payments' ),
'type' => 'text' ,
'classes' => array ( 'ppcp-field-indent' ),
'desc_tip' => true ,
'description' => __ (
'This controls the title of the Fastlane gateway the user sees on checkout.' ,
'woocommerce-paypal-payments'
),
'default' => __ (
2024-04-29 15:26:56 +02:00
'Debit & Credit Cards' ,
2024-02-08 14:37:56 +00:00
'woocommerce-paypal-payments'
),
'screens' => array (
State :: STATE_ONBOARDED ,
),
2024-04-29 15:42:54 +02:00
'requirements' => array ( 'axo' ),
'gateway' => array ( 'dcc' , 'axo' ),
2024-02-08 14:37:56 +00:00
),
2024-04-11 18:07:20 +01:00
'axo_privacy' => array (
2024-04-10 15:51:19 +01:00
'title' => __ ( 'Privacy' , 'woocommerce-paypal-payments' ),
2024-02-08 14:37:56 +00:00
'type' => 'select' ,
2024-04-29 22:58:46 +02:00
'label' => __ (
2024-05-02 16:53:19 +02:00
' This setting will control whether Fastlane branding is shown by email field .
2024-04-29 22:58:46 +02:00
< p class = " description " > PayPal powers this accelerated checkout solution from Fastlane . Since you\ 'll share consumers\' email addresses with PayPal, please consult your legal advisors on the apropriate privacy setting for your business.</p>' ,
'woocommerce-paypal-payments'
),
2024-02-08 14:37:56 +00:00
'desc_tip' => true ,
'description' => __ (
2024-04-10 15:51:19 +01:00
'This setting will control whether Fastlane branding is shown by email field.' ,
2024-02-08 14:37:56 +00:00
'woocommerce-paypal-payments'
),
'classes' => array ( 'ppcp-field-indent' ),
'class' => array (),
'input_class' => array ( 'wc-enhanced-select' ),
2024-04-10 15:51:19 +01:00
'default' => 'yes' ,
'options' => PropertiesDictionary :: privacy_options (),
2024-02-08 14:37:56 +00:00
'screens' => array ( State :: STATE_ONBOARDED ),
2024-04-29 15:42:54 +02:00
'gateway' => array ( 'dcc' , 'axo' ),
'requirements' => array ( 'axo' ),
2024-02-08 14:37:56 +00:00
),
2024-05-01 15:33:23 +02:00
'axo_name_on_card' => array (
2024-05-02 14:39:23 +02:00
'title' => __ ( 'Display Name on Card' , 'woocommerce-paypal-payments' ),
2024-05-01 15:33:23 +02:00
'type' => 'checkbox' ,
'default' => 'yes' ,
'classes' => array ( 'ppcp-field-indent' ),
'class' => array (),
2024-05-02 14:39:23 +02:00
'label' => __ ( 'Enable this to display the "Name on Card" field for new Fastlane buyers.' , 'woocommerce-paypal-payments' ),
2024-05-01 15:33:23 +02:00
'screens' => array ( State :: STATE_ONBOARDED ),
2024-05-06 12:28:14 +02:00
'gateway' => array (),
2024-05-01 15:33:23 +02:00
'requirements' => array ( 'axo' ),
),
2024-04-11 18:07:20 +01:00
'axo_style_heading' => array (
2024-04-10 15:51:19 +01:00
'heading' => __ ( 'Advanced Style Settings (optional)' , 'woocommerce-paypal-payments' ),
'heading_html' => sprintf (
// translators: %1$s and %2$s are the opening and closing of HTML <a> tag.
__ (
'Advanced Style Settings (optional) %1$sSee more%2$s %3$sSee less%4$s' ,
'woocommerce-paypal-payments'
),
2024-04-10 18:27:21 +01:00
'<a href="javascript:void(0)" id="ppcp-axo-style-more" onclick="jQuery(this).hide(); jQuery(\'#ppcp-axo-style-less\').show(); document.ppcpAxoShowStyles = true; jQuery(document).trigger(\'ppcp-display-change\');" style="font-weight: normal;">' ,
2024-04-10 15:51:19 +01:00
'</a>' ,
2024-04-10 18:27:21 +01:00
'<a href="javascript:void(0)" id="ppcp-axo-style-less" onclick="jQuery(this).hide(); jQuery(\'#ppcp-axo-style-more\').show(); document.ppcpAxoShowStyles = false; jQuery(document).trigger(\'ppcp-display-change\');" style="font-weight: normal; display: none;">' ,
2024-04-10 15:51:19 +01:00
'</a>'
),
'type' => 'ppcp-heading' ,
'description' => wp_kses_post (
sprintf (
// translators: %1$s and %2$s is a link tag.
__ (
2024-04-10 18:27:21 +01:00
'Leave the default styling, or customize how Fastlane looks on your website. %1$sSee PayPal\'s developer docs%2$s for info' ,
2024-04-10 15:51:19 +01:00
'woocommerce-paypal-payments'
),
2024-04-10 18:27:21 +01:00
'<a href="https://www.paypal.com/us/fastlane" target="_blank">' ,
2024-04-10 15:51:19 +01:00
'</a>'
)
),
'classes' => array ( 'ppcp-field-indent' ),
'class' => array (),
'screens' => array (
State :: STATE_ONBOARDED ,
),
2024-04-29 15:42:54 +02:00
'requirements' => array ( 'dcc' , 'axo' ),
'gateway' => array ( 'dcc' , 'axo' ),
2024-04-10 15:51:19 +01:00
),
2024-04-11 18:07:20 +01:00
'axo_style_root_heading' => array (
2024-04-10 15:51:19 +01:00
'heading' => __ ( 'Root Settings' , 'woocommerce-paypal-payments' ),
'type' => 'ppcp-heading' ,
2024-02-08 14:37:56 +00:00
'description' => __ (
2024-04-10 15:51:19 +01:00
'These apply to the overall Fastlane checkout module.' ,
'woocommerce-paypal-payments'
),
'classes' => array ( 'ppcp-field-indent' ),
'screens' => array ( State :: STATE_ONBOARDED ),
2024-04-29 15:42:54 +02:00
'requirements' => array ( 'dcc' , 'axo' ),
'gateway' => array ( 'dcc' , 'axo' ),
2024-04-10 15:51:19 +01:00
),
2024-04-11 18:07:20 +01:00
'axo_style_root_bg_color' => array (
2024-04-10 15:51:19 +01:00
'title' => __ ( 'Background Color' , 'woocommerce-paypal-payments' ),
'type' => 'text' ,
2024-05-01 15:12:01 +02:00
'placeholder' => '#ffffff' ,
'classes' => array ( 'ppcp-field-indent' ),
'default' => '' ,
'screens' => array (
State :: STATE_ONBOARDED ,
),
'requirements' => array ( 'axo' ),
'gateway' => array ( 'dcc' , 'axo' ),
),
'axo_style_root_primary_color' => array (
'title' => __ ( 'Primary Color' , 'woocommerce-paypal-payments' ),
'type' => 'text' ,
'placeholder' => '#0057F' ,
2024-04-10 15:51:19 +01:00
'classes' => array ( 'ppcp-field-indent' ),
2024-05-01 14:54:59 +02:00
'default' => '' ,
2024-04-10 15:51:19 +01:00
'screens' => array (
State :: STATE_ONBOARDED ,
),
2024-04-29 15:42:54 +02:00
'requirements' => array ( 'axo' ),
'gateway' => array ( 'dcc' , 'axo' ),
2024-04-10 15:51:19 +01:00
),
2024-04-11 18:07:20 +01:00
'axo_style_root_error_color' => array (
2024-04-10 15:51:19 +01:00
'title' => __ ( 'Error Color' , 'woocommerce-paypal-payments' ),
'type' => 'text' ,
2024-05-01 15:12:01 +02:00
'placeholder' => '#D9360B' ,
2024-04-10 15:51:19 +01:00
'classes' => array ( 'ppcp-field-indent' ),
2024-05-01 14:54:59 +02:00
'default' => '' ,
2024-04-10 15:51:19 +01:00
'screens' => array (
State :: STATE_ONBOARDED ,
),
2024-04-29 15:42:54 +02:00
'requirements' => array ( 'axo' ),
'gateway' => array ( 'dcc' , 'axo' ),
2024-04-10 15:51:19 +01:00
),
2024-04-11 18:07:20 +01:00
'axo_style_root_font_family' => array (
2024-04-10 15:51:19 +01:00
'title' => __ ( 'Font Family' , 'woocommerce-paypal-payments' ),
'type' => 'text' ,
2024-05-06 12:46:33 +02:00
'placeholder' => 'PayPal-Open' ,
2024-04-10 15:51:19 +01:00
'classes' => array ( 'ppcp-field-indent' ),
2024-05-01 14:54:59 +02:00
'default' => '' ,
'screens' => array (
State :: STATE_ONBOARDED ,
),
'requirements' => array ( 'axo' ),
'gateway' => array ( 'dcc' , 'axo' ),
),
'axo_style_root_text_color_base' => array (
'title' => __ ( 'Text Color Base' , 'woocommerce-paypal-payments' ),
'type' => 'text' ,
2024-05-01 15:12:01 +02:00
'placeholder' => '#010B0D' ,
2024-05-01 14:54:59 +02:00
'classes' => array ( 'ppcp-field-indent' ),
'default' => '' ,
2024-04-10 15:51:19 +01:00
'screens' => array (
State :: STATE_ONBOARDED ,
),
2024-04-29 15:42:54 +02:00
'requirements' => array ( 'axo' ),
'gateway' => array ( 'dcc' , 'axo' ),
2024-04-10 15:51:19 +01:00
),
2024-04-11 18:07:20 +01:00
'axo_style_root_font_size_base' => array (
2024-04-10 15:51:19 +01:00
'title' => __ ( 'Font Size Base' , 'woocommerce-paypal-payments' ),
'type' => 'text' ,
2024-05-01 15:12:01 +02:00
'placeholder' => '16px' ,
2024-04-10 15:51:19 +01:00
'classes' => array ( 'ppcp-field-indent' ),
2024-05-01 14:54:59 +02:00
'default' => '' ,
2024-04-10 15:51:19 +01:00
'screens' => array (
State :: STATE_ONBOARDED ,
),
2024-04-29 15:42:54 +02:00
'requirements' => array ( 'axo' ),
'gateway' => array ( 'dcc' , 'axo' ),
2024-04-10 15:51:19 +01:00
),
2024-04-11 18:07:20 +01:00
'axo_style_root_padding' => array (
2024-04-10 15:51:19 +01:00
'title' => __ ( 'Padding' , 'woocommerce-paypal-payments' ),
'type' => 'text' ,
2024-05-01 15:12:01 +02:00
'placeholder' => '4px' ,
2024-04-10 15:51:19 +01:00
'classes' => array ( 'ppcp-field-indent' ),
2024-05-01 14:54:59 +02:00
'default' => '' ,
2024-04-10 15:51:19 +01:00
'screens' => array (
State :: STATE_ONBOARDED ,
),
2024-04-29 15:42:54 +02:00
'requirements' => array ( 'axo' ),
'gateway' => array ( 'dcc' , 'axo' ),
2024-04-10 15:51:19 +01:00
),
2024-04-11 18:07:20 +01:00
'axo_style_input_heading' => array (
2024-04-10 15:51:19 +01:00
'heading' => __ ( 'Input Settings' , 'woocommerce-paypal-payments' ),
'type' => 'ppcp-heading' ,
'description' => __ (
'These apply to the customer input fields on your Fastlane module.' ,
2024-02-08 14:37:56 +00:00
'woocommerce-paypal-payments'
),
'classes' => array ( 'ppcp-field-indent' ),
'screens' => array ( State :: STATE_ONBOARDED ),
2024-04-29 15:42:54 +02:00
'requirements' => array ( 'dcc' , 'axo' ),
'gateway' => array ( 'dcc' , 'axo' ),
2024-04-10 15:51:19 +01:00
),
2024-04-11 18:07:20 +01:00
'axo_style_input_bg_color' => array (
2024-04-10 15:51:19 +01:00
'title' => __ ( 'Background Color' , 'woocommerce-paypal-payments' ),
'type' => 'text' ,
2024-05-01 15:12:01 +02:00
'placeholder' => '#ffffff' ,
2024-04-10 15:51:19 +01:00
'classes' => array ( 'ppcp-field-indent' ),
2024-05-01 14:54:59 +02:00
'default' => '' ,
2024-04-10 15:51:19 +01:00
'screens' => array (
State :: STATE_ONBOARDED ,
),
2024-04-29 15:42:54 +02:00
'requirements' => array ( 'axo' ),
'gateway' => array ( 'dcc' , 'axo' ),
2024-02-08 14:37:56 +00:00
),
2024-04-11 18:07:20 +01:00
'axo_style_input_border_radius' => array (
2024-04-10 15:51:19 +01:00
'title' => __ ( 'Border Radius' , 'woocommerce-paypal-payments' ),
'type' => 'text' ,
2024-05-01 15:12:01 +02:00
'placeholder' => '0.25em' ,
2024-04-10 15:51:19 +01:00
'classes' => array ( 'ppcp-field-indent' ),
2024-05-01 14:54:59 +02:00
'default' => '' ,
2024-04-10 15:51:19 +01:00
'screens' => array (
State :: STATE_ONBOARDED ,
),
2024-04-29 15:42:54 +02:00
'requirements' => array ( 'axo' ),
'gateway' => array ( 'dcc' , 'axo' ),
2024-04-10 15:51:19 +01:00
),
2024-04-11 18:07:20 +01:00
'axo_style_input_border_color' => array (
2024-04-10 15:51:19 +01:00
'title' => __ ( 'Border Color' , 'woocommerce-paypal-payments' ),
'type' => 'text' ,
2024-05-01 15:12:01 +02:00
'placeholder' => '#DADDDD' ,
2024-04-10 15:51:19 +01:00
'classes' => array ( 'ppcp-field-indent' ),
2024-05-01 14:54:59 +02:00
'default' => '' ,
2024-04-10 15:51:19 +01:00
'screens' => array (
State :: STATE_ONBOARDED ,
),
2024-04-29 15:42:54 +02:00
'requirements' => array ( 'axo' ),
'gateway' => array ( 'dcc' , 'axo' ),
2024-04-10 15:51:19 +01:00
),
2024-04-11 18:07:20 +01:00
'axo_style_input_border_width' => array (
2024-04-10 15:51:19 +01:00
'title' => __ ( 'Border Width' , 'woocommerce-paypal-payments' ),
'type' => 'text' ,
2024-05-01 15:12:01 +02:00
'placeholder' => '1px' ,
2024-04-10 15:51:19 +01:00
'classes' => array ( 'ppcp-field-indent' ),
2024-05-01 14:54:59 +02:00
'default' => '' ,
2024-04-10 15:51:19 +01:00
'screens' => array (
State :: STATE_ONBOARDED ,
),
2024-04-29 15:42:54 +02:00
'requirements' => array ( 'axo' ),
'gateway' => array ( 'dcc' , 'axo' ),
2024-04-10 15:51:19 +01:00
),
2024-04-11 18:07:20 +01:00
'axo_style_input_text_color_base' => array (
2024-04-10 15:51:19 +01:00
'title' => __ ( 'Text Color Base' , 'woocommerce-paypal-payments' ),
'type' => 'text' ,
2024-05-01 15:12:01 +02:00
'placeholder' => '#010B0D' ,
2024-04-10 15:51:19 +01:00
'classes' => array ( 'ppcp-field-indent' ),
2024-05-01 14:54:59 +02:00
'default' => '' ,
2024-04-10 15:51:19 +01:00
'screens' => array (
State :: STATE_ONBOARDED ,
),
2024-04-29 15:42:54 +02:00
'requirements' => array ( 'axo' ),
'gateway' => array ( 'dcc' , 'axo' ),
2024-04-10 15:51:19 +01:00
),
2024-04-11 17:14:22 +01:00
'axo_style_input_focus_border_color' => array (
2024-04-10 15:51:19 +01:00
'title' => __ ( 'Focus Border Color' , 'woocommerce-paypal-payments' ),
'type' => 'text' ,
2024-05-01 15:12:01 +02:00
'placeholder' => '#0057FF' ,
2024-04-10 15:51:19 +01:00
'classes' => array ( 'ppcp-field-indent' ),
2024-05-01 14:54:59 +02:00
'default' => '' ,
2024-04-10 15:51:19 +01:00
'screens' => array (
State :: STATE_ONBOARDED ,
),
2024-04-29 15:42:54 +02:00
'requirements' => array ( 'axo' ),
'gateway' => array ( 'dcc' , 'axo' ),
2024-04-10 15:51:19 +01:00
),
2024-02-08 14:37:56 +00:00
)
);
},
2024-02-06 12:01:38 +00:00
);