diff --git a/resources/js/settings.js b/resources/js/settings.js index 0cd19c22..54eb4515 100644 --- a/resources/js/settings.js +++ b/resources/js/settings.js @@ -4,17 +4,6 @@ const {current_section = false} = mollieSettingsData jQuery(function($) { - $('#mollie-payments-for-woocommerce_test_mode_enabled').change(function() { - if ($(this).is(':checked')) - { - $('#mollie-payments-for-woocommerce_test_api_key').attr('required', true).closest('tr').show(); - } - else - { - $('#mollie-payments-for-woocommerce_test_api_key').removeAttr('required').closest('tr').hide(); - } - }).change(); - if(_.isEmpty(mollieSettingsData)){ return } diff --git a/src/Assets/AssetsModule.php b/src/Assets/AssetsModule.php index 9cb2e361..40277df4 100644 --- a/src/Assets/AssetsModule.php +++ b/src/Assets/AssetsModule.php @@ -490,7 +490,7 @@ public function enqueueAdvancedSettingsJS($ar) if ( $current_screen->id !== 'woocommerce_page_wc-settings' || $current_tab !== 'mollie_settings' - || $current_section !== 'advanced' + || $current_section !== 'mollie_advanced' ) { return; } diff --git a/src/Buttons/ApplePayButton/ApplePayDataObjectHttp.php b/src/Buttons/ApplePayButton/ApplePayDataObjectHttp.php index db7f6919..38f91294 100644 --- a/src/Buttons/ApplePayButton/ApplePayDataObjectHttp.php +++ b/src/Buttons/ApplePayButton/ApplePayDataObjectHttp.php @@ -326,7 +326,7 @@ protected function addressHasRequiredFieldsValues( sprintf('ApplePay Data Error: Missing value for %s', $requiredField) ); $this->errors[] - = [ + = [ 'errorCode' => $errorCode, 'contactField' => $errorValue, ]; diff --git a/src/PaymentMethods/Alma.php b/src/PaymentMethods/Alma.php index 57ac08fa..d127a986 100644 --- a/src/PaymentMethods/Alma.php +++ b/src/PaymentMethods/Alma.php @@ -26,6 +26,7 @@ protected function getConfig(): array 'billingAddress', 'shippingAddress', ], + 'docs' => 'https://www.mollie.com/gb/payments/alma', ]; } diff --git a/src/PaymentMethods/Applepay.php b/src/PaymentMethods/Applepay.php index 63a32c9a..b1ae1f9e 100644 --- a/src/PaymentMethods/Applepay.php +++ b/src/PaymentMethods/Applepay.php @@ -24,6 +24,7 @@ protected function getConfig(): array 'confirmationDelayed' => false, 'SEPA' => false, 'Subscription' => true, + 'docs' => 'https://www.mollie.com/gb/payments/apple-pay', ]; } diff --git a/src/PaymentMethods/Bancomatpay.php b/src/PaymentMethods/Bancomatpay.php index 054ef951..7f9600fa 100644 --- a/src/PaymentMethods/Bancomatpay.php +++ b/src/PaymentMethods/Bancomatpay.php @@ -21,6 +21,7 @@ public function getConfig(): array ], 'filtersOnBuild' => false, 'confirmationDelayed' => false, + 'docs' => 'https://www.mollie.com/gb/payments/bancomat-pay', ]; } diff --git a/src/PaymentMethods/Bancontact.php b/src/PaymentMethods/Bancontact.php index 9d01c9d9..14ac3832 100644 --- a/src/PaymentMethods/Bancontact.php +++ b/src/PaymentMethods/Bancontact.php @@ -22,6 +22,7 @@ protected function getConfig(): array 'filtersOnBuild' => false, 'confirmationDelayed' => true, 'SEPA' => true, + 'docs' => 'https://www.mollie.com/gb/payments/bancontact', ]; } diff --git a/src/PaymentMethods/Banktransfer.php b/src/PaymentMethods/Banktransfer.php index 93a6f3f1..6abc7586 100644 --- a/src/PaymentMethods/Banktransfer.php +++ b/src/PaymentMethods/Banktransfer.php @@ -42,6 +42,7 @@ protected function getConfig(): array 'confirmationDelayed' => true, 'SEPA' => false, 'customRedirect' => true, + 'docs' => 'https://www.mollie.com/gb/payments/bank-transfer', ]; } diff --git a/src/PaymentMethods/Belfius.php b/src/PaymentMethods/Belfius.php index ea98768f..c8876451 100644 --- a/src/PaymentMethods/Belfius.php +++ b/src/PaymentMethods/Belfius.php @@ -22,6 +22,7 @@ protected function getConfig(): array 'filtersOnBuild' => false, 'confirmationDelayed' => true, 'SEPA' => true, + 'docs' => 'https://www.mollie.com/gb/payments/belfius', ]; } diff --git a/src/PaymentMethods/Billie.php b/src/PaymentMethods/Billie.php index 369f4952..0269b9da 100644 --- a/src/PaymentMethods/Billie.php +++ b/src/PaymentMethods/Billie.php @@ -31,6 +31,7 @@ protected function getConfig(): array 'mollie-payments-for-woocommerce' ), 'companyPlaceholder' => __('Please enter your company name here.', 'mollie-payments-for-woocommerce'), + 'docs' => 'https://www.mollie.com/gb/payments/billie', ]; } diff --git a/src/PaymentMethods/Blik.php b/src/PaymentMethods/Blik.php index 83e05ef2..c0590dcd 100644 --- a/src/PaymentMethods/Blik.php +++ b/src/PaymentMethods/Blik.php @@ -22,6 +22,7 @@ protected function getConfig(): array 'filtersOnBuild' => false, 'confirmationDelayed' => false, 'SEPA' => false, + 'docs' => 'https://www.mollie.com/gb/payments/blik', ]; } diff --git a/src/PaymentMethods/Creditcard.php b/src/PaymentMethods/Creditcard.php index 237ad4ce..85e26b43 100644 --- a/src/PaymentMethods/Creditcard.php +++ b/src/PaymentMethods/Creditcard.php @@ -27,6 +27,7 @@ protected function getConfig(): array 'confirmationDelayed' => false, 'SEPA' => false, 'Subscription' => true, + 'docs' => 'https://www.mollie.com/gb/payments/credit-card', ]; } diff --git a/src/PaymentMethods/Directdebit.php b/src/PaymentMethods/Directdebit.php index 5b4b91d3..0b7bf94f 100644 --- a/src/PaymentMethods/Directdebit.php +++ b/src/PaymentMethods/Directdebit.php @@ -22,6 +22,7 @@ protected function getConfig(): array 'filtersOnBuild' => false, 'confirmationDelayed' => true, 'SEPA' => false, + 'docs' => 'https://www.mollie.com/gb/payments/direct-debit', ]; } diff --git a/src/PaymentMethods/Eps.php b/src/PaymentMethods/Eps.php index 15bd8eb5..327a53ac 100644 --- a/src/PaymentMethods/Eps.php +++ b/src/PaymentMethods/Eps.php @@ -22,6 +22,7 @@ protected function getConfig(): array 'filtersOnBuild' => false, 'confirmationDelayed' => true, 'SEPA' => true, + 'docs' => 'https://www.mollie.com/gb/payments/eps', ]; } diff --git a/src/PaymentMethods/Giftcard.php b/src/PaymentMethods/Giftcard.php index 812e3cd7..b5154541 100644 --- a/src/PaymentMethods/Giftcard.php +++ b/src/PaymentMethods/Giftcard.php @@ -70,6 +70,7 @@ protected function getConfig(): array 'filtersOnBuild' => false, 'confirmationDelayed' => false, 'SEPA' => false, + 'docs' => 'https://www.mollie.com/gb/payments/gift-cards', ]; } diff --git a/src/PaymentMethods/Giropay.php b/src/PaymentMethods/Giropay.php index 440b8f0b..8939ce56 100644 --- a/src/PaymentMethods/Giropay.php +++ b/src/PaymentMethods/Giropay.php @@ -22,6 +22,7 @@ protected function getConfig(): array 'filtersOnBuild' => false, 'confirmationDelayed' => true, 'SEPA' => true, + 'docs' => 'https://help.mollie.com/hc/en-gb/articles/19745480480786-Giropay-Depreciation-FAQ', ]; } diff --git a/src/PaymentMethods/Ideal.php b/src/PaymentMethods/Ideal.php index c7638b05..d4464b36 100644 --- a/src/PaymentMethods/Ideal.php +++ b/src/PaymentMethods/Ideal.php @@ -24,6 +24,7 @@ public function getConfig(): array 'filtersOnBuild' => false, 'confirmationDelayed' => true, 'SEPA' => true, + 'docs' => 'https://www.mollie.com/gb/payments/ideal-2-0', ]; } diff --git a/src/PaymentMethods/In3.php b/src/PaymentMethods/In3.php index d86beb12..f839c6e7 100644 --- a/src/PaymentMethods/In3.php +++ b/src/PaymentMethods/In3.php @@ -29,6 +29,7 @@ public function getConfig(): array ), 'phonePlaceholder' => __('Please enter your phone here. +316xxxxxxxx', 'mollie-payments-for-woocommerce'), 'birthdatePlaceholder' => __('Please enter your birthdate here.', 'mollie-payments-for-woocommerce'), + 'docs' => 'https://www.mollie.com/gb/payments/ideal-in3', ]; } diff --git a/src/PaymentMethods/Kbc.php b/src/PaymentMethods/Kbc.php index 4005b83f..99de76e9 100644 --- a/src/PaymentMethods/Kbc.php +++ b/src/PaymentMethods/Kbc.php @@ -23,6 +23,7 @@ protected function getConfig(): array 'filtersOnBuild' => false, 'confirmationDelayed' => true, 'SEPA' => true, + 'docs' => 'https://www.mollie.com/gb/payments/kbc-cbc', ]; } diff --git a/src/PaymentMethods/Klarna.php b/src/PaymentMethods/Klarna.php index bdad1b51..0c0b3ccc 100644 --- a/src/PaymentMethods/Klarna.php +++ b/src/PaymentMethods/Klarna.php @@ -26,6 +26,7 @@ protected function getConfig(): array 'confirmationDelayed' => false, 'SEPA' => false, 'orderMandatory' => true, + 'docs' => 'https://www.mollie.com/gb/payments/klarna', ]; } diff --git a/src/PaymentMethods/Klarnapaylater.php b/src/PaymentMethods/Klarnapaylater.php index 99140ba4..edd6f6c9 100644 --- a/src/PaymentMethods/Klarnapaylater.php +++ b/src/PaymentMethods/Klarnapaylater.php @@ -26,6 +26,7 @@ protected function getConfig(): array 'confirmationDelayed' => false, 'SEPA' => false, 'orderMandatory' => true, + 'docs' => 'https://www.mollie.com/gb/payments/klarna', ]; } diff --git a/src/PaymentMethods/Klarnapaynow.php b/src/PaymentMethods/Klarnapaynow.php index 32cd04a9..5cdddfeb 100644 --- a/src/PaymentMethods/Klarnapaynow.php +++ b/src/PaymentMethods/Klarnapaynow.php @@ -26,6 +26,7 @@ protected function getConfig(): array 'confirmationDelayed' => false, 'SEPA' => false, 'orderMandatory' => true, + 'docs' => 'https://www.mollie.com/gb/payments/klarna', ]; } diff --git a/src/PaymentMethods/Klarnasliceit.php b/src/PaymentMethods/Klarnasliceit.php index 9b97b3db..dd8e31c2 100644 --- a/src/PaymentMethods/Klarnasliceit.php +++ b/src/PaymentMethods/Klarnasliceit.php @@ -26,6 +26,7 @@ protected function getConfig(): array 'confirmationDelayed' => false, 'SEPA' => false, 'orderMandatory' => true, + 'docs' => 'https://www.mollie.com/gb/payments/klarna', ]; } diff --git a/src/PaymentMethods/Mybank.php b/src/PaymentMethods/Mybank.php index a2f38ba2..e656d23e 100644 --- a/src/PaymentMethods/Mybank.php +++ b/src/PaymentMethods/Mybank.php @@ -22,6 +22,7 @@ protected function getConfig(): array 'filtersOnBuild' => false, 'confirmationDelayed' => false, 'SEPA' => false, + 'docs' => '', ]; } diff --git a/src/PaymentMethods/Payconiq.php b/src/PaymentMethods/Payconiq.php index 59f9899a..b89696c9 100644 --- a/src/PaymentMethods/Payconiq.php +++ b/src/PaymentMethods/Payconiq.php @@ -19,6 +19,7 @@ protected function getConfig(): array 'filtersOnBuild' => false, 'confirmationDelayed' => false, 'SEPA' => false, + 'docs' => '', ]; } diff --git a/src/PaymentMethods/Paypal.php b/src/PaymentMethods/Paypal.php index e3713f01..07be034b 100644 --- a/src/PaymentMethods/Paypal.php +++ b/src/PaymentMethods/Paypal.php @@ -22,6 +22,7 @@ protected function getConfig(): array 'filtersOnBuild' => false, 'confirmationDelayed' => false, 'SEPA' => false, + 'docs' => 'https://www.mollie.com/gb/payments/paypal', ]; } diff --git a/src/PaymentMethods/Paysafecard.php b/src/PaymentMethods/Paysafecard.php index b1e180f3..4e1fe4d5 100644 --- a/src/PaymentMethods/Paysafecard.php +++ b/src/PaymentMethods/Paysafecard.php @@ -19,6 +19,7 @@ protected function getConfig(): array 'filtersOnBuild' => false, 'confirmationDelayed' => false, 'SEPA' => false, + 'docs' => 'https://www.mollie.com/gb/payments/paysafecard', ]; } diff --git a/src/PaymentMethods/Przelewy24.php b/src/PaymentMethods/Przelewy24.php index d3e6e9f7..58eb2692 100644 --- a/src/PaymentMethods/Przelewy24.php +++ b/src/PaymentMethods/Przelewy24.php @@ -25,6 +25,7 @@ protected function getConfig(): array 'filtersOnBuild' => false, 'confirmationDelayed' => false, 'SEPA' => false, + 'docs' => 'https://www.mollie.com/gb/payments/przelewy24', ]; } diff --git a/src/PaymentMethods/Riverty.php b/src/PaymentMethods/Riverty.php index 9482f69c..e7db2037 100644 --- a/src/PaymentMethods/Riverty.php +++ b/src/PaymentMethods/Riverty.php @@ -31,6 +31,7 @@ protected function getConfig(): array 'orderMandatory' => true, 'phonePlaceholder' => __('Please enter your phone here. +316xxxxxxxx', 'mollie-payments-for-woocommerce'), 'birthdatePlaceholder' => __('Please enter your birthdate here.', 'mollie-payments-for-woocommerce'), + 'docs' => 'https://www.mollie.com/gb/payments/riverty', ]; } diff --git a/src/PaymentMethods/Satispay.php b/src/PaymentMethods/Satispay.php index 5919e9d6..61bd49f7 100644 --- a/src/PaymentMethods/Satispay.php +++ b/src/PaymentMethods/Satispay.php @@ -19,6 +19,7 @@ protected function getConfig(): array 'filtersOnBuild' => false, 'confirmationDelayed' => false, 'SEPA' => false, + 'docs' => 'https://www.mollie.com/gb/payments/satispay', ]; } diff --git a/src/PaymentMethods/Sofort.php b/src/PaymentMethods/Sofort.php index 625f15cd..d33a0865 100644 --- a/src/PaymentMethods/Sofort.php +++ b/src/PaymentMethods/Sofort.php @@ -22,6 +22,7 @@ protected function getConfig(): array 'filtersOnBuild' => false, 'confirmationDelayed' => true, 'SEPA' => true, + 'docs' => 'https://help.mollie.com/hc/en-us/articles/20904206772626-SOFORT-Deprecation-30-September-2024', ]; } diff --git a/src/PaymentMethods/Trustly.php b/src/PaymentMethods/Trustly.php index 05179fbb..aa73fccf 100644 --- a/src/PaymentMethods/Trustly.php +++ b/src/PaymentMethods/Trustly.php @@ -22,6 +22,7 @@ protected function getConfig(): array 'filtersOnBuild' => false, 'confirmationDelayed' => true, 'SEPA' => false, + 'docs' => 'https://www.mollie.com/gb/payments/trustly', ]; } diff --git a/src/PaymentMethods/Twint.php b/src/PaymentMethods/Twint.php index eeaa9b02..8b33f958 100644 --- a/src/PaymentMethods/Twint.php +++ b/src/PaymentMethods/Twint.php @@ -22,6 +22,7 @@ protected function getConfig(): array 'filtersOnBuild' => false, 'confirmationDelayed' => false, 'SEPA' => false, + 'docs' => 'https://www.mollie.com/gb/payments/twint', ]; } diff --git a/src/PaymentMethods/Voucher.php b/src/PaymentMethods/Voucher.php index 1df331bb..80224f32 100644 --- a/src/PaymentMethods/Voucher.php +++ b/src/PaymentMethods/Voucher.php @@ -43,6 +43,7 @@ protected function getConfig(): array 'confirmationDelayed' => false, 'SEPA' => false, 'orderMandatory' => true, + 'docs' => 'https://www.mollie.com/gb/payments/meal-eco-gift-vouchers', ]; } diff --git a/src/Settings/MollieSettingsPage.php b/src/Settings/MollieSettingsPage.php index 53cd41b1..7c521201 100644 --- a/src/Settings/MollieSettingsPage.php +++ b/src/Settings/MollieSettingsPage.php @@ -10,33 +10,36 @@ use Mollie\WooCommerce\Settings\Page\PageNoApiKey; use Mollie\WooCommerce\Settings\Page\PagePaymentMethods; use Mollie\WooCommerce\Shared\Data; +use Mollie\WooCommerce\PaymentMethods\Constants; +use WC_Gateway_BACS; use WC_Settings_Page; class MollieSettingsPage extends WC_Settings_Page { - protected Settings $settingsHelper; + protected Settings $settings; protected string $pluginPath; protected string $pluginUrl; - protected array $gateways; + protected array $mollieGateways; protected array $paymentMethods; protected bool $isTestModeEnabled; protected Data $dataHelper; public function __construct( - Settings $settingsHelper, - string $pluginPath, - string $pluginUrl, - array $gateways, - array $paymentMethods, - bool $isTestModeEnabled, - Data $dataHelper + Settings $settings, + string $pluginPath, + string $pluginUrl, + array $mollieGateways, + array $paymentMethods, + bool $isTestModeEnabled, + Data $dataHelper ) { + $this->id = 'mollie_settings'; $this->label = __('Mollie Settings', 'mollie-payments-for-woocommerce'); - $this->settingsHelper = $settingsHelper; + $this->settings = $settings; $this->pluginPath = $pluginPath; $this->pluginUrl = $pluginUrl; - $this->gateways = $gateways; + $this->mollieGateways = $mollieGateways; $this->isTestModeEnabled = $isTestModeEnabled; $this->dataHelper = $dataHelper; $this->paymentMethods = $paymentMethods; @@ -57,9 +60,15 @@ public function registerContentFieldType(): void
= $value['desc']; ?>
+'; + $content .= $warning_message; + $content .= '
'; + $content .= __( + 'You have the WooCommerce default Direct Bank Transfer (BACS) payment gateway enabled in WooCommerce. Mollie strongly advices only using Bank Transfer via Mollie and disabling the default WooCommerce BACS payment gateway to prevent possible conflicts.', + 'mollie-payments-for-woocommerce' + ); + $content .= '
'; + $content .= sprintf( + /* translators: Placeholder 1: Opening link tag. Placeholder 2: Closing link tag. Placeholder 3: Opening link tag. Placeholder 4: Closing link tag. */ + __( + 'You have activated Klarna. To accept payments, please make sure all default WooCommerce checkout fields are enabled and required. For more information, go to %1$sKlarna Pay Later documentation%2$s or %3$sKlarna Slice it documentation%4$s', + 'mollie-payments-for-woocommerce' + ), + '', + '', + '', + '' + ); + $content .= '
' . __('The following options are required to use the plugin and are used by all Mollie payment methods', 'mollie-payments-for-woocommerce') . '
', + ], + [ + 'id' => $this->settings->getSettingId('order_status_cancelled_payments'), + 'title' => __('Order status after cancelled payment', 'mollie-payments-for-woocommerce'), + 'type' => 'select', + 'options' => [ + 'pending' => __('Pending', 'woocommerce'), + 'cancelled' => __('Cancelled', 'woocommerce'), + ], + 'desc' => __('Status for orders when a payment (not a Mollie order via the Orders API) is cancelled. Default: pending. Orders with status Pending can be paid with another payment method, customers can try again. Cancelled orders are final. Set this to Cancelled if you only have one payment method or don\'t want customers to re-try paying with a different payment method. This doesn\'t apply to payments for orders via the new Orders API and Klarna payments.', 'mollie-payments-for-woocommerce'), + 'default' => 'pending', + ], + [ + 'id' => $this->settings->getSettingId(SharedDataDictionary::SETTING_NAME_PAYMENT_LOCALE), + 'title' => __('Payment screen language', 'mollie-payments-for-woocommerce'), + 'type' => 'select', + 'options' => [ + SharedDataDictionary::SETTING_LOCALE_WP_LANGUAGE => __( + 'Automatically send WordPress language', + 'mollie-payments-for-woocommerce' + ) . ' (' . __('default', 'mollie-payments-for-woocommerce') . ')', + SharedDataDictionary::SETTING_LOCALE_DETECT_BY_BROWSER => __( + 'Detect using browser language', + 'mollie-payments-for-woocommerce' + ), + 'en_US' => __('English', 'mollie-payments-for-woocommerce'), + 'nl_NL' => __('Dutch', 'mollie-payments-for-woocommerce'), + 'nl_BE' => __('Flemish (Belgium)', 'mollie-payments-for-woocommerce'), + 'fr_FR' => __('French', 'mollie-payments-for-woocommerce'), + 'fr_BE' => __('French (Belgium)', 'mollie-payments-for-woocommerce'), + 'de_DE' => __('German', 'mollie-payments-for-woocommerce'), + 'de_AT' => __('Austrian German', 'mollie-payments-for-woocommerce'), + 'de_CH' => __('Swiss German', 'mollie-payments-for-woocommerce'), + 'es_ES' => __('Spanish', 'mollie-payments-for-woocommerce'), + 'ca_ES' => __('Catalan', 'mollie-payments-for-woocommerce'), + 'pt_PT' => __('Portuguese', 'mollie-payments-for-woocommerce'), + 'it_IT' => __('Italian', 'mollie-payments-for-woocommerce'), + 'nb_NO' => __('Norwegian', 'mollie-payments-for-woocommerce'), + 'sv_SE' => __('Swedish', 'mollie-payments-for-woocommerce'), + 'fi_FI' => __('Finnish', 'mollie-payments-for-woocommerce'), + 'da_DK' => __('Danish', 'mollie-payments-for-woocommerce'), + 'is_IS' => __('Icelandic', 'mollie-payments-for-woocommerce'), + 'hu_HU' => __('Hungarian', 'mollie-payments-for-woocommerce'), + 'pl_PL' => __('Polish', 'mollie-payments-for-woocommerce'), + 'lv_LV' => __('Latvian', 'mollie-payments-for-woocommerce'), + 'lt_LT' => __('Lithuanian', 'mollie-payments-for-woocommerce'), + ], + 'desc' => sprintf( + /* translators: Placeholder 1: link tag Placeholder 2: closing tag */ + __('Sending a language (or locale) is required. The option \'Automatically send WordPress language\' will try to get the customer\'s language in WordPress (and respects multilanguage plugins) and convert it to a format Mollie understands. If this fails, or if the language is not supported, it will fall back to American English. You can also select one of the locales currently supported by Mollie, that will then be used for all customers.', 'mollie-payments-for-woocommerce'), + '', + '' + ), + 'default' => SharedDataDictionary::SETTING_LOCALE_WP_LANGUAGE, + ], + [ + 'id' => $this->settings->getSettingId('customer_details'), + 'title' => __('Store customer details at Mollie', 'mollie-payments-for-woocommerce'), + 'desc' => sprintf( + /* translators: Placeholder 1: enabled or disabled Placeholder 2: translated string */ + __( + 'Should Mollie store customers name and email address for Single Click Payments? Default%1$s
. Required if WooCommerce Subscriptions is being used! Read more about %2$s and how it improves your conversion.',
+ 'mollie-payments-for-woocommerce'
+ ),
+ strtolower(__('Enabled', 'mollie-payments-for-woocommerce')),
+ __('Single Click Payments', 'mollie-payments-for-woocommerce')
+ ),
+ 'type' => 'checkbox',
+ 'default' => 'yes',
+
+ ],
+ [
+ 'id' => $this->settings->getSettingId('api_switch'),
+ 'title' => __(
+ 'Select API Method',
+ 'mollie-payments-for-woocommerce'
+ ),
+ 'type' => 'select',
+ 'options' => [
+ PaymentService::PAYMENT_METHOD_TYPE_ORDER => ucfirst(
+ PaymentService::PAYMENT_METHOD_TYPE_ORDER
+ ) . ' (' . __('default', 'mollie-payments-for-woocommerce')
+ . ')',
+ PaymentService::PAYMENT_METHOD_TYPE_PAYMENT => ucfirst(
+ PaymentService::PAYMENT_METHOD_TYPE_PAYMENT
+ ),
+ ],
+ 'default' => PaymentService::PAYMENT_METHOD_TYPE_ORDER,
+ 'desc' => sprintf(
+ /* translators: Placeholder 1: opening link tag, placeholder 2: closing link tag */
+ __(
+ 'Click %1$shere%2$s to read more about the differences between the Payments and Orders API',
+ 'mollie-payments-for-woocommerce'
+ ),
+ '',
+ ''
+ ),
+ ],
+ [
+ 'id' => $this->settings->getSettingId('api_payment_description'),
+ 'title' => __(
+ 'API Payment Description',
+ 'mollie-payments-for-woocommerce'
+ ),
+ 'type' => 'text',
+ 'default' => '{orderNumber}',
+ 'desc' => sprintf(
+ '
+
+ %3$s', + _x('Available variables', 'Payment description options', 'mollie-payments-for-woocommerce'), + implode('', array_map( + static function ($label, $labelDescription) { + return sprintf( + '
', + '
' + ) + ), + ], + [ + 'id' => $this->settings->getSettingId('gatewayFeeLabel'), + 'title' => __( + 'Surcharge gateway fee label', + 'mollie-payments-for-woocommerce' + ), + 'type' => 'text', + 'custom_attributes' => ['maxlength' => '30'], + 'default' => __('Gateway Fee', 'mollie-payments-for-woocommerce'), + 'desc' => __( + 'This is the label will appear in frontend when the surcharge applies', + 'mollie-payments-for-woocommerce' + ), + ], + [ + 'id' => $this->settings->getSettingId('removeOptionsAndTransients'), + 'title' => __( + 'Remove Mollie data from Database on uninstall', + 'mollie-payments-for-woocommerce' + ), + 'type' => 'checkbox', + 'default' => 'no', + 'desc' => __("Remove options and scheduled actions from database when uninstalling the plugin.", "mollie-payments-for-woocommerce") . ' (' . strtolower( + __('Clear now', 'mollie-payments-for-woocommerce') + ) . ')', + ], + [ + 'id' => $this->settings->getSettingId('sectionend'), + 'type' => 'sectionend', + ], + ]; + + return apply_filters( + 'inpsyde.mollie-advanced-settings', + $config, + $this->settings->getPluginId() + ); + } + + protected function paymentDescriptionLabels(): array{ + return [ + '{orderNumber}' => _x('Order number', 'Label {orderNumber} description for payment description options', 'mollie-payments-for-woocommerce'), + '{storeName}' => _x('Site Title', 'Label {storeName} description for payment description options', 'mollie-payments-for-woocommerce'), + '{customer.firstname}' => _x('Customer\'s first name', 'Label {customer.firstname} description for payment description options', 'mollie-payments-for-woocommerce'), + '{customer.lastname}' => _x('Customer\'s last name', 'Label {customer.lastname} description for payment description options', 'mollie-payments-for-woocommerce'), + '{customer.company}' => _x('Customer\'s company name', 'Label {customer.company} description for payment description options', 'mollie-payments-for-woocommerce'), + ]; + } + + protected function cleanDbUrl(): string{ + return add_query_arg( + ['cleanDB-mollie' => 1, 'nonce_mollie_cleanDb' => wp_create_nonce('nonce_mollie_cleanDb')] + ); + } + + protected function content(): string + { + ob_start(); + ?> + $this->settings->getSettingId('title'), 'title' => '', - 'type' => 'title' + 'type' => 'title', ], + $this->connectionStatusField($this->settings, $this->connectionStatus), [ 'id' => $this->settings->getSettingId('test_mode_enabled'), 'title' => __('Mollie Payment Mode', 'mollie-payments-for-woocommerce'), @@ -21,8 +24,12 @@ public function config(): array 'type' => 'select', 'options' => [ 'no' => 'Live API', - 'yes' => 'Test API' + 'yes' => 'Test API', ], + 'desc' => __( + 'Select Live API to receive real payments and Test API to test transactions without a fee.', + 'mollie-payments-for-woocommerce' + ), 'desc_tip' => __( 'Enable test mode if you want to test the plugin without using real payments.', 'mollie-payments-for-woocommerce' @@ -34,14 +41,11 @@ public function config(): array 'default' => '', 'type' => 'text', 'desc' => sprintf( - /* translators: Placeholder 1: API key mode (live or test). The surrounding %s's Will be replaced by a link to the Mollie profile */ __( - 'The API key is used to connect to Mollie. You can find your %1$s API key in your %2$sMollie account%3$s', + "Use your Live API key when you're ready to receive real payments.", 'mollie-payments-for-woocommerce' ), - 'live', - '', - '' + 'https://my.mollie.com/dashboard/developers/api-keys?utm_source=woocommerce&utm_medium=plugin&utm_campaign=partner' ), 'css' => 'width: 350px', 'placeholder' => __( @@ -55,14 +59,11 @@ public function config(): array 'default' => '', 'type' => 'text', 'desc' => sprintf( - /* translators: Placeholder 1: API key mode (live or test). The surrounding %s's Will be replaced by a link to the Mollie profile */ __( - 'The API key is used to connect to Mollie. You can find your %1$s API key in your %2$sMollie account%3$s', + "Use your Test APl key to check the connection and test transactions without a fee.", 'mollie-payments-for-woocommerce' ), - 'test', - '', - '' + 'https://my.mollie.com/dashboard/developers/api-keys?utm_source=woocommerce&utm_medium=plugin&utm_campaign=partner' ), 'css' => 'width: 350px', 'placeholder' => __( @@ -74,7 +75,13 @@ public function config(): array 'id' => $this->settings->getSettingId('debug'), 'title' => __('Debug Log', 'mollie-payments-for-woocommerce'), 'type' => 'checkbox', - 'desc' => __('Log plugin events.', 'mollie-payments-for-woocommerce'), + 'desc' => sprintf( + __( + "Log plugin events. View logs", + 'mollie-payments-for-woocommerce' + ), + $this->settings->getLogsUrl() + ), 'default' => 'yes', ], [ diff --git a/src/Settings/Page/Section/ConnectionStatusFields.php b/src/Settings/Page/Section/ConnectionStatusFields.php new file mode 100644 index 00000000..68312324 --- /dev/null +++ b/src/Settings/Page/Section/ConnectionStatusFields.php @@ -0,0 +1,46 @@ + $this->settings->getSettingId('title'), + 'title' => '', + 'type' => 'title', + ], + $this->connectionStatusField($this->settings, $this->connectionStatus), + $this->refreshStatusField(), + [ + 'id' => $this->settings->getSettingId('sectionend'), + 'type' => 'sectionend', + ], + ]; + } + + public function refreshStatusField(): array + { + $refreshNonce = wp_create_nonce('nonce_mollie_refresh_methods'); + $refreshUrl = add_query_arg( + ['refresh-methods' => 1, 'nonce_mollie_refresh_methods' => $refreshNonce] + ); + + return [ + 'id' => $this->settings->getSettingId('refresh_status'), + 'title' => __('Payment method availability', 'mollie-payments-for-woocommerce'), + 'value' => '' . __('Refresh Mollie payment methods', 'mollie-payments-for-woocommerce') . '', + 'desc' => __( + 'Click this button to refresh your payment methods, e.g. if you recently enabled new payment methods in your Mollie profile', + 'mollie-payments-for-woocommerce' + ), + 'type' => 'mollie_custom_input', + ]; + } +} diff --git a/src/Settings/Page/Section/ConnectionStatusTrait.php b/src/Settings/Page/Section/ConnectionStatusTrait.php new file mode 100644 index 00000000..ff1c0514 --- /dev/null +++ b/src/Settings/Page/Section/ConnectionStatusTrait.php @@ -0,0 +1,36 @@ + $settings->getSettingId('connection_status'), + 'title' => __('Mollie Connection Status', 'mollie-payments-for-woocommerce'), + 'value' => $this->connectionStatus($settings, $connectionStatus), + 'type' => 'mollie_custom_input', + ]; + } + + protected function connectionStatus(Settings $settings, bool $connectionStatus): ?string + { + $testMode = $settings->isTestModeEnabled(); + if (!$connectionStatus) { + return __( + 'Failed to connect to Mollie API - check your API keys ✖', + 'mollie-payments-for-woocommerce' + ); + } + if ($testMode) { + return __('Successfully connected with Test API ✓', 'mollie-payments-for-woocommerce'); + } + return __('Successfully connected with Live API ✓', 'mollie-payments-for-woocommerce'); + } +} diff --git a/src/Settings/Page/Section/Header.php b/src/Settings/Page/Section/Header.php index c6408fce..0f07b030 100644 --- a/src/Settings/Page/Section/Header.php +++ b/src/Settings/Page/Section/Header.php @@ -10,10 +10,10 @@ public function config(): array { return [ [ - 'id' => $this->settings->getSettingId('header'), - 'type' => 'mollie_content', - 'value' => $this->content() - ] + 'id' => $this->settings->getSettingId('header'), + 'type' => 'mollie_content', + 'value' => $this->content(), + ], ]; } @@ -62,8 +62,8 @@ protected function content(): string= __( - 'Effortless payments for your customers, designed for growth', - 'mollie-payments-for-woocommerce' + 'Effortless payments for your customers, designed for growth', + 'mollie-payments-for-woocommerce' ); ?>
diff --git a/src/Settings/Page/Section/InstructionsConnected.php b/src/Settings/Page/Section/InstructionsConnected.php new file mode 100644 index 00000000..689e9dbf --- /dev/null +++ b/src/Settings/Page/Section/InstructionsConnected.php @@ -0,0 +1,46 @@ + $this->settings->getSettingId('instructions'), + 'type' => 'mollie_content', + 'value' => $this->content(), + ], + ]; + } + + protected function content(): string + { + ob_start(); + ?> ++ = sprintf( + __( + "To start receiving payments through the Mollie plugin in your WooCommerce store, + you'll need to connect it to your Mollie account using an API key.", + 'mollie-payments-for-woocommerce' + ), + 'https://my.mollie.com/dashboard/developers/api-keys?utm_source=woocommerce&utm_medium=plugin&utm_campaign=partner' + ); ?> +
++ = + __( + 'Please note that your API keys are unique to your Mollie account and should be kept private + to ensure the security of your transactions.', 'mollie-payments-for-woocommerce' + ); + ?> +
+ $this->settings->getSettingId('instructions'), 'type' => 'mollie_content', - 'value' => $this->content() - ] + 'value' => $this->content(), + ], ]; } @@ -24,9 +24,9 @@ protected function content(): string= __( - "To start receiving payments through the Mollie plugin in your WooCommerce store, + "To start receiving payments through the Mollie plugin in your WooCommerce store, you'll need to connect it to your Mollie account using an API key.", - 'mollie-payments-for-woocommerce' + 'mollie-payments-for-woocommerce' ); ?>
@@ -37,11 +37,11 @@ protected function content(): string
= __( - "Please note that your API keys are unique to your Mollie account and should be kept + "Please note that your API keys are unique to your Mollie account and should be kept private to ensure the security of your transactions.", - 'mollie-payments-for-woocommerce' + 'mollie-payments-for-woocommerce' ); ?>
$this->settings->getSettingId('notices'), - 'type' => 'mollie_content', - 'value' => $this->content() - ] + 'id' => $this->settings->getSettingId('notices'), + 'type' => 'mollie_content', + 'value' => $this->content(), + ], ]; } diff --git a/src/Settings/Page/Section/PaymentMethods.php b/src/Settings/Page/Section/PaymentMethods.php new file mode 100644 index 00000000..9bf80ea8 --- /dev/null +++ b/src/Settings/Page/Section/PaymentMethods.php @@ -0,0 +1,246 @@ + $this->settings->getSettingId('notices'), + 'type' => 'mollie_content', + 'value' => $this->content(), + ], + ]; + } + + protected function content(): string + { + ob_start(); + ?> += $description; ?>
+