solve sethook part
This commit is contained in:
parent
bb5115f04b
commit
3cecfbed74
|
@ -208,8 +208,8 @@ class Ssbhesabix_Setting {
|
|||
<form id="ssbhesabix_form" enctype="multipart/form-data" action="" method="post">
|
||||
<?php
|
||||
global $plugin_version;
|
||||
if (defined('SSBHESABFA_VERSION')) {
|
||||
$plugin_version = constant('SSBHESABFA_VERSION');
|
||||
if (defined('SSBHESABIX_VERSION')) {
|
||||
$plugin_version = constant('SSBHESABIX_VERSION');
|
||||
}
|
||||
$server_php_version = phpversion();
|
||||
$plugin_php_version = '8.1';
|
||||
|
@ -1632,8 +1632,8 @@ class Ssbhesabix_Setting {
|
|||
if ( is_object( $response ) ) {
|
||||
if ( $response->Success ) {
|
||||
update_option( 'ssbhesabix_live_mode', 1 );
|
||||
update_option( 'ssbhesabix_business_expired', 0 );
|
||||
|
||||
update_option( 'ssbhesabix_account_bid', $response->bid );
|
||||
update_option( 'ssbhesabix_account_year', $response->year );
|
||||
//set the last log ID if is not set
|
||||
$lastChanges = get_option( 'ssbhesabix_last_log_check_id' );
|
||||
if ( ! $lastChanges ) {
|
||||
|
|
|
@ -29,6 +29,8 @@ class Ssbhesabix_Activator {
|
|||
add_option('ssbhesabix_webhook_password', bin2hex(openssl_random_pseudo_bytes(16)));
|
||||
add_option('ssbhesabix_last_log_check_id', 0);
|
||||
add_option('ssbhesabix_live_mode', 0);
|
||||
add_option('ssbhesabix_live_mode', 0);
|
||||
add_option('ssbhesabix_live_mode', 0);
|
||||
add_option('ssbhesabix_debug_mode', 0);
|
||||
add_option('ssbhesabix_contact_address_status', 1);
|
||||
add_option('ssbhesabix_contact_node_family', 'مشتریان فروشگاه آنلاین');
|
||||
|
@ -40,6 +42,8 @@ class Ssbhesabix_Activator {
|
|||
add_option('ssbhesabix_do_not_submit_product_automatically', "no");
|
||||
add_option('ssbhesabix_do_not_update_product_price_in_hesabix', "no");
|
||||
add_option('ssbhesabix_contact_add_additional_checkout_fields_hesabix', 1);
|
||||
add_option('ssbhesabix_account_bid', 1);
|
||||
add_option('ssbhesabix_account_year', 1);
|
||||
|
||||
self::ssbhesabix_create_database_table();
|
||||
}
|
||||
|
|
|
@ -24,13 +24,10 @@ class Ssbhesabix_Api
|
|||
|
||||
$apiAddress = get_option('ssbhesabix_api_address', 0);
|
||||
|
||||
if($apiAddress == 1) $endpoint = 'http://next.hesabix.ir/' . $method;
|
||||
if($apiAddress == 1) $endpoint = 'https://next.hesabix.ir/' . $method;
|
||||
|
||||
$body = array_merge(array(
|
||||
'apiKey' => get_option('ssbhesabix_account_api'),
|
||||
'userId' => get_option('ssbhesabix_account_username'),
|
||||
'password' => get_option('ssbhesabix_account_password'),
|
||||
'loginToken' => get_option('ssbhesabix_account_login_token') ? get_option('ssbhesabix_account_login_token') : '',
|
||||
'API-KEY' => get_option('ssbhesabix_account_api'),
|
||||
), $data);
|
||||
|
||||
//Debug mode
|
||||
|
@ -42,6 +39,9 @@ class Ssbhesabix_Api
|
|||
'body' => wp_json_encode($body),
|
||||
'headers' => array(
|
||||
'Content-Type' => 'application/json',
|
||||
'API-KEY' => get_option('ssbhesabix_account_api'),
|
||||
'activeBid' => get_option('ssbhesabix_account_bid'),
|
||||
'activeYear' => get_option('ssbhesabix_account_year'),
|
||||
),
|
||||
'timeout' => 60,
|
||||
'redirection' => 5,
|
||||
|
@ -52,10 +52,8 @@ class Ssbhesabix_Api
|
|||
);
|
||||
|
||||
//HesabixLogService::writeLogObj($options);
|
||||
|
||||
$wp_remote_post = wp_remote_post($endpoint, $options);
|
||||
$result = json_decode(wp_remote_retrieve_body($wp_remote_post));
|
||||
|
||||
//Debug mode
|
||||
if (get_option('ssbhesabix_debug_mode')) {
|
||||
HesabixLogService::log(array("Debug Mode - Result: " . print_r($result, true)));
|
||||
|
@ -66,42 +64,9 @@ class Ssbhesabix_Api
|
|||
|
||||
if ($result == null) {
|
||||
return 'No response from Hesabix';
|
||||
} else {
|
||||
if (!isset($result->Success)) {
|
||||
switch ($result->errorCode) {
|
||||
case '100':
|
||||
return 'InternalServerError';
|
||||
case '101':
|
||||
return 'TooManyRequests';
|
||||
case '103':
|
||||
return 'MissingData';
|
||||
case '104':
|
||||
return 'MissingParameter' . '. ErrorMessage: ' . $result->ErrorMessage;
|
||||
case '105':
|
||||
return 'ApiDisabled';
|
||||
case '106':
|
||||
return 'UserIsNotOwner';
|
||||
case '107':
|
||||
return 'BusinessNotFound';
|
||||
case '108':
|
||||
return 'BusinessExpired';
|
||||
case '110':
|
||||
return 'IdMustBeZero';
|
||||
case '111':
|
||||
return 'IdMustNotBeZero';
|
||||
case '112':
|
||||
return 'ObjectNotFound' . '. ErrorMessage: ' . $result->ErrorMessage;
|
||||
case '113':
|
||||
return 'MissingApiKey';
|
||||
case '114':
|
||||
return 'ParameterIsOutOfRange' . '. ErrorMessage: ' . $result->ErrorMessage;
|
||||
case '190':
|
||||
return 'ApplicationError' . '. ErrorMessage: ' . $result->ErrorMessage;
|
||||
}
|
||||
} else {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//================================================================================================
|
||||
|
@ -398,8 +363,7 @@ class Ssbhesabix_Api
|
|||
//Settings functions
|
||||
public function settingSetChangeHook($url, $hookPassword)
|
||||
{
|
||||
$method = 'api/settings/chack-api';
|
||||
echo 11;
|
||||
$method = 'hooks/setting/SetChangeHook';
|
||||
$data = array(
|
||||
'url' => $url,
|
||||
'hookPassword' => $hookPassword,
|
||||
|
|
|
@ -61,8 +61,8 @@ class Ssbhesabix
|
|||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if (defined('SSBHESABFA_VERSION')) {
|
||||
$this->version = SSBHESABFA_VERSION;
|
||||
if (defined('SSBHESABIX_VERSION')) {
|
||||
$this->version = SSBHESABIX_VERSION;
|
||||
} else {
|
||||
$this->version = '2.0.93';
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue