From d6f6d05431c0d80989442054a97ac8b162d9d16c Mon Sep 17 00:00:00 2001
From: Pedro Silva
Date: Wed, 30 Aug 2023 11:28:18 +0100
Subject: [PATCH] Refactor APM admin settings
---
modules/ppcp-googlepay/extensions.php | 48 ++++++++++++++-------------
modules/ppcp-wc-gateway/services.php | 27 +++++++++++----
2 files changed, 46 insertions(+), 29 deletions(-)
diff --git a/modules/ppcp-googlepay/extensions.php b/modules/ppcp-googlepay/extensions.php
index 0f441489f..03b117ddc 100644
--- a/modules/ppcp-googlepay/extensions.php
+++ b/modules/ppcp-googlepay/extensions.php
@@ -14,29 +14,31 @@ use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
return array(
- 'wcgateway.settings.fields' => static function ( ContainerInterface $container, array $fields ): array {
- $fields['googlepay_heading'] = array(
- 'heading' => __( 'Google Pay', 'woocommerce-paypal-payments' ),
- 'description' =>
- __(
- 'Customize the behaviour of the GooglePay button.',
- 'woocommerce-paypal-payments'
- ),
- 'type' => 'ppcp-heading',
- 'screens' => array( State::STATE_ONBOARDED ),
- 'requirements' => array(),
- 'gateway' => 'paypal',
- );
- $fields['googlepay_button_enabled'] = array(
- 'title' => __( 'Google Pay Button', 'woocommerce-paypal-payments' ),
- 'type' => 'checkbox',
- 'label' => __( 'Enable Google Pay button', 'woocommerce-paypal-payments' ),
- 'default' => 'yes',
- 'screens' => array( State::STATE_ONBOARDED ),
- 'gateway' => 'paypal',
- 'requirements' => array(),
- );
- return $fields;
+ '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(
+ 'googlepay_button_enabled' => array(
+ 'title' => __( 'Google Pay Button', 'woocommerce-paypal-payments' ),
+ 'type' => 'checkbox',
+ 'label' => __( 'Enable Google Pay button', 'woocommerce-paypal-payments' ),
+ 'default' => 'yes',
+ 'screens' => array( State::STATE_ONBOARDED ),
+ 'gateway' => 'paypal',
+ 'requirements' => array(),
+ ),
+ )
+ );
},
+
);
diff --git a/modules/ppcp-wc-gateway/services.php b/modules/ppcp-wc-gateway/services.php
index 2e9c6211d..1b0e4a245 100644
--- a/modules/ppcp-wc-gateway/services.php
+++ b/modules/ppcp-wc-gateway/services.php
@@ -619,8 +619,24 @@ return array(
'requirements' => array(),
'gateway' => 'paypal',
),
+ 'alternative_payment_methods' => array(
+ 'heading' => __( 'Alternative Payment Methods', 'woocommerce-paypal-payments' ),
+ 'description' => sprintf(
+ // translators: %1$s, %2$s, %3$s and %4$s are a link tags.
+ __( '%1$sAlternative Payment Methods%2$s allow you to accept payments from customers around the globe who use their credit cards, bank accounts, wallets, and local payment methods. When a buyer pays in a currency different than yours, PayPal handles currency conversion for you and presents conversion information to the buyer during checkout.', 'woocommerce-paypal-payments' ),
+ '',
+ ''
+ ),
+ 'type' => 'ppcp-heading',
+ 'screens' => array(
+ State::STATE_START,
+ State::STATE_ONBOARDED,
+ ),
+ 'requirements' => array(),
+ 'gateway' => 'paypal',
+ ),
'disable_funding' => array(
- 'title' => __( 'Hide Funding Source(s)', 'woocommerce-paypal-payments' ),
+ 'title' => __( 'Disable Alternative Payment Methods', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-multiselect',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
@@ -628,7 +644,7 @@ return array(
'desc_tip' => false,
'description' => sprintf(
// translators: %1$s and %2$s are the opening and closing of HTML tag.
- __( 'By default, all possible funding sources will be shown. This setting can disable funding sources such as Credit Cards, Pay Later, Venmo, or other %1$sAlternative Payment Methods%2$s.', 'woocommerce-paypal-payments' ),
+ __( 'Choose to hide specific %1$sAlternative Payment Methods%2$s such as Credit Cards, Venmo, or others.', 'woocommerce-paypal-payments' ),
' 'paypal',
),
'card_billing_data_mode' => array(
- 'title' => __( 'Card billing data handling', 'woocommerce-paypal-payments' ),
+ 'title' => __( 'Send checkout billing data to card fields', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
@@ -664,10 +680,10 @@ return array(
'gateway' => array( 'paypal', CardButtonGateway::ID ),
),
'allow_card_button_gateway' => array(
- 'title' => __( 'Separate Card Button from PayPal gateway', 'woocommerce-paypal-payments' ),
+ 'title' => __( 'Create gateway for Standard Card Button', 'woocommerce-paypal-payments' ),
'type' => 'checkbox',
'desc_tip' => true,
- 'label' => __( 'Enable a separate payment gateway for the branded PayPal Debit or Credit Card button.', 'woocommerce-paypal-payments' ),
+ 'label' => __( 'Moves the Standard Card Button from the PayPal gateway into its own dedicated gateway.', 'woocommerce-paypal-payments' ),
'description' => __( 'By default, the Debit or Credit Card button is displayed in the Standard Payments payment gateway. This setting creates a second gateway for the Card button.', 'woocommerce-paypal-payments' ),
'default' => $container->get( 'wcgateway.settings.allow_card_button_gateway.default' ),
'screens' => array(
@@ -677,7 +693,6 @@ return array(
'requirements' => array(),
'gateway' => 'paypal',
),
-
'disable_cards' => array(
'title' => __( 'Disable specific credit cards', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-multiselect',