diff --git a/modules/addons/gofasnfeio/callback.php b/modules/addons/gofasnfeio/callback.php index 11ee787..c9308ed 100644 --- a/modules/addons/gofasnfeio/callback.php +++ b/modules/addons/gofasnfeio/callback.php @@ -5,9 +5,15 @@ $post = json_decode(file_get_contents('php://input'), true); logModuleCall('gofas_nfeio', 'callback', $post, '', '', 'replaceVars'); +logModuleCall('gofas_nfeio', 'callback db', Capsule::table('gofasnfeio')->where('nfe_id', '=', $post['id'])->count(), '', '', 'replaceVars'); +logModuleCall('gofas_nfeio', 'callback environment', $post['environment'], '', '', 'replaceVars'); if ($post) { require_once __DIR__.'/functions.php'; + if (Capsule::table('gofasnfeio')->where('nfe_id', '=', $post['id'])->count() == 0 && $post['environment'] == 'Production') { + return ''; + } + $params = []; foreach (Capsule::table('tbladdonmodules')->where('module', '=', 'gofasnfeio')->get(['setting', 'value']) as $settings) { $params[$settings->setting] = $settings->value; @@ -17,7 +23,6 @@ $nfe_for_invoice[$key] = json_decode(json_encode($value), true); } $nfe = $nfe_for_invoice['0']; - logModuleCall('gofas_nfeio', 'callback2', $nfe, '', '', 'replaceVars'); if ((string) $nfe['nfe_id'] === (string) $post['id'] and $nfe['status'] !== (string) $post['status']) { $new_nfe = [ diff --git a/modules/addons/gofasnfeio/functions.php b/modules/addons/gofasnfeio/functions.php index e71106f..2ba33c9 100644 --- a/modules/addons/gofasnfeio/functions.php +++ b/modules/addons/gofasnfeio/functions.php @@ -324,8 +324,12 @@ function gnfe_issue_nfe($postfields) curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($postfields)); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $response = curl_exec($curl); + $info =curl_getinfo($curl); curl_close($curl); - + if ($params['debug']) { + logModuleCall('gofas_nfeio', 'response', $response, '', '', 'replaceVars'); + logModuleCall('gofas_nfeio', 'info', $info, '', '', 'replaceVars'); + } return json_decode(json_encode(json_decode($response))); } }