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
+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;
}