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-05-10 02:07:51 +02:00
use WooCommerce\PayPalCommerce\Axo\Helper\NoticeRenderer ;
2024-02-08 14:37:56 +00:00
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-04-19 15:26:55 +01:00
'wcgateway.settings.fields' => function ( array $fields , ContainerInterface $container ) : array {
2024-02-08 14:37:56 +00:00
$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-09-30 16:41:54 +02:00
. sprintf (
// translators: %1$s and %2$s are the opening and closing of HTML <a> tag.
__ ( 'Help accelerate the checkout process for guests with PayPal\'s autofill solution. When enabled, Fastlane is presented as the default payment method for guests. See the %1$sFastlane setup guide%2$s for more details on the Fastlane configuration.' , 'woocommerce-paypal-payments' ),
'<a href="https://woocommerce.com/document/woocommerce-paypal-payments/#fastlane" target="_blank">' ,
'</a>'
)
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' )
2024-08-01 22:25:46 +02:00
-> action_visible ( 'axo_main_notice' )
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-07-18 00:27:35 +02:00
'axo_main_notice' => array (
2024-05-10 02:07:51 +02:00
'heading' => '' ,
2024-07-25 00:18:15 +02:00
'html' => implode (
'' ,
array (
2024-07-31 14:04:48 +02:00
$container -> get ( 'axo.settings-conflict-notice' ),
2024-07-25 00:18:15 +02:00
$container -> get ( 'axo.checkout-config-notice' ),
$container -> get ( 'axo.incompatible-plugins-notice' ),
)
),
2024-07-17 19:06:40 +02:00
'type' => 'ppcp-html' ,
'classes' => array ( 'ppcp-field-indent' ),
'class' => array (),
'screens' => array (
State :: STATE_ONBOARDED ,
),
'requirements' => array ( 'dcc' , 'axo' ),
'gateway' => array ( 'dcc' , '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-05-28 18:32:49 +02:00
'Leave the default styling, or customize how Fastlane looks on your website. Styles that don\'t meet accessibility guidelines will revert to the defaults. See %1$sPayPal\'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' ,
2024-04-10 15:51:19 +01:00
'classes' => array ( 'ppcp-field-indent' ),
2024-05-01 15:12:01 +02:00
'default' => '' ,
2024-04-10 15:51:19 +01:00
'screens' => array (
State :: STATE_ONBOARDED ,
),
2024-05-01 15:12:01 +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-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_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_root_primary_color' => array (
2024-04-10 15:51:19 +01:00
'title' => __ ( 'Primary Color' , 'woocommerce-paypal-payments' ),
'type' => 'text' ,
2024-05-28 18:32:49 +02:00
'placeholder' => '#0057FF' ,
2024-04-10 15:51:19 +01:00
'classes' => array ( 'ppcp-field-indent' ),
2024-05-28 18:32:49 +02:00
'default' => '' ,
2024-04-10 15:51:19 +01:00
'screens' => array (
State :: STATE_ONBOARDED ,
),
2024-05-28 18:32:49 +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
);