commit 99307c1e59583261947c8eee137c8c8bcf36e28d
parent 6f0813ade5c844c30314047781ac8348da9467c3
Author: Marcello Stanisci <marcello.stanisci@inria.fr>
Date: Mon, 19 Jun 2017 16:09:44 +0200
finishing with /refund handlers
Diffstat:
2 files changed, 39 insertions(+), 5 deletions(-)
diff --git a/src/backend/taler-merchant-httpd_refund.c b/src/backend/taler-merchant-httpd_refund.c
@@ -227,7 +227,7 @@ MH_handler_refund_increase (struct TMH_RequestHandler *rh,
}
/**
- * FIXME: return to the frontend. The frontend will then return
+ * Return to the frontend at this point. The frontend will then return
* a "402 Payment required" carrying a "X-Taler-Refund-Url: www"
* where 'www' is the URL where the wallet can automatically fetch
* the refund permission.
diff --git a/src/lib/merchant_api_refund.c b/src/lib/merchant_api_refund.c
@@ -118,7 +118,9 @@ handle_refund_increase_finished (void *cls,
{
case 0:
/* Hard error */
- break;
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Backend didn't even return from POST /refund\n");
+ return;
case MHD_HTTP_OK:
rio->cb (rio->cb_cls,
MHD_HTTP_OK,
@@ -239,10 +241,42 @@ handle_refund_lookup_finished (void *cls,
long response_code,
const json_t *json)
{
- /**
- * TBD
- */
+ struct TALER_MERCHANT_RefundLookupOperation *rlo = cls;
+ char *error;
+ char *hint;
+ enum TALER_ErrorCode code;
+ rlo->job = NULL;
+ switch (response_code)
+ {
+ case 0:
+ /* Hard error */
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Backend didn't even return from GET /refund\n");
+ return;
+ case MHD_HTTP_OK:
+ rlo->cb (rlo->cb_cls,
+ MHD_HTTP_OK,
+ TALER_EC_NONE,
+ json);
+ break;
+ default:
+ /**
+ * The backend gave response, but it's error, log it.
+ * NOTE that json must be a Taler-specific error object (FIXME,
+ * need a link to error objects at docs)
+ */
+ json_unpack ((json_t *) json,
+ "{s:s, s:I, s:s}",
+ "error", &error,
+ "code", &code,
+ "hint", &hint);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed GET /refund, error: %s, code: %d, hint: %s\n",
+ error,
+ code,
+ hint);
+ }
}
/**