summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-05-18 18:12:23 +0200
committerChristian Grothoff <christian@grothoff.org>2022-05-18 18:12:23 +0200
commitcb081e0d19d9fa945b1d8cf2487aa25b9d6404da (patch)
treef12592b9928ab8767e6570e92ad1bc4be3626ddd /src
parent55319d8dd2bc1d9fd58864cedcb1d5b2024a45f6 (diff)
downloadtaler-mdb-cb081e0d19d9fa945b1d8cf2487aa25b9d6404da.tar.gz
taler-mdb-cb081e0d19d9fa945b1d8cf2487aa25b9d6404da.tar.bz2
taler-mdb-cb081e0d19d9fa945b1d8cf2487aa25b9d6404da.zip
use pack
Diffstat (limited to 'src')
-rw-r--r--src/main.c53
1 files changed, 30 insertions, 23 deletions
diff --git a/src/main.c b/src/main.c
index c6ab55d..5fbd355 100644
--- a/src/main.c
+++ b/src/main.c
@@ -73,6 +73,16 @@ along with
#define BACKEND_POLL_TIMEOUT GNUNET_TIME_relative_multiply ( \
GNUNET_TIME_UNIT_MINUTES, 5)
+/**
+ * How long could it take at most for us to notify the Taler merchant
+ * backend to grant a refund to a user if dispensing the product
+ * failed? (Very conservative value here, for vending machines brewing
+ * coffee or something complex that could fail.)
+ */
+#define MAX_REFUND_DELAY GNUNET_TIME_relative_multiply ( \
+ GNUNET_TIME_UNIT_MINUTES, 5)
+
+
#define NFC_FAILURE_RETRY_FREQ GNUNET_TIME_UNIT_SECONDS
/**
@@ -92,15 +102,6 @@ along with
GNUNET_TIME_UNIT_MILLISECONDS, 500)
/**
- * How long could it take at most for us to notify the Taler merchant
- * backend to grant a refund to a user if dispensing the product
- * failed? (Very conservative value here, for vending machines brewing
- * coffee or something complex that could fail.)
- */
-#define MAX_REFUND_DELAY GNUNET_TIME_relative_multiply ( \
- GNUNET_TIME_UNIT_MINUTES, 5)
-
-/**
* Code returned by libnfc in case of success.
*/
#define APDU_SUCCESS "\x90\x00"
@@ -1560,20 +1561,26 @@ launch_payment (struct Product *product)
/* create the json object for the order request */
if (NULL != product->preview)
{
- orderReq = json_pack (
- "{ s:s, s:[ { s:s, s:s, s:o, s:I } ], s:o, s:s, s:o }",
- "summary", product->description,
- "products",
- /* */ "description", product->description,
- /* */ "image", product->preview,
- /* */ "price", TALER_JSON_from_amount (
- &product->price),
- /* */ "quantity", (json_int_t) 1,
- "amount", TALER_JSON_from_amount (&product->price),
- "fulfillment_message", msg,
- "auto_refund", GNUNET_JSON_from_time_rel (
- MAX_REFUND_DELAY)
- );
+ orderReq = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_string ("summary",
+ product->description),
+ GNUNET_JSON_pack_object_steal (
+ "products",
+ GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_string ("description",
+ product->description),
+ GNUNET_JSON_pack_string ("image",
+ product->preview),
+ TALER_JSON_pack_amount ("price",
+ &product->price),
+ GNUNET_JSON_pack_uint64 ("quantity",
+ 1))),
+ TALER_JSON_pack_amount ("amount",
+ &product->price),
+ GNUNET_JSON_pack_string ("fulfillment_message",
+ msg),
+ GNUNET_JSON_pack_time_rel ("auto_refund",
+ MAX_REFUND_DELAY));
}
else
{