Backend Provider added

This commit is contained in:
2019-03-03 22:59:30 +00:00
parent 5680845ed3
commit 2247e5eb3a
3 changed files with 78 additions and 33 deletions
+10
View File
@@ -0,0 +1,10 @@
#ifndef __mx_providers_h__
#define __mx_providers_h__
#include "vars.h"
long providers_call(CVars in, CVars &out) ;
#endif
+5 -33
View File
@@ -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)");
+63
View File
@@ -0,0 +1,63 @@
// Topup management toosl
#include "clog.h"
#include "cgi.h"
#include "input.h"
#include "mermsemr_api.h"
#include "safestring.h"
#include <string>
#include "pgsql.h"
#include "pgsql_wrapper.h"
#include <curl/curl.h>
#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;
}