Skip to content

Commit af8ec3b

Browse files
authored
Merge branch 'master' into feature/PLUG-5038
2 parents 521b71b + a86437e commit af8ec3b

7 files changed

Lines changed: 91 additions & 44 deletions

File tree

includes/classes/PPMFWC/Gateway/Abstract.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ public static function getAlternativeExchangeUrl()
784784
*/
785785
public static function getServiceId()
786786
{
787-
return get_option('paynl_serviceid');
787+
return PPMFWC_Helper_Config::getServiceId();
788788
}
789789

790790
/**

includes/classes/PPMFWC/Gateways.php

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,9 @@ public static function ppmfwc_checkCredentials()
304304
}
305305
PPMFWC_Helper_Data::loadPaymentMethods();
306306
} catch (Exception $e) {
307-
$current_apitoken = get_option('paynl_apitoken');
308-
$current_serviceid = get_option('paynl_serviceid');
309-
$current_tokencode = get_option('paynl_tokencode');
307+
$current_apitoken = PPMFWC_Helper_Config::getApiToken();
308+
$current_serviceid = PPMFWC_Helper_Config::getServiceId();
309+
$current_tokencode = PPMFWC_Helper_Config::getTokenCode();
310310
$error = $e->getMessage();
311311
if (strlen(trim($current_apitoken . $current_serviceid . $current_tokencode)) == 0) {
312312
$post_apitoken = PPMFWC_Helper_Data::getPostTextField('paynl_apitoken');
@@ -704,63 +704,64 @@ public static function ppmfwc_addGlobalSettings()
704704
);
705705
} else {
706706
$status = '';
707+
$isConfiguredInWpConfig = PPMFWC_Helper_Config::isConfiguredInWpConfig();
707708

708-
$post_apitoken = PPMFWC_Helper_Data::getPostTextField('paynl_apitoken');
709-
$post_serviceid = PPMFWC_Helper_Data::getPostTextField('paynl_serviceid');
710-
$post_tokencode = PPMFWC_Helper_Data::getPostTextField('paynl_tokencode');
709+
if (!$isConfiguredInWpConfig) {
710+
$post_apitoken = PPMFWC_Helper_Data::getPostTextField('paynl_apitoken');
711+
$post_serviceid = PPMFWC_Helper_Data::getPostTextField('paynl_serviceid');
712+
$post_tokencode = PPMFWC_Helper_Data::getPostTextField('paynl_tokencode');
711713

712-
if (!empty($post_apitoken) || !empty($post_serviceid) || !empty($post_tokencode)) {
713-
$current_apitoken = get_option('paynl_apitoken');
714-
$current_serviceid = get_option('paynl_serviceid');
715-
$current_tokencode = get_option('paynl_tokencode');
716-
if (($post_apitoken == $current_apitoken) && ($post_serviceid == $current_serviceid) && ($post_tokencode == $current_tokencode)) {
714+
if (!empty($post_apitoken) || !empty($post_serviceid) || !empty($post_tokencode)) {
715+
$current_apitoken = PPMFWC_Helper_Config::getApiToken();
716+
$current_serviceid = PPMFWC_Helper_Config::getServiceId();
717+
$current_tokencode = PPMFWC_Helper_Config::getTokenCode();
718+
if (($post_apitoken == $current_apitoken) && ($post_serviceid == $current_serviceid) && ($post_tokencode == $current_tokencode)) {
719+
$status = self::ppmfwc_checkCredentials();
720+
}
721+
} else {
717722
$status = self::ppmfwc_checkCredentials();
718723
}
719724
} else {
720725
$status = self::ppmfwc_checkCredentials();
721726
}
727+
722728
$addedSettings[] = array(
723729
'title' => esc_html(__('Pay. Setup', PPMFWC_WOOCOMMERCE_TEXTDOMAIN)),
724730
'type' => 'title',
725731
'desc' => $status,
726732
'id' => 'paynl_setup',
727733
);
734+
728735
$addedSettings[] = array(
729736
'name' => esc_html(__('Token Code *', PPMFWC_WOOCOMMERCE_TEXTDOMAIN)),
730737
'placeholder' => 'AT-####-####',
731-
'type' => 'text',
732-
'desc' => esc_html(
733-
__(
734-
'The AT-code belonging to your API token, you can find this ',
735-
PPMFWC_WOOCOMMERCE_TEXTDOMAIN
736-
)
737-
) . '<a href="https://admin.pay.nl/company/tokens" target="api_token">' . esc_html(__('here', PPMFWC_WOOCOMMERCE_TEXTDOMAIN)) . '</a>',
738+
'type' => $isConfiguredInWpConfig ? 'info' : 'text',
739+
'text' => 'Token Code',
740+
'desc' => esc_html(__('The AT-code belonging to your API token, you can find this ', PPMFWC_WOOCOMMERCE_TEXTDOMAIN)) . '<a href="https://admin.pay.nl/company/tokens" target="api_token">' . esc_html(__('here', PPMFWC_WOOCOMMERCE_TEXTDOMAIN)) . '</a>',
738741
'id' => 'paynl_tokencode',
742+
'desc_tip' => __('The Token Code should be in the following format: AT-xxxx-xxxx <br/> Optionally, this credential can be defined in the config as "PAYNL_TOKEN_CODE"', PPMFWC_WOOCOMMERCE_TEXTDOMAIN),
739743
);
744+
740745
$addedSettings[] = array(
741746
'name' => esc_html(__('API token', PPMFWC_WOOCOMMERCE_TEXTDOMAIN)),
742-
'type' => 'text',
743-
'desc' => esc_html(
744-
__(
745-
'The API token used to communicate with the Pay. API, you can find your API token ',
746-
PPMFWC_WOOCOMMERCE_TEXTDOMAIN
747-
)
748-
) . '<a href="https://admin.pay.nl/company/tokens" target="api_token">' . esc_html(__('here', PPMFWC_WOOCOMMERCE_TEXTDOMAIN)) . '</a>',
747+
'type' => $isConfiguredInWpConfig ? 'info' : 'text',
748+
'text' => 'API Token',
749+
'desc' => esc_html(__('The API token used to communicate with the Pay. API, you can find your API token ', PPMFWC_WOOCOMMERCE_TEXTDOMAIN)) .
750+
'<a href="https://admin.pay.nl/company/tokens" target="api_token">' . esc_html(__('here', PPMFWC_WOOCOMMERCE_TEXTDOMAIN)) . '</a>',
749751
'id' => 'paynl_apitoken',
750752
'class' => 'obscuredInput',
753+
'desc_tip' => __('Optionally, this credential can be defined in the config as "PAYNL_API_TOKEN"', PPMFWC_WOOCOMMERCE_TEXTDOMAIN),
751754
);
755+
752756
$addedSettings[] = array(
753757
'name' => esc_html(__('Sales Location *', PPMFWC_WOOCOMMERCE_TEXTDOMAIN)),
754758
'placeholder' => 'SL-####-####',
755-
'type' => 'text',
756-
'desc' => esc_html(
757-
__(
758-
'The SL-code of your Sales Location, you can find your SL-code ',
759-
PPMFWC_WOOCOMMERCE_TEXTDOMAIN
760-
)
761-
) . '<a href="https://admin.pay.nl/programs/programs" target="serviceid">' . esc_html(__('here', PPMFWC_WOOCOMMERCE_TEXTDOMAIN)) . '</a>',
759+
'type' => $isConfiguredInWpConfig ? 'info' : 'text',
760+
'text' => 'Service ID',
761+
'desc' => esc_html(__('The SL-code of your Sales Location, you can find your SL-code ', PPMFWC_WOOCOMMERCE_TEXTDOMAIN)) .
762+
'<a href="https://admin.pay.nl/programs/programs" target="serviceid">' . esc_html(__('here', PPMFWC_WOOCOMMERCE_TEXTDOMAIN)) . '</a>',
762763
'id' => 'paynl_serviceid',
763-
'desc_tip' => __('The Sales Location should be in the following format: SL-xxxx-xxxx', PPMFWC_WOOCOMMERCE_TEXTDOMAIN),
764+
'desc_tip' => __('The Sales Location should be in the following format: SL-xxxx-xxxx <br/> Optionally, this credential can be defined in the config as "PAYNL_SERVICE_ID"', PPMFWC_WOOCOMMERCE_TEXTDOMAIN),
764765
);
765766
$addedSettings[] = array(
766767
'name' => esc_html(__('Test mode', PPMFWC_WOOCOMMERCE_TEXTDOMAIN)),

includes/classes/PPMFWC/Helper/Config.php

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,60 @@
55
class PPMFWC_Helper_Config
66
{
77

8+
/**
9+
* @return string
10+
*/
11+
public static function getTokenCode(): string
12+
{
13+
if (defined('PAYNL_TOKEN_CODE') && !empty(PAYNL_TOKEN_CODE)) {
14+
return PAYNL_TOKEN_CODE;
15+
}
16+
return get_option('paynl_tokencode', '');
17+
}
18+
19+
/**
20+
* @return string
21+
*/
22+
public static function getApiToken(): string
23+
{
24+
if (defined('PAYNL_API_TOKEN') && !empty(PAYNL_API_TOKEN)) {
25+
return PAYNL_API_TOKEN;
26+
}
27+
return get_option('paynl_apitoken', '');
28+
}
29+
30+
/**
31+
* @return string
32+
*/
33+
public static function getServiceId(): string
34+
{
35+
if (defined('PAYNL_SERVICE_ID') && !empty(PAYNL_SERVICE_ID)) {
36+
return PAYNL_SERVICE_ID;
37+
}
38+
return get_option('paynl_serviceid', '');
39+
}
40+
41+
/**
42+
* @return bool
43+
*/
44+
public static function isConfiguredInWpConfig(): bool
45+
{
46+
return (defined('PAYNL_TOKEN_CODE') && !empty(PAYNL_TOKEN_CODE)) &&
47+
(defined('PAYNL_API_TOKEN') && !empty(PAYNL_API_TOKEN)) &&
48+
(defined('PAYNL_SERVICE_ID') && !empty(PAYNL_SERVICE_ID));
49+
}
50+
51+
852
/**
953
* @return PayConfig
1054
*/
1155
public static function getPayConfig(): PayConfig
1256
{
1357
$config = new PayConfig;
1458
$config->setCaching(false);
15-
$config->setUsername(get_option('paynl_tokencode'));
16-
$config->setPassword(get_option('paynl_apitoken'));
17-
$config->setServiceId(get_option('paynl_serviceid'));
59+
$config->setUsername(self::getTokenCode());
60+
$config->setPassword(self::getApiToken());
61+
$config->setServiceId(self::getServiceId());
1862

1963
$failOver = get_option('paynl_failover_gateway');
2064
if ($failOver == 'custom') {

includes/classes/PPMFWC/Helper/Data.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ private static function parseDefaultLanguage($http_accept, $deflang = "en")
298298
*/
299299
public static function getVersion()
300300
{
301-
return '4.0.3';
301+
return '4.0.4';
302302
}
303303

304304
/**

includes/classes/PPMFWC/Hooks/FastCheckout/TransactionCreate.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class PPMFWC_Hooks_FastCheckout_TransactionCreate
2020
public function getData($data, $order)
2121
{
2222
$parameters = [
23-
'serviceId' => get_option('paynl_serviceid'),
23+
'serviceId' => PPMFWC_Helper_Config::getServiceId(),
2424
'amount' => [
2525
'value' => $data['amount'] * 100,
2626
'currency' => $data['currency'],
@@ -121,7 +121,7 @@ public function create($data, $order)
121121

122122
$url = 'https://connect.payments.nl/v1/orders';
123123

124-
$rawResponse = (array) $this->sendCurlRequest($url, $payload, get_option('paynl_tokencode'), get_option('paynl_apitoken'));
124+
$rawResponse = (array) $this->sendCurlRequest($url, $payload, PPMFWC_Helper_Config::getTokenCode(), PPMFWC_Helper_Config::getApiToken());
125125

126126
return array(
127127
'redirectURL' => $rawResponse['links']->redirect ?? '',

readme.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ Donate link: https://www.pay.nl/webshops/plugin-woocommerce
44
Link: https://www.pay.nl
55
Tags: paynl, paymentmethods, iDEAL, betaalmethoden, pay
66
Requires at least: 6.1.0
7-
Stable tag: 4.0.3
7+
Stable tag: 4.0.4
88
Tested up to: 6.9.0
9-
WC tested up to: 10.3.5
9+
WC tested up to: 10.4.2
1010
WC requires at least: 3.0
1111
Requires PHP: 8.1
1212
License: GPLv2
@@ -188,6 +188,8 @@ Paid accounts have better tariffs! see: [tariffs](https://pay.nl/tarieven)
188188
8. One platform for all payments.
189189

190190
== Changelog ==
191+
= 4.0.4 =
192+
Fixed instore issues
191193
= 4.0.3 =
192194
Improved handling paid order data
193195
= 4.0.2 =

woocommerce-payment-paynl.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
* Plugin Name: Pay. Payment Methods for WooCommerce
55
* Plugin URI: https://wordpress.org/plugins/woocommerce-paynl-payment-methods/
66
* Description: Pay. Payment Methods for WooCommerce
7-
* Version: 4.0.3
7+
* Version: 4.0.4
88
* Author: Pay.
99
* Author URI: https://www.pay.nl
1010
* Requires at least: 6.1.0
1111
* WC requires at least: 6.5
12-
* WC tested up to: 10.3.3
12+
* WC tested up to: 10.4.2
1313
* Requires PHP: 8.1
1414
* Text Domain: woocommerce-paynl-payment-methods
1515
* Domain Path: /i18n/languages

0 commit comments

Comments
 (0)