diff --git a/mermsemr/src/include/providers.h b/mermsemr/src/include/providers.h new file mode 100644 index 0000000..c6bad7d --- /dev/null +++ b/mermsemr/src/include/providers.h @@ -0,0 +1,10 @@ +#ifndef __mx_providers_h__ +#define __mx_providers_h__ + +#include "vars.h" + +long providers_call(CVars in, CVars &out) ; + + +#endif + diff --git a/mermsemr/src/shared_tool/mermsemr_api_main.cc b/mermsemr/src/shared_tool/mermsemr_api_main.cc index 9747fea..6067c1c 100644 --- a/mermsemr/src/shared_tool/mermsemr_api_main.cc +++ b/mermsemr/src/shared_tool/mermsemr_api_main.cc @@ -13,6 +13,8 @@ main entry point for API calls Chiefsoft July 2017 */ #include "stripe_charge.h" #include "medTEmails.h" #include "medTUpload.h" +#include "providers.h" + long mermsemr_api_main(CVars in, CVars &out) { logfmt(logINFO, "long mermsemr_api_main(CVars in, CVars &out)"); @@ -20,43 +22,13 @@ long mermsemr_api_main(CVars in, CVars &out) { long action = REQ_LONG(in, "action", 0, -1); //REQ_LONG( in, "pid", 0, -1); // global implementation - who is calling try { - if (action == MEDTRANS_UPLOADS) { - return medtrans_upload(in, out); - } - if (action == MEDTRANS_DOWNLOAD) { - return medtrans_download(in, out); - } - if (action >= MEDTRANS_BKO_START && action <= MEDTRANS_BKO_END) { - return backoffice_calls(in, out); + if (action >= MERMS_PROVIDERS_START && action <= MERMS_PROVIDERS_END) { + return providers_call(in, out); } - if (action >= MEDTRANS_USER_START && action <= MEDTRANS_USER_END) { - return members_call(in, out); - } - - if (action >= MEDTRANS_INTERP_START && action <= MEDTRANS_INTERP_END) { - } - - if (action >= MEDTRANS_TRANSP_START && action <= MEDTRANS_TRANSP_END) { - return trasnporter_call(in, out); - } - - if (action >= MEDTRANS_CRON_START && action <= MEDTRANS_CRON_END) { - return cron_call(in, out); - } - - - if (action == MEDTRANS_STRIPE_CHARGE_ONE) { - return stripe_one_time_charge(in, out); - } - if (action == MEDTRANS_STRIPE_CHARGE_NEW) { - return stripe_new_customer_charge(in, out); - } - if (action == MEDTRANS_EMAIL_TEST) { - return email_test(in, out); - } + } catch (bad_parameter) { logfmt(logINFO, "ERROR CALL long mermsemr_api_main(CVars in, CVars &out)"); diff --git a/mermsemr/src/shared_tool/providers.cc b/mermsemr/src/shared_tool/providers.cc new file mode 100644 index 0000000..9abab41 --- /dev/null +++ b/mermsemr/src/shared_tool/providers.cc @@ -0,0 +1,63 @@ +// Topup management toosl +#include "clog.h" +#include "cgi.h" +#include "input.h" +#include "mermsemr_api.h" +#include "safestring.h" +#include +#include "pgsql.h" +#include "pgsql_wrapper.h" +#include +#include "medTEmails.h" + +/* -- */ +#include "function_members.h" +#include "providers.h" +#include "function_members.h" + + + + +long providers_call(CVars in, CVars &out) { + long ret = PHP_API_BAD_PARAM; + char vname[20]; + logfmt(logINFO, "ERROR CALL long providers_call(CVars in, CVars &out)"); + try { + REQ_LONG(in, "action", 0, -1); + + switch (in["action"].Long()) { + + case MERMS_PROVIDERS_LOGIN: + + REQ_STRING(in, "cardnumber", 10, 17, "(.*)"); + REQ_LONG(in, "exp_month", 0, -1); + REQ_LONG(in, "exp_year", 0, -1); + REQ_LONG(in, "cvc", 0, -1); + + ret = PHP_API_OK; + break; + + case EXISTING_CARD: + REQ_LONG(in, "paymentid", 0, -1); // now we have to make sure the payment id is valid for this customer + + break; + + + + case INVOICED: + const PGresult *res = pgsql_query("SELECT * FROM members WHERE invoiced =1 AND id=%lu", in["member_id"].Long()); + if (res != NULL && pgsql_num_rows(res) > 0) { + ret = PHP_API_OK; + } else { + out["error_status"] = "user not authorized to use invoice"; + } + break; + + } + + } catch (bad_parameter) { + logfmt(logINFO, "ERROR CALL long providers_call(CVars in, CVars &out)"); + } + return ret; +} +