diff --git a/wrenchboard/src/shared_tool/payments.cc b/wrenchboard/src/shared_tool/payments.cc index d2aef3d9..25c41860 100644 --- a/wrenchboard/src/shared_tool/payments.cc +++ b/wrenchboard/src/shared_tool/payments.cc @@ -164,25 +164,20 @@ long WrenchFamilyPayment( CVars in, CVars &out ) long retDb2 = load_db_record( out, "SELECT * FROM family_transfer " - " WHERE member_id = %lu AND currency ='%s' AND id = %lu AND active IS NULL", in["member_id"].Long(), in["currency"].c_str(),transfer_id ); + " WHERE member_id = %lu AND currency ='%s' AND id = %lu AND status = 1 ", in["member_id"].Long(), in["currency"].c_str(),transfer_id ); if (retDb2>0) { in["coupon_amount"] =out["amount"]; in["coupon_amount"].set_valid( true ); CVars x; x["member_id"] = member_id; x["member_id"].set_valid( true ); - x["code"] = "COUP"; x["code"].set_valid( true ); - x["dir"] = "1"; x["dir"].set_valid( true ); + x["code"] = "FAMDE"; x["code"].set_valid( true ); + x["dir"] = "0"; x["dir"].set_valid( true ); x["loc"] = in["loc"]; x["loc"].set_valid( true ); - x["curr_balance"] = in["curr_balance"]; x["curr_balance"].set_valid( true ); x["amount"] = in["coupon_amount"]; x["amount"].set_valid( true ); x["fee"] = "0"; x["fee"].set_valid( true ); - - // x["what_offer"] = offer_id; x["what_offer"].set_valid( true ); - x["what_coupon"] = code_id; x["what_coupon"].set_valid( true ); // assign coupon id - - + x["what_family_transfer"] = transfer_id; x["what_family_transfer"].set_valid( true ); x["flags"] = FLAG_INIT; x["flags"].set_valid( true ); // starting the pprocess payment_id = 0; // insert_db_record( DBS_VALID, "members_payments", "members_payments_id_seq", x ); @@ -192,14 +187,12 @@ long WrenchFamilyPayment( CVars in, CVars &out ) // now generate the confirmation char confirmation[15] = ""; Confirmation(payment_id, confirmation, sizeof (confirmation)); // this stamp the offer code directly in that call - - UpdateMemberWallet( x["member_id"].Long(), wallet_id,x["amount"].Long(), payment_id); // correct this dont send amount - + DeductMemberWallet( x["member_id"].Long(), wallet_id,x["amount"].Long(), payment_id); // correct this dont send amount x["flags"] = FLAG_OK; x["flags"].set_valid( true ); x["payment_id"] = payment_id; x["payment_id"].set_valid( true ); pgsql_exec("UPDATE members_payments SET flags = %lu WHERE id = %lu",x["flags"].Long(),payment_id ); - pgsql_exec("UPDATE family_transfer SET active = now() WHERE id = %lu AND CODE='%s' ",code_id,in["code"].c_str() ); - load_db_record( out, "SELECT * FROM family_transfer WHERE id = %lu ", payment_id ); + pgsql_exec("UPDATE family_transfer SET pay_confirm = now() WHERE id = %lu ",confirmation, transfer_id ); + load_db_record( out, "SELECT * FROM family_transfer WHERE id = %lu ", payment_id ); } else { out["status"] = "Unable to create payment"; }