commit e919344cc2bf38326abc4c31b5753dcbdaff8e5a
parent e2dccbdda2e085b011218f59a7f18aa0e792cf12
Author: Christian Grothoff <christian@grothoff.org>
Date: Mon, 24 Aug 2020 14:20:14 +0200
substitute PRODUCT_DESCRIPTION in fulfillment-msg
Diffstat:
2 files changed, 27 insertions(+), 11 deletions(-)
diff --git 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,
diff --git a/taler.conf b/taler.conf
@@ -4,14 +4,8 @@ currency = TESTKUDOS
[taler-mdb]
backend-base-url = http://backend.test.taler.net/
backend-authorization = ApiKey Sandbox
-# taler url for success message (see taler documentation)
-fulfillment-url = taler://fulfillment-success
-# alternative url (see taler documentation)
-#fulfillment-url = https(s)://
# Message to diplay after purchase is completed,
-# will be concatenated with product
-# must be url - utf8 encoded
-fulfillment-msg = /Enjoy+your+
+fulfillment-msg = Enjoy your ${PRODUCT_DESCRIPTION}
# Name of the UART where the MDB connector is reachable.
UART_DEVICE = /dev/ttyAMA0