summaryrefslogtreecommitdiff
path: root/src/lib/merchant_api_merchant_get_order.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-10-02 20:20:08 +0200
committerChristian Grothoff <christian@grothoff.org>2020-10-02 20:20:20 +0200
commite24064063f5d7dc36ab14e1f911708e6d981a10e (patch)
tree0c46d0fe2e8f6401eef0c40256d0c434fc00c1f5 /src/lib/merchant_api_merchant_get_order.c
parentfc51e020796e4faa5435520adb5e3ca67ee6105f (diff)
downloadmerchant-e24064063f5d7dc36ab14e1f911708e6d981a10e.tar.gz
merchant-e24064063f5d7dc36ab14e1f911708e6d981a10e.tar.bz2
merchant-e24064063f5d7dc36ab14e1f911708e6d981a10e.zip
implement #6616 claim status in /private/orders/ID handler
Diffstat (limited to 'src/lib/merchant_api_merchant_get_order.c')
-rw-r--r--src/lib/merchant_api_merchant_get_order.c50
1 files changed, 48 insertions, 2 deletions
diff --git a/src/lib/merchant_api_merchant_get_order.c b/src/lib/merchant_api_merchant_get_order.c
index 21e60efb..22c0dcd3 100644
--- a/src/lib/merchant_api_merchant_get_order.c
+++ b/src/lib/merchant_api_merchant_get_order.c
@@ -95,7 +95,7 @@ handle_unpaid (struct TALER_MERCHANT_OrderMerchantGetHandle *omgh,
}
{
struct TALER_MERCHANT_OrderStatusResponse osr = {
- .paid = false,
+ .status = TALER_MERCHANT_OSC_UNPAID,
.details.unpaid.taler_pay_uri = taler_pay_uri,
.details.unpaid.already_paid_order_id = already_paid_order_id
};
@@ -109,6 +109,47 @@ handle_unpaid (struct TALER_MERCHANT_OrderMerchantGetHandle *omgh,
/**
* Function called when we're done processing the GET /private/orders/$ORDER
+ * request and we got an HTTP status of OK and the order was claimed but not
+ * paid. Parse the response and call the callback.
+ *
+ * @param omgh handle for the request
+ * @param[in,out] hr HTTP response we got
+ */
+static void
+handle_claimed (struct TALER_MERCHANT_OrderMerchantGetHandle *omgh,
+ struct TALER_MERCHANT_HttpResponse *hr)
+{
+ struct TALER_MERCHANT_OrderStatusResponse osr = {
+ .status = TALER_MERCHANT_OSC_CLAIMED
+ };
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_json ("contract_terms",
+ (json_t **) &osr.details.claimed.contract_terms),
+ GNUNET_JSON_spec_end ()
+ };
+
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (hr->reply,
+ spec,
+ NULL, NULL))
+ {
+ GNUNET_break_op (0);
+ hr->http_status = 0;
+ hr->ec = TALER_EC_MERCHANT_ORDER_GET_REPLY_MALFORMED;
+ omgh->cb (omgh->cb_cls,
+ hr,
+ NULL);
+ return;
+ }
+ omgh->cb (omgh->cb_cls,
+ hr,
+ &osr);
+ GNUNET_JSON_parse_free (spec);
+}
+
+
+/**
+ * Function called when we're done processing the GET /private/orders/$ORDER
* request and we got an HTTP status of OK and the order was paid. Parse
* the response and call the callback.
*
@@ -125,7 +166,7 @@ handle_paid (struct TALER_MERCHANT_OrderMerchantGetHandle *omgh,
json_t *wire_reports;
json_t *refund_details;
struct TALER_MERCHANT_OrderStatusResponse osr = {
- .paid = true
+ .status = TALER_MERCHANT_OSC_PAID
};
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_bool ("refunded",
@@ -377,6 +418,11 @@ handle_merchant_order_get_finished (void *cls,
handle_paid (omgh,
&hr);
}
+ else if (0 == strcmp ("claimed", order_status))
+ {
+ handle_claimed (omgh,
+ &hr);
+ }
else if (0 == strcmp ("unpaid", order_status))
{
handle_unpaid (omgh,