summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-08-24 14:20:14 +0200
committerChristian Grothoff <christian@grothoff.org>2020-08-24 14:20:14 +0200
commite919344cc2bf38326abc4c31b5753dcbdaff8e5a (patch)
tree5117f94510e1ef61ed2f923f1633a10e5e566c92 /src
parente2dccbdda2e085b011218f59a7f18aa0e792cf12 (diff)
downloadtaler-mdb-e919344cc2bf38326abc4c31b5753dcbdaff8e5a.tar.gz
taler-mdb-e919344cc2bf38326abc4c31b5753dcbdaff8e5a.tar.bz2
taler-mdb-e919344cc2bf38326abc4c31b5753dcbdaff8e5a.zip
substitute PRODUCT_DESCRIPTION in fulfillment-msg
Diffstat (limited to 'src')
-rw-r--r--src/main.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/src/main.c b/src/main.c
index e50b5e6..21a87a0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1534,16 +1534,37 @@ launch_payment (struct Product *product)
{
struct PaymentActivity *pa;
json_t *orderReq;
+ char *msg;
+ const char *pos;
+
+ pos = strstr (fulfillment_msg,
+ "${PRODUCT_DESCRIPTION}");
+ if (NULL != pos)
+ {
+ /* replace ${PRODUCT_DESCRIPTION} with the real one */
+ GNUNET_asprintf (&msg,
+ "%.*s%s%s",
+ /* first output URL until ${PRODUCT_DESCRIPTION} */
+ (int) (pos - fulfillment_msg),
+ fulfillment_msg,
+ /* replace ${PRODUCT_DESCRIPTION} with the right description */
+ product->description,
+ /* append rest of original URL */
+ pos + strlen ("${PRODUCT_DESCRIPTION}"));
+ }
+ else
+ {
+ msg = GNUNET_strdup (fulfillment_msg);
+ }
/* create the json object for the order request */
if (NULL != product->preview)
{
orderReq = json_pack ("{ s:s, s:s, s:o, s:s, s:o }",
- "summary",
- product->description,
+ "summary", product->description,
"preview", product->preview,
"amount", TALER_JSON_from_amount (&product->price),
- "fulfillment_message", fulfillment_msg,
+ "fulfillment_message", msg,
"auto_refund", GNUNET_JSON_from_time_rel (
MAX_REFUND_DELAY)
);
@@ -1554,11 +1575,12 @@ launch_payment (struct Product *product)
"summary",
product->description,
"amount", TALER_JSON_from_amount (&product->price),
- "fulfillment_message", fulfillment_msg,
+ "fulfillment_message", msg,
"auto_refund", GNUNET_JSON_from_time_rel (
MAX_REFUND_DELAY)
);
}
+ GNUNET_free (msg);
if (NULL == orderReq)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,