summaryrefslogtreecommitdiff
path: root/src/lib/merchant_api_post_orders.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/merchant_api_post_orders.c')
-rw-r--r--src/lib/merchant_api_post_orders.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/src/lib/merchant_api_post_orders.c b/src/lib/merchant_api_post_orders.c
index f1617aa2..1dafeb7f 100644
--- a/src/lib/merchant_api_post_orders.c
+++ b/src/lib/merchant_api_post_orders.c
@@ -87,14 +87,23 @@ handle_post_order_finished (void *cls,
{
struct TALER_MERCHANT_PostOrdersOperation *po = cls;
const char *order_id = NULL;
+ struct TALER_ClaimTokenP token;
const json_t *json = response;
struct TALER_MERCHANT_HttpResponse hr = {
.http_status = (unsigned int) response_code,
.reply = json
};
+ bool has_token = ((NULL != json_object_get (json,
+ "token")) &&
+ (false == json_is_null (json_object_get (json,
+ "token"))));
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_string ("order_id",
&order_id),
+ (!has_token) ?
+ GNUNET_JSON_spec_end () :
+ GNUNET_JSON_spec_fixed_auto ("token",
+ &token),
GNUNET_JSON_spec_end ()
};
@@ -161,9 +170,15 @@ handle_post_order_finished (void *cls,
GNUNET_break_op (0);
break;
}
- po->cb (po->cb_cls,
- &hr,
- order_id);
+ {
+ const struct TALER_ClaimTokenP *token_ptr = &token;
+ if (!has_token)
+ token_ptr = NULL;
+ po->cb (po->cb_cls,
+ &hr,
+ order_id,
+ token_ptr);
+ }
if (MHD_HTTP_OK == response_code)
GNUNET_JSON_parse_free (spec);
TALER_MERCHANT_orders_post_cancel (po);
@@ -201,6 +216,7 @@ TALER_MERCHANT_orders_post (struct GNUNET_CURL_Context *ctx,
NULL,
0,
NULL,
+ true,
cb,
cb_cls);
}
@@ -220,6 +236,7 @@ TALER_MERCHANT_orders_post (struct GNUNET_CURL_Context *ctx,
* @param inventory_products products to add to the order from the inventory
* @param lock_uuids_length length of the @a uuids array
* @param uuids array of UUIDs with locks on @a inventory_products
+ * @param create_token whether to create a claim token
* @param cb the callback to call when a reply for this request is available
* @param cb_cls closure for @a cb
* @return a handle for this request, NULL on error
@@ -235,6 +252,7 @@ TALER_MERCHANT_orders_post2 (
const struct TALER_MERCHANT_InventoryProduct inventory_products[],
unsigned int uuids_length,
const struct GNUNET_Uuid uuids[],
+ bool create_token,
TALER_MERCHANT_PostOrdersCallback cb,
void *cb_cls)
{
@@ -316,6 +334,13 @@ TALER_MERCHANT_orders_post2 (
"lock_uuids",
ua));
}
+ if (true != create_token)
+ {
+ GNUNET_assert (0 ==
+ json_object_set_new (req,
+ "create_token",
+ json_boolean (create_token)));
+ }
eh = curl_easy_init ();
GNUNET_assert (NULL != eh);
if (GNUNET_OK != TALER_curl_easy_post (&po->post_ctx,