← All changes
|
includes/Core/Integration/ZohoSign/ZohoSignHandler.php
+18
-42
3.2.1
→
2.7.0
View file →
| @@ -6,16 +6,11 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | namespace BitCode\BitForm\Core\Integration\ZohoSign; |
| 9 | 9 | |
| 10 | -if (!defined('ABSPATH')) { | |
| 11 | - exit; | |
| 12 | -} | |
| 13 | - | |
| 14 | 10 | use BitCode\BitForm\Core\Integration\IntegrationHandler; |
| 15 | 11 | use BitCode\BitForm\Core\Util\HttpHelper; |
| 16 | 12 | use BitCode\BitForm\Core\Util\IpTool; |
| 17 | -use BitCode\BitForm\GlobalHelper; | |
| 18 | 13 | use WP_Error; |
| 19 | 14 | |
| 20 | 15 | /** |
| 21 | 16 | * Provide functionality for ZohoCrm integration |
| @@ -49,16 +44,11 @@ | ||
| 49 | 44 | * @return JSON zoho crm api response and status |
| 50 | 45 | */ |
| 51 | 46 | public static function generateTokens() |
| 52 | 47 | { |
| 53 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 54 | - GlobalHelper::requirePostMethod(); | |
| 55 | - | |
| 56 | - try { | |
| 57 | - $requestsParams = GlobalHelper::formatRequestData(); | |
| 58 | - } catch (\InvalidArgumentException $e) { | |
| 59 | - wp_send_json_error($e->getMessage(), 400); | |
| 60 | - } | |
| 48 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 49 | + $inputJSON = file_get_contents('php://input'); | |
| 50 | + $requestsParams = json_decode($inputJSON); | |
| 61 | 51 | if ( |
| 62 | 52 | empty($requestsParams->{'accounts-server'}) |
| 63 | 53 | || empty($requestsParams->dataCenter) |
| 64 | 54 | || empty($requestsParams->clientId) |
| @@ -106,10 +96,10 @@ | ||
| 106 | 96 | |
| 107 | 97 | /** |
| 108 | 98 | * Helps to refresh zoho crm access_token |
| 109 | 99 | * |
| 110 | - * @param object $apiData Contains required data for refresh access token | |
| 111 | - * @return string|boolean $tokenDetails API token details | |
| 100 | + * @param Array $apiData Contains required data for refresh access token | |
| 101 | + * @return JSON $tokenDetails API token details | |
| 112 | 102 | */ |
| 113 | 103 | protected static function _refreshAccessToken($apiData) |
| 114 | 104 | { |
| 115 | 105 | if ( |
| @@ -142,11 +132,11 @@ | ||
| 142 | 132 | |
| 143 | 133 | /** |
| 144 | 134 | * Save updated access_token to avoid unnecessary token generation |
| 145 | 135 | * |
| 146 | - * @param integer $fromID ID of Integration related form | |
| 147 | - * @param integer $integrationID ID of Zoho crm Integration | |
| 148 | - * @param object $tokenDetails refreshed token info | |
| 136 | + * @param Integer $fromID ID of Integration related form | |
| 137 | + * @param Integer $integrationID ID of Zoho crm Integration | |
| 138 | + * @param Obeject $tokenDetails refreshed token info | |
| 149 | 139 | * |
| 150 | 140 | * @return null |
| 151 | 141 | */ |
| 152 | 142 | protected static function _saveRefreshedToken($formID, $integrationID, $tokenDetails, $others = null) |
| @@ -164,24 +154,17 @@ | ||
| 164 | 154 | $newDetails = json_decode($zsignDetails[0]->integration_details); |
| 165 | 155 | |
| 166 | 156 | $newDetails->tokenDetails = $tokenDetails; |
| 167 | 157 | |
| 168 | - $integrationHandler->updateIntegration($integrationID, $zsignDetails[0]->integration_name, 'Zoho Sign', wp_json_encode($newDetails), 'form'); | |
| 158 | + $integrationHandler->updateIntegration($integrationID, $zsignDetails[0]->integration_name, 'Zoho Sign', \json_encode($newDetails), 'form'); | |
| 169 | 159 | } |
| 170 | 160 | |
| 171 | - public static function refreshTemplatesAjaxHelper() | |
| 161 | + public function refreshTemplatesAjaxHelper() | |
| 172 | 162 | { |
| 173 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 163 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 174 | 164 | $authorizationHeader = null; |
| 175 | - | |
| 176 | - GlobalHelper::requirePostMethod(); | |
| 177 | - | |
| 178 | - try { | |
| 179 | - $queryParams = GlobalHelper::formatRequestData(); | |
| 180 | - } catch (\InvalidArgumentException $e) { | |
| 181 | - wp_send_json_error($e->getMessage(), 400); | |
| 182 | - } | |
| 183 | - | |
| 165 | + $inputJSON = file_get_contents('php://input'); | |
| 166 | + $queryParams = json_decode($inputJSON); | |
| 184 | 167 | if ( |
| 185 | 168 | empty($queryParams->tokenDetails) |
| 186 | 169 | || empty($queryParams->dataCenter) |
| 187 | 170 | || empty($queryParams->clientId) |
| @@ -236,21 +219,14 @@ | ||
| 236 | 219 | ); |
| 237 | 220 | } |
| 238 | 221 | } |
| 239 | 222 | |
| 240 | - public static function refreshTemplateDetailsAjaxHelper() | |
| 223 | + public function refreshTemplateDetailsAjaxHelper() | |
| 241 | 224 | { |
| 242 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 225 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 243 | 226 | $authorizationHeader = null; |
| 244 | - | |
| 245 | - GlobalHelper::requirePostMethod(); | |
| 246 | - | |
| 247 | - try { | |
| 248 | - $queryParams = GlobalHelper::formatRequestData(); | |
| 249 | - } catch (\InvalidArgumentException $e) { | |
| 250 | - wp_send_json_error($e->getMessage(), 400); | |
| 251 | - } | |
| 252 | - | |
| 227 | + $inputJSON = file_get_contents('php://input'); | |
| 228 | + $queryParams = json_decode($inputJSON); | |
| 253 | 229 | if ( |
| 254 | 230 | empty($queryParams->tokenDetails) |
| 255 | 231 | || empty($queryParams->dataCenter) |
| 256 | 232 | || empty($queryParams->clientId) |
| @@ -331,9 +307,9 @@ | ||
| 331 | 307 | } |
| 332 | 308 | } |
| 333 | 309 | |
| 334 | 310 | // $actions = $integrationDetails->actions; |
| 335 | - $recordApiHelper = new RecordApiHelper($tokenDetails, $this->_integrationID, $logID, $this->_formID, $entryID); | |
| 311 | + $recordApiHelper = new RecordApiHelper($tokenDetails, $this->_integrationID, $logID); | |
| 336 | 312 | |
| 337 | 313 | $zsignApiResponse = $recordApiHelper->executeRecordApi( |
| 338 | 314 | $dataCenter, |
| 339 | 315 | $template, |