diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-06-21 23:52:30 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-06-21 23:52:30 +0200 |
commit | 5d3bfab13a189a5f8a94ccadf257a6a612e618dc (patch) | |
tree | 696f6b036c78044f057ea77ca7754744f7dc8dfa /src/backend/taler-merchant-httpd_post-orders-ID-pay.c | |
parent | e5c81bcae0e402877fc9b6c54f91ef9ef3267b67 (diff) | |
download | merchant-5d3bfab13a189a5f8a94ccadf257a6a612e618dc.tar.gz merchant-5d3bfab13a189a5f8a94ccadf257a6a612e618dc.tar.bz2 merchant-5d3bfab13a189a5f8a94ccadf257a6a612e618dc.zip |
add missing notifications to private-get-orders long poller
Diffstat (limited to 'src/backend/taler-merchant-httpd_post-orders-ID-pay.c')
-rw-r--r-- | src/backend/taler-merchant-httpd_post-orders-ID-pay.c | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c index 405a48e0..15f57c47 100644 --- a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c +++ b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c @@ -31,6 +31,7 @@ #include "taler-merchant-httpd_auditors.h" #include "taler-merchant-httpd_exchanges.h" #include "taler-merchant-httpd_post-orders-ID-pay.h" +#include "taler-merchant-httpd_private-get-orders.h" /** @@ -204,6 +205,11 @@ struct PayContext char *order_id; /** + * Serial number of this order in the database (set once we did the lookup). + */ + uint64_t order_serial; + + /** * Hashed proposal. */ struct GNUNET_HashCode h_contract_terms; @@ -340,9 +346,9 @@ struct PayContext int suspended; /** - * #GNUNET_YES if we already tried a forced /keys download. + * true if we already tried a forced /keys download. */ - int tried_force_keys; + bool tried_force_keys; }; @@ -772,7 +778,7 @@ process_pay_with_exchange (void *cls, { /* let's try *forcing* a re-download of /keys from the exchange. Maybe the wallet has seen /keys that we missed. */ - pc->tried_force_keys = GNUNET_YES; + pc->tried_force_keys = true; pc->fo = TMH_EXCHANGES_find_exchange (pc->current_exchange, pc->wm->wire_method, GNUNET_YES, @@ -1257,6 +1263,7 @@ begin_transaction (struct PayContext *pc) enum GNUNET_DB_QueryStatus qs; struct TMH_HandlerContext *hc = pc->hc; const char *instance_id = hc->instance->settings.id; + bool refunded; /* Avoid re-trying transactions on soft errors forever! */ if (pc->retry_counter++ > MAX_RETRIES) @@ -1345,6 +1352,7 @@ begin_transaction (struct PayContext *pc) "Merchant database error checking for refunds"); return; } + refunded = (qs > 0); /* Check if there are coins that still need to be processed */ @@ -1415,6 +1423,13 @@ begin_transaction (struct PayContext *pc) TMH_long_poll_resume (pc->order_id, hc->instance, NULL); + TMH_notify_order_change (hc->instance, + pc->order_id, + true, /* paid */ + refunded, + false, /* wired */ + pc->timestamp, + pc->order_serial); /* Generate response (payment successful) */ { @@ -1593,13 +1608,12 @@ parse_pay (struct MHD_Connection *connection, { enum GNUNET_DB_QueryStatus qs; json_t *contract_terms = NULL; - uint64_t order_serial; qs = TMH_db->lookup_contract_terms (TMH_db->cls, hc->instance->settings.id, pc->order_id, &contract_terms, - &order_serial); + &pc->order_serial); if (0 > qs) { /* single, read-only SQL statements should never cause @@ -1687,12 +1701,9 @@ parse_pay (struct MHD_Connection *connection, }; enum GNUNET_GenericReturnValue res; - /* FIXME: this is a tad wrong, as IF the contract is - malformed, the routine generates an error that blames - it on the client (400) instead of on us! */ - res = TALER_MHD_parse_json_data (connection, - contract_terms, - espec); + res = TALER_MHD_parse_internal_json_data (connection, + contract_terms, + espec); json_decref (contract_terms); if (GNUNET_YES != res) { |