mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Check for features are available on PayPal, reorder the sections
This commit is contained in:
parent
6742229345
commit
a693829815
2 changed files with 164 additions and 102 deletions
|
@ -16,7 +16,6 @@ use WooCommerce\PayPalCommerce\ApiClient\Helper\DccApplies;
|
|||
use WooCommerce\PayPalCommerce\Onboarding\Environment;
|
||||
use WooCommerce\PayPalCommerce\Onboarding\Render\OnboardingOptionsRenderer;
|
||||
use WooCommerce\PayPalCommerce\Onboarding\State;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
||||
|
||||
return function ( ContainerInterface $container, array $fields ): array {
|
||||
|
||||
|
@ -33,52 +32,8 @@ return function ( ContainerInterface $container, array $fields ): array {
|
|||
|
||||
$module_url = $container->get( 'wcgateway.url' );
|
||||
|
||||
$dash_icon_yes = '<span class="dashicons dashicons-yes"></span>';
|
||||
$dash_icon_no = '<span class="dashicons dashicons-no"></span>';
|
||||
|
||||
$connected_to_paypal_markup = sprintf(
|
||||
'<p>%1$s %2$s</p><p><button type="button" class="button ppcp-disconnect sandbox">%3$s</button></p>',
|
||||
esc_html__( 'Status: Connected', 'woocommerce-paypal-payments' ),
|
||||
$dash_icon_yes,
|
||||
esc_html__( 'Disconnect Account', 'woocommerce-paypal-payments' )
|
||||
);
|
||||
|
||||
$settings = $container->get( 'wcgateway.settings' );
|
||||
assert( $settings instanceof Settings );
|
||||
|
||||
$enabled_status_text = esc_html__( 'Status: Enabled', 'woocommerce-paypal-payments' );
|
||||
$disabled_status_text = esc_html__( 'Status: Not yet enabled', 'woocommerce-paypal-payments' );
|
||||
|
||||
$dcc_enabled = $settings->has( 'dcc_enabled' ) && $settings->get( 'dcc_enabled' );
|
||||
|
||||
$dcc_button_text = $dcc_enabled
|
||||
? esc_html__( 'Disable Advanced Card Payments', 'woocommerce-paypal-payments' )
|
||||
: esc_html__( 'Enable Advanced Card Payments', 'woocommerce-paypal-payments' );
|
||||
|
||||
$dcc_status = sprintf(
|
||||
'<p>%1$s %2$s</p><p><a href="%3$s" class="button">%4$s</a></p>',
|
||||
$dcc_enabled ? $enabled_status_text : $disabled_status_text,
|
||||
$dcc_enabled ? $dash_icon_yes : $dash_icon_no,
|
||||
admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=ppcp-gateway&ppcp-tab=ppcp-credit-card-gateway' ),
|
||||
esc_html( $dcc_button_text )
|
||||
);
|
||||
|
||||
$pui_enabled = $settings->has( 'products_pui_enabled' ) && $settings->get( 'products_pui_enabled' );
|
||||
|
||||
$pui_button_text = $pui_enabled
|
||||
? esc_html__( 'Disable Pay Upon Invoice', 'woocommerce-paypal-payments' )
|
||||
: esc_html__( 'Enable Pay Upon Invoice', 'woocommerce-paypal-payments' );
|
||||
|
||||
$pui_status = sprintf(
|
||||
'<p>%1$s %2$s</p><p><a href="%3$s" class="button">%4$s</a></p>',
|
||||
$pui_enabled ? $enabled_status_text : $disabled_status_text,
|
||||
$pui_enabled ? $dash_icon_yes : $dash_icon_no,
|
||||
admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=ppcp-pay-upon-invoice-gateway' ),
|
||||
esc_html( $pui_button_text )
|
||||
);
|
||||
|
||||
$connection_fields = array(
|
||||
'ppcp_onboarading_header' => array(
|
||||
'ppcp_onboarading_header' => array(
|
||||
'type' => 'ppcp-text',
|
||||
'classes' => array( 'ppcp-onboarding-element' ),
|
||||
'text' => '
|
||||
|
@ -110,7 +65,7 @@ return function ( ContainerInterface $container, array $fields ): array {
|
|||
'requirements' => array(),
|
||||
'gateway' => 'connection',
|
||||
),
|
||||
'credentials_production_heading' => array(
|
||||
'credentials_production_heading' => array(
|
||||
'heading' => __( 'API Credentials', 'woocommerce-paypal-payments' ),
|
||||
'type' => 'ppcp-heading',
|
||||
'screens' => array(
|
||||
|
@ -120,7 +75,7 @@ return function ( ContainerInterface $container, array $fields ): array {
|
|||
'requirements' => array(),
|
||||
'gateway' => 'connection',
|
||||
),
|
||||
'credentials_sandbox_heading' => array(
|
||||
'credentials_sandbox_heading' => array(
|
||||
'heading' => __( 'Sandbox API Credentials', 'woocommerce-paypal-payments' ),
|
||||
'type' => 'ppcp-heading',
|
||||
'screens' => array(
|
||||
|
@ -132,7 +87,7 @@ return function ( ContainerInterface $container, array $fields ): array {
|
|||
'description' => __( 'Your account is connected to sandbox, no real charging takes place. To accept live payments, turn off sandbox mode and connect your live PayPal account.', 'woocommerce-paypal-payments' ),
|
||||
),
|
||||
|
||||
'ppcp_onboarading_options' => array(
|
||||
'ppcp_onboarading_options' => array(
|
||||
'type' => 'ppcp-text',
|
||||
'classes' => array( 'ppcp-onboarding-element' ),
|
||||
'text' => $onboarding_options_renderer->render( $is_shop_supports_dcc ),
|
||||
|
@ -148,7 +103,7 @@ return function ( ContainerInterface $container, array $fields ): array {
|
|||
// We need to have a button for each option (ppcp, express)
|
||||
// because currently the only documented way to use the PayPal onboarding JS library
|
||||
// is to have the buttons before loading the script.
|
||||
'ppcp_onboarding_production_ppcp' => array(
|
||||
'ppcp_onboarding_production_ppcp' => array(
|
||||
'type' => 'ppcp_onboarding',
|
||||
'classes' => array( 'ppcp-onboarding-element' ),
|
||||
'screens' => array(
|
||||
|
@ -160,7 +115,7 @@ return function ( ContainerInterface $container, array $fields ): array {
|
|||
'requirements' => array(),
|
||||
'gateway' => 'connection',
|
||||
),
|
||||
'ppcp_onboarding_production_express' => array(
|
||||
'ppcp_onboarding_production_express' => array(
|
||||
'type' => 'ppcp_onboarding',
|
||||
'classes' => array( 'ppcp-onboarding-element' ),
|
||||
'screens' => array(
|
||||
|
@ -172,7 +127,7 @@ return function ( ContainerInterface $container, array $fields ): array {
|
|||
'requirements' => array(),
|
||||
'gateway' => 'connection',
|
||||
),
|
||||
'ppcp_onboarding_sandbox_ppcp' => array(
|
||||
'ppcp_onboarding_sandbox_ppcp' => array(
|
||||
'type' => 'ppcp_onboarding',
|
||||
'classes' => array( 'ppcp-onboarding-element' ),
|
||||
'screens' => array(
|
||||
|
@ -185,7 +140,7 @@ return function ( ContainerInterface $container, array $fields ): array {
|
|||
'gateway' => 'connection',
|
||||
'description' => __( 'Prior to accepting live payments, you can test payments on your WooCommerce platform in a safe PayPal sandbox environment.', 'woocommerce-paypal-payments' ),
|
||||
),
|
||||
'ppcp_onboarding_sandbox_express' => array(
|
||||
'ppcp_onboarding_sandbox_express' => array(
|
||||
'type' => 'ppcp_onboarding',
|
||||
'classes' => array( 'ppcp-onboarding-element' ),
|
||||
'screens' => array(
|
||||
|
@ -199,7 +154,7 @@ return function ( ContainerInterface $container, array $fields ): array {
|
|||
'description' => __( 'Prior to accepting live payments, you can test payments on your WooCommerce platform in a safe PayPal sandbox environment.', 'woocommerce-paypal-payments' ),
|
||||
),
|
||||
|
||||
'ppcp_disconnect_production' => array(
|
||||
'ppcp_disconnect_production' => array(
|
||||
'title' => __( 'Disconnect from PayPal', 'woocommerce-paypal-payments' ),
|
||||
'type' => 'ppcp-text',
|
||||
'text' => '<button type="button" class="button ppcp-disconnect production">' . esc_html__( 'Disconnect', 'woocommerce-paypal-payments' ) . '</button>',
|
||||
|
@ -212,10 +167,14 @@ return function ( ContainerInterface $container, array $fields ): array {
|
|||
'gateway' => 'connection',
|
||||
'description' => __( 'Click to reset current credentials and use another account.', 'woocommerce-paypal-payments' ),
|
||||
),
|
||||
'ppcp_disconnect_sandbox' => array(
|
||||
'ppcp_disconnect_sandbox' => array(
|
||||
'title' => __( 'Disconnect from PayPal Sandbox', 'woocommerce-paypal-payments' ),
|
||||
'type' => 'ppcp-text',
|
||||
'text' => $connected_to_paypal_markup,
|
||||
'text' => sprintf(
|
||||
'<p>%1$s <span class="dashicons dashicons-yes"></span></p><p><button type="button" class="button ppcp-disconnect sandbox">%2$s</button></p>',
|
||||
esc_html__( 'Status: Connected', 'woocommerce-paypal-payments' ),
|
||||
esc_html__( 'Disconnect Account', 'woocommerce-paypal-payments' )
|
||||
),
|
||||
'screens' => array(
|
||||
State::STATE_ONBOARDED,
|
||||
),
|
||||
|
@ -225,7 +184,7 @@ return function ( ContainerInterface $container, array $fields ): array {
|
|||
'gateway' => 'connection',
|
||||
'description' => __( 'Click to reset current credentials and use another account.', 'woocommerce-paypal-payments' ),
|
||||
),
|
||||
'toggle_manual_input' => array(
|
||||
'toggle_manual_input' => array(
|
||||
'type' => 'ppcp-text',
|
||||
'text' => '<button type="button" id="ppcp[toggle_manual_input]">' . __( 'Toggle to manual credential input', 'woocommerce-paypal-payments' ) . '</button>',
|
||||
'classes' => array( 'ppcp-onboarding-element' ),
|
||||
|
@ -236,27 +195,7 @@ return function ( ContainerInterface $container, array $fields ): array {
|
|||
'requirements' => array(),
|
||||
'gateway' => 'connection',
|
||||
),
|
||||
'ppcp_dcc_status' => array(
|
||||
'title' => __( 'Advanced Credit & Debit Crad Payments', 'woocommerce-paypal-payments' ),
|
||||
'type' => 'ppcp-text',
|
||||
'text' => $dcc_status,
|
||||
'screens' => array(
|
||||
State::STATE_ONBOARDED,
|
||||
),
|
||||
'requirements' => array(),
|
||||
'gateway' => 'connection',
|
||||
),
|
||||
'ppcp_pui_status' => array(
|
||||
'title' => __( 'Pay Upon Invoice', 'woocommerce-paypal-payments' ),
|
||||
'type' => 'ppcp-text',
|
||||
'text' => $pui_status,
|
||||
'screens' => array(
|
||||
State::STATE_ONBOARDED,
|
||||
),
|
||||
'requirements' => array( 'pui_ready' ),
|
||||
'gateway' => 'connection',
|
||||
),
|
||||
'error_label' => array(
|
||||
'error_label' => array(
|
||||
'type' => 'ppcp-text',
|
||||
'text' => '<label class="error" id="ppcp-form-errors-label"></label>',
|
||||
'classes' => array( 'hide', 'ppcp-always-shown-element' ),
|
||||
|
@ -267,7 +206,7 @@ return function ( ContainerInterface $container, array $fields ): array {
|
|||
'requirements' => array(),
|
||||
'gateway' => 'connection',
|
||||
),
|
||||
'sandbox_on' => array(
|
||||
'sandbox_on' => array(
|
||||
'title' => __( 'Sandbox', 'woocommerce-paypal-payments' ),
|
||||
'classes' => array( 'ppcp-onboarding-element', 'ppcp-always-shown-element' ),
|
||||
'type' => 'checkbox',
|
||||
|
@ -280,7 +219,7 @@ return function ( ContainerInterface $container, array $fields ): array {
|
|||
'requirements' => array(),
|
||||
'gateway' => 'connection',
|
||||
),
|
||||
'merchant_email_production' => array(
|
||||
'merchant_email_production' => array(
|
||||
'title' => __( 'Live Email address', 'woocommerce-paypal-payments' ),
|
||||
'classes' => array( State::STATE_ONBOARDED === $state->production_state() ? 'onboarded' : '', 'ppcp-always-shown-element' ),
|
||||
'type' => 'text',
|
||||
|
@ -295,7 +234,7 @@ return function ( ContainerInterface $container, array $fields ): array {
|
|||
'requirements' => array(),
|
||||
'gateway' => 'connection',
|
||||
),
|
||||
'merchant_id_production' => array(
|
||||
'merchant_id_production' => array(
|
||||
'title' => __( 'Live Merchant Id', 'woocommerce-paypal-payments' ),
|
||||
'classes' => array( State::STATE_ONBOARDED === $state->production_state() ? 'onboarded' : '', 'ppcp-always-shown-element' ),
|
||||
'type' => 'ppcp-text-input',
|
||||
|
@ -309,7 +248,7 @@ return function ( ContainerInterface $container, array $fields ): array {
|
|||
'requirements' => array(),
|
||||
'gateway' => 'connection',
|
||||
),
|
||||
'client_id_production' => array(
|
||||
'client_id_production' => array(
|
||||
'title' => __( 'Live Client Id', 'woocommerce-paypal-payments' ),
|
||||
'classes' => array( State::STATE_ONBOARDED === $state->production_state() ? 'onboarded' : '', 'ppcp-always-shown-element' ),
|
||||
'type' => 'ppcp-text-input',
|
||||
|
@ -323,7 +262,7 @@ return function ( ContainerInterface $container, array $fields ): array {
|
|||
'requirements' => array(),
|
||||
'gateway' => 'connection',
|
||||
),
|
||||
'client_secret_production' => array(
|
||||
'client_secret_production' => array(
|
||||
'title' => __( 'Live Secret Key', 'woocommerce-paypal-payments' ),
|
||||
'classes' => array( State::STATE_ONBOARDED === $state->production_state() ? 'onboarded' : '', 'ppcp-always-shown-element' ),
|
||||
'type' => 'ppcp-password',
|
||||
|
@ -338,7 +277,7 @@ return function ( ContainerInterface $container, array $fields ): array {
|
|||
'gateway' => 'connection',
|
||||
),
|
||||
|
||||
'merchant_email_sandbox' => array(
|
||||
'merchant_email_sandbox' => array(
|
||||
'title' => __( 'Sandbox Email address', 'woocommerce-paypal-payments' ),
|
||||
'classes' => array( State::STATE_ONBOARDED === $state->sandbox_state() ? 'onboarded' : '', 'ppcp-always-shown-element' ),
|
||||
'type' => 'text',
|
||||
|
@ -353,7 +292,7 @@ return function ( ContainerInterface $container, array $fields ): array {
|
|||
'requirements' => array(),
|
||||
'gateway' => 'connection',
|
||||
),
|
||||
'merchant_id_sandbox' => array(
|
||||
'merchant_id_sandbox' => array(
|
||||
'title' => __( 'Sandbox Merchant Id', 'woocommerce-paypal-payments' ),
|
||||
'classes' => array( State::STATE_ONBOARDED === $state->sandbox_state() ? 'onboarded' : '', 'ppcp-always-shown-element' ),
|
||||
'type' => 'ppcp-text-input',
|
||||
|
@ -367,7 +306,7 @@ return function ( ContainerInterface $container, array $fields ): array {
|
|||
'requirements' => array(),
|
||||
'gateway' => 'connection',
|
||||
),
|
||||
'client_id_sandbox' => array(
|
||||
'client_id_sandbox' => array(
|
||||
'title' => __( 'Sandbox Client Id', 'woocommerce-paypal-payments' ),
|
||||
'classes' => array( State::STATE_ONBOARDED === $state->sandbox_state() ? 'onboarded' : '', 'ppcp-always-shown-element' ),
|
||||
'type' => 'ppcp-text-input',
|
||||
|
@ -381,7 +320,7 @@ return function ( ContainerInterface $container, array $fields ): array {
|
|||
'requirements' => array(),
|
||||
'gateway' => 'connection',
|
||||
),
|
||||
'client_secret_sandbox' => array(
|
||||
'client_secret_sandbox' => array(
|
||||
'title' => __( 'Sandbox Secret Key', 'woocommerce-paypal-payments' ),
|
||||
'classes' => array( State::STATE_ONBOARDED === $state->sandbox_state() ? 'onboarded' : '', 'ppcp-always-shown-element' ),
|
||||
'type' => 'ppcp-password',
|
||||
|
@ -395,22 +334,65 @@ return function ( ContainerInterface $container, array $fields ): array {
|
|||
'requirements' => array(),
|
||||
'gateway' => 'connection',
|
||||
),
|
||||
'logging_enabled' => array(
|
||||
'title' => __( 'Logging', 'woocommerce-paypal-payments' ),
|
||||
'type' => 'checkbox',
|
||||
'desc_tip' => true,
|
||||
'label' => __( 'Enable logging. ', 'woocommerce-paypal-payments' ) .
|
||||
' <a href="' . admin_url( 'admin.php?page=wc-status&tab=logs' ) . '">' . __( 'View logs', 'woocommerce-paypal-payments' ) . '</a>',
|
||||
'description' => __( 'Enable logging of unexpected behavior. This can also log private data and should only be enabled in a development or stage environment.', 'woocommerce-paypal-payments' ),
|
||||
'default' => false,
|
||||
|
||||
'credentials_feature_onboarding_heading' => array(
|
||||
'heading' => __( 'Feature Onboarding', 'woocommerce-paypal-payments' ),
|
||||
'type' => 'ppcp-heading',
|
||||
'screens' => array(
|
||||
State::STATE_ONBOARDED,
|
||||
),
|
||||
'state_from' => Environment::SANDBOX,
|
||||
'requirements' => array(),
|
||||
'gateway' => 'connection',
|
||||
'description' => __( 'See which features are available.', 'woocommerce-paypal-payments' ),
|
||||
),
|
||||
'ppcp_dcc_status' => array(
|
||||
'title' => __( 'Advanced Credit and Debit Card Payments', 'woocommerce-paypal-payments' ),
|
||||
'type' => 'ppcp-text',
|
||||
'text' => $container->get( 'wcgateway.settings.connection.dcc-status-text' ),
|
||||
'screens' => array(
|
||||
State::STATE_START,
|
||||
State::STATE_ONBOARDED,
|
||||
),
|
||||
'requirements' => array(),
|
||||
'gateway' => 'connection',
|
||||
),
|
||||
'prefix' => array(
|
||||
'ppcp_pui_status' => array(
|
||||
'title' => __( 'Pay Upon Invoice', 'woocommerce-paypal-payments' ),
|
||||
'type' => 'ppcp-text',
|
||||
'text' => $container->get( 'wcgateway.settings.connection.pui-status-text' ),
|
||||
'screens' => array(
|
||||
State::STATE_ONBOARDED,
|
||||
),
|
||||
'requirements' => array( 'pui_ready' ),
|
||||
'gateway' => 'connection',
|
||||
),
|
||||
'tracking_enabled' => array(
|
||||
'title' => __( 'Tracking', 'woocommerce-paypal-payments' ),
|
||||
'type' => 'checkbox',
|
||||
'desc_tip' => true,
|
||||
'label' => $container->get( 'wcgateway.settings.tracking-label' ),
|
||||
'description' => __( 'Allows to send shipment tracking numbers to PayPal for PayPal transactions.', 'woocommerce-paypal-payments' ),
|
||||
'default' => false,
|
||||
'screens' => array(
|
||||
State::STATE_ONBOARDED,
|
||||
),
|
||||
'requirements' => array(),
|
||||
'gateway' => 'connection',
|
||||
'input_class' => $container->get( 'wcgateway.settings.should-disable-tracking-checkbox' ) ? array( 'ppcp-disabled-checkbox' ) : array(),
|
||||
),
|
||||
|
||||
'credentials_integration_configuration_heading' => array(
|
||||
'heading' => __( 'Integration configuration', 'woocommerce-paypal-payments' ),
|
||||
'type' => 'ppcp-heading',
|
||||
'screens' => array(
|
||||
State::STATE_ONBOARDED,
|
||||
),
|
||||
'state_from' => Environment::SANDBOX,
|
||||
'requirements' => array(),
|
||||
'gateway' => 'connection',
|
||||
'description' => __( 'See which features are available.', 'woocommerce-paypal-payments' ),
|
||||
),
|
||||
'prefix' => array(
|
||||
'title' => __( 'Invoice prefix', 'woocommerce-paypal-payments' ),
|
||||
'type' => 'text',
|
||||
'desc_tip' => true,
|
||||
|
@ -433,19 +415,20 @@ return function ( ContainerInterface $container, array $fields ): array {
|
|||
'requirements' => array(),
|
||||
'gateway' => 'connection',
|
||||
),
|
||||
'tracking_enabled' => array(
|
||||
'title' => __( 'Tracking', 'woocommerce-paypal-payments' ),
|
||||
'logging_enabled' => array(
|
||||
'title' => __( 'Logging', 'woocommerce-paypal-payments' ),
|
||||
'type' => 'checkbox',
|
||||
'desc_tip' => true,
|
||||
'label' => $container->get( 'wcgateway.settings.tracking-label' ),
|
||||
'description' => __( 'Allows to send shipment tracking numbers to PayPal for PayPal transactions.', 'woocommerce-paypal-payments' ),
|
||||
'label' => __( 'Enable logging. ', 'woocommerce-paypal-payments' ) .
|
||||
' <a href="' . admin_url( 'admin.php?page=wc-status&tab=logs' ) . '">' . __( 'View logs', 'woocommerce-paypal-payments' ) . '</a>',
|
||||
'description' => __( 'Enable logging of unexpected behavior. This can also log private data and should only be enabled in a development or stage environment.', 'woocommerce-paypal-payments' ),
|
||||
'default' => false,
|
||||
'screens' => array(
|
||||
State::STATE_START,
|
||||
State::STATE_ONBOARDED,
|
||||
),
|
||||
'requirements' => array(),
|
||||
'gateway' => 'connection',
|
||||
'input_class' => $container->get( 'wcgateway.settings.should-disable-tracking-checkbox' ) ? array( 'ppcp-disabled-checkbox' ) : array(),
|
||||
),
|
||||
);
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
|||
use WooCommerce\PayPalCommerce\ApiClient\Helper\Cache;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Helper\DccApplies;
|
||||
use WooCommerce\PayPalCommerce\Button\Helper\MessagesDisclaimers;
|
||||
use WooCommerce\PayPalCommerce\Onboarding\Environment;
|
||||
use WooCommerce\PayPalCommerce\Onboarding\Render\OnboardingOptionsRenderer;
|
||||
use WooCommerce\PayPalCommerce\Onboarding\State;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Admin\FeesRenderer;
|
||||
|
@ -2132,4 +2133,82 @@ return array(
|
|||
|
||||
return $tracking_label;
|
||||
},
|
||||
'wcgateway.enable-dcc-url-sandbox' => static function ( ContainerInterface $container ): string {
|
||||
return 'https://www.sandbox.paypal.com/bizsignup/entry/product/ppcp';
|
||||
},
|
||||
'wcgateway.enable-dcc-url-live' => static function ( ContainerInterface $container ): string {
|
||||
return 'https://www.paypal.com/bizsignup/entry/product/ppcp';
|
||||
},
|
||||
'wcgateway.enable-pui-url-sandbox' => static function ( ContainerInterface $container ): string {
|
||||
return 'https://www.sandbox.paypal.com/bizsignup/entry?country.x=DE&product=payment_methods&capabilities=PAY_UPON_INVOICE';
|
||||
},
|
||||
'wcgateway.enable-pui-url-live' => static function ( ContainerInterface $container ): string {
|
||||
return 'https://www.paypal.com/bizsignup/entry?country.x=DE&product=payment_methods&capabilities=PAY_UPON_INVOICE';
|
||||
},
|
||||
'wcgateway.settings.connection.dcc-status-text' => static function ( ContainerInterface $container ): string {
|
||||
$dcc_applies = $container->get( 'api.helpers.dccapplies' );
|
||||
assert( $dcc_applies instanceof DccApplies );
|
||||
|
||||
$environment = $container->get( 'onboarding.environment' );
|
||||
assert( $environment instanceof Environment );
|
||||
|
||||
$dcc_enabled = $dcc_applies->for_country_currency() || $dcc_applies->for_wc_payments();
|
||||
|
||||
$enabled_status_text = esc_html__( 'Status: Enabled', 'woocommerce-paypal-payments' );
|
||||
$disabled_status_text = esc_html__( 'Status: Not yet enabled', 'woocommerce-paypal-payments' );
|
||||
|
||||
$dcc_button_text = $dcc_enabled
|
||||
? esc_html__( 'Settings', 'woocommerce-paypal-payments' )
|
||||
: esc_html__( 'Enable Advanced Card Payments', 'woocommerce-paypal-payments' );
|
||||
|
||||
$enable_dcc_url = $environment->current_environment_is( Environment::PRODUCTION )
|
||||
? $container->get('wcgateway.enable-dcc-url-live')
|
||||
: $container->get('wcgateway.enable-dcc-url-sandbox');
|
||||
|
||||
$dcc_button_url = $dcc_enabled
|
||||
? admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=ppcp-gateway&ppcp-tab=ppcp-credit-card-gateway' )
|
||||
: $enable_dcc_url;
|
||||
|
||||
return sprintf(
|
||||
'<p>%1$s %2$s</p><p><a target="_blank" href="%3$s" class="button">%4$s</a></p>',
|
||||
$dcc_enabled ? $enabled_status_text : $disabled_status_text,
|
||||
$dcc_enabled ? '<span class="dashicons dashicons-yes"></span>' : '<span class="dashicons dashicons-no"></span>',
|
||||
esc_url( $dcc_button_url ),
|
||||
esc_html( $dcc_button_text )
|
||||
);
|
||||
},
|
||||
'wcgateway.settings.connection.pui-status-text' => static function ( ContainerInterface $container ): string {
|
||||
$pui_product_status = $container->get( 'wcgateway.pay-upon-invoice-product-status' );
|
||||
assert( $pui_product_status instanceof PayUponInvoiceProductStatus );
|
||||
|
||||
$environment = $container->get( 'onboarding.environment' );
|
||||
assert( $environment instanceof Environment );
|
||||
|
||||
$shop_country = $container->get( 'api.shop.country' );
|
||||
|
||||
$pui_enabled = 'DE' === $shop_country && $pui_product_status->pui_is_active();
|
||||
|
||||
$enabled_status_text = esc_html__( 'Status: Enabled', 'woocommerce-paypal-payments' );
|
||||
$disabled_status_text = esc_html__( 'Status: Not yet enabled', 'woocommerce-paypal-payments' );
|
||||
|
||||
$enable_pui_url = $environment->current_environment_is( Environment::PRODUCTION )
|
||||
? $container->get('wcgateway.enable-pui-url-live')
|
||||
: $container->get('wcgateway.enable-pui-url-sandbox');
|
||||
|
||||
$pui_button_url = $pui_enabled
|
||||
? admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=ppcp-pay-upon-invoice-gateway' )
|
||||
: $enable_pui_url;
|
||||
|
||||
$pui_button_text = $pui_enabled
|
||||
? esc_html__( 'Settings', 'woocommerce-paypal-payments' )
|
||||
: esc_html__( 'Enable Pay Upon Invoice', 'woocommerce-paypal-payments' );
|
||||
|
||||
return sprintf(
|
||||
'<p>%1$s %2$s</p><p><a target="_blank" href="%3$s" class="button">%4$s</a></p>',
|
||||
$pui_enabled ? $enabled_status_text : $disabled_status_text,
|
||||
$pui_enabled ? '<span class="dashicons dashicons-yes"></span>' : '<span class="dashicons dashicons-no"></span>',
|
||||
esc_url( $pui_button_url ),
|
||||
esc_html( $pui_button_text )
|
||||
);
|
||||
},
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue