diff options
Diffstat (limited to 'src/backend/taler-merchant-httpd_post-orders-ID-abort.c')
-rw-r--r-- | src/backend/taler-merchant-httpd_post-orders-ID-abort.c | 53 |
1 files changed, 44 insertions, 9 deletions
diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-abort.c b/src/backend/taler-merchant-httpd_post-orders-ID-abort.c index 7ac1665d..1498bcac 100644 --- a/src/backend/taler-merchant-httpd_post-orders-ID-abort.c +++ b/src/backend/taler-merchant-httpd_post-orders-ID-abort.c @@ -57,6 +57,18 @@ struct RefundDetails struct TALER_CoinSpendPublicKeyP coin_pub; /** + * Signature from the exchange confirming the refund. + * Set if we were successful (status 200). + */ + struct TALER_ExchangeSignatureP exchange_sig; + + /** + * Public key used for @e exchange_sig. + * Set if we were successful (status 200). + */ + struct TALER_ExchangePublicKeyP exchange_pub; + + /** * Reference to the main AbortContext */ struct AbortContext *ac; @@ -348,15 +360,31 @@ generate_success_response (struct AbortContext *ac) for (unsigned int i = 0; i<ac->coins_cnt; i++) { struct RefundDetails *rdi = &ac->rd[i]; - - if (0 != - json_array_append_new ( - refunds, - json_pack ("{s:I, s:O}", - "exchange_http_status", - (json_int_t) rdi->http_status, - "exchange_reply", - rdi->exchange_reply))) + json_t *detail; + + detail = (MHD_HTTP_OK != rdi->http_status) + ? json_pack ("{s:s, s:I, s:I, s:O}", + "type", + "failure", + "exchange_status", + (json_int_t) rdi->http_status, + "exchange_code", + (json_int_t) TALER_JSON_get_error_code ( + rdi->exchange_reply), + "exchange_reply", + rdi->exchange_reply) + : json_pack ("{s:s, s:I, s:o, s:o}", + "type", + "success", + "exchange_status", + (json_int_t) rdi->http_status, + "exchange_sig", + GNUNET_JSON_from_data_auto (&rdi->exchange_sig), + "exchange_pub", + GNUNET_JSON_from_data_auto (&rdi->exchange_pub)); + if ( (NULL == detail) || + (0 != json_array_append_new (refunds, + detail)) ) { json_decref (refunds); GNUNET_break (0); @@ -455,6 +483,13 @@ refund_cb (void *cls, rd->rh = NULL; rd->http_status = hr->http_status; rd->exchange_reply = json_incref ((json_t*) hr->reply); + if (MHD_HTTP_OK == hr->http_status) + { + GNUNET_assert (NULL != sign_key); + GNUNET_assert (NULL != signature); + rd->exchange_pub = *sign_key; + rd->exchange_sig = *signature; + } ac->pending_at_ce--; if (0 == ac->pending_at_ce) find_next_exchange (ac); |