summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-07-19 00:45:25 +0200
committerChristian Grothoff <christian@grothoff.org>2020-07-19 13:56:10 +0200
commited7cd6ce6d37212992c2c3eeffca404bbbd2d41e (patch)
treecf17808629cd4cabdcc0f049e7376bba24e7310f /src
parentec0bd63ed17f54657a5aa049977b6f1e195f16b0 (diff)
downloadmerchant-ed7cd6ce6d37212992c2c3eeffca404bbbd2d41e.tar.gz
merchant-ed7cd6ce6d37212992c2c3eeffca404bbbd2d41e.tar.bz2
merchant-ed7cd6ce6d37212992c2c3eeffca404bbbd2d41e.zip
design for TALER_MERCHANT_order_paid API
Diffstat (limited to 'src')
-rw-r--r--src/backend/taler-merchant-httpd_post-orders-ID-paid.c7
-rw-r--r--src/include/taler_merchant_service.h58
2 files changed, 64 insertions, 1 deletions
diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-paid.c b/src/backend/taler-merchant-httpd_post-orders-ID-paid.c
index 45f13c45..74328f55 100644
--- a/src/backend/taler-merchant-httpd_post-orders-ID-paid.c
+++ b/src/backend/taler-merchant-httpd_post-orders-ID-paid.c
@@ -47,6 +47,7 @@ TMH_post_orders_ID_paid (const struct TMH_RequestHandler *rh,
.purpose.size = htonl (sizeof (pr))
};
struct TALER_MerchantSignatureP merchant_sig;
+ const char *session_id;
{
struct GNUNET_JSON_Specification spec[] = {
@@ -69,6 +70,9 @@ TMH_post_orders_ID_paid (const struct TMH_RequestHandler *rh,
: MHD_NO;
}
}
+ session_id = json_string_value (
+ json_object_get (hc->request_body,
+ "session_id"));
#if FIXME
if (GNUNET_OK !=
@@ -87,7 +91,8 @@ TMH_post_orders_ID_paid (const struct TMH_RequestHandler *rh,
}
// FIXME: check that h_contract_terms matches
- // this order-id (and that the order is known)
+ // this order-id (and that the order is known),
+ // and if it does, update 'session_id' (if non-NULL)
if (0)
{
return TALER_MHD_reply_json_pack (
diff --git a/src/include/taler_merchant_service.h b/src/include/taler_merchant_service.h
index 213ea466..0e3ec5c4 100644
--- a/src/include/taler_merchant_service.h
+++ b/src/include/taler_merchant_service.h
@@ -2026,6 +2026,64 @@ TALER_MERCHANT_order_pay_cancel (struct TALER_MERCHANT_OrderPayHandle *oph);
/**
+ * @brief Handle to a POST /orders/$ID/paid operation at a merchant.
+ */
+struct TALER_MERCHANT_OrderPaidHandle;
+
+
+/**
+ * Callbacks of this type are used to serve the result of submitting a
+ * POST /orders/$ID/paid request to a merchant.
+ *
+ * @param cls closure
+ * @param hr HTTP response details
+ */
+typedef void
+(*TALER_MERCHANT_OrderPaidCallback) (
+ void *cls,
+ const struct TALER_MERCHANT_HttpResponse *hr);
+
+
+/**
+ * Send proof of payment to a merchant.
+ *
+ * This is a PUBLIC API, albeit in this form useful for the frontend,
+ * in case the frontend is proxying the request.
+ *
+ * @param ctx execution context
+ * @param merchant_url base URL of the merchant
+ * @param order_id which order should be paid
+ * @param session_id session to pay for, or NULL for none
+ * @param h_contract_terms hash of the contract terms
+ * @param merchant_sig signature from the merchant
+ * affirming payment, or NULL on errors
+ * @param paid_cb the callback to call when a reply for this request is available
+ * @param paid_cb_cls closure for @a paid_cb
+ * @return a handle for this request
+ */
+struct TALER_MERCHANT_OrderPaidHandle *
+TALER_MERCHANT_order_paid (
+ struct GNUNET_CURL_Context *ctx,
+ const char *merchant_url,
+ const char *order_id,
+ const char *session_id,
+ const struct GNUNET_HashCode *h_contract_terms,
+ const struct TALER_MerchantSignatureP *merchant_sig,
+ TALER_MERCHANT_OrderPaidCallback paid_cb,
+ void *paid_cb_cls);
+
+
+/**
+ * Cancel POST /orders/$ID/paid operation.
+ *
+ * @param oph operation to cancel
+ */
+void
+TALER_MERCHANT_order_paid_cancel (
+ struct TALER_MERCHANT_OrderPaidHandle *oph);
+
+
+/**
* Handle for an POST /orders/$ID/abort operation.
*/
struct TALER_MERCHANT_OrderAbortHandle;