diff options
author | Florian Dold <florian.dold@gmail.com> | 2019-08-30 14:41:56 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2019-08-30 14:41:56 +0200 |
commit | 87f78ab077166b90d087f69219db9c24dd5569ce (patch) | |
tree | 0336dbcbb6107382780fa4b765a6b4368301bc66 | |
parent | 3ad285a1c7fed72f78f8726fc6c9b6884d290806 (diff) | |
download | merchant-87f78ab077166b90d087f69219db9c24dd5569ce.tar.gz merchant-87f78ab077166b90d087f69219db9c24dd5569ce.tar.bz2 merchant-87f78ab077166b90d087f69219db9c24dd5569ce.zip |
return amount_left of tip to wallet
-rw-r--r-- | src/backend/taler-merchant-httpd_tip-pickup.c | 8 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_tip-pickup.h | 20 | ||||
-rw-r--r-- | src/backenddb/plugin_merchantdb_postgres.c | 9 | ||||
-rw-r--r-- | src/backenddb/test_merchantdb.c | 2 | ||||
-rw-r--r-- | src/include/taler_merchantdb_plugin.h | 2 |
5 files changed, 37 insertions, 4 deletions
diff --git a/src/backend/taler-merchant-httpd_tip-pickup.c b/src/backend/taler-merchant-httpd_tip-pickup.c index 9d72b810..3d26c634 100644 --- a/src/backend/taler-merchant-httpd_tip-pickup.c +++ b/src/backend/taler-merchant-httpd_tip-pickup.c @@ -399,7 +399,7 @@ prepare_pickup (struct PickupContext *pc) qs = db->lookup_tip_by_id (db->cls, &pc->tip_id, &pc->exchange_url, - NULL, NULL, NULL); + NULL, NULL, NULL, NULL); if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) { unsigned int response_code; @@ -624,6 +624,7 @@ MH_handler_tip_pickup_get (struct TMH_RequestHandler *rh, json_t *extra; struct GNUNET_HashCode tip_id; struct TALER_Amount tip_amount; + struct TALER_Amount tip_amount_left; int ret; int qs; @@ -665,7 +666,9 @@ MH_handler_tip_pickup_get (struct TMH_RequestHandler *rh, &tip_id, &exchange_url, &extra, - &tip_amount, NULL); + &tip_amount, + &tip_amount_left, + NULL); if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) { @@ -702,6 +705,7 @@ MH_handler_tip_pickup_get (struct TMH_RequestHandler *rh, "{s:s, s:o}", "exchange_url", exchange_url, "amount", TALER_JSON_from_amount (&tip_amount), + "amount_left", TALER_JSON_from_amount (&tip_amount_left), "extra", extra); GNUNET_free (exchange_url); diff --git a/src/backend/taler-merchant-httpd_tip-pickup.h b/src/backend/taler-merchant-httpd_tip-pickup.h index da42eaa6..181725a7 100644 --- a/src/backend/taler-merchant-httpd_tip-pickup.h +++ b/src/backend/taler-merchant-httpd_tip-pickup.h @@ -24,7 +24,7 @@ #include "taler-merchant-httpd.h" /** - * Manages a /tip-pickup call, checking that the tip is authorized, + * Manages a POST /tip-pickup call, checking that the tip is authorized, * and if so, returning the withdrawal permissions. * * @param rh context of the handler @@ -41,4 +41,22 @@ MH_handler_tip_pickup (struct TMH_RequestHandler *rh, const char *upload_data, size_t *upload_data_size); +/** + * Manages a GET /tip-pickup call. + * + * @param rh context of the handler + * @param connection the MHD connection to handle + * @param[in,out] connection_cls the connection's closure (can be updated) + * @param upload_data upload data + * @param[in,out] upload_data_size number of bytes (left) in @a upload_data + * @return MHD result code + */ +int +MH_handler_tip_pickup_get (struct TMH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size); + + #endif diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c index 2b2c016a..961bac26 100644 --- a/src/backenddb/plugin_merchantdb_postgres.c +++ b/src/backenddb/plugin_merchantdb_postgres.c @@ -668,6 +668,8 @@ postgres_initialize (void *cls) ",timestamp" ",amount_val" ",amount_frac" + ",left_val" + ",left_frac" " FROM merchant_tips" " WHERE tip_id=$1", 1), @@ -3343,6 +3345,7 @@ postgres_authorize_tip_TR (void *cls, * @param[out] exchange_url set to the URL of the exchange (unless NULL) * @param[out] extra extra data to pass to the wallet (unless NULL) * @param[out] amount set to the authorized amount (unless NULL) + * @param[out] amount_left set to the amount left (unless NULL) * @param[out] timestamp set to the timestamp of the tip authorization (unless NULL) * @return transaction status, usually * #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT for success @@ -3354,12 +3357,14 @@ postgres_lookup_tip_by_id (void *cls, char **exchange_url, json_t **extra, struct TALER_Amount *amount, + struct TALER_Amount *amount_left, struct GNUNET_TIME_Absolute *timestamp) { struct PostgresClosure *pg = cls; char *res_exchange_url; json_t *res_extra; struct TALER_Amount res_amount; + struct TALER_Amount res_amount_left; struct GNUNET_TIME_Absolute res_timestamp; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (tip_id), @@ -3374,6 +3379,8 @@ postgres_lookup_tip_by_id (void *cls, &res_extra), TALER_PQ_RESULT_SPEC_AMOUNT ("amount", &res_amount), + TALER_PQ_RESULT_SPEC_AMOUNT ("left", + &res_amount_left), GNUNET_PQ_result_spec_end }; enum GNUNET_DB_QueryStatus qs; @@ -3392,6 +3399,8 @@ postgres_lookup_tip_by_id (void *cls, *exchange_url = strdup (res_exchange_url); if (NULL != amount) *amount = res_amount; + if (NULL != amount_left) + *amount_left = res_amount_left; if (NULL != timestamp) *timestamp = res_timestamp; if (NULL != extra) diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c index 89732f5c..84a100c3 100644 --- a/src/backenddb/test_merchantdb.c +++ b/src/backenddb/test_merchantdb.c @@ -612,7 +612,7 @@ test_tipping () plugin->lookup_tip_by_id (plugin->cls, &tip_id, &url, - NULL, NULL, NULL)) + NULL, NULL, NULL, NULL)) { GNUNET_break (0); return GNUNET_SYSERR; diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h index c7009ad7..04fb2664 100644 --- a/src/include/taler_merchantdb_plugin.h +++ b/src/include/taler_merchantdb_plugin.h @@ -753,6 +753,7 @@ struct TALER_MERCHANTDB_Plugin * @param[out] exchange_url set to the URL of the exchange (unless NULL) * @param[out] extra extra data to pass to the wallet * @param[out] amount set to the authorized amount (unless NULL) + * @param[out] amount_left set to the amount left (unless NULL) * @param[out] timestamp set to the timestamp of the tip authorization (unless NULL) * @return transaction status, usually * #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT for success @@ -764,6 +765,7 @@ struct TALER_MERCHANTDB_Plugin char **exchange_url, json_t **extra, struct TALER_Amount *amount, + struct TALER_Amount *amount_left, struct GNUNET_TIME_Absolute *timestamp); |