first commit

This commit is contained in:
dev-chiefworks
2022-05-31 16:21:53 -04:00
commit f76abffdcd
5978 changed files with 1078901 additions and 0 deletions
+154
View File
@@ -0,0 +1,154 @@
<?php
/*
* members account imports
*/
include '../backend.php';
define("FLOAT_SYSTEM_IMPORT_ACCONTTYPES", 91010);
function Fextension_call($in, &$out) {
// logToFl("Merchant_Name count->" . $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();
accounts_benefits_importing($inX, $outX);
logToFl("Total count->" . $outX->count);
if ($outX->count > 0) {
foreach ($outX->results as $res) {
// logToFl("API Result ->".$res);
echo "Yes ---------------------------------------------- <br>";
$in = array();
$in = (array) $res;
// print_r( $in );
$in["pid"] = 100;
$in["import_id"] = $in["id"];
$out = array();
$in["action"] = FLOAT_SYSTEM_IMPORT_ACCONTTYPES;
$extension_call = true;
if ($extension_call == true && $in["member_id"] != '') {
// logToFl("merchant_name count->" . $res->merchant_name);
// echo "Here " .rand(1000,9999);
Fextension_call($in, $out);
if ($out["result_import_id"] != '' && $out["result_import_id"] > 0) {
makedimported_accounts_types($in, $out); // call back to merk transaction imported
}
}
//
} // end for each
} // if records avilable
function makedimported_accounts_types($in, &$out) {
global $savvyext;
$target_url = $savvyext->cfgReadChar('microservices.account') . "/api/v1/accounts/" . $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 accounts_benefits_importing($in, &$out) {
global $savvyext;
$target_url = $savvyext->cfgReadChar('microservices.account') . "/api/v1/accounts/?intel_imported=false"; // 
$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);
// print_r( $out );
}
function logToFl($lg_strr) {
/* $myfile = fopen("LOG/logf_benefit.txt", "a+");
$txt = $lg_strr . "\n";
fwrite($myfile, $txt);
fclose($myfile);
*
*/
}