Card data
This commit is contained in:
@@ -13,10 +13,75 @@
|
||||
#include "creditcards.h"
|
||||
#include "stripe_charge.h"
|
||||
|
||||
/*
|
||||
|
||||
wrenchboard=> SELECT type,digits,firstname,lastname,description,uid,added_dt::date,status,active FROM creditcard WHERE active = 1 AND member_id =1;
|
||||
type | digits | firstname | lastname | description | uid | added_dt | status | active
|
||||
------+--------+-----------+----------+-------------+--------------------------------------+------------+--------+--------
|
||||
100 | 4242 | Olusesan | Last11 | Visa | 8d646ac6-afb8-4371-9e78-265a195971cc | 2023-06-18 | 3 | 1
|
||||
100 | 4242 | Olusesan | Last11 | Visa | b36d494a-0b25-4066-b0e7-e33db889f9ed | 2023-06-18 | 3 | 1
|
||||
100 | 4242 | Olusesan | Last11 | Visa | 12bf0b82-b20d-4358-8373-74f0133c5001 | 2023-06-18 | 3 | 1
|
||||
100 | 4242 | Olusesan | Last11 | Visa | a1ea56d1-ba2d-4125-a6ad-306874a672dc | 2023-06-18 | 3 | 1
|
||||
100 | 4242 | Olusesan | Last11 | Visa | 97e6a9ac-cbae-4ec4-baaa-c03abd5a01d2 | 2023-06-19 | 3 | 1
|
||||
100 | 4242 | Olusesan | Last11 | Visa | 55aa3bfe-4bf0-4dee-8133-8f3114c32207 | 2023-06-19 | 3 | 1
|
||||
(6 rows)
|
||||
|
||||
|
||||
*/
|
||||
long WrenchUsersCCardList(CVars in, CVars &out) {
|
||||
logfmt(FLOG_MAX, "long WrenchUsersCCardList(CVars in, CVars &out)" );
|
||||
char vname[30];
|
||||
long ret = PHP_API_BAD_PARAM;
|
||||
|
||||
try {
|
||||
REQ_LONG(in, "member_id", 1, -1);
|
||||
REQ_STRING(in, "uid", 3, 55, "(.*)"); //234"
|
||||
|
||||
out["total_record"] = "0";
|
||||
const PGresult *res;
|
||||
res = pgsql_query("SELECT type,digits,firstname,lastname,description,uid,added_dt::date,status,active FROM creditcard WHERE active = 1 AND member_id = %lu", in["member_id"].Long());
|
||||
|
||||
if (res != NULL && pgsql_num_rows(res) > 0) {
|
||||
out["total_record"] = pgsql_num_rows(res);
|
||||
|
||||
for (int i = 0, n = pgsql_num_rows(res); i < n; i++) {
|
||||
map<const char*, const char*>f = pgsql_fetch_assoc(res, i);
|
||||
if (f.empty()) continue;
|
||||
CVars rec;
|
||||
map_to_cvars(f, rec);
|
||||
|
||||
snprintf(vname, sizeof (vname), "type_%05d", i);
|
||||
out[vname] = rec["type"];
|
||||
|
||||
snprintf(vname, sizeof (vname), "digits_%05d", i);
|
||||
out[vname] = rec["digits"];
|
||||
|
||||
snprintf(vname, sizeof (vname), "firstname_%05d", i);
|
||||
out[vname] = rec["firstname"];
|
||||
|
||||
snprintf(vname, sizeof (vname), "lastname_%05d", i);
|
||||
out[vname] = rec["lastname"];
|
||||
|
||||
snprintf(vname, sizeof (vname), "description_%05d", i);
|
||||
out[vname] = rec["description"];
|
||||
|
||||
snprintf(vname, sizeof (vname), "added_%05d", i);
|
||||
out[vname] = rec["added_dt"];
|
||||
|
||||
snprintf(vname, sizeof (vname), "card_uid_%05d", i);
|
||||
out[vname] = rec["uid"];
|
||||
|
||||
snprintf(vname, sizeof (vname), "active_%05d", i);
|
||||
out[vname] = rec["active"];
|
||||
}
|
||||
}
|
||||
ret = PHP_API_OK;
|
||||
out["status"] = "OK";
|
||||
} catch (bad_parameter) {
|
||||
logfmt(logINFO, "ERROR CALL long WrenchUsersCCardList(CVars in, CVars &out)");
|
||||
}
|
||||
|
||||
logfmt(FLOG_MAX, "/long save_creditcard(CVars in, CVars &out)" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user