Fix merge conflicts

This commit is contained in:
emilicastells 2023-01-17 15:03:20 +01:00
commit 9055c702e7
No known key found for this signature in database
GPG key ID: 1520C07081754570
52 changed files with 4882 additions and 1004 deletions

View file

@ -82,6 +82,8 @@ return array(
$logger,
$application_context_repository,
$subscription_helper,
$container->get( 'wcgateway.is-fraudnet-enabled' ),
$container->get( 'wcgateway.fraudnet' ),
$bn_code
);
},
@ -98,12 +100,17 @@ return array(
},
'wcgateway.settings.fields' => function ( ContainerInterface $container, array $fields ): array {
$get_connection_tab_fields = require __DIR__ . '/connection-tab-settings.php';
$path_to_settings_fields = __DIR__ . '/src/Settings/Fields';
$get_paypal_button_fields = require $path_to_settings_fields . '/paypal-smart-button-fields.php';
$paypal_button_fields = $get_paypal_button_fields( $container, $fields ) ?? array();
$get_connection_tab_fields = require $path_to_settings_fields . '/connection-tab-fields.php';
$connection_tab_fields = $get_connection_tab_fields( $container, $fields ) ?? array();
$get_pay_later_tab_fields = require __DIR__ . '/pay-later-tab-settings.php';
$get_pay_later_tab_fields = require $path_to_settings_fields . '/pay-later-tab-fields.php';
$pay_later_tab_fields = $get_pay_later_tab_fields( $container, $fields ) ?? array();
return array_merge( $connection_tab_fields, $pay_later_tab_fields );
return array_merge( $paypal_button_fields, $connection_tab_fields, $pay_later_tab_fields );
},
);

View file

@ -12,7 +12,7 @@
@media (min-width: 1200px) {
float: right;
margin-top: -400px;
margin-top: -300px;
}
@media (min-width: 1400px) {
@ -29,12 +29,6 @@
}
}
.ppcp-message-preview {
@media (min-width: 1200px) {
margin-top: -300px;
}
}
.ppcp-button-preview.pay-later {
@media (min-width: 1200px) {
margin-top: -250px;

View file

@ -45,11 +45,13 @@ import {setVisibleByClass, isVisible} from "../../../ppcp-button/resources/js/mo
if (separateCardButtonCheckbox) {
separateCardButtonCheckbox.addEventListener('change', () => {
setVisibleByClass('#field-button_layout', !separateCardButtonCheckbox.checked, 'hide');
setVisibleByClass('#field-button_general_layout', !separateCardButtonCheckbox.checked, 'hide');
});
}
[
{layoutSelector: '#ppcp-button_layout', taglineSelector: '#field-button_tagline', canHaveSeparateButtons: true},
{layoutSelector: '#ppcp-button_general_layout', taglineSelector: '#field-button_general_tagline', canHaveSeparateButtons: true},
{layoutSelector: '#ppcp-button_product_layout', taglineSelector: '#field-button_product_tagline'},
{layoutSelector: '#ppcp-button_cart_layout', taglineSelector: '#field-button_cart_tagline'},
{layoutSelector: '#ppcp-button_mini-cart_layout', taglineSelector: '#field-button_mini-cart_tagline'},
@ -262,7 +264,7 @@ import {setVisibleByClass, isVisible} from "../../../ppcp-button/resources/js/mo
loadPaypalScript(oldScriptSettings, () => {
const payLaterMessagingLocations = ['product', 'cart', 'checkout', 'general'];
const paypalButtonLocations = ['product', 'cart', 'checkout', 'mini-cart'];
const paypalButtonLocations = ['product', 'cart', 'checkout', 'mini-cart', 'general'];
paypalButtonLocations.forEach((location) => {
const inputNamePrefix = location === 'checkout' ? '#ppcp-button' : '#ppcp-button_' + location;

View file

@ -11,6 +11,7 @@ declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\WcGateway;
use WooCommerce\PayPalCommerce\Session\SessionHandler;
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
use WooCommerce\PayPalCommerce\ApiClient\Authentication\Bearer;
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\PayUponInvoiceOrderEndpoint;
@ -28,6 +29,7 @@ use WooCommerce\PayPalCommerce\WcGateway\Admin\FeesRenderer;
use WooCommerce\PayPalCommerce\WcGateway\Admin\OrderTablePaymentStatusColumn;
use WooCommerce\PayPalCommerce\WcGateway\Admin\PaymentStatusOrderDetail;
use WooCommerce\PayPalCommerce\WcGateway\Admin\RenderAuthorizeAction;
use WooCommerce\PayPalCommerce\WcGateway\Assets\FraudNetAssets;
use WooCommerce\PayPalCommerce\WcGateway\Checkout\CheckoutPayPalAddressPreset;
use WooCommerce\PayPalCommerce\WcGateway\Checkout\DisableGateways;
use WooCommerce\PayPalCommerce\WcGateway\Endpoint\ReturnUrlEndpoint;
@ -38,9 +40,9 @@ use WooCommerce\PayPalCommerce\WcGateway\Gateway\OXXO\OXXO;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\OXXO\OXXOEndpoint;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\OXXO\OXXOGateway;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayUponInvoice\FraudNet;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayUponInvoice\FraudNetSessionId;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayUponInvoice\FraudNetSourceWebsiteId;
use WooCommerce\PayPalCommerce\WcGateway\FraudNet\FraudNet;
use WooCommerce\PayPalCommerce\WcGateway\FraudNet\FraudNetSessionId;
use WooCommerce\PayPalCommerce\WcGateway\FraudNet\FraudNetSourceWebsiteId;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayUponInvoice\PaymentSourceFactory;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayUponInvoice\PayUponInvoice;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayUponInvoice\PayUponInvoiceGateway;
@ -142,7 +144,8 @@ return array(
'wcgateway.disabler' => static function ( ContainerInterface $container ): DisableGateways {
$session_handler = $container->get( 'session.handler' );
$settings = $container->get( 'wcgateway.settings' );
return new DisableGateways( $session_handler, $settings );
$settings_status = $container->get( 'wcgateway.settings.status' );
return new DisableGateways( $session_handler, $settings, $settings_status );
},
'wcgateway.is-wc-payments-page' => static function ( ContainerInterface $container ): bool {
@ -194,8 +197,8 @@ return array(
},
'wcgateway.settings' => static function ( ContainerInterface $container ): Settings {
$messaging_locations = $container->get( 'wcgateway.settings.pay-later.messaging-locations' );
return new Settings( array_keys( $messaging_locations ) );
$default_button_locations = $container->get( 'wcgateway.button.default-locations' );
return new Settings( $default_button_locations );
},
'wcgateway.notice.connect' => static function ( ContainerInterface $container ): ConnectAdminNotice {
$state = $container->get( 'onboarding.state' );
@ -432,19 +435,9 @@ return array(
$onboarding_options_renderer = $container->get( 'onboarding.render-options' );
assert( $onboarding_options_renderer instanceof OnboardingOptionsRenderer );
$render_preview_element = function ( string $id ): string {
return '
<div class="ppcp-preview ppcp-button-preview">
<h4>' . __( 'Preview', 'woocommerce-paypal-payments' ) . '</h4>
<div id="' . $id . '" class="ppcp-button-preview-inner"></div>
</div>';
};
$subscription_helper = $container->get( 'subscription.helper' );
assert( $subscription_helper instanceof SubscriptionHelper );
$has_enabled_separate_button_gateways = $container->get( 'wcgateway.settings.has_enabled_separate_button_gateways' );
$fields = array(
'checkout_settings_heading' => array(
'heading' => __( 'Standard Payments Settings', 'woocommerce-paypal-payments' ),
@ -710,627 +703,6 @@ return array(
'gateway' => 'paypal',
),
// General button styles.
'button_style_heading' => array(
'heading' => __( 'Checkout Buttons', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-heading',
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
'description' => sprintf(
// translators: %1$s and %2$s are the opening and closing of HTML <a> tag.
__( 'Customize the appearance of the PayPal smart buttons on the %1$sCheckout page%2$s.', 'woocommerce-paypal-payments' ),
'<a href="https://woocommerce.com/document/woocommerce-paypal-payments/#button-on-checkout" target="_blank">',
'</a>'
),
),
'button_enabled' => array(
'title' => __( 'Enable buttons on Checkout', 'woocommerce-paypal-payments' ),
'type' => 'checkbox',
'label' => __( 'Enable on Checkout', 'woocommerce-paypal-payments' ),
'default' => true,
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_layout' => array(
'title' => __( 'Button Layout', 'woocommerce-paypal-payments' ),
'type' => 'select',
'classes' => $has_enabled_separate_button_gateways ? array( 'hide' ) : array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'vertical',
'desc_tip' => true,
'description' => __(
'If additional funding sources are available to the buyer through PayPal, then multiple buttons are displayed in the space provided. Choose "vertical" for a dynamic list of alternative and local payment options, or "horizontal" when space is limited.',
'woocommerce-paypal-payments'
),
'options' => array(
'vertical' => __( 'Vertical', 'woocommerce-paypal-payments' ),
'horizontal' => __( 'Horizontal', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_tagline' => array(
'title' => __( 'Tagline', 'woocommerce-paypal-payments' ),
'type' => 'checkbox',
'default' => false,
'label' => __( 'Enable tagline', 'woocommerce-paypal-payments' ),
'desc_tip' => true,
'description' => __(
'Add the tagline. This line will only show up, if you select a horizontal layout.',
'woocommerce-paypal-payments'
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_label' => array(
'title' => __( 'Button Label', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
/**
* Returns default label ID of the PayPal button.
*/
'default' => apply_filters( 'woocommerce_paypal_payments_button_label_default', 'paypal' ),
'desc_tip' => true,
'description' => __(
'This controls the label on the primary button.',
'woocommerce-paypal-payments'
),
'options' => array(
'paypal' => __( 'PayPal', 'woocommerce-paypal-payments' ),
'checkout' => __( 'Checkout', 'woocommerce-paypal-payments' ),
'buynow' => __( 'PayPal Buy Now', 'woocommerce-paypal-payments' ),
'pay' => __( 'Pay with PayPal', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_color' => array(
'title' => __( 'Color', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'gold',
'desc_tip' => true,
'description' => __(
'Controls the background color of the primary button. Use "Gold" to leverage PayPal\'s recognition and preference, or change it to match your site design or aesthetic.',
'woocommerce-paypal-payments'
),
'options' => array(
'gold' => __( 'Gold (Recommended)', 'woocommerce-paypal-payments' ),
'blue' => __( 'Blue', 'woocommerce-paypal-payments' ),
'silver' => __( 'Silver', 'woocommerce-paypal-payments' ),
'black' => __( 'Black', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_shape' => array(
'title' => __( 'Shape', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'rect',
'desc_tip' => true,
'description' => __(
'The pill-shaped button\'s unique and powerful shape signifies PayPal in people\'s minds. Use the rectangular button as an alternative when pill-shaped buttons might pose design challenges.',
'woocommerce-paypal-payments'
),
'options' => array(
'pill' => __( 'Pill', 'woocommerce-paypal-payments' ),
'rect' => __( 'Rectangle', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_preview' => array(
'type' => 'ppcp-text',
'text' => $render_preview_element( 'ppcpCheckoutButtonPreview' ),
'screens' => array(
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
// Single product page.
'button_product_heading' => array(
'heading' => __( 'Single Product Page Buttons', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-heading',
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
'description' => sprintf(
// translators: %1$s and %2$s are the opening and closing of HTML <a> tag.
__( 'Customize the appearance of the PayPal smart buttons on the %1$sSingle Product Page%2$s.', 'woocommerce-paypal-payments' ),
'<a href="https://woocommerce.com/document/woocommerce-paypal-payments/#button-on-single-product" target="_blank">',
'</a>'
),
),
'button_product_enabled' => array(
'title' => __( 'Enable buttons on Single Product', 'woocommerce-paypal-payments' ),
'type' => 'checkbox',
'label' => __( 'Enable on Single Product', 'woocommerce-paypal-payments' ),
'default' => true,
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_product_layout' => array(
'title' => __( 'Button Layout', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'horizontal',
'desc_tip' => true,
'description' => __(
'If additional funding sources are available to the buyer through PayPal, such as Venmo, then multiple buttons are displayed in the space provided. Choose "vertical" for a dynamic list of alternative and local payment options, or "horizontal" when space is limited.',
'woocommerce-paypal-payments'
),
'options' => array(
'vertical' => __( 'Vertical', 'woocommerce-paypal-payments' ),
'horizontal' => __( 'Horizontal', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_product_tagline' => array(
'title' => __( 'Tagline', 'woocommerce-paypal-payments' ),
'type' => 'checkbox',
'label' => __( 'Enable tagline', 'woocommerce-paypal-payments' ),
'default' => false,
'desc_tip' => true,
'description' => __(
'Add the tagline. This line will only show up, if you select a horizontal layout.',
'woocommerce-paypal-payments'
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_product_label' => array(
'title' => __( 'Button Label', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
/**
* Returns default label ID of the PayPal button on product pages.
*/
'default' => apply_filters( 'woocommerce_paypal_payments_button_product_label_default', 'paypal' ),
'desc_tip' => true,
'description' => __(
'This controls the label on the primary button.',
'woocommerce-paypal-payments'
),
'options' => array(
'paypal' => __( 'PayPal', 'woocommerce-paypal-payments' ),
'checkout' => __( 'Checkout', 'woocommerce-paypal-payments' ),
'buynow' => __( 'PayPal Buy Now', 'woocommerce-paypal-payments' ),
'pay' => __( 'Pay with PayPal', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_product_color' => array(
'title' => __( 'Color', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'gold',
'desc_tip' => true,
'description' => __(
'Controls the background color of the primary button. Use "Gold" to leverage PayPal\'s recognition and preference, or change it to match your site design or aesthetic.',
'woocommerce-paypal-payments'
),
'options' => array(
'gold' => __( 'Gold (Recommended)', 'woocommerce-paypal-payments' ),
'blue' => __( 'Blue', 'woocommerce-paypal-payments' ),
'silver' => __( 'Silver', 'woocommerce-paypal-payments' ),
'black' => __( 'Black', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_product_shape' => array(
'title' => __( 'Shape', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'rect',
'desc_tip' => true,
'description' => __(
'The pill-shaped button\'s unique and powerful shape signifies PayPal in people\'s minds. Use the rectangular button as an alternative when pill-shaped buttons might pose design challenges.',
'woocommerce-paypal-payments'
),
'options' => array(
'pill' => __( 'Pill', 'woocommerce-paypal-payments' ),
'rect' => __( 'Rectangle', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_product_preview' => array(
'type' => 'ppcp-text',
'text' => $render_preview_element( 'ppcpProductButtonPreview' ),
'screens' => array(
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
// Cart settings.
'button_cart_heading' => array(
'heading' => __( 'Cart Buttons', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-heading',
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
'description' => sprintf(
// translators: %1$s and %2$s are the opening and closing of HTML <a> tag.
__( 'Customize the appearance of the PayPal smart buttons %1$son the Cart page%2$s.', 'woocommerce-paypal-payments' ),
'<a href="https://woocommerce.com/document/woocommerce-paypal-payments/#button-on-cart" target="_blank">',
'</a>'
),
),
'button_cart_enabled' => array(
'title' => __( 'Enable buttons on Cart', 'woocommerce-paypal-payments' ),
'type' => 'checkbox',
'label' => __( 'Enable on Cart', 'woocommerce-paypal-payments' ),
'default' => true,
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_cart_layout' => array(
'title' => __( 'Button Layout', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'horizontal',
'desc_tip' => true,
'description' => __(
'If additional funding sources are available to the buyer through PayPal, such as Venmo, then multiple buttons are displayed in the space provided. Choose "vertical" for a dynamic list of alternative and local payment options, or "horizontal" when space is limited.',
'woocommerce-paypal-payments'
),
'options' => array(
'vertical' => __( 'Vertical', 'woocommerce-paypal-payments' ),
'horizontal' => __( 'Horizontal', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_cart_tagline' => array(
'title' => __( 'Tagline', 'woocommerce-paypal-payments' ),
'type' => 'checkbox',
'label' => __( 'Enable tagline', 'woocommerce-paypal-payments' ),
'default' => false,
'desc_tip' => true,
'description' => __(
'Add the tagline. This line will only show up, if you select a horizontal layout.',
'woocommerce-paypal-payments'
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_cart_label' => array(
'title' => __( 'Button Label', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
/**
* Returns default label ID of the PayPal button in cart.
*/
'default' => apply_filters( 'woocommerce_paypal_payments_button_cart_label_default', 'paypal' ),
'desc_tip' => true,
'description' => __(
'This controls the label on the primary button.',
'woocommerce-paypal-payments'
),
'options' => array(
'paypal' => __( 'PayPal', 'woocommerce-paypal-payments' ),
'checkout' => __( 'Checkout', 'woocommerce-paypal-payments' ),
'buynow' => __( 'PayPal Buy Now', 'woocommerce-paypal-payments' ),
'pay' => __( 'Pay with PayPal', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_cart_color' => array(
'title' => __( 'Color', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'gold',
'desc_tip' => true,
'description' => __(
'Controls the background color of the primary button. Use "Gold" to leverage PayPal\'s recognition and preference, or change it to match your site design or aesthetic.',
'woocommerce-paypal-payments'
),
'options' => array(
'gold' => __( 'Gold (Recommended)', 'woocommerce-paypal-payments' ),
'blue' => __( 'Blue', 'woocommerce-paypal-payments' ),
'silver' => __( 'Silver', 'woocommerce-paypal-payments' ),
'black' => __( 'Black', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_cart_shape' => array(
'title' => __( 'Shape', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'rect',
'desc_tip' => true,
'description' => __(
'The pill-shaped button\'s unique and powerful shape signifies PayPal in people\'s minds. Use the rectangular button as an alternative when pill-shaped buttons might pose design challenges.',
'woocommerce-paypal-payments'
),
'options' => array(
'pill' => __( 'Pill', 'woocommerce-paypal-payments' ),
'rect' => __( 'Rectangle', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_cart_preview' => array(
'type' => 'ppcp-text',
'text' => $render_preview_element( 'ppcpCartButtonPreview' ),
'screens' => array(
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
// Mini cart settings.
'button_mini-cart_heading' => array(
'heading' => __( 'Mini Cart Buttons', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-heading',
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
'description' => sprintf(
// translators: %1$s and %2$s are the opening and closing of HTML <a> tag.
__( 'Customize the appearance of the PayPal smart buttons %1$son the Mini Cart page%2$s.', 'woocommerce-paypal-payments' ),
'<a href="https://woocommerce.com/document/woocommerce-paypal-payments/#button-on-mini-cart" target="_blank">',
'</a>'
),
),
'button_mini-cart_enabled' => array(
'title' => __( 'Enable buttons on Mini Cart', 'woocommerce-paypal-payments' ),
'type' => 'checkbox',
'label' => __( 'Enable on Mini Cart', 'woocommerce-paypal-payments' ),
'default' => false,
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_mini-cart_layout' => array(
'title' => __( 'Button Layout', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'vertical',
'desc_tip' => true,
'description' => __(
'If additional funding sources are available to the buyer through PayPal, such as Venmo, then multiple buttons are displayed in the space provided. Choose "vertical" for a dynamic list of alternative and local payment options, or "horizontal" when space is limited.',
'woocommerce-paypal-payments'
),
'options' => array(
'vertical' => __( 'Vertical', 'woocommerce-paypal-payments' ),
'horizontal' => __( 'Horizontal', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_mini-cart_tagline' => array(
'title' => __( 'Tagline', 'woocommerce-paypal-payments' ),
'type' => 'checkbox',
'label' => __( 'Enable tagline', 'woocommerce-paypal-payments' ),
'default' => false,
'desc_tip' => true,
'description' => __(
'Add the tagline. This line will only show up, if you select a horizontal layout.',
'woocommerce-paypal-payments'
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_mini-cart_label' => array(
'title' => __( 'Button Label', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
/**
* Returns default label ID of the PayPal button in mini cart.
*/
'default' => apply_filters( 'woocommerce_paypal_payments_button_mini_cart_label_default', 'paypal' ),
'desc_tip' => true,
'description' => __(
'This controls the label on the primary button.',
'woocommerce-paypal-payments'
),
'options' => array(
'paypal' => __( 'PayPal', 'woocommerce-paypal-payments' ),
'checkout' => __( 'Checkout', 'woocommerce-paypal-payments' ),
'buynow' => __( 'PayPal Buy Now', 'woocommerce-paypal-payments' ),
'pay' => __( 'Pay with PayPal', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_mini-cart_color' => array(
'title' => __( 'Color', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'gold',
'desc_tip' => true,
'description' => __(
'Controls the background color of the primary button. Use "Gold" to leverage PayPal\'s recognition and preference, or change it to match your site design or aesthetic.',
'woocommerce-paypal-payments'
),
'options' => array(
'gold' => __( 'Gold (Recommended)', 'woocommerce-paypal-payments' ),
'blue' => __( 'Blue', 'woocommerce-paypal-payments' ),
'silver' => __( 'Silver', 'woocommerce-paypal-payments' ),
'black' => __( 'Black', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_mini-cart_shape' => array(
'title' => __( 'Shape', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'rect',
'desc_tip' => true,
'description' => __(
'The pill-shaped button\'s unique and powerful shape signifies PayPal in people\'s minds. Use the rectangular button as an alternative when pill-shaped buttons might pose design challenges.',
'woocommerce-paypal-payments'
),
'options' => array(
'pill' => __( 'Pill', 'woocommerce-paypal-payments' ),
'rect' => __( 'Rectangle', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_mini-cart_height' => array(
'title' => __( 'Button Height', 'woocommerce-paypal-payments' ),
'type' => 'number',
'default' => '35',
'custom_attributes' => array(
'min' => 25,
'max' => 55,
),
'desc_tip' => true,
'description' => __( 'Add a value from 25 to 55.', 'woocommerce-paypal-payments' ),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_mini-cart_preview' => array(
'type' => 'ppcp-text',
'text' => $render_preview_element( 'ppcpMiniCartButtonPreview' ),
'screens' => array(
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'disable_cards' => array(
'title' => __( 'Disable specific credit cards', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-multiselect',
@ -1571,7 +943,7 @@ return array(
$container->get( 'api.host' ),
$container->get( 'api.bearer' ),
$container->get( 'api.factory.order' ),
$container->get( 'wcgateway.pay-upon-invoice-fraudnet' ),
$container->get( 'wcgateway.fraudnet' ),
$container->get( 'woocommerce.logger.woocommerce' )
);
},
@ -1592,15 +964,15 @@ return array(
$container->get( 'wcgateway.processor.refunds' )
);
},
'wcgateway.pay-upon-invoice-fraudnet-session-id' => static function ( ContainerInterface $container ): FraudNetSessionId {
'wcgateway.fraudnet-session-id' => static function ( ContainerInterface $container ): FraudNetSessionId {
return new FraudNetSessionId();
},
'wcgateway.pay-upon-invoice-fraudnet-source-website-id' => static function ( ContainerInterface $container ): FraudNetSourceWebsiteId {
'wcgateway.fraudnet-source-website-id' => static function ( ContainerInterface $container ): FraudNetSourceWebsiteId {
return new FraudNetSourceWebsiteId( $container->get( 'api.merchant_id' ) );
},
'wcgateway.pay-upon-invoice-fraudnet' => static function ( ContainerInterface $container ): FraudNet {
$session_id = $container->get( 'wcgateway.pay-upon-invoice-fraudnet-session-id' );
$source_website_id = $container->get( 'wcgateway.pay-upon-invoice-fraudnet-source-website-id' );
'wcgateway.fraudnet' => static function ( ContainerInterface $container ): FraudNet {
$session_id = $container->get( 'wcgateway.fraudnet-session-id' );
$source_website_id = $container->get( 'wcgateway.fraudnet-source-website-id' );
return new FraudNet(
(string) $session_id(),
(string) $source_website_id()
@ -1621,21 +993,15 @@ return array(
},
'wcgateway.pay-upon-invoice' => static function ( ContainerInterface $container ): PayUponInvoice {
return new PayUponInvoice(
$container->get( 'wcgateway.url' ),
$container->get( 'wcgateway.pay-upon-invoice-fraudnet' ),
$container->get( 'wcgateway.pay-upon-invoice-order-endpoint' ),
$container->get( 'woocommerce.logger.woocommerce' ),
$container->get( 'wcgateway.settings' ),
$container->get( 'onboarding.environment' ),
$container->get( 'ppcp.asset-version' ),
$container->get( 'onboarding.state' ),
$container->get( 'wcgateway.is-ppcp-settings-page' ),
$container->get( 'wcgateway.current-ppcp-settings-page-id' ),
$container->get( 'wcgateway.pay-upon-invoice-product-status' ),
$container->get( 'wcgateway.pay-upon-invoice-helper' ),
$container->get( 'wcgateway.checkout-helper' ),
$container->get( 'api.factory.capture' ),
$container->get( 'session.handler' )
$container->get( 'api.factory.capture' )
);
},
'wcgateway.oxxo' => static function( ContainerInterface $container ): OXXO {
@ -1893,40 +1259,118 @@ return array(
'dcc.status-cache' => static function( ContainerInterface $container ): Cache {
return new Cache( 'ppcp-paypal-dcc-status-cache' );
},
'wcgateway.settings.pay-later.messaging-locations' => static function( ContainerInterface $container ): array {
'wcgateway.button.locations' => static function( ContainerInterface $container ): array {
return array(
'product' => 'Single Product',
'cart' => 'Cart',
'checkout' => 'Checkout',
'product' => 'Single Product',
'cart' => 'Cart',
'checkout' => 'Checkout',
'mini-cart' => 'Mini Cart',
);
},
'wcgateway.settings.pay-later.messaging-locations' => static function( ContainerInterface $container ): array {
$button_locations = $container->get( 'wcgateway.button.locations' );
unset( $button_locations['mini-cart'] );
return $button_locations;
},
'wcgateway.button.default-locations' => static function( ContainerInterface $container ): array {
return array_keys( $container->get( 'wcgateway.settings.pay-later.messaging-locations' ) );
},
'wcgateway.settings.pay-later.button-locations' => static function( ContainerInterface $container ): array {
$button_locations = array();
$settings = $container->get( 'wcgateway.settings' );
assert( $settings instanceof Settings );
$is_product_buttons_enabled = $settings->has( 'button_product_enabled' ) && $settings->get( 'button_product_enabled' );
$is_mini_cart_buttons_enabled = $settings->has( 'button_mini-cart_enabled' ) && $settings->get( 'button_mini-cart_enabled' );
$is_cart_buttons_enabled = $settings->has( 'button_cart_enabled' ) && $settings->get( 'button_cart_enabled' );
$is_checkout_buttons_enabled = $settings->has( 'button_enabled' ) && $settings->get( 'button_enabled' );
$button_locations = $container->get( 'wcgateway.button.locations' );
unset( $button_locations['mini-cart'] );
if ( $is_product_buttons_enabled ) {
$button_locations['product'] = 'Single Product';
$smart_button_selected_locations = $settings->has( 'smart_button_locations' ) ? $settings->get( 'smart_button_locations' ) : array();
$pay_later_button_locations = array();
if ( empty( $smart_button_selected_locations ) ) {
return $pay_later_button_locations;
}
if ( $is_mini_cart_buttons_enabled ) {
$button_locations['mini-cart'] = 'Mini Cart';
foreach ( $button_locations as $location_key => $location ) {
if ( ! in_array( $location_key, $smart_button_selected_locations, true ) ) {
continue;
}
$pay_later_button_locations[ $location_key ] = $location;
}
if ( $is_cart_buttons_enabled ) {
$button_locations['cart'] = 'Cart';
return $pay_later_button_locations;
},
'wcgateway.ppcp-gateways' => static function ( ContainerInterface $container ): array {
return array(
PayPalGateway::ID,
CreditCardGateway::ID,
PayUponInvoiceGateway::ID,
CardButtonGateway::ID,
OXXOGateway::ID,
);
},
'wcgateway.enabled-ppcp-gateways' => static function ( ContainerInterface $container ): array {
$available_gateways = WC()->payment_gateways->get_available_payment_gateways();
$ppcp_gateways = $container->get( 'wcgateway.ppcp-gateways' );
$enabled_ppcp_gateways = array();
foreach ( $ppcp_gateways as $gateway ) {
if ( ! isset( $available_gateways[ $gateway ] ) ) {
continue;
}
$enabled_ppcp_gateways[] = $gateway;
}
if ( $is_checkout_buttons_enabled ) {
$button_locations['checkout'] = 'Checkout';
}
return $enabled_ppcp_gateways;
},
'wcgateway.is-paypal-continuation' => static function ( ContainerInterface $container ): bool {
$session_handler = $container->get( 'session.handler' );
assert( $session_handler instanceof SessionHandler );
return $button_locations;
$order = $session_handler->order();
if ( ! $order ) {
return false;
}
$source = $order->payment_source();
if ( $source && $source->card() ) {
return false; // Ignore for DCC.
}
if ( 'card' === $session_handler->funding_source() ) {
return false; // Ignore for card buttons.
}
return true;
},
'wcgateway.current-context' => static function ( ContainerInterface $container ): string {
$context = 'mini-cart';
if ( is_product() || wc_post_content_has_shortcode( 'product_page' ) ) {
$context = 'product';
}
if ( is_cart() ) {
$context = 'cart';
}
if ( is_checkout() && ! $container->get( 'wcgateway.is-paypal-continuation' ) ) {
$context = 'checkout';
}
if ( is_checkout_pay_page() ) {
$context = 'pay-now';
}
return $context;
},
'wcgateway.is-fraudnet-enabled' => static function ( ContainerInterface $container ): bool {
$settings = $container->get( 'wcgateway.settings' );
assert( $settings instanceof Settings );
return $settings->has( 'fraudnet_enabled' ) && $settings->get( 'fraudnet_enabled' );
},
'wcgateway.fraudnet-assets' => function( ContainerInterface $container ) : FraudNetAssets {
return new FraudNetAssets(
$container->get( 'wcgateway.url' ),
$container->get( 'ppcp.asset-version' ),
$container->get( 'wcgateway.fraudnet' ),
$container->get( 'onboarding.environment' ),
$container->get( 'wcgateway.settings' ),
$container->get( 'wcgateway.enabled-ppcp-gateways' ),
$container->get( 'wcgateway.current-context' ),
$container->get( 'wcgateway.is-fraudnet-enabled' )
);
},
);

View file

@ -0,0 +1,186 @@
<?php
/**
* Register and configure FraudNet assets
*
* @package WooCommerce\PayPalCommerce\WcGateway\Assets
*/
declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\WcGateway\Assets;
use WooCommerce\PayPalCommerce\Onboarding\Environment;
use WooCommerce\PayPalCommerce\WcGateway\FraudNet\FraudNet;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayUponInvoice\PayUponInvoiceGateway;
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
/**
* Class FraudNetAssets
*/
class FraudNetAssets {
/**
* The URL of this module.
*
* @var string
*/
protected $module_url;
/**
* The assets version.
*
* @var string
*/
protected $version;
/**
* The FraudNet entity.
*
* @var FraudNet
*/
protected $fraud_net;
/**
* The environment.
*
* @var Environment
*/
protected $environment;
/**
* The Settings.
*
* @var Settings
*/
protected $settings;
/**
* The list of enabled PayPal gateways.
*
* @var string[]
*/
protected $enabled_ppcp_gateways;
/**
* The current context.
*
* @var string
*/
protected $context;
/**
* True if FraudNet support is enabled in settings, otherwise false.
*
* @var bool
*/
protected $is_fraudnet_enabled;
/**
* Assets constructor.
*
* @param string $module_url The url of this module.
* @param string $version The assets version.
* @param FraudNet $fraud_net The FraudNet entity.
* @param Environment $environment The environment.
* @param Settings $settings The Settings.
* @param string[] $enabled_ppcp_gateways The list of enabled PayPal gateways.
* @param string $context The current context.
* @param bool $is_fraudnet_enabled true if FraudNet support is enabled in settings, otherwise false.
*/
public function __construct(
string $module_url,
string $version,
FraudNet $fraud_net,
Environment $environment,
Settings $settings,
array $enabled_ppcp_gateways,
string $context,
bool $is_fraudnet_enabled
) {
$this->module_url = $module_url;
$this->version = $version;
$this->fraud_net = $fraud_net;
$this->environment = $environment;
$this->settings = $settings;
$this->enabled_ppcp_gateways = $enabled_ppcp_gateways;
$this->context = $context;
$this->is_fraudnet_enabled = $is_fraudnet_enabled;
}
/**
* Registers FraudNet assets.
*/
public function register_assets(): void {
add_action(
'wp_enqueue_scripts',
function() {
if ( $this->should_load_fraudnet_script() ) {
wp_enqueue_script(
'ppcp-fraudnet',
trailingslashit( $this->module_url ) . 'assets/js/fraudnet.js',
array(),
$this->version,
true
);
wp_localize_script(
'ppcp-fraudnet',
'FraudNetConfig',
array(
'f' => $this->fraud_net->session_id(),
's' => $this->fraud_net->source_website_id(),
'sandbox' => $this->environment->current_environment_is( Environment::SANDBOX ),
)
);
}
}
);
}
/**
* Checks if FraudNet script should be loaded.
*
* @return bool true if FraudNet script should be loaded, otherwise false.
*/
protected function should_load_fraudnet_script(): bool {
if ( empty( $this->enabled_ppcp_gateways ) ) {
return false;
}
$is_pui_gateway_enabled = in_array( PayUponInvoiceGateway::ID, $this->enabled_ppcp_gateways, true );
$is_only_standard_gateway_enabled = $this->enabled_ppcp_gateways === array( PayPalGateway::ID );
if ( $this->context !== 'checkout' || $is_only_standard_gateway_enabled ) {
return $this->is_fraudnet_enabled && $this->are_buttons_enabled_for_context();
}
return $is_pui_gateway_enabled ? true : $this->is_fraudnet_enabled;
}
/**
* Checks if buttons are enabled for current context.
*
* @return bool true if enabled, otherwise false.
*/
protected function are_buttons_enabled_for_context() : bool {
if ( ! in_array( PayPalGateway::ID, $this->enabled_ppcp_gateways, true ) ) {
return false;
}
$location_prefix = $this->context === 'checkout' ? '' : "{$this->context}_";
$setting_name = "button_{$location_prefix}enabled";
$buttons_enabled_for_context = $this->settings->has( $setting_name ) && $this->settings->get( $setting_name );
if ( $this->context === 'product' ) {
return $buttons_enabled_for_context || $this->settings->has( 'mini-cart' ) && $this->settings->get( 'mini-cart' );
}
if ( $this->context === 'pay-now' ) {
return true;
}
return $buttons_enabled_for_context;
}
}

View file

@ -14,6 +14,7 @@ use WooCommerce\PayPalCommerce\WcGateway\Gateway\CardButtonGateway;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\CreditCardGateway;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
use WooCommerce\PayPalCommerce\WcGateway\Helper\SettingsStatus;
/**
* Class DisableGateways
@ -34,19 +35,29 @@ class DisableGateways {
*/
private $settings;
/**
* The Settings status helper.
*
* @var SettingsStatus
*/
protected $settings_status;
/**
* DisableGateways constructor.
*
* @param SessionHandler $session_handler The Session Handler.
* @param ContainerInterface $settings The Settings.
* @param SettingsStatus $settings_status The Settings status helper.
*/
public function __construct(
SessionHandler $session_handler,
ContainerInterface $settings
ContainerInterface $settings,
SettingsStatus $settings_status
) {
$this->session_handler = $session_handler;
$this->settings = $settings;
$this->settings_status = $settings_status;
}
/**
@ -71,7 +82,7 @@ class DisableGateways {
unset( $methods[ CreditCardGateway::ID ] );
}
if ( $this->settings->has( 'button_enabled' ) && ! $this->settings->get( 'button_enabled' ) && ! $this->session_handler->order() && is_checkout() ) {
if ( ! $this->settings_status->is_smart_button_enabled_for_location( 'checkout' ) && ! $this->session_handler->order() && is_checkout() ) {
unset( $methods[ PayPalGateway::ID ] );
}

View file

@ -7,7 +7,7 @@
declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\WcGateway\Gateway\PayUponInvoice;
namespace WooCommerce\PayPalCommerce\WcGateway\FraudNet;
/**
* Class FraudNet

View file

@ -7,7 +7,7 @@
declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\WcGateway\Gateway\PayUponInvoice;
namespace WooCommerce\PayPalCommerce\WcGateway\FraudNet;
use Exception;

View file

@ -7,7 +7,7 @@
declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\WcGateway\Gateway\PayUponInvoice;
namespace WooCommerce\PayPalCommerce\WcGateway\FraudNet;
/**
* Class FraudNetSourceWebsiteId.

View file

@ -270,7 +270,7 @@ class PayPalGateway extends \WC_Payment_Gateway {
'type' => 'checkbox',
'desc_tip' => true,
'description' => __( 'In order to use PayPal or Advanced Card Processing, you need to enable the Gateway.', 'woocommerce-paypal-payments' ),
'label' => __( 'Enable the PayPal Gateway', 'woocommerce-paypal-payments' ),
'label' => __( 'Enable PayPal features for your store', 'woocommerce-paypal-payments' ),
'default' => 'no',
),
'ppcp' => array(

View file

@ -17,6 +17,7 @@ use WooCommerce\PayPalCommerce\ApiClient\Factory\CaptureFactory;
use WooCommerce\PayPalCommerce\Button\Exception\RuntimeException;
use WooCommerce\PayPalCommerce\Onboarding\Environment;
use WooCommerce\PayPalCommerce\Session\SessionHandler;
use WooCommerce\PayPalCommerce\WcGateway\FraudNet\FraudNet;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
use WooCommerce\PayPalCommerce\WcGateway\Helper\CheckoutHelper;
use WooCommerce\PayPalCommerce\WcGateway\Helper\PayUponInvoiceHelper;
@ -34,20 +35,6 @@ class PayUponInvoice {
use TransactionIdHandlingTrait;
/**
* The module URL.
*
* @var string
*/
protected $module_url;
/**
* The FraudNet entity.
*
* @var FraudNet
*/
protected $fraud_net;
/**
* The pui order endpoint.
*
@ -69,20 +56,6 @@ class PayUponInvoice {
*/
protected $settings;
/**
* The environment.
*
* @var Environment
*/
protected $environment;
/**
* The asset version.
*
* @var string
*/
protected $asset_version;
/**
* The PUI helper.
*
@ -97,13 +70,6 @@ class PayUponInvoice {
*/
protected $state;
/**
* Whether the current page is the PPCP settings page.
*
* @var bool
*/
protected $is_ppcp_settings_page;
/**
* Current PayPal settings page id.
*
@ -132,64 +98,39 @@ class PayUponInvoice {
*/
protected $capture_factory;
/**
* The session handler
*
* @var SessionHandler
*/
protected $session_handler;
/**
* PayUponInvoice constructor.
*
* @param string $module_url The module URL.
* @param FraudNet $fraud_net The FraudNet entity.
* @param PayUponInvoiceOrderEndpoint $pui_order_endpoint The PUI order endpoint.
* @param LoggerInterface $logger The logger.
* @param Settings $settings The settings.
* @param Environment $environment The environment.
* @param string $asset_version The asset version.
* @param State $state The onboarding state.
* @param bool $is_ppcp_settings_page Whether page is PayPal settings poge.
* @param string $current_ppcp_settings_page_id Current PayPal settings page id.
* @param PayUponInvoiceProductStatus $pui_product_status The PUI product status.
* @param PayUponInvoiceHelper $pui_helper The PUI helper.
* @param CheckoutHelper $checkout_helper The checkout helper.
* @param CaptureFactory $capture_factory The capture factory.
* @param SessionHandler $session_handler The session handler.
*/
public function __construct(
string $module_url,
FraudNet $fraud_net,
PayUponInvoiceOrderEndpoint $pui_order_endpoint,
LoggerInterface $logger,
Settings $settings,
Environment $environment,
string $asset_version,
State $state,
bool $is_ppcp_settings_page,
string $current_ppcp_settings_page_id,
PayUponInvoiceProductStatus $pui_product_status,
PayUponInvoiceHelper $pui_helper,
CheckoutHelper $checkout_helper,
CaptureFactory $capture_factory,
SessionHandler $session_handler
CaptureFactory $capture_factory
) {
$this->module_url = $module_url;
$this->fraud_net = $fraud_net;
$this->pui_order_endpoint = $pui_order_endpoint;
$this->logger = $logger;
$this->settings = $settings;
$this->environment = $environment;
$this->asset_version = $asset_version;
$this->state = $state;
$this->is_ppcp_settings_page = $is_ppcp_settings_page;
$this->current_ppcp_settings_page_id = $current_ppcp_settings_page_id;
$this->pui_product_status = $pui_product_status;
$this->pui_helper = $pui_helper;
$this->checkout_helper = $checkout_helper;
$this->capture_factory = $capture_factory;
$this->session_handler = $session_handler;
}
/**
@ -236,11 +177,6 @@ class PayUponInvoice {
}
);
add_action(
'wp_enqueue_scripts',
array( $this, 'register_assets' )
);
add_action(
'ppcp_payment_capture_completed_webhook_handler',
function ( WC_Order $wc_order, string $order_id ) {
@ -610,31 +546,4 @@ class PayUponInvoice {
}
);
}
/**
* Registers PUI assets.
*/
public function register_assets(): void {
$gateway_settings = get_option( 'woocommerce_ppcp-pay-upon-invoice-gateway_settings' );
$gateway_enabled = $gateway_settings['enabled'] ?? '';
if ( $gateway_enabled === 'yes' && ! $this->session_handler->order() && ( is_checkout() || is_checkout_pay_page() ) ) {
wp_enqueue_script(
'ppcp-pay-upon-invoice',
trailingslashit( $this->module_url ) . 'assets/js/pay-upon-invoice.js',
array(),
$this->asset_version,
true
);
wp_localize_script(
'ppcp-pay-upon-invoice',
'FraudNetConfig',
array(
'f' => $this->fraud_net->session_id(),
's' => $this->fraud_net->source_website_id(),
'sandbox' => $this->environment->current_environment_is( Environment::SANDBOX ),
)
);
}
}
}

View file

@ -125,4 +125,20 @@ class SettingsStatus {
return $context === 'product' ? $enabled_for_product || $enabled_for_mini_cart : $enabled_for_current_location;
}
/**
* Checks whether smart buttons are enabled for a given location.
*
* @param string $location The location.
* @return bool true if is enabled, otherwise false.
*/
public function is_smart_button_enabled_for_location( string $location ): bool {
$selected_locations = $this->settings->has( 'smart_button_locations' ) ? $this->settings->get( 'smart_button_locations' ) : array();
if ( empty( $selected_locations ) ) {
return false;
}
return in_array( $location, $selected_locations, true );
}
}

View file

@ -10,9 +10,11 @@ declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\WcGateway\Processor;
use Psr\Log\LoggerInterface;
use WC_Order;
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\OrderEndpoint;
use WooCommerce\PayPalCommerce\ApiClient\Entity\Order;
use WooCommerce\PayPalCommerce\ApiClient\Entity\OrderStatus;
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
use WooCommerce\PayPalCommerce\ApiClient\Factory\OrderFactory;
use WooCommerce\PayPalCommerce\ApiClient\Helper\OrderHelper;
use WooCommerce\PayPalCommerce\Button\Helper\ThreeDSecure;
@ -160,12 +162,27 @@ class OrderProcessor {
*
* @return bool
*/
public function process( \WC_Order $wc_order ): bool {
$order_id = $wc_order->get_meta( PayPalGateway::ORDER_ID_META_KEY );
$order = $this->session_handler->order() ?? $this->order_endpoint->order( $order_id );
public function process( WC_Order $wc_order ): bool {
$order = $this->session_handler->order();
if ( ! $order ) {
$this->last_error = __( 'No PayPal order found in the current WooCommerce session.', 'woocommerce-paypal-payments' );
return false;
$order_id = $wc_order->get_meta( PayPalGateway::ORDER_ID_META_KEY );
if ( ! $order_id ) {
$this->logger->warning(
sprintf(
'No PayPal order ID found in order #%d meta.',
$wc_order->get_id()
)
);
$this->last_error = __( 'Could not retrieve order. This browser may not be supported. Please try again with a different browser.', 'woocommerce-paypal-payments' );
return false;
}
try {
$order = $this->order_endpoint->order( $order_id );
} catch ( RuntimeException $exception ) {
$this->last_error = __( 'Could not retrieve PayPal order.', 'woocommerce-paypal-payments' );
return false;
}
}
$this->add_paypal_meta( $wc_order, $order, $this->environment );

View file

@ -9,14 +9,13 @@
declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\WcGateway;
namespace WooCommerce\PayPalCommerce\WcGateway\Settings;
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
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 {
@ -395,6 +394,24 @@ return function ( ContainerInterface $container, array $fields ): array {
'gateway' => Settings::CONNECTION_TAB_ID,
'input_class' => $container->get( 'wcgateway.settings.should-disable-tracking-checkbox' ) ? array( 'ppcp-disabled-checkbox' ) : array(),
),
'fraudnet_enabled' => array(
'title' => __( 'FraudNet', 'woocommerce-paypal-payments' ),
'type' => 'checkbox',
'desc_tip' => true,
'label' => sprintf(
// translators: %1$s and %2$s are the opening and closing of HTML <a> tag.
__( 'Manage online risk with %1$sFraudNet%2$s.', 'woocommerce-paypal-payments' ),
'<a href="https://woocommerce.com/document/woocommerce-paypal-payments/#FraudNet" target="_blank">',
'</a>'
),
'description' => __( 'FraudNet is a JavaScript library developed by PayPal and embedded into a merchants web page to collect browser-based data to help reduce fraud.', 'woocommerce-paypal-payments' ),
'default' => false,
'screens' => array(
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => Settings::CONNECTION_TAB_ID,
),
'credentials_integration_configuration_heading' => array(
'heading' => __( 'General integration configuration', 'woocommerce-paypal-payments' ),

View file

@ -9,11 +9,10 @@
declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\WcGateway;
namespace WooCommerce\PayPalCommerce\WcGateway\Settings;
use WooCommerce\PayPalCommerce\Onboarding\State;
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
return function ( ContainerInterface $container, array $fields ): array {
@ -32,8 +31,6 @@ return function ( ContainerInterface $container, array $fields ): array {
? __( "You have PayPal vaulting enabled, that's why Pay Later options are unavailable now. You cannot use both features at the same time.", 'woocommerce-paypal-payments' )
: __( 'Enabled', 'woocommerce-paypal-payments' );
$default_locations = array_keys( $container->get( 'wcgateway.settings.pay-later.messaging-locations' ) );
$selected_country = $container->get( 'api.shop.country' );
$default_messaging_flex_color = $selected_country === 'US' ? 'white-no-border' : 'white';
@ -75,7 +72,7 @@ return function ( ContainerInterface $container, array $fields ): array {
'type' => 'ppcp-multiselect',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => $default_locations,
'default' => $container->get( 'wcgateway.button.default-locations' ),
'desc_tip' => false,
'description' => __( 'Select where the Pay Later button should be displayed.', 'woocommerce-paypal-payments' ),
'options' => $container->get( 'wcgateway.settings.pay-later.button-locations' ),
@ -121,7 +118,7 @@ return function ( ContainerInterface $container, array $fields ): array {
'type' => 'ppcp-multiselect',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => $default_locations,
'default' => $container->get( 'wcgateway.button.default-locations' ),
'desc_tip' => false,
'description' => __( 'Select where the Pay Later messaging should be displayed.', 'woocommerce-paypal-payments' ),
'options' => $container->get( 'wcgateway.settings.pay-later.messaging-locations' ),

View file

@ -0,0 +1,787 @@
<?php
/**
* The services of the Gateway module.
*
* @package WooCommerce\PayPalCommerce\WcGateway
*/
// phpcs:disable WordPress.Security.NonceVerification.Recommended
declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\WcGateway\Settings;
use WooCommerce\PayPalCommerce\Onboarding\State;
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
return function ( ContainerInterface $container, array $fields ): array {
$current_page_id = $container->get( 'wcgateway.current-ppcp-settings-page-id' );
if ( $current_page_id !== PayPalGateway::ID ) {
return $fields;
}
$settings = $container->get( 'wcgateway.settings' );
assert( $settings instanceof Settings );
$has_enabled_separate_button_gateways = $container->get( 'wcgateway.settings.has_enabled_separate_button_gateways' );
$render_preview_element = function ( string $id ): string {
return '
<div class="ppcp-preview ppcp-button-preview">
<h4>' . __( 'Preview', 'woocommerce-paypal-payments' ) . '</h4>
<div id="' . $id . '" class="ppcp-button-preview-inner"></div>
</div>';
};
$smart_button_fields = array(
'button_style_heading' => array(
'heading' => __( 'PayPal Smart Buttons', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-heading',
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
'description' => sprintf(
// translators: %1$s and %2$s are the opening and closing of HTML <a> tag.
__(
'Customize the appearance of the PayPal smart buttons on the
%1$sCheckout page%5$s, %2$sSingle Product Page%5$s, %3$sCart page%5$s or on %4$sMini Cart%5$s.',
'woocommerce-paypal-payments'
),
'<a href="https://woocommerce.com/document/woocommerce-paypal-payments/#button-on-checkout" target="_blank">',
'<a href="https://woocommerce.com/document/woocommerce-paypal-payments/#button-on-single-product" target="_blank">',
'<a href="https://woocommerce.com/document/woocommerce-paypal-payments/#button-on-cart" target="_blank">',
'<a href="https://woocommerce.com/document/woocommerce-paypal-payments/#button-on-mini-cart" target="_blank">',
'</a>'
),
),
'smart_button_locations' => array(
'title' => __( 'Smart Button Locations', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-multiselect',
'input_class' => array( 'wc-enhanced-select' ),
'default' => $container->get( 'wcgateway.button.default-locations' ),
'description' => __( 'Select where the PayPal smart buttons should be displayed.', 'woocommerce-paypal-payments' ),
'options' => $container->get( 'wcgateway.button.locations' ),
'screens' => array( State::STATE_START, State::STATE_ONBOARDED ),
'requirements' => array(),
'gateway' => 'paypal',
),
'smart_button_enable_styling_per_location' => array(
'title' => __( 'Customize Smart Buttons Per Location', 'woocommerce-paypal-payments' ),
'type' => 'checkbox',
'label' => __( 'Customize smart button style per location', 'woocommerce-paypal-payments' ),
'default' => true,
'screens' => array( State::STATE_START, State::STATE_ONBOARDED ),
'requirements' => array(),
'gateway' => 'paypal',
),
// General button styles.
'button_general_layout' => array(
'title' => __( 'Button Layout', 'woocommerce-paypal-payments' ),
'type' => 'select',
'classes' => $has_enabled_separate_button_gateways ? array( 'hide' ) : array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'vertical',
'desc_tip' => true,
'description' => __(
'If additional funding sources are available to the buyer through PayPal, then multiple buttons are displayed in the space provided. Choose "vertical" for a dynamic list of alternative and local payment options, or "horizontal" when space is limited.',
'woocommerce-paypal-payments'
),
'options' => array(
'vertical' => __( 'Vertical', 'woocommerce-paypal-payments' ),
'horizontal' => __( 'Horizontal', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_general_tagline' => array(
'title' => __( 'Tagline', 'woocommerce-paypal-payments' ),
'type' => 'checkbox',
'default' => false,
'label' => __( 'Enable tagline', 'woocommerce-paypal-payments' ),
'desc_tip' => true,
'description' => __(
'Add the tagline. This line will only show up, if you select a horizontal layout.',
'woocommerce-paypal-payments'
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_general_label' => array(
'title' => __( 'Button Label', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
/**
* Returns default label ID of the PayPal button.
*/
'default' => apply_filters( 'woocommerce_paypal_payments_button_label_default', 'paypal' ),
'desc_tip' => true,
'description' => __(
'This controls the label on the primary button.',
'woocommerce-paypal-payments'
),
'options' => array(
'paypal' => __( 'PayPal', 'woocommerce-paypal-payments' ),
'checkout' => __( 'Checkout', 'woocommerce-paypal-payments' ),
'buynow' => __( 'PayPal Buy Now', 'woocommerce-paypal-payments' ),
'pay' => __( 'Pay with PayPal', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_general_color' => array(
'title' => __( 'Color', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'gold',
'desc_tip' => true,
'description' => __(
'Controls the background color of the primary button. Use "Gold" to leverage PayPal\'s recognition and preference, or change it to match your site design or aesthetic.',
'woocommerce-paypal-payments'
),
'options' => array(
'gold' => __( 'Gold (Recommended)', 'woocommerce-paypal-payments' ),
'blue' => __( 'Blue', 'woocommerce-paypal-payments' ),
'silver' => __( 'Silver', 'woocommerce-paypal-payments' ),
'black' => __( 'Black', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_general_shape' => array(
'title' => __( 'Shape', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'rect',
'desc_tip' => true,
'description' => __(
'The pill-shaped button\'s unique and powerful shape signifies PayPal in people\'s minds. Use the rectangular button as an alternative when pill-shaped buttons might pose design challenges.',
'woocommerce-paypal-payments'
),
'options' => array(
'pill' => __( 'Pill', 'woocommerce-paypal-payments' ),
'rect' => __( 'Rectangle', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_general_preview' => array(
'type' => 'ppcp-text',
'text' => $render_preview_element( 'ppcpGeneralButtonPreview' ),
'screens' => array(
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
// Checkout page.
'button_checkout_heading' => array(
'heading' => __( 'Checkout Buttons', 'woocommerce-paypal-payments' ),
'description' => sprintf(
// translators: %1$s and %2$s are the opening and closing of HTML <a> tag.
__(
'Customize the appearance of the PayPal smart buttons on the %1$sCheckout page%2$s.
%3$sCheckout Buttons must be enabled to display the PayPal gateway on the Checkout page.
',
'woocommerce-paypal-payments'
),
'<a href="https://woocommerce.com/document/woocommerce-paypal-payments/#button-on-checkout" target="_blank">',
'</a>',
'</ br>'
),
'type' => 'ppcp-heading',
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_layout' => array(
'title' => __( 'Button Layout', 'woocommerce-paypal-payments' ),
'type' => 'select',
'classes' => $has_enabled_separate_button_gateways ? array( 'hide' ) : array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'vertical',
'desc_tip' => true,
'description' => __(
'If additional funding sources are available to the buyer through PayPal, then multiple buttons are displayed in the space provided. Choose "vertical" for a dynamic list of alternative and local payment options, or "horizontal" when space is limited.',
'woocommerce-paypal-payments'
),
'options' => array(
'vertical' => __( 'Vertical', 'woocommerce-paypal-payments' ),
'horizontal' => __( 'Horizontal', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_tagline' => array(
'title' => __( 'Tagline', 'woocommerce-paypal-payments' ),
'type' => 'checkbox',
'default' => false,
'label' => __( 'Enable tagline', 'woocommerce-paypal-payments' ),
'desc_tip' => true,
'description' => __(
'Add the tagline. This line will only show up, if you select a horizontal layout.',
'woocommerce-paypal-payments'
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_label' => array(
'title' => __( 'Button Label', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
/**
* Returns default label ID of the PayPal button.
*/
'default' => apply_filters( 'woocommerce_paypal_payments_button_label_default', 'paypal' ),
'desc_tip' => true,
'description' => __(
'This controls the label on the primary button.',
'woocommerce-paypal-payments'
),
'options' => array(
'paypal' => __( 'PayPal', 'woocommerce-paypal-payments' ),
'checkout' => __( 'Checkout', 'woocommerce-paypal-payments' ),
'buynow' => __( 'PayPal Buy Now', 'woocommerce-paypal-payments' ),
'pay' => __( 'Pay with PayPal', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_color' => array(
'title' => __( 'Color', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'gold',
'desc_tip' => true,
'description' => __(
'Controls the background color of the primary button. Use "Gold" to leverage PayPal\'s recognition and preference, or change it to match your site design or aesthetic.',
'woocommerce-paypal-payments'
),
'options' => array(
'gold' => __( 'Gold (Recommended)', 'woocommerce-paypal-payments' ),
'blue' => __( 'Blue', 'woocommerce-paypal-payments' ),
'silver' => __( 'Silver', 'woocommerce-paypal-payments' ),
'black' => __( 'Black', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_shape' => array(
'title' => __( 'Shape', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'rect',
'desc_tip' => true,
'description' => __(
'The pill-shaped button\'s unique and powerful shape signifies PayPal in people\'s minds. Use the rectangular button as an alternative when pill-shaped buttons might pose design challenges.',
'woocommerce-paypal-payments'
),
'options' => array(
'pill' => __( 'Pill', 'woocommerce-paypal-payments' ),
'rect' => __( 'Rectangle', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_preview' => array(
'type' => 'ppcp-text',
'text' => $render_preview_element( 'ppcpCheckoutButtonPreview' ),
'screens' => array(
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
// Single product page.
'button_product_heading' => array(
'heading' => __( 'Single Product Page Buttons', 'woocommerce-paypal-payments' ),
'description' => sprintf(
// translators: %1$s and %2$s are the opening and closing of HTML <a> tag.
__(
'Customize the appearance of the PayPal smart buttons on the %1$sSingle Product Page%2$s.',
'woocommerce-paypal-payments'
),
'<a href="https://woocommerce.com/document/woocommerce-paypal-payments/#button-on-single-product" target="_blank">',
'</a>'
),
'type' => 'ppcp-heading',
'screens' => array( State::STATE_START, State::STATE_ONBOARDED ),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_product_layout' => array(
'title' => __( 'Button Layout', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'horizontal',
'desc_tip' => true,
'description' => __(
'If additional funding sources are available to the buyer through PayPal, such as Venmo, then multiple buttons are displayed in the space provided. Choose "vertical" for a dynamic list of alternative and local payment options, or "horizontal" when space is limited.',
'woocommerce-paypal-payments'
),
'options' => array(
'vertical' => __( 'Vertical', 'woocommerce-paypal-payments' ),
'horizontal' => __( 'Horizontal', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_product_tagline' => array(
'title' => __( 'Tagline', 'woocommerce-paypal-payments' ),
'type' => 'checkbox',
'label' => __( 'Enable tagline', 'woocommerce-paypal-payments' ),
'default' => false,
'desc_tip' => true,
'description' => __(
'Add the tagline. This line will only show up, if you select a horizontal layout.',
'woocommerce-paypal-payments'
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_product_label' => array(
'title' => __( 'Button Label', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
/**
* Returns default label ID of the PayPal button on product pages.
*/
'default' => apply_filters( 'woocommerce_paypal_payments_button_product_label_default', 'paypal' ),
'desc_tip' => true,
'description' => __(
'This controls the label on the primary button.',
'woocommerce-paypal-payments'
),
'options' => array(
'paypal' => __( 'PayPal', 'woocommerce-paypal-payments' ),
'checkout' => __( 'Checkout', 'woocommerce-paypal-payments' ),
'buynow' => __( 'PayPal Buy Now', 'woocommerce-paypal-payments' ),
'pay' => __( 'Pay with PayPal', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_product_color' => array(
'title' => __( 'Color', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'gold',
'desc_tip' => true,
'description' => __(
'Controls the background color of the primary button. Use "Gold" to leverage PayPal\'s recognition and preference, or change it to match your site design or aesthetic.',
'woocommerce-paypal-payments'
),
'options' => array(
'gold' => __( 'Gold (Recommended)', 'woocommerce-paypal-payments' ),
'blue' => __( 'Blue', 'woocommerce-paypal-payments' ),
'silver' => __( 'Silver', 'woocommerce-paypal-payments' ),
'black' => __( 'Black', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_product_shape' => array(
'title' => __( 'Shape', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'rect',
'desc_tip' => true,
'description' => __(
'The pill-shaped button\'s unique and powerful shape signifies PayPal in people\'s minds. Use the rectangular button as an alternative when pill-shaped buttons might pose design challenges.',
'woocommerce-paypal-payments'
),
'options' => array(
'pill' => __( 'Pill', 'woocommerce-paypal-payments' ),
'rect' => __( 'Rectangle', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_product_preview' => array(
'type' => 'ppcp-text',
'text' => $render_preview_element( 'ppcpProductButtonPreview' ),
'screens' => array(
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
// Cart settings.
'button_cart_heading' => array(
'heading' => __( 'Cart Buttons', 'woocommerce-paypal-payments' ),
'description' => sprintf(
// translators: %1$s and %2$s are the opening and closing of HTML <a> tag.
__(
'Customize the appearance of the PayPal smart buttons on the %1$sCart page%2$s.',
'woocommerce-paypal-payments'
),
'<a href="https://woocommerce.com/document/woocommerce-paypal-payments/#button-on-cart" target="_blank">',
'</a>'
),
'type' => 'ppcp-heading',
'screens' => array( State::STATE_START, State::STATE_ONBOARDED ),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_cart_layout' => array(
'title' => __( 'Button Layout', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'horizontal',
'desc_tip' => true,
'description' => __(
'If additional funding sources are available to the buyer through PayPal, such as Venmo, then multiple buttons are displayed in the space provided. Choose "vertical" for a dynamic list of alternative and local payment options, or "horizontal" when space is limited.',
'woocommerce-paypal-payments'
),
'options' => array(
'vertical' => __( 'Vertical', 'woocommerce-paypal-payments' ),
'horizontal' => __( 'Horizontal', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_cart_tagline' => array(
'title' => __( 'Tagline', 'woocommerce-paypal-payments' ),
'type' => 'checkbox',
'label' => __( 'Enable tagline', 'woocommerce-paypal-payments' ),
'default' => false,
'desc_tip' => true,
'description' => __(
'Add the tagline. This line will only show up, if you select a horizontal layout.',
'woocommerce-paypal-payments'
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_cart_label' => array(
'title' => __( 'Button Label', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
/**
* Returns default label ID of the PayPal button in cart.
*/
'default' => apply_filters( 'woocommerce_paypal_payments_button_cart_label_default', 'paypal' ),
'desc_tip' => true,
'description' => __(
'This controls the label on the primary button.',
'woocommerce-paypal-payments'
),
'options' => array(
'paypal' => __( 'PayPal', 'woocommerce-paypal-payments' ),
'checkout' => __( 'Checkout', 'woocommerce-paypal-payments' ),
'buynow' => __( 'PayPal Buy Now', 'woocommerce-paypal-payments' ),
'pay' => __( 'Pay with PayPal', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_cart_color' => array(
'title' => __( 'Color', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'gold',
'desc_tip' => true,
'description' => __(
'Controls the background color of the primary button. Use "Gold" to leverage PayPal\'s recognition and preference, or change it to match your site design or aesthetic.',
'woocommerce-paypal-payments'
),
'options' => array(
'gold' => __( 'Gold (Recommended)', 'woocommerce-paypal-payments' ),
'blue' => __( 'Blue', 'woocommerce-paypal-payments' ),
'silver' => __( 'Silver', 'woocommerce-paypal-payments' ),
'black' => __( 'Black', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_cart_shape' => array(
'title' => __( 'Shape', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'rect',
'desc_tip' => true,
'description' => __(
'The pill-shaped button\'s unique and powerful shape signifies PayPal in people\'s minds. Use the rectangular button as an alternative when pill-shaped buttons might pose design challenges.',
'woocommerce-paypal-payments'
),
'options' => array(
'pill' => __( 'Pill', 'woocommerce-paypal-payments' ),
'rect' => __( 'Rectangle', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_cart_preview' => array(
'type' => 'ppcp-text',
'text' => $render_preview_element( 'ppcpCartButtonPreview' ),
'screens' => array(
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
// Mini cart settings.
'button_mini-cart_heading' => array(
'heading' => __( 'Mini Cart Buttons', 'woocommerce-paypal-payments' ),
'description' => sprintf(
// translators: %1$s and %2$s are the opening and closing of HTML <a> tag.
__(
'Customize the appearance of the PayPal smart buttons on the %1$sMini Cart%2$s.',
'woocommerce-paypal-payments'
),
'<a href="https://woocommerce.com/document/woocommerce-paypal-payments/#button-on-mini-cart" target="_blank">',
'</a>'
),
'type' => 'ppcp-heading',
'screens' => array( State::STATE_START, State::STATE_ONBOARDED ),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_mini-cart_layout' => array(
'title' => __( 'Button Layout', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'vertical',
'desc_tip' => true,
'description' => __(
'If additional funding sources are available to the buyer through PayPal, such as Venmo, then multiple buttons are displayed in the space provided. Choose "vertical" for a dynamic list of alternative and local payment options, or "horizontal" when space is limited.',
'woocommerce-paypal-payments'
),
'options' => array(
'vertical' => __( 'Vertical', 'woocommerce-paypal-payments' ),
'horizontal' => __( 'Horizontal', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_mini-cart_tagline' => array(
'title' => __( 'Tagline', 'woocommerce-paypal-payments' ),
'type' => 'checkbox',
'label' => __( 'Enable tagline', 'woocommerce-paypal-payments' ),
'default' => false,
'desc_tip' => true,
'description' => __(
'Add the tagline. This line will only show up, if you select a horizontal layout.',
'woocommerce-paypal-payments'
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_mini-cart_label' => array(
'title' => __( 'Button Label', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
/**
* Returns default label ID of the PayPal button in mini cart.
*/
'default' => apply_filters( 'woocommerce_paypal_payments_button_mini_cart_label_default', 'paypal' ),
'desc_tip' => true,
'description' => __(
'This controls the label on the primary button.',
'woocommerce-paypal-payments'
),
'options' => array(
'paypal' => __( 'PayPal', 'woocommerce-paypal-payments' ),
'checkout' => __( 'Checkout', 'woocommerce-paypal-payments' ),
'buynow' => __( 'PayPal Buy Now', 'woocommerce-paypal-payments' ),
'pay' => __( 'Pay with PayPal', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_mini-cart_color' => array(
'title' => __( 'Color', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'gold',
'desc_tip' => true,
'description' => __(
'Controls the background color of the primary button. Use "Gold" to leverage PayPal\'s recognition and preference, or change it to match your site design or aesthetic.',
'woocommerce-paypal-payments'
),
'options' => array(
'gold' => __( 'Gold (Recommended)', 'woocommerce-paypal-payments' ),
'blue' => __( 'Blue', 'woocommerce-paypal-payments' ),
'silver' => __( 'Silver', 'woocommerce-paypal-payments' ),
'black' => __( 'Black', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_mini-cart_shape' => array(
'title' => __( 'Shape', 'woocommerce-paypal-payments' ),
'type' => 'select',
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'rect',
'desc_tip' => true,
'description' => __(
'The pill-shaped button\'s unique and powerful shape signifies PayPal in people\'s minds. Use the rectangular button as an alternative when pill-shaped buttons might pose design challenges.',
'woocommerce-paypal-payments'
),
'options' => array(
'pill' => __( 'Pill', 'woocommerce-paypal-payments' ),
'rect' => __( 'Rectangle', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_mini-cart_height' => array(
'title' => __( 'Button Height', 'woocommerce-paypal-payments' ),
'type' => 'number',
'default' => '35',
'custom_attributes' => array(
'min' => 25,
'max' => 55,
),
'desc_tip' => true,
'description' => __( 'Add a value from 25 to 55.', 'woocommerce-paypal-payments' ),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'button_mini-cart_preview' => array(
'type' => 'ppcp-text',
'text' => $render_preview_element( 'ppcpMiniCartButtonPreview' ),
'screens' => array(
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
);
return array_merge( $fields, $smart_button_fields );
};

View file

@ -29,19 +29,19 @@ class Settings implements ContainerInterface {
private $settings = array();
/**
* The list of pay later selected default locations.
* The list of selected default button locations.
*
* @var string[]
*/
protected $pay_later_default_locations;
protected $default_button_locations;
/**
* Settings constructor.
*
* @param string[] $pay_later_default_locations The list of pay later selected default locations.
* @param string[] $default_button_locations The list of selected default button locations.
*/
public function __construct( array $pay_later_default_locations ) {
$this->pay_later_default_locations = $pay_later_default_locations;
public function __construct( array $default_button_locations ) {
$this->default_button_locations = $default_button_locations;
}
/**
@ -104,22 +104,20 @@ class Settings implements ContainerInterface {
$this->settings = get_option( self::KEY, array() );
$defaults = array(
'title' => __( 'PayPal', 'woocommerce-paypal-payments' ),
'description' => __(
'title' => __( 'PayPal', 'woocommerce-paypal-payments' ),
'description' => __(
'Pay via PayPal.',
'woocommerce-paypal-payments'
),
'button_product_enabled' => true,
'button_mini-cart_enabled' => false,
'button_cart_enabled' => true,
'pay_later_messaging_enabled' => true,
'button_enabled' => true,
'pay_later_button_enabled' => true,
'pay_later_button_locations' => $this->pay_later_default_locations,
'pay_later_messaging_locations' => $this->pay_later_default_locations,
'brand_name' => get_bloginfo( 'name' ),
'dcc_gateway_title' => __( 'Credit Cards', 'woocommerce-paypal-payments' ),
'dcc_gateway_description' => __(
'smart_button_locations' => $this->default_button_locations,
'smart_button_enable_styling_per_location' => true,
'pay_later_messaging_enabled' => true,
'pay_later_button_enabled' => true,
'pay_later_button_locations' => $this->default_button_locations,
'pay_later_messaging_locations' => $this->default_button_locations,
'brand_name' => get_bloginfo( 'name' ),
'dcc_gateway_title' => __( 'Credit Cards', 'woocommerce-paypal-payments' ),
'dcc_gateway_description' => __(
'Pay with your credit card.',
'woocommerce-paypal-payments'
),

View file

@ -21,6 +21,7 @@ use WooCommerce\PayPalCommerce\WcGateway\Admin\FeesRenderer;
use WooCommerce\PayPalCommerce\WcGateway\Admin\OrderTablePaymentStatusColumn;
use WooCommerce\PayPalCommerce\WcGateway\Admin\PaymentStatusOrderDetail;
use WooCommerce\PayPalCommerce\WcGateway\Admin\RenderAuthorizeAction;
use WooCommerce\PayPalCommerce\WcGateway\Assets\FraudNetAssets;
use WooCommerce\PayPalCommerce\WcGateway\Assets\SettingsPageAssets;
use WooCommerce\PayPalCommerce\WcGateway\Checkout\CheckoutPayPalAddressPreset;
use WooCommerce\PayPalCommerce\WcGateway\Checkout\DisableGateways;
@ -258,6 +259,10 @@ class WCGatewayModule implements ModuleInterface {
}
( $c->get( 'wcgateway.oxxo' ) )->init();
$fraudnet_assets = $c->get( 'wcgateway.fraudnet-assets' );
assert( $fraudnet_assets instanceof FraudNetAssets );
$fraudnet_assets->register_assets();
}
);

View file

@ -7,7 +7,7 @@ module.exports = {
target: 'web',
entry: {
'gateway-settings': path.resolve('./resources/js/gateway-settings.js'),
'pay-upon-invoice': path.resolve('./resources/js/pay-upon-invoice.js'),
'fraudnet': path.resolve('./resources/js/fraudnet.js'),
'oxxo': path.resolve('./resources/js/oxxo.js'),
'gateway-settings-style': path.resolve('./resources/css/gateway-settings.scss'),
},