fix query
This commit is contained in:
@@ -512,6 +512,8 @@ long WrenchFlutterCreditHook(CVars in, CVars &out) {
|
||||
tx["status"] = "5"; tx["status"].set_valid(true);
|
||||
tx["tx_ref"] = xx["txRef"]; tx["tx_ref"].set_valid(true);
|
||||
tx["transaction_id"] = xx["txRef"]; tx["transaction_id"].set_valid(true);
|
||||
tx["flutterwave_payments_id"] = trx_id; tx["flutterwave_payments_id"].set_valid(true);
|
||||
|
||||
long credit_id = WrenchBoardCompleteBalanceTopup(tx, out);
|
||||
|
||||
}
|
||||
@@ -683,10 +685,12 @@ long WrenchBoardCompleteBalanceTopup(CVars in, CVars &out){
|
||||
|
||||
try {
|
||||
REQ_STRING(in, "tx_ref", 2, 50, "(.*)");
|
||||
REQ_STRING(in, "transaction_id", 2, 50, "(.*)");
|
||||
// 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 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 FROM flutterwave_payments WHERE id = %lu AND status=0",in["flutterwave_payments_id"].Long());
|
||||
if (res != NULL && pgsql_num_rows(res) > 0) {
|
||||
map<const char*, const char*>f = pgsql_fetch_assoc(res, 0);
|
||||
CVars rec;
|
||||
@@ -695,10 +699,14 @@ long WrenchBoardCompleteBalanceTopup(CVars in, CVars &out){
|
||||
in["member_id"] = rec["member_id"]; in["member_id"].set_valid( true );
|
||||
in["trx_id"] = rec["trx_id"]; in["trx_id"].set_valid( true );
|
||||
|
||||
pgsql_exec("UPDATE flutterwave_payments SET transaction_id = '%s', " \
|
||||
/* pgsql_exec("UPDATE flutterwave_payments SET transaction_id = '%s', " \
|
||||
"status=%lu,updated=now(),return_status='%s' WHERE id = %lu AND status=0 AND " \
|
||||
"tx_ref='%s' ", in["transaction_id"].c_str(),in["status"].Long(),in["return_status"].c_str(),rec["trx_id"].Long(), in["tx_ref"].c_str());
|
||||
|
||||
*/
|
||||
pgsql_exec("UPDATE flutterwave_payments SET " \
|
||||
"status=%lu,updated=now(),return_status='%s' WHERE id = %lu AND status=0 AND " \
|
||||
"tx_ref='%s' ",in["status"].Long(),in["return_status"].c_str(),rec["trx_id"].Long(), in["tx_ref"].c_str());
|
||||
|
||||
if ( in["status"].Long() == 5){
|
||||
return WrenchMemberTopupPayment( in, out ); // This start the actual crediting
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user