Top up result
This commit is contained in:
@@ -653,29 +653,43 @@ return ret;
|
||||
}
|
||||
|
||||
long WrenchBoardTopupResult(CVars in, CVars &out){
|
||||
/*
|
||||
action
|
||||
:
|
||||
11062
|
||||
amount
|
||||
:
|
||||
555
|
||||
currency
|
||||
:
|
||||
"NGN"
|
||||
member_id
|
||||
:
|
||||
"1"
|
||||
sessionid
|
||||
:
|
||||
"72227C1650AA2D3838C448E5393B3CAD2E694A483B1C4F52C44662FE6FC01B0C"
|
||||
uid
|
||||
:
|
||||
"3119b744-42ad-4834-bb83-b737588754ca"
|
||||
*/
|
||||
logfmt(logINFO, "WrenchBoardTopupResult()");
|
||||
const PGresult *res;
|
||||
const PGresult *res0;
|
||||
long ret = PHP_API_BAD_PARAM;
|
||||
|
||||
try {
|
||||
REQ_STRING(in, "tx_ref", 2, 50, "(.*)");
|
||||
REQ_STRING(in, "uid", 3, 50, "(.*)");
|
||||
REQ_LONG(in, "member_id", 1, -1);
|
||||
|
||||
res0 = pgsql_query("SELECT * FROM members_credit WHERE uid ='%s' AND member_id=%lu",in["tx_ref"].c_str(),in["member_id"].Long());
|
||||
if (res0 != NULL && pgsql_num_rows(res0) > 0) {
|
||||
|
||||
}
|
||||
else{
|
||||
out["status_message"] = "invalid_reference_for_member";
|
||||
return PHP_API_BAD_PARAM;
|
||||
}
|
||||
|
||||
res = pgsql_query("SELECT return_status,payment_id from flutterwave_payments where transaction_id='%s'",in["tx_ref"].c_str());
|
||||
if (res != NULL && pgsql_num_rows(res) > 0) {
|
||||
map<const char*, const char*>f = pgsql_fetch_assoc(res, 0);
|
||||
CVars rec;
|
||||
map_to_cvars(f, rec);
|
||||
|
||||
out["return_status"] = rec["return_status"]; out["return_status"].set_valid( true );
|
||||
in["payment_id"] = rec["trx_id"]; in["payment_id"].set_valid( true );
|
||||
if ( in["payment_id"] !="" && in["payment_id"].Long() > 0 ){
|
||||
load_db_record( out, "SELECT confirmation FROM members_payments WHERE id = %lu", in["payment_id"].Long());
|
||||
}
|
||||
ret = PHP_API_OK;
|
||||
}
|
||||
out["status"] = "OK";
|
||||
} catch (bad_parameter) {
|
||||
logfmt(logINFO, "ERROR CALL long WrenchBoardTopupResult(CVars in, CVars &out)");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
long WrenchBoardCompleteBalanceTopup(CVars in, CVars &out){
|
||||
@@ -688,7 +702,7 @@ long WrenchBoardCompleteBalanceTopup(CVars in, CVars &out){
|
||||
// REQ_STRING(in, "transaction_id", 2, 50, "(.*)"); Handled else where
|
||||
REQ_LONG(in, "status", 1, -1);
|
||||
REQ_LONG(in, "flutterwave_payments_id", 1, -1);
|
||||
|
||||
|
||||
//res = pgsql_query("SELECT id AS trx_id,member_id FROM flutterwave_payments WHERE tx_ref = '%s' AND status=0",in["tx_ref"].c_str());
|
||||
res = pgsql_query("SELECT id AS trx_id,member_id,tx_ref FROM flutterwave_payments WHERE id = %lu AND status=0",in["flutterwave_payments_id"].Long());
|
||||
if (res != NULL && pgsql_num_rows(res) > 0) {
|
||||
|
||||
Reference in New Issue
Block a user