diff options
Diffstat (limited to 'src/exchange')
| -rw-r--r-- | src/exchange/taler-exchange-httpd.c | 62 | ||||
| -rw-r--r-- | src/exchange/taler-exchange-httpd_deposit.c | 15 |
2 files changed, 66 insertions, 11 deletions
diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c index d97c68e3..32cbd8dd 100644 --- a/src/exchange/taler-exchange-httpd.c +++ b/src/exchange/taler-exchange-httpd.c @@ -1070,18 +1070,32 @@ handle_get_extensions (struct TEH_RequestContext *rc, "/extensions/$EXTENSION unknown"); } - if (NULL == ext->http_get_handler) + if (NULL == ext->policy_get_handler) return TALER_MHD_reply_with_error (rc->connection, MHD_HTTP_NOT_IMPLEMENTED, TALER_EC_EXCHANGE_GENERIC_OPERATION_UNKNOWN, "GET /extensions/$EXTENSION not supported"); - return ext->http_get_handler ( + return ext->policy_get_handler ( rc->connection, &args[1]); } +/* @brief function pointer for TALER_extension.check */ +static enum GNUNET_GenericReturnValue +check_serial_ids ( + struct GNUNET_HashCode serial_ids[], + size_t size) +{ + for (size_t i = 0; i < size; i++) + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Got to check serial_id: %s\n", + GNUNET_h2s (&serial_ids[i])); + return GNUNET_OK; +} + + /** * Handle POST "/extensions/..." requests. * @@ -1096,6 +1110,7 @@ handle_post_extensions (struct TEH_RequestContext *rc, const char *const args[]) { const struct TALER_Extension *ext = NULL; + json_t *output; if (NULL == args[0]) { @@ -1112,16 +1127,49 @@ handle_post_extensions (struct TEH_RequestContext *rc, "/extensions/$EXTENSION unknown"); } - if (NULL == ext->http_post_handler) + if (NULL == ext->policy_post_handler) return TALER_MHD_reply_with_error (rc->connection, MHD_HTTP_NOT_IMPLEMENTED, TALER_EC_EXCHANGE_GENERIC_OPERATION_UNKNOWN, "POST /extensions/$EXTENSION not supported"); - return ext->http_post_handler ( - rc->connection, - root, - &args[1]); + { + enum GNUNET_GenericReturnValue ret; + struct TALER_PolicyFulfilmentOutcome *outcome; + + ret = ext->policy_post_handler (root, + &args[1], + &check_serial_ids, + &outcome, + &output); + + if (GNUNET_OK != ret) + { + TALER_policy_fulfilment_outcome_free (outcome); + TALER_MHD_reply_json_steal ( + rc->connection, + output, + MHD_HTTP_BAD_REQUEST); + } + + /* TODO: deal with outcome */ + { + for (size_t i = 0; i < outcome->len; i++) + { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Got outcome for serial_id: %s, state: %s, amount: %s\n", + GNUNET_h2s (&outcome->positions[i].serial_id), + TALER_policy_fulfilment_state_str ( + outcome->positions[i].state), + TALER_amount_to_string (&outcome->positions[i].new_amount)); + } + } + + } + + return TALER_MHD_reply_json_steal (rc->connection, + output, + MHD_HTTP_OK); } diff --git a/src/exchange/taler-exchange-httpd_deposit.c b/src/exchange/taler-exchange-httpd_deposit.c index 5d38de82..12741c6b 100644 --- a/src/exchange/taler-exchange-httpd_deposit.c +++ b/src/exchange/taler-exchange-httpd_deposit.c @@ -337,15 +337,22 @@ TEH_handler_deposit (struct MHD_Connection *connection, if (deposit.has_policy_details) { const char *error_hint = NULL; + enum TALER_PolicyFulfilmentState state_on_timeout; + if (GNUNET_OK != - TALER_extensions_serial_from_policy_details (deposit.policy_details, - &deposit.policy_serial_id, - &deposit.policy_deadline, - &error_hint)) + TALER_extensions_extract_meta_data_from_policy_details ( + deposit.policy_details, + &deposit.policy_serial_id, + &deposit.policy_deadline, + &state_on_timeout, + &error_hint)) return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, TALER_EC_EXCHANGE_DEPOSITS_POLICY_NOT_ACCEPTED, error_hint); + + GNUNET_assert (TALER_PolicyFulfilmentStateMax >= state_on_timeout); + deposit.policy_state_on_timeout = state_on_timeout; } /* new deposit */ |
