" . $in["merchant_name"]); global $savvyext; $out = $savvyext->savvyext_api($in); $ret = $out["retval"]; return $ret; } $inX["limit"] = 250; $inX["offset"] = 0; $inX["intel_imported"] = 'false'; $outX=array(); import_accounts_transactions($inX, $outX); // test_import_accounts_transactions($inX, $outX); // just for testing -- to be removed logToFl("Total count->".$outX->count); if ($outX->count > 0) { foreach ($outX->results as $res) { $in = array(); $in["pid"] =100; $in["import_id"] = $res->id; $in["account"] = $res->account; $in["member_id"] = $res->member_id; $in["amount"] = (int)(100.0*$res->amount); $in["currency"] = $res->currency; $in["description"] = $res->description; $in["time"] = $res->time; $in["category"] = $res->category; $in["provider_category"] = $res->provider_category; $in["intel_imported"] = $res->intel_imported; $in["merchant_provider_id"] = $res->merchant_provider_id; $in["merchant_name"] = $res->merchant_name; $in["status"] = isset($res->status) ? $res->status : "0"; $in["fake"] = isset($res->extra->fake) ? $res->extra->fake : false; $in["mode"] = isset($res->extra->mode) ? $res->extra->mode : ""; $in["duplicated"] = isset($res->extra->duplicated) ? $res->extra->duplicated : false; $out = array(); $in["action"] = FLOAT_SYSTEM_IMPORT_TRANSACTIONS; $extension_call = true; if ($extension_call == true && $in["member_id"] !='') { // logToFl("merchant_name count->" . $res->merchant_name); Fextension_call($in, $out); } makedimported_accounts_transactions($in, $out); // call back to merk transaction imported } // end for each } // if records avilable function makedimported_accounts_transactions($in, &$out) { global $savvyext; $target_url = $savvyext->cfgReadChar('microservices.account') . "/api/v1/transactions/".$in["import_id"]."/"; // $fields_string = ""; //url-ify the data for the POST foreach ($in as $key => $value) { $fields_string .= $key . '=' . $value . '&'; } rtrim($fields_string, '&'); // $target_url = $target_url . "/?" . $fields_string; $returnData = json_encode( [ "intel_imported"=> date("Y-m-d H:i:s") ] ); //open connection $ch = curl_init(); //set the url, number of POST vars, POST data curl_setopt($ch, CURLOPT_URL, $target_url); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Connection: Keep-Alive', 'Authorization: Server-Token ' . $savvyext->cfgReadChar('system.bank_token'), 'Accept: application/json' )); // curl_setopt($ch, CURLOPT_POST, count($in)); curl_setopt($ch, CURLOPT_POSTFIELDS, $returnData); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //execute post $result = curl_exec($ch); //close connection curl_close($ch); //logToFl("API Result ->".$result); $out = json_decode($result); } function import_accounts_transactions($in, &$out) { global $savvyext; $target_url = $savvyext->cfgReadChar('microservices.account') . "/api/v1/transactions"; // $fields_string = ""; //url-ify the data for the POST foreach ($in as $key => $value) { $fields_string .= $key . '=' . $value . '&'; } rtrim($fields_string, '&'); $target_url = $target_url . "/?" . $fields_string; logToFl("API URL ->".$target_url); //open connection $ch = curl_init(); //set the url, number of POST vars, POST data curl_setopt($ch, CURLOPT_URL, $target_url); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Connection: Keep-Alive', 'Authorization: Server-Token ' . $savvyext->cfgReadChar('system.bank_token'), 'Accept: application/json' )); // curl_setopt($ch, CURLOPT_POST, count($in)); // curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //execute post $result = curl_exec($ch); //close connection curl_close($ch); //logToFl("API Result ->".$result); $out = json_decode($result); } function test_import_accounts_transactions($in, &$out) { $target_url = "http://chiefsoft.net/DATA/transactions.php"; // $fields_string = ""; //url-ify the data for the POST foreach ($in as $key => $value) { $fields_string .= $key . '=' . $value . '&'; } rtrim($fields_string, '&'); $target_url = $target_url . "/?" . $fields_string; //open connection $ch = curl_init(); //set the url, number of POST vars, POST data curl_setopt($ch, CURLOPT_URL, $target_url); // curl_setopt($ch, CURLOPT_POST, count($in)); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //execute post $result = curl_exec($ch); //close connection curl_close($ch); //logToFl("Result ->".$result); $out = json_decode($result); // Parse result /* foreach (explode("\n", $result) as $line) { if ($line == "" || strpos($line, "=") === false) continue; $key = trim(strtok($line, "=")); if ($key != "") { $out[$key] = base64_decode(substr($line, 1 + strlen($key))); } } * */ } function logToFl($lg_strr) { $myfile = fopen("LOG/logf.txt", "a+"); $txt = $lg_strr."\n"; fwrite($myfile, $txt); fclose($myfile); }