diff options
Diffstat (limited to 'src/backend/taler-merchant-httpd.h')
-rw-r--r-- | src/backend/taler-merchant-httpd.h | 195 |
1 files changed, 116 insertions, 79 deletions
diff --git a/src/backend/taler-merchant-httpd.h b/src/backend/taler-merchant-httpd.h index 6e8362a4..48547e84 100644 --- a/src/backend/taler-merchant-httpd.h +++ b/src/backend/taler-merchant-httpd.h @@ -123,6 +123,12 @@ struct TMH_MerchantInstance struct TMH_PendingOrder *po_tail; /** + * Database event we are waiting on to be resuming + * long-polling requests from the @e po_head. + */ + struct GNUNET_DB_EventHandler *po_eh; + + /** * Merchant's private key. */ struct TALER_MerchantPrivateKeyP merchant_priv; @@ -155,10 +161,13 @@ struct TMH_MerchantInstance }; +GNUNET_NETWORK_STRUCT_BEGIN + + /** * Event triggered when an order is paid. */ -struct TMH_OrderPayEvent +struct TMH_OrderPayEventP { /** * Type is #TALER_DBEVENT_MERCHANT_ORDER_PAID @@ -168,7 +177,12 @@ struct TMH_OrderPayEvent /** * Always zero (for alignment). */ - uint32_t reserved; + uint32_t reserved GNUNET_PACKED; + + /** + * Merchant's public key + */ + struct TALER_MerchantPublicKeyP merchant_pub; /** * Hash of the order ID. @@ -181,7 +195,7 @@ struct TMH_OrderPayEvent * Event triggered when a fulfillment URL is * bound to a session (as paid). */ -struct TMH_SessionEvent +struct TMH_SessionEventP { /** * Type is #TALER_DBEVENT_MERCHANT_SESSION_CAPTURED @@ -191,7 +205,12 @@ struct TMH_SessionEvent /** * Always zero (for alignment). */ - uint32_t reserved; + uint32_t reserved GNUNET_PACKED; + + /** + * Merchant's public key + */ + struct TALER_MerchantPublicKeyP merchant_pub; /** * Hash of the fulfillment URL. @@ -206,19 +225,28 @@ struct TMH_SessionEvent /** - * Event triggered when an order's refund is increased. + * Event triggered when an order's refund is increased + * or obtained by the respective wallet. + * + * Extra arguments are the amount (as a string). */ -struct TMH_OrderRefundEvent +struct TMH_OrderRefundEventP { /** - * Type is #TALER_DBEVENT_MERCHANT_ORDER_REFUND + * Type is #TALER_DBEVENT_MERCHANT_ORDER_REFUND or + * #TALER_DBEVENT_MERCHANT_REFUND_OBTAINED */ struct GNUNET_DB_EventHeaderP header; /** * Always zero (for alignment). */ - uint32_t reserved; + uint32_t reserved GNUNET_PACKED; + + /** + * Merchant's public key + */ + struct TALER_MerchantPublicKeyP merchant_pub; /** * Hash of the order ID. @@ -228,6 +256,86 @@ struct TMH_OrderRefundEvent /** + * Possible flags indicating the state of an order. + */ +enum TMH_OrderStateFlags +{ + TMH_OSF_NONE = 0, + + /** + * Not yet used. + */ + TMH_OSF_CLAIMED = 1, + + /** + * Customer paid the order. + */ + TMH_OSF_PAID = 2, + + /** + * Merchant granted (possibly partial) refund. + */ + TMH_OSF_REFUNDED = 4, + + /** + * Merchant received the payment from the exchange. + */ + TMH_OSF_WIRED = 8 +}; + + +/** + * Extra information passed for a + * #TALER_DBEVENT_MERCHANT_ORDERS_CHANGE. + */ +struct TMH_OrderChangeEventDetailsP +{ + /** + * Order ID, in NBO. + */ + uint64_t order_serial_id GNUNET_PACKED; + + /** + * Execution date of the order. + */ + struct GNUNET_TIME_AbsoluteNBO execution_date; + + /** + * See `enum TMH_OrderStateFlags`. In NBO. + */ + uint32_t order_state GNUNET_PACKED; + +}; + + +/** + * Event triggered when an order's refund is increased + * or obtained by the respective wallet. + * + * Extra arguments are the amount (as a string). + */ +struct TMH_OrderChangeEventP +{ + /** + * Type is #TALER_DBEVENT_MERCHANT_ORDERS_CHANGE. + */ + struct GNUNET_DB_EventHeaderP header; + + /** + * Always zero (for alignment). + */ + uint32_t reserved GNUNET_PACKED; + + /** + * Merchant's public key + */ + struct TALER_MerchantPublicKeyP merchant_pub; +}; + + +GNUNET_NETWORK_STRUCT_END + +/** * @brief Struct describing an URL and the handler for it. * * The overall URL is always @e url_prefix, optionally followed by the @@ -443,25 +551,6 @@ struct TMH_SuspendedConnection struct MHD_Connection *con; /** - * Associated heap node. Used internally by #TMH_long_poll_suspend() - * and TMH_long_poll_resume(). - */ - struct GNUNET_CONTAINER_HeapNode *hn; - - /** - * Key of this entry in the #payment_trigger_map. Used internally by - * #TMH_long_poll_suspend() and TMH_long_poll_resume(). - */ - struct GNUNET_HashCode key; - - /** - * Optional session/fulfillment URI-based key - * of this entry in the #payment_trigger_map. Used internally by - * TMH_long_poll_resume2(). - */ - struct GNUNET_HashCode key2; - - /** * At what time does this request expire? If set in the future, we * may wait this long for a payment to arrive before responding. */ @@ -482,10 +571,6 @@ struct TMH_SuspendedConnection */ bool awaiting_refund_obtained; - /** - * True if @a key2 is set. - */ - bool has_key2; }; @@ -525,54 +610,6 @@ extern char *TMH_default_auth; /** - * Suspend connection from @a sc until payment has been received. - * - * @param order_id the order that we are waiting on - * @param session_id session ID of the requester - * @param fulfillment_url fulfillment URL of the contract - * @param mi the merchant instance we are waiting on - * @param sc connection to suspend - * @param min_refund refund amount we are waiting on to be exceeded before resuming, - * NULL if we are not waiting for refunds - */ -void -TMH_long_poll_suspend (const char *order_id, - const char *session_id, - const char *fulfillment_url, - const struct TMH_MerchantInstance *mi, - struct TMH_SuspendedConnection *sc, - const struct TALER_Amount *min_refund); - - -/** - * Find out if we have any clients long-polling for @a order_id to be - * confirmed at merchant @a mpub, and if so, tell them to resume. - * - * @param order_id the order that was paid or refunded - * @param mi the merchant instance where the payment or refund happened - * @param refund_amount refunded amount, if the trigger was a refund, otherwise NULL - * @param obtained if true, the wallet has obtained the refunds for the order - */ -void -TMH_long_poll_resume (const char *order_id, - const struct TMH_MerchantInstance *mi, - const struct TALER_Amount *refund_amount, - bool obtained); - - -/** - * Find out if we have any clients long-polling for @a order_id to be - * confirmed at merchant @a mpub, and if so, tell them to resume. - * - * @param session_id the session for which @a fulfillment_url became paid - * @param fulfillment_url fullfillment URL of which an order was paid - */ -void -TMH_long_poll_resume2 (const char *session_id, - const char *fulfillment_url); - - -/** * Callback that frees an instances removing * it from the global hashmap. * |