start credit

This commit is contained in:
CHIEFSOFT\ameye
2023-11-26 22:31:27 -05:00
parent 4d0a6d3e27
commit 2e95be6dfe
+14 -5
View File
@@ -463,6 +463,8 @@ long WrenchStartPayment( CVars in, CVars &out ){
long amount = REQ_LONG( in, "amount", 1, -1 );
REQ_STRING (in, "currency", 2, 10, "(.*)");
REQ_STRING(in, "uid", 3, 150, "(.*)");
OPTIONAL(in, "card_uid") REQ_STRING(in, "card_uid", 3, 150, "(.*)");
const PGresult *res = pgsql_query("SELECT uid,id AS member_id FROM members WHERE id=%lu AND uid='%s'", member_id, in["uid"].c_str());
if (res != NULL && pgsql_num_rows(res) > 0) {
map<const char*, const char*>f = pgsql_fetch_assoc(res, 0);
@@ -484,15 +486,22 @@ long WrenchStartPayment( CVars in, CVars &out ){
xx["amount"].set_valid(true);
xx["currency"] = in["currency"];
xx["currency"].set_valid(true);
xx["card_uid"] = in["card_uid"];
xx["card_uid"].set_valid(true);
out["credit_ref_no"] = "0";
out["credit_ref_no"] = insert_db_record(DBS_VALID, "members_credit", "members_credit_id_seq", xx);
if ( out["credit_ref_no"].Long() > 0) {
load_db_record( out, "SELECT uid AS credit_reference, fee, currency "
" FROM members_credit WHERE member_id = %lu AND id=%lu ", member_id, out["credit_ref_no"].Long());
out["status"] = "OK";
out["flutterwave_key"] = CfgReadChar("flutterwave.public_key");
ret = PHP_API_OK;
if( load_db_record( out, "SELECT uid AS credit_reference, fee, currency "
" FROM members_credit WHERE member_id = %lu AND id=%lu ", member_id, out["credit_ref_no"].Long())> 0){
out["total"].Long() = out["amount"].Long() + out["fee"].Long();
out["status"] = "OK";
out["flutterwave_key"] = CfgReadChar("flutterwave.public_key");
ret = PHP_API_OK;
}
}
} catch (bad_parameter) {