@@ -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 )),
0 commit comments