diff --git a/wrenchboard/src/shared_tool/payments.cc b/wrenchboard/src/shared_tool/payments.cc index 961c2750..28c3ecd4 100644 --- a/wrenchboard/src/shared_tool/payments.cc +++ b/wrenchboard/src/shared_tool/payments.cc @@ -717,7 +717,7 @@ long WrenchCanceContractPayment( CVars in, CVars &out ) // TEST FOR DUPLICATE long retDb = load_db_record( out, "SELECT balance AS curr_balance FROM members WHERE id = %lu", member_id); - if (retDb) + if (retDb>0) { in["curr_balance"] =out["curr_balance"]; in["curr_balance"].set_valid( true ); // get this one LIVE } else @@ -728,7 +728,7 @@ long WrenchCanceContractPayment( CVars in, CVars &out ) CVars vw; - vw["currency"] = "NAIRA"; // this might become a variable based on the country + vw["currency"] = y["currency"]; //"N-AI-RA"; // this might become a variable based on the country vw["currency"].set_valid( true ); long wallet_id = CheckWallet(in["member_id"].Long(),vw); @@ -853,7 +853,7 @@ Foreign-key constraints: CVars vw; - vw["currency"] = out["currency"]; // ""NAIRA"; // this might become a variable based on the country + vw["currency"] = out["currency"]; // // this might become a variable based on the country vw["currency"].set_valid( true ); long wallet_id = CheckWallet(in["member_id"].Long(),vw); @@ -934,27 +934,28 @@ long WrenchRefundoffer( CVars in, CVars &out ) long offer_id = REQ_LONG( in, "offer_id", 1, -1 ); long payment_id = REQ_LONG( in, "payment_id", 1, -1 ); - CVars vw; - vw["currency"] = "NAIRA"; // this might become a variable based on the country - vw["currency"].set_valid( true ); - long wallet_id = CheckWallet(in["member_id"].Long(),vw); - - long retDb = load_db_record( out, "SELECT amount AS curr_balance FROM members_wallet WHERE member_id = %lu AND id = %lu", in["member_id"].Long(),wallet_id); - - if (retDb) - { in["curr_balance"] =out["curr_balance"]; in["curr_balance"].set_valid( true ); // get this one LIVE - } - else - { out["status"] = "Invalid user"; - return PHP_API_BAD_PARAM; - } - long retDb2 = load_db_record( out, "SELECT id AS current_payment_id, * FROM members_payments WHERE id =%lu AND what_offer = %lu AND member_id=%lu AND code = 'OFDPS' AND status = 1 AND flags = 4 AND confirmation IS NOT NULL",payment_id,offer_id,member_id); if (retDb2) { long current_payment_id = out["current_payment_id"].Long(); - + + + CVars vw; + vw["currency"] = out["currency"]; // this might become a variable based on the country + vw["currency"].set_valid( true ); + long wallet_id = CheckWallet(in["member_id"].Long(),vw); + + long retDb = load_db_record( out, "SELECT amount AS curr_balance FROM members_wallet WHERE member_id = %lu AND id = %lu", in["member_id"].Long(),wallet_id); + + if (retDb > 0) + { in["curr_balance"] =out["curr_balance"]; in["curr_balance"].set_valid( true ); // get this one LIVE + } + else + { out["status"] = "Invalid user"; + return PHP_API_BAD_PARAM; + } + CVars x; x["member_id"] = in["member_id"]; x["member_id"].set_valid( true ); x["code"] = in["code"]; x["code"].set_valid( true ); @@ -1136,11 +1137,6 @@ long WrenchSendMoneyPayment( CVars in, CVars &out ) REQ_LONG( in, "sendmoney_id", 1, -1 ); long wallet_id = REQ_LONG( in, "wallet_id", 1, -1 ); - // CVars vw; - // vw["currency"] = "NAIRA"; // this might become a variable based on the country - // vw["currency"].set_valid( true ); - //long wallet_id = CheckWallet(in["member_id"].Long(),vw); - long retDb = load_db_record( out, "SELECT amount AS curr_balance FROM members_wallet WHERE id = %lu AND member_id = %lu",wallet_id, in["member_id"].Long()); if (retDb)