mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
onboarding init
This commit is contained in:
parent
772c1f52d7
commit
98d201968e
35 changed files with 7521 additions and 268 deletions
|
@ -5,5 +5,5 @@ declare(strict_types=1);
|
|||
namespace Inpsyde\PayPalCommerce\WcGateway;
|
||||
|
||||
return [
|
||||
|
||||
|
||||
];
|
||||
|
|
|
@ -5,7 +5,7 @@ declare(strict_types=1);
|
|||
namespace Inpsyde\PayPalCommerce\WcGateway;
|
||||
|
||||
use Dhii\Data\Container\ContainerInterface;
|
||||
use Inpsyde\PayPalCommerce\WcGateway\Admin\OrderDetail;
|
||||
use Inpsyde\PayPalCommerce\Onboarding\State;
|
||||
use Inpsyde\PayPalCommerce\WcGateway\Admin\OrderTablePaymentStatusColumn;
|
||||
use Inpsyde\PayPalCommerce\WcGateway\Admin\PaymentStatusOrderDetail;
|
||||
use Inpsyde\PayPalCommerce\WcGateway\Checkout\DisableGateways;
|
||||
|
@ -15,8 +15,11 @@ use Inpsyde\PayPalCommerce\WcGateway\Notice\AuthorizeOrderActionNotice;
|
|||
use Inpsyde\PayPalCommerce\WcGateway\Notice\ConnectAdminNotice;
|
||||
use Inpsyde\PayPalCommerce\WcGateway\Processor\AuthorizedPaymentsProcessor;
|
||||
use Inpsyde\PayPalCommerce\WcGateway\Processor\OrderProcessor;
|
||||
use Inpsyde\PayPalCommerce\WcGateway\Settings\FullyOnboardedSettings;
|
||||
use Inpsyde\PayPalCommerce\WcGateway\Settings\ProgressiveSettings;
|
||||
use Inpsyde\PayPalCommerce\WcGateway\Settings\Settings;
|
||||
use Inpsyde\PayPalCommerce\WcGateway\Settings\SettingsFields;
|
||||
use Inpsyde\PayPalCommerce\WcGateway\Settings\StartSettings;
|
||||
|
||||
return [
|
||||
'wcgateway.gateway.base' => static function (ContainerInterface $container): WcGatewayBase {
|
||||
|
@ -27,11 +30,13 @@ return [
|
|||
$settingsFields = $container->get('wcgateway.settings.fields');
|
||||
$authorizedPayments = $container->get('wcgateway.processor.authorized-payments');
|
||||
$notice = $container->get('wcgateway.notice.authorize-order-action');
|
||||
$onboardingRender = $container->get('onboarding.render');
|
||||
return new WcGateway(
|
||||
$settingsFields,
|
||||
$orderProcessor,
|
||||
$authorizedPayments,
|
||||
$notice
|
||||
$notice,
|
||||
$onboardingRender
|
||||
);
|
||||
},
|
||||
'wcgateway.disabler' => static function (ContainerInterface $container): DisableGateways {
|
||||
|
@ -40,19 +45,29 @@ return [
|
|||
},
|
||||
'wcgateway.settings' => static function (ContainerInterface $container): Settings {
|
||||
$gateway = $container->get('wcgateway.gateway.base');
|
||||
$settingsField = $container->get('wcgateway.settings.fields');
|
||||
return new Settings($gateway, $settingsField);
|
||||
return new Settings($gateway);
|
||||
},
|
||||
'wcgateway.notice.connect' => static function (ContainerInterface $container): ConnectAdminNotice {
|
||||
$state = $container->get('onboarding.state');
|
||||
$settings = $container->get('wcgateway.settings');
|
||||
return new ConnectAdminNotice($settings);
|
||||
return new ConnectAdminNotice($state, $settings);
|
||||
},
|
||||
'wcgateway.notice.authorize-order-action' =>
|
||||
static function (ContainerInterface $container): AuthorizeOrderActionNotice {
|
||||
return new AuthorizeOrderActionNotice();
|
||||
},
|
||||
'wcgateway.settings.fields' => static function (ContainerInterface $container): SettingsFields {
|
||||
return new SettingsFields();
|
||||
$state = $container->get('onboarding.state');
|
||||
/**
|
||||
* @var State $state
|
||||
*/
|
||||
if ($state->currentState() === State::STATE_START) {
|
||||
return new StartSettings();
|
||||
}
|
||||
if ($state->currentState() === State::STATE_PROGRESSIVE) {
|
||||
return new ProgressiveSettings();
|
||||
}
|
||||
return new FullyOnboardedSettings();
|
||||
},
|
||||
'wcgateway.order-processor' => static function (ContainerInterface $container): OrderProcessor {
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ class OrderTablePaymentStatusColumn
|
|||
|
||||
public function register(array $columns): array
|
||||
{
|
||||
if ($this->settings->get('intent') !== self::INTENT) {
|
||||
if (! $this->settings->has('intent') || $this->settings->get('intent') !== self::INTENT) {
|
||||
return $columns;
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ class OrderTablePaymentStatusColumn
|
|||
|
||||
public function render(string $column, int $wcOrderId)
|
||||
{
|
||||
if ($this->settings->get('intent') !== self::INTENT) {
|
||||
if (! $this->settings->has('intent') || $this->settings->get('intent') !== self::INTENT) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ use Inpsyde\PayPalCommerce\ApiClient\Entity\Order;
|
|||
use Inpsyde\PayPalCommerce\ApiClient\Entity\OrderStatus;
|
||||
use Inpsyde\PayPalCommerce\ApiClient\Factory\OrderFactory;
|
||||
use Inpsyde\PayPalCommerce\ApiClient\Repository\CartRepository;
|
||||
use Inpsyde\PayPalCommerce\Onboarding\Render\OnboardingRenderer;
|
||||
use Inpsyde\PayPalCommerce\Session\SessionHandler;
|
||||
use Inpsyde\PayPalCommerce\WcGateway\Notice\AuthorizeOrderActionNotice;
|
||||
use Inpsyde\PayPalCommerce\WcGateway\Processor\AuthorizedPaymentsProcessor;
|
||||
|
@ -30,18 +31,21 @@ class WcGateway extends WcGatewayBase
|
|||
private $authorizedPayments;
|
||||
private $notice;
|
||||
private $orderProcessor;
|
||||
private $onboardingRenderer;
|
||||
|
||||
public function __construct(
|
||||
SettingsFields $settingsFields,
|
||||
OrderProcessor $orderProcessor,
|
||||
AuthorizedPaymentsProcessor $authorizedPayments,
|
||||
AuthorizeOrderActionNotice $notice
|
||||
AuthorizeOrderActionNotice $notice,
|
||||
OnboardingRenderer $onboardingRenderer
|
||||
) {
|
||||
|
||||
$this->orderProcessor = $orderProcessor;
|
||||
$this->authorizedPayments = $authorizedPayments;
|
||||
$this->notice = $notice;
|
||||
$this->settingsFields = $settingsFields;
|
||||
$this->onboardingRenderer = $onboardingRenderer;
|
||||
|
||||
$this->method_title = __('PayPal Payments', 'woocommerce-paypal-gateway');
|
||||
$this->method_description = __(
|
||||
|
@ -132,4 +136,8 @@ class WcGateway extends WcGatewayBase
|
|||
$displayMessage = (isset($messageMapping[$status])) ? $messageMapping[$status] : AuthorizeOrderActionNotice::FAILED;
|
||||
$this->notice->displayMessage($displayMessage);
|
||||
}
|
||||
|
||||
public function generate_ppcp_onboarding_html($a, $b) {
|
||||
$this->onboardingRenderer->render();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,14 +5,18 @@ declare(strict_types=1);
|
|||
namespace Inpsyde\PayPalCommerce\WcGateway\Notice;
|
||||
|
||||
use Inpsyde\PayPalCommerce\AdminNotices\Entity\Message;
|
||||
use Inpsyde\PayPalCommerce\Onboarding\State;
|
||||
use Inpsyde\PayPalCommerce\WcGateway\Settings\Settings;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
class ConnectAdminNotice
|
||||
{
|
||||
private $state;
|
||||
private $settings;
|
||||
|
||||
public function __construct(Settings $settings)
|
||||
public function __construct(State $state, ContainerInterface $settings)
|
||||
{
|
||||
$this->state = $state;
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
||||
|
@ -28,7 +32,7 @@ class ConnectAdminNotice
|
|||
'%1$s is almost ready. To get started, <a href="%2$s">connect your account</a>.',
|
||||
'woocommerce-paypal-commerce-gateway'
|
||||
),
|
||||
$this->settings->get('title'),
|
||||
$this->settings->has('title') ? $this->settings->get('title') : '',
|
||||
// TODO: find a better way to get the url
|
||||
admin_url('admin.php?page=wc-settings&tab=checkout§ion=ppcp-gateway')
|
||||
);
|
||||
|
@ -38,6 +42,6 @@ class ConnectAdminNotice
|
|||
protected function shouldDisplay(): bool
|
||||
{
|
||||
// TODO: decide on what condition to display
|
||||
return !wc_string_to_bool($this->settings->get('enabled'));
|
||||
return $this->state->currentState() < State::STATE_PROGRESSIVE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,234 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Inpsyde\PayPalCommerce\WcGateway\Settings;
|
||||
|
||||
|
||||
class FullyOnboardedSettings implements SettingsFields
|
||||
{
|
||||
public function fields(): array
|
||||
{
|
||||
return array_merge(
|
||||
$this->gateway(),
|
||||
$this->account(),
|
||||
$this->buttons(),
|
||||
$this->creditCards(),
|
||||
);
|
||||
}
|
||||
|
||||
private function gateway(): array
|
||||
{
|
||||
return [
|
||||
'enabled' => [
|
||||
'title' => __('Enable/Disable', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'checkbox',
|
||||
'label' => __('Enable PayPal Payments', 'woocommerce-paypal-gateway'),
|
||||
'default' => 'yes',
|
||||
],
|
||||
'title' => [
|
||||
'title' => __('Title', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'text',
|
||||
'description' => __(
|
||||
'This controls the title which the user sees during checkout.',
|
||||
'woocommerce-paypal-gateway'
|
||||
),
|
||||
'default' => __('PayPal', 'woocommerce-paypal-gateway'),
|
||||
'desc_tip' => true,
|
||||
],
|
||||
'description' => [
|
||||
'title' => __('Description', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'text',
|
||||
'desc_tip' => true,
|
||||
'description' => __(
|
||||
'This controls the description which the user sees during checkout.',
|
||||
'woocommerce-paypal-gateway'
|
||||
),
|
||||
'default' => __(
|
||||
'Pay via PayPal; you can pay with your credit card if you don\'t have a PayPal account.',
|
||||
'woocommerce-paypal-gateway'
|
||||
),
|
||||
],
|
||||
'intent' => [
|
||||
'title' => __('Intent', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'select',
|
||||
'class' => 'wc-enhanced-select',
|
||||
'default' => 'capture',
|
||||
'desc_tip' => true,
|
||||
'description' => __(
|
||||
'The intent to either capture payment immediately or authorize a payment for an order after order creation.',
|
||||
'woocommerce-paypal-gateway'
|
||||
),
|
||||
'options' => [
|
||||
'capture' => __('Capture', 'woocommerce-paypal-gateway'),
|
||||
'authorize' => __('Authorize', 'woocommerce-paypal-gateway'),
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
private function account(): array
|
||||
{
|
||||
return [
|
||||
'account_settings' => [
|
||||
'title' => __('Account Settings', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'title',
|
||||
'description' => '',
|
||||
],
|
||||
'sandbox_on' => [
|
||||
'title' => __('Enable Sandbox', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'checkbox',
|
||||
'label' => __(
|
||||
'For testing your integration, you can enable the sandbox.',
|
||||
'woocommerce-paypal-gateway'
|
||||
),
|
||||
'default' => 'yes',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
private function buttons(): array
|
||||
{
|
||||
return [
|
||||
'button_settings' => [
|
||||
'title' => __('SmartButton Settings', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'title',
|
||||
'description' => __(
|
||||
'Customize the appearance of PayPal Payments on your site.',
|
||||
'woocommerce-paypal-gateway'
|
||||
),
|
||||
],
|
||||
'button_single_product_enabled' => [
|
||||
'title' => __('Buttons on Single Product', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'checkbox',
|
||||
'label' => __('Enable on Single Product', 'woocommerce-paypal-gateway'),
|
||||
'default' => 'yes',
|
||||
],
|
||||
'button_mini_cart_enabled' => [
|
||||
'title' => __('Buttons on Mini Cart', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'checkbox',
|
||||
'label' => __('Enable on Mini Cart', 'woocommerce-paypal-gateway'),
|
||||
'default' => 'yes',
|
||||
],
|
||||
'button_cart_enabled' => [
|
||||
'title' => __('Buttons on Cart', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'checkbox',
|
||||
'label' => __('Enable on Cart', 'woocommerce-paypal-gateway'),
|
||||
'default' => 'yes',
|
||||
],
|
||||
'button_color' => [
|
||||
'title' => __('Color', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'select',
|
||||
'class' => '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-gateway'
|
||||
),
|
||||
'options' => [
|
||||
'gold' => __('Gold (Recommended)', 'woocommerce-paypal-gateway'),
|
||||
'blue' => __('Blue', 'woocommerce-paypal-gateway'),
|
||||
'silver' => __('Silver', 'woocommerce-paypal-gateway'),
|
||||
'black' => __('Black', 'woocommerce-paypal-gateway'),
|
||||
],
|
||||
],
|
||||
'button_shape' => [
|
||||
'title' => __('Shape', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'select',
|
||||
'class' => '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-gateway'
|
||||
),
|
||||
'options' => [
|
||||
'pill' => __('Pill', 'woocommerce-paypal-gateway'),
|
||||
'rect' => __('Rectangle', 'woocommerce-paypal-gateway'),
|
||||
],
|
||||
],
|
||||
'disable_funding' => [
|
||||
'title' => __('Disable funding sources', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'multiselect',
|
||||
'class' => 'wc-enhanced-select',
|
||||
'default' => [],
|
||||
'desc_tip' => true,
|
||||
'description' => __(
|
||||
'By default all possible funding sources will be shown. You can disable some sources, if you wish.',
|
||||
'woocommerce-paypal-gateway'
|
||||
),
|
||||
'options' => [
|
||||
'card' => _x('Credit or debit cards', 'Name of payment method', 'woocommerce-paypal-gateway'),
|
||||
'credit' => _x('PayPal Credit', 'Name of payment method', 'woocommerce-paypal-gateway'),
|
||||
'venmo' => _x('Venmo', 'Name of payment method', 'woocommerce-paypal-gateway'),
|
||||
'sepa' => _x('SEPA-Lastschrift', 'Name of payment method', 'woocommerce-paypal-gateway'),
|
||||
'bancontact' => _x('Bancontact', 'Name of payment method', 'woocommerce-paypal-gateway'),
|
||||
'eps' => _x('eps', 'Name of payment method', 'woocommerce-paypal-gateway'),
|
||||
'giropay' => _x('giropay', 'Name of payment method', 'woocommerce-paypal-gateway'),
|
||||
'ideal' => _x('iDEAL', 'Name of payment method', 'woocommerce-paypal-gateway'),
|
||||
'mybank' => _x('MyBank', 'Name of payment method', 'woocommerce-paypal-gateway'),
|
||||
'p24' => _x('Przelewy24', 'Name of payment method', 'woocommerce-paypal-gateway'),
|
||||
'sofort' => _x('Sofort', 'Name of payment method', 'woocommerce-paypal-gateway'),
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
private function creditCards() : array {
|
||||
return [
|
||||
|
||||
'credit_card_settings' => [
|
||||
'title' => __('Credit Card Settings', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'title',
|
||||
'description' => __(
|
||||
'Customize the appearance of Credit Card Payments on your site.',
|
||||
'woocommerce-paypal-gateway'
|
||||
),
|
||||
],
|
||||
'dcc_cart_enabled' => [
|
||||
'title' => __('Enable credit card on cart', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'checkbox',
|
||||
'label' => __('Allow your customers to pay with credit card directly in your cart.', 'woocommerce-paypal-gateway'),
|
||||
'default' => 'yes',
|
||||
],
|
||||
'dcc_mini_cart_enabled' => [
|
||||
'title' => __('Enable credit card on mini cart', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'checkbox',
|
||||
'label' => __('Allow your customers to pay with credit card directly in your mini cart.', 'woocommerce-paypal-gateway'),
|
||||
'default' => 'yes',
|
||||
],
|
||||
'dcc_checkout_enabled' => [
|
||||
'title' => __('Enable credit card on checkout', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'checkbox',
|
||||
'label' => __('Allow your customers to pay with credit card in the checkout.', 'woocommerce-paypal-gateway'),
|
||||
'default' => 'yes',
|
||||
],
|
||||
'dcc_single_product_enabled' => [
|
||||
'title' => __('Enable credit card on products', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'checkbox',
|
||||
'label' => __('Allow your customers to pay with credit card instantly on the product page.', 'woocommerce-paypal-gateway'),
|
||||
'default' => 'yes',
|
||||
],
|
||||
'disable_cards' => [
|
||||
'title' => __('Disable specific credid cards', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'multiselect',
|
||||
'class' => 'wc-enhanced-select',
|
||||
'default' => [],
|
||||
'desc_tip' => true,
|
||||
'description' => __(
|
||||
'By default all possible credit cards will be shown. You can disable some cards, if you wish.',
|
||||
'woocommerce-paypal-gateway'
|
||||
),
|
||||
'options' => [
|
||||
'visa' => _x('Visa', 'Name of credit card', 'woocommerce-paypal-gateway'),
|
||||
'mastercard' => _x('Mastercard', 'Name of credit card', 'woocommerce-paypal-gateway'),
|
||||
'amex' => _x('American Express', 'Name of credit card', 'woocommerce-paypal-gateway'),
|
||||
'discover' => _x('Discover', 'Name of credit card', 'woocommerce-paypal-gateway'),
|
||||
'jcb' => _x('JCB', 'Name of credit card', 'woocommerce-paypal-gateway'),
|
||||
'elo' => _x('Elo', 'Name of credit card', 'woocommerce-paypal-gateway'),
|
||||
'hiper' => _x('Hiper', 'Name of credit card', 'woocommerce-paypal-gateway'),
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Inpsyde\PayPalCommerce\WcGateway\Settings;
|
||||
|
||||
|
||||
class ProgressiveSettings extends StartSettings implements SettingsFields
|
||||
{
|
||||
|
||||
public function fields(): array
|
||||
{
|
||||
$fields = parent::fields();
|
||||
$fields[] = [
|
||||
'type' => 'ppcp_onboarding',
|
||||
];
|
||||
return $fields;
|
||||
}
|
||||
}
|
|
@ -11,12 +11,10 @@ use Psr\Container\ContainerInterface;
|
|||
class Settings implements ContainerInterface
|
||||
{
|
||||
private $gateway;
|
||||
private $formFields;
|
||||
|
||||
public function __construct(WcGatewayInterface $gateway, SettingsFields $formFields)
|
||||
public function __construct(WcGatewayInterface $gateway)
|
||||
{
|
||||
$this->gateway = $gateway;
|
||||
$this->formFields = $formFields;
|
||||
}
|
||||
|
||||
// phpcs:disable Inpsyde.CodeQuality.ReturnTypeDeclaration.NoReturnType
|
||||
|
@ -31,6 +29,6 @@ class Settings implements ContainerInterface
|
|||
|
||||
public function has($id)
|
||||
{
|
||||
return array_key_exists($id, $this->formFields->fields());
|
||||
return !!$this->gateway->get_option($id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,231 +6,7 @@ namespace Inpsyde\PayPalCommerce\WcGateway\Settings;
|
|||
|
||||
//phpcs:disable Inpsyde.CodeQuality.FunctionLength.TooLong
|
||||
|
||||
class SettingsFields
|
||||
interface SettingsFields
|
||||
{
|
||||
public function fields(): array
|
||||
{
|
||||
return array_merge(
|
||||
$this->gateway(),
|
||||
$this->account(),
|
||||
$this->buttons(),
|
||||
$this->creditCards(),
|
||||
);
|
||||
}
|
||||
|
||||
private function gateway(): array
|
||||
{
|
||||
return [
|
||||
'enabled' => [
|
||||
'title' => __('Enable/Disable', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'checkbox',
|
||||
'label' => __('Enable PayPal Payments', 'woocommerce-paypal-gateway'),
|
||||
'default' => 'yes',
|
||||
],
|
||||
'title' => [
|
||||
'title' => __('Title', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'text',
|
||||
'description' => __(
|
||||
'This controls the title which the user sees during checkout.',
|
||||
'woocommerce-paypal-gateway'
|
||||
),
|
||||
'default' => __('PayPal', 'woocommerce-paypal-gateway'),
|
||||
'desc_tip' => true,
|
||||
],
|
||||
'description' => [
|
||||
'title' => __('Description', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'text',
|
||||
'desc_tip' => true,
|
||||
'description' => __(
|
||||
'This controls the description which the user sees during checkout.',
|
||||
'woocommerce-paypal-gateway'
|
||||
),
|
||||
'default' => __(
|
||||
'Pay via PayPal; you can pay with your credit card if you don\'t have a PayPal account.',
|
||||
'woocommerce-paypal-gateway'
|
||||
),
|
||||
],
|
||||
'intent' => [
|
||||
'title' => __('Intent', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'select',
|
||||
'class' => 'wc-enhanced-select',
|
||||
'default' => 'capture',
|
||||
'desc_tip' => true,
|
||||
'description' => __(
|
||||
'The intent to either capture payment immediately or authorize a payment for an order after order creation.',
|
||||
'woocommerce-paypal-gateway'
|
||||
),
|
||||
'options' => [
|
||||
'capture' => __('Capture', 'woocommerce-paypal-gateway'),
|
||||
'authorize' => __('Authorize', 'woocommerce-paypal-gateway'),
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
private function account(): array
|
||||
{
|
||||
return [
|
||||
'account_settings' => [
|
||||
'title' => __('Account Settings', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'title',
|
||||
'description' => '',
|
||||
],
|
||||
'sandbox_on' => [
|
||||
'title' => __('Enable Sandbox', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'checkbox',
|
||||
'label' => __(
|
||||
'For testing your integration, you can enable the sandbox.',
|
||||
'woocommerce-paypal-gateway'
|
||||
),
|
||||
'default' => 'yes',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
private function buttons(): array
|
||||
{
|
||||
return [
|
||||
'button_settings' => [
|
||||
'title' => __('SmartButton Settings', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'title',
|
||||
'description' => __(
|
||||
'Customize the appearance of PayPal Payments on your site.',
|
||||
'woocommerce-paypal-gateway'
|
||||
),
|
||||
],
|
||||
'button_single_product_enabled' => [
|
||||
'title' => __('Buttons on Single Product', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'checkbox',
|
||||
'label' => __('Enable on Single Product', 'woocommerce-paypal-gateway'),
|
||||
'default' => 'yes',
|
||||
],
|
||||
'button_mini_cart_enabled' => [
|
||||
'title' => __('Buttons on Mini Cart', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'checkbox',
|
||||
'label' => __('Enable on Mini Cart', 'woocommerce-paypal-gateway'),
|
||||
'default' => 'yes',
|
||||
],
|
||||
'button_cart_enabled' => [
|
||||
'title' => __('Buttons on Cart', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'checkbox',
|
||||
'label' => __('Enable on Cart', 'woocommerce-paypal-gateway'),
|
||||
'default' => 'yes',
|
||||
],
|
||||
'button_color' => [
|
||||
'title' => __('Color', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'select',
|
||||
'class' => '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-gateway'
|
||||
),
|
||||
'options' => [
|
||||
'gold' => __('Gold (Recommended)', 'woocommerce-paypal-gateway'),
|
||||
'blue' => __('Blue', 'woocommerce-paypal-gateway'),
|
||||
'silver' => __('Silver', 'woocommerce-paypal-gateway'),
|
||||
'black' => __('Black', 'woocommerce-paypal-gateway'),
|
||||
],
|
||||
],
|
||||
'button_shape' => [
|
||||
'title' => __('Shape', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'select',
|
||||
'class' => '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-gateway'
|
||||
),
|
||||
'options' => [
|
||||
'pill' => __('Pill', 'woocommerce-paypal-gateway'),
|
||||
'rect' => __('Rectangle', 'woocommerce-paypal-gateway'),
|
||||
],
|
||||
],
|
||||
'disable_funding' => [
|
||||
'title' => __('Disable funding sources', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'multiselect',
|
||||
'class' => 'wc-enhanced-select',
|
||||
'default' => [],
|
||||
'desc_tip' => true,
|
||||
'description' => __(
|
||||
'By default all possible funding sources will be shown. You can disable some sources, if you wish.',
|
||||
'woocommerce-paypal-gateway'
|
||||
),
|
||||
'options' => [
|
||||
'card' => _x('Credit or debit cards', 'Name of payment method', 'woocommerce-paypal-gateway'),
|
||||
'credit' => _x('PayPal Credit', 'Name of payment method', 'woocommerce-paypal-gateway'),
|
||||
'venmo' => _x('Venmo', 'Name of payment method', 'woocommerce-paypal-gateway'),
|
||||
'sepa' => _x('SEPA-Lastschrift', 'Name of payment method', 'woocommerce-paypal-gateway'),
|
||||
'bancontact' => _x('Bancontact', 'Name of payment method', 'woocommerce-paypal-gateway'),
|
||||
'eps' => _x('eps', 'Name of payment method', 'woocommerce-paypal-gateway'),
|
||||
'giropay' => _x('giropay', 'Name of payment method', 'woocommerce-paypal-gateway'),
|
||||
'ideal' => _x('iDEAL', 'Name of payment method', 'woocommerce-paypal-gateway'),
|
||||
'mybank' => _x('MyBank', 'Name of payment method', 'woocommerce-paypal-gateway'),
|
||||
'p24' => _x('Przelewy24', 'Name of payment method', 'woocommerce-paypal-gateway'),
|
||||
'sofort' => _x('Sofort', 'Name of payment method', 'woocommerce-paypal-gateway'),
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
private function creditCards() : array {
|
||||
return [
|
||||
|
||||
'credit_card_settings' => [
|
||||
'title' => __('Credit Card Settings', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'title',
|
||||
'description' => __(
|
||||
'Customize the appearance of Credit Card Payments on your site.',
|
||||
'woocommerce-paypal-gateway'
|
||||
),
|
||||
],
|
||||
'dcc_cart_enabled' => [
|
||||
'title' => __('Enable credit card on cart', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'checkbox',
|
||||
'label' => __('Allow your customers to pay with credit card directly in your cart.', 'woocommerce-paypal-gateway'),
|
||||
'default' => 'yes',
|
||||
],
|
||||
'dcc_mini_cart_enabled' => [
|
||||
'title' => __('Enable credit card on mini cart', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'checkbox',
|
||||
'label' => __('Allow your customers to pay with credit card directly in your mini cart.', 'woocommerce-paypal-gateway'),
|
||||
'default' => 'yes',
|
||||
],
|
||||
'dcc_checkout_enabled' => [
|
||||
'title' => __('Enable credit card on checkout', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'checkbox',
|
||||
'label' => __('Allow your customers to pay with credit card in the checkout.', 'woocommerce-paypal-gateway'),
|
||||
'default' => 'yes',
|
||||
],
|
||||
'dcc_single_product_enabled' => [
|
||||
'title' => __('Enable credit card on products', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'checkbox',
|
||||
'label' => __('Allow your customers to pay with credit card instantly on the product page.', 'woocommerce-paypal-gateway'),
|
||||
'default' => 'yes',
|
||||
],
|
||||
'disable_cards' => [
|
||||
'title' => __('Disable specific credid cards', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'multiselect',
|
||||
'class' => 'wc-enhanced-select',
|
||||
'default' => [],
|
||||
'desc_tip' => true,
|
||||
'description' => __(
|
||||
'By default all possible credit cards will be shown. You can disable some cards, if you wish.',
|
||||
'woocommerce-paypal-gateway'
|
||||
),
|
||||
'options' => [
|
||||
'visa' => _x('Visa', 'Name of credit card', 'woocommerce-paypal-gateway'),
|
||||
'mastercard' => _x('Mastercard', 'Name of credit card', 'woocommerce-paypal-gateway'),
|
||||
'amex' => _x('American Express', 'Name of credit card', 'woocommerce-paypal-gateway'),
|
||||
'discover' => _x('Discover', 'Name of credit card', 'woocommerce-paypal-gateway'),
|
||||
'jcb' => _x('JCB', 'Name of credit card', 'woocommerce-paypal-gateway'),
|
||||
'elo' => _x('Elo', 'Name of credit card', 'woocommerce-paypal-gateway'),
|
||||
'hiper' => _x('Hiper', 'Name of credit card', 'woocommerce-paypal-gateway'),
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
public function fields(): array;
|
||||
}
|
||||
|
|
24
modules.local/ppcp-wc-gateway/src/Settings/StartSettings.php
Normal file
24
modules.local/ppcp-wc-gateway/src/Settings/StartSettings.php
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Inpsyde\PayPalCommerce\WcGateway\Settings;
|
||||
|
||||
|
||||
class StartSettings implements SettingsFields
|
||||
{
|
||||
|
||||
public function fields(): array
|
||||
{
|
||||
return [
|
||||
'merchant_email' => [
|
||||
'title' => __('Email', 'woocommerce-paypal-gateway'),
|
||||
'type' => 'email',
|
||||
'description' => __(
|
||||
'Please enter the email address with which you want to receive payments.',
|
||||
'woocommerce-paypal-gateway'
|
||||
),
|
||||
'default' => '',
|
||||
'desc_tip' => true,
|
||||
],];
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue