Skip to content

Commit

Permalink
add log no envio para a api e checagem do callback
Browse files Browse the repository at this point in the history
  • Loading branch information
JoaoVictorLNacional committed Jan 15, 2021
1 parent d3dc809 commit 101e2f1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion modules/addons/gofasnfeio/callback.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 = [
Expand Down
6 changes: 5 additions & 1 deletion modules/addons/gofasnfeio/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}
}
Expand Down

0 comments on commit 101e2f1

Please sign in to comment.