Refactor APM admin settings

This commit is contained in:
Pedro Silva 2023-08-30 11:28:18 +01:00
parent 78d58f1a03
commit d6f6d05431
No known key found for this signature in database
GPG key ID: E2EE20C0669D24B3
2 changed files with 46 additions and 29 deletions

View file

@ -14,20 +14,21 @@ use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
return array( return array(
'wcgateway.settings.fields' => static function ( ContainerInterface $container, array $fields ): array {
$fields['googlepay_heading'] = array( 'wcgateway.settings.fields' => function ( ContainerInterface $container, array $fields ): array {
'heading' => __( 'Google Pay', 'woocommerce-paypal-payments' ), $insert_after = function( array $array, string $key, array $new ): array {
'description' => $keys = array_keys( $array );
__( $index = array_search( $key, $keys, true );
'Customize the behaviour of the GooglePay button.', $pos = false === $index ? count( $array ) : $index + 1;
'woocommerce-paypal-payments'
), return array_merge( array_slice( $array, 0, $pos ), $new, array_slice( $array, $pos ) );
'type' => 'ppcp-heading', };
'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array(), return $insert_after(
'gateway' => 'paypal', $fields,
); 'allow_card_button_gateway',
$fields['googlepay_button_enabled'] = array( array(
'googlepay_button_enabled' => array(
'title' => __( 'Google Pay Button', 'woocommerce-paypal-payments' ), 'title' => __( 'Google Pay Button', 'woocommerce-paypal-payments' ),
'type' => 'checkbox', 'type' => 'checkbox',
'label' => __( 'Enable Google Pay button', 'woocommerce-paypal-payments' ), 'label' => __( 'Enable Google Pay button', 'woocommerce-paypal-payments' ),
@ -35,8 +36,9 @@ return array(
'screens' => array( State::STATE_ONBOARDED ), 'screens' => array( State::STATE_ONBOARDED ),
'gateway' => 'paypal', 'gateway' => 'paypal',
'requirements' => array(), 'requirements' => array(),
),
)
); );
return $fields;
}, },
); );

View file

@ -619,8 +619,24 @@ return array(
'requirements' => array(), 'requirements' => array(),
'gateway' => 'paypal', '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' ),
'<a href="https://woocommerce.com/document/woocommerce-paypal-payments/#alternative-payment-methods" target="_blank">',
'</a>'
),
'type' => 'ppcp-heading',
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'disable_funding' => array( 'disable_funding' => array(
'title' => __( 'Hide Funding Source(s)', 'woocommerce-paypal-payments' ), 'title' => __( 'Disable Alternative Payment Methods', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-multiselect', 'type' => 'ppcp-multiselect',
'class' => array(), 'class' => array(),
'input_class' => array( 'wc-enhanced-select' ), 'input_class' => array( 'wc-enhanced-select' ),
@ -628,7 +644,7 @@ return array(
'desc_tip' => false, 'desc_tip' => false,
'description' => sprintf( 'description' => sprintf(
// translators: %1$s and %2$s are the opening and closing of HTML <a> tag. // translators: %1$s and %2$s are the opening and closing of HTML <a> 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' ),
'<a '<a
href="https://developer.paypal.com/docs/checkout/apm/" href="https://developer.paypal.com/docs/checkout/apm/"
target="_blank" target="_blank"
@ -644,7 +660,7 @@ return array(
'gateway' => 'paypal', 'gateway' => 'paypal',
), ),
'card_billing_data_mode' => array( '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', 'type' => 'select',
'class' => array(), 'class' => array(),
'input_class' => array( 'wc-enhanced-select' ), 'input_class' => array( 'wc-enhanced-select' ),
@ -664,10 +680,10 @@ return array(
'gateway' => array( 'paypal', CardButtonGateway::ID ), 'gateway' => array( 'paypal', CardButtonGateway::ID ),
), ),
'allow_card_button_gateway' => array( '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', 'type' => 'checkbox',
'desc_tip' => true, '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' ), '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' ), 'default' => $container->get( 'wcgateway.settings.allow_card_button_gateway.default' ),
'screens' => array( 'screens' => array(
@ -677,7 +693,6 @@ return array(
'requirements' => array(), 'requirements' => array(),
'gateway' => 'paypal', 'gateway' => 'paypal',
), ),
'disable_cards' => array( 'disable_cards' => array(
'title' => __( 'Disable specific credit cards', 'woocommerce-paypal-payments' ), 'title' => __( 'Disable specific credit cards', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-multiselect', 'type' => 'ppcp-multiselect',