diff options
author | Christian Grothoff <christian@grothoff.org> | 2023-02-21 13:00:53 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2023-02-21 13:00:53 +0100 |
commit | c1976d63028260964cf0eda49ab7b6892e23c647 (patch) | |
tree | 860044c2c721f70dd20f672eb3589a6de222eaba | |
parent | 3a9bfda488bb649e47b58ccd11b605b21ed17eb8 (diff) |
-update pay to return confirmation code
-rw-r--r-- | src/backend/taler-merchant-httpd_post-orders-ID-pay.c | 26 |
1 files changed, 24 insertions, 2 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 e9f7895d..9b9b1a00 100644 --- a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c +++ b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c @@ -1,6 +1,6 @@ /* This file is part of TALER - (C) 2014-2022 Taler Systems SA + (C) 2014-2023 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -368,6 +368,16 @@ struct PayContext struct GNUNET_TIME_Timestamp pay_deadline; /** + * Set to the POS key, if applicable for this order. + */ + char *pos_key; + + /** + * Algorithm chosen for generating the confirmation code. + */ + enum TALER_MerchantConfirmationAlgorithm pos_alg; + + /** * Number of transactions that the wire fees are expected to be * amortized over. Never zero, defaults (conservateively) to 1. * May be higher if merchants expect many small transactions to @@ -716,6 +726,7 @@ pay_context_cleanup (void *cls) GNUNET_CONTAINER_DLL_remove (pc_head, pc_tail, pc); + GNUNET_free (pc->pos_key); GNUNET_free (pc); } @@ -1947,6 +1958,7 @@ static void generate_success_response (struct PayContext *pc) { struct GNUNET_CRYPTO_EddsaSignature sig; + char *pos_confirmation; /* Sign on our end (as the payment did go through, even if it may have been refunded already) */ @@ -1954,12 +1966,22 @@ generate_success_response (struct PayContext *pc) &pc->hc->instance->merchant_priv, &sig); /* Build the response */ + pos_confirmation = (NULL == pc->pos_key) + ? NULL + : TALER_build_pos_confirmation (pc->pos_key, + pc->pos_alg, + &pc->total_paid, + pc->timestamp); resume_pay_with_response ( pc, MHD_HTTP_OK, TALER_MHD_MAKE_JSON_PACK ( + GNUNET_JSON_pack_allow_null ( + GNUNET_JSON_pack_string ("pos_confirmation", + pos_confirmation)), GNUNET_JSON_pack_data_auto ("sig", &sig))); + GNUNET_free (pos_confirmation); } @@ -2563,7 +2585,7 @@ check_contract (struct PayContext *pc) &pc->contract_terms, &pc->order_serial, &paid, - NULL); + NULL); // FIXME: add &pc->pos_key + &pc->pos_alg! if (0 > qs) { /* single, read-only SQL statements should never cause |