diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/taler_merchant_service.h | 104 | ||||
-rw-r--r-- | src/include/taler_merchant_testing_lib.h | 273 |
2 files changed, 228 insertions, 149 deletions
diff --git a/src/include/taler_merchant_service.h b/src/include/taler_merchant_service.h index 740c213d..4d8c0ef5 100644 --- a/src/include/taler_merchant_service.h +++ b/src/include/taler_merchant_service.h @@ -2793,7 +2793,7 @@ TALER_MERCHANT_reserve_delete_cancel ( /** * Handle for a GET /tips/$TIP_ID (public variant) operation. */ -struct TALER_MERCHANT_TipGetHandle; +struct TALER_MERCHANT_TipWalletGetHandle; /** @@ -2806,12 +2806,12 @@ struct TALER_MERCHANT_TipGetHandle; * @param amount_remaining total amount still available for the tip */ typedef void -(*TALER_MERCHANT_TipGetCallback) ( +(*TALER_MERCHANT_TipWalletGetCallback) ( void *cls, const struct TALER_MERCHANT_HttpResponse *hr, struct GNUNET_TIME_Absolute expiration, const char *exchange_url, - struct TALER_Amount *amount_remaining); + const struct TALER_Amount *amount_remaining); /** @@ -2825,21 +2825,102 @@ typedef void * @param cb_cls closure for @a cb * @return handle for this operation, NULL upon errors */ -struct TALER_MERCHANT_TipGetHandle * -TALER_MERCHANT_tip_get (struct GNUNET_CURL_Context *ctx, - const char *backend_url, - const struct GNUNET_HashCode *tip_id, - TALER_MERCHANT_TipGetCallback cb, - void *cb_cls); +struct TALER_MERCHANT_TipWalletGetHandle * +TALER_MERCHANT_wallet_tip_get (struct GNUNET_CURL_Context *ctx, + const char *backend_url, + const struct GNUNET_HashCode *tip_id, + TALER_MERCHANT_TipWalletGetCallback cb, + void *cb_cls); /** - * Cancel a GET /tip-get request. + * Cancel a GET /tips/$TIP_ID request. * * @param tqo handle to the request to be canceled */ void -TALER_MERCHANT_tip_get_cancel (struct TALER_MERCHANT_TipGetHandle *tqh); +TALER_MERCHANT_wallet_tip_get_cancel (struct + TALER_MERCHANT_TipWalletGetHandle *tgh); + + +/** + * Handle for a GET /private/tips/$TIP_ID (private variant) operation. + */ +struct TALER_MERCHANT_TipMerchantGetHandle; + + +/** + * Summary information for a tip pickup. + */ +struct TALER_MERCHANT_PickupDetail +{ + /** + * Identifier of the pickup. + */ + struct GNUNET_HashCode pickup_id; + + /** + * Number of planchets involved. + */ + uint64_t num_planchets; + + /** + * Total amount requested for this pickup. + */ + struct TALER_Amount requested_amount; +}; + +/** + * Callback to process a GET /private/tips/$TIP_ID request + * + * @param cls closure + * @param hr HTTP response details + * @param expiration when the tip will expire + * @param exchange_url exchange from which the coins should be withdrawn + * @param amount_remaining total amount still available for the tip + */ +typedef void +(*TALER_MERCHANT_TipMerchantGetCallback) ( + void *cls, + const struct TALER_MERCHANT_HttpResponse *hr, + const struct TALER_Amount *total_authorized, + const struct TALER_Amount *total_picked_up, + const char *reason, + struct GNUNET_TIME_Absolute expiration, + const struct TALER_ReservePublicKeyP *reserve_pub, + unsigned int pickups_length, + const struct TALER_MERCHANT_PickupDetail pickups[]); + + +/** + * Issue a GET /private/tips/$TIP_ID (private variant) request to the backend. + * Returns information needed to pick up a tip. + * + * @param ctx execution context + * @param backend_url base URL of the merchant backend + * @param tip_id which tip should we query + * @param pickups whether to fetch associated pickups + * @param cb function to call with the result + * @param cb_cls closure for @a cb + * @return handle for this operation, NULL upon errors + */ +struct TALER_MERCHANT_TipMerchantGetHandle * +TALER_MERCHANT_merchant_tip_get (struct GNUNET_CURL_Context *ctx, + const char *backend_url, + const struct GNUNET_HashCode *tip_id, + bool pickups, + TALER_MERCHANT_TipMerchantGetCallback cb, + void *cb_cls); + + +/** + * Cancel a GET /private/tips/$TIP_ID request. + * + * @param tqo handle to the request to be canceled + */ +void +TALER_MERCHANT_merchant_tip_get_cancel (struct + TALER_MERCHANT_TipMerchantGetHandle *tgh); /** @@ -2858,7 +2939,6 @@ struct TALER_MERCHANT_TipEntry */ uint64_t row_id; - /** * Identifier for the tip. */ diff --git a/src/include/taler_merchant_testing_lib.h b/src/include/taler_merchant_testing_lib.h index 60846a9e..c7813176 100644 --- a/src/include/taler_merchant_testing_lib.h +++ b/src/include/taler_merchant_testing_lib.h @@ -661,6 +661,142 @@ TALER_TESTING_cmd_get_tips (const char *label, unsigned int http_status); +/** + * Define a GET /private/tips/$TIP_ID CMD. + * + * @param label the command label + * @param merchant_url base URL of the merchant which will + * serve the request. + * @param tip_reference reference to a command that created a tip. + * @param http_status expected HTTP response code for the request. + */ +struct TALER_TESTING_Command +TALER_TESTING_cmd_merchant_get_tip (const char *label, + const char *merchant_url, + const char *tip_reference, + unsigned int http_status); + + +/** + * Define a GET /tips/$TIP_ID CMD. + * + * @param label the command label + * @param merchant_url base URL of the merchant which will + * serve the request. + * @param tip_reference reference to a command that created a tip. + * @param http_status expected HTTP response code for the request. + */ +struct TALER_TESTING_Command +TALER_TESTING_cmd_wallet_get_tip (const char *label, + const char *merchant_url, + const char *tip_reference, + unsigned int http_status); + + +/** + * Create a /tip-authorize CMD, specifying the Taler error code + * that is expected to be returned by the backend. + * + * @param label this command label + * @param merchant_url the base URL of the merchant that will + * serve the /tip-authorize request. + * @param exchange_url the base URL of the exchange that owns + * the reserve from which the tip is going to be gotten. + * @param http_status the HTTP response code which is expected + * for this operation. + * @param justification human-readable justification for this + * tip authorization. + * @param amount the amount to authorize for tipping. + * @param ec expected Taler-defined error code. + */ +struct TALER_TESTING_Command +TALER_TESTING_cmd_tip_authorize_with_ec (const char *label, + const char *merchant_url, + const char *exchange_url, + unsigned int http_status, + const char *justification, + const char *amount, + enum TALER_ErrorCode ec); + + +/** + * This commands does not query the backend at all, + * but just makes up a fake authorization id that will + * be subsequently used by the "pick up" CMD in order + * to test against such a case. + * + * @param label command label. + * @return the command. + */ +struct TALER_TESTING_Command +TALER_TESTING_cmd_tip_authorize_fake (const char *label); + + +/** + * Create a /tip-authorize CMD. + * + * @param label this command label + * @param merchant_url the base URL of the merchant that will + * serve the /tip-authorize request. + * @param exchange_url the base URL of the exchange that owns + * the reserve from which the tip is going to be gotten. + * @param http_status the HTTP response code which is expected + * for this operation. + * @param justification human-readable justification for this + * tip authorization. + * @param amount the amount to authorize for tipping. + */ +struct TALER_TESTING_Command +TALER_TESTING_cmd_tip_authorize (const char *label, + const char *merchant_url, + const char *exchange_url, + unsigned int http_status, + const char *justification, + const char *amount); + + +/** + * Define a /tip-pickup CMD, equipped with the expected error + * code. + * + * @param label the command label + * @param merchant_url base URL of the backend which will serve + * the /tip-pickup request. + * @param http_status expected HTTP response code. + * @param authorize_reference reference to a /tip-autorize CMD + * that offers a tip id to pick up. + * @param amounts array of string-defined amounts that specifies + * which denominations will be accepted for tipping. + * @param ec expected Taler error code. + */ +struct TALER_TESTING_Command +TALER_TESTING_cmd_tip_pickup_with_ec (const char *label, + const char *merchant_url, + unsigned int http_status, + const char *authorize_reference, + const char **amounts, + enum TALER_ErrorCode ec); + +/** + * Define a /tip-pickup CMD. + * + * @param label the command label + * @param merchant_url base URL of the backend which will serve + * the /tip-pickup request. + * @param http_status expected HTTP response code. + * @param authorize_reference reference to a /tip-autorize CMD + * that offers a tip id to pick up. + * @param amounts array of string-defined amounts that specifies + * which denominations will be accepted for tipping. + */ +struct TALER_TESTING_Command +TALER_TESTING_cmd_tip_pickup (const char *label, + const char *merchant_url, + unsigned int http_status, + const char *authorize_reference, + const char **amounts); + + /* ******************** OLD ******************* */ @@ -1096,143 +1232,6 @@ TALER_TESTING_get_trait_refund_entry ( // FIXME: rename: entry->detail unsigned int index, const struct TALER_MERCHANT_RefundDetail **refund_entry); -/** - * Create a /tip-authorize CMD, specifying the Taler error code - * that is expected to be returned by the backend. - * - * @param label this command label - * @param merchant_url the base URL of the merchant that will - * serve the /tip-authorize request. - * @param exchange_url the base URL of the exchange that owns - * the reserve from which the tip is going to be gotten. - * @param http_status the HTTP response code which is expected - * for this operation. - * @param justification human-readable justification for this - * tip authorization. - * @param amount the amount to authorize for tipping. - * @param ec expected Taler-defined error code. - */ -struct TALER_TESTING_Command -TALER_TESTING_cmd_tip_authorize_with_ec (const char *label, - const char *merchant_url, - const char *exchange_url, - unsigned int http_status, - const char *justification, - const char *amount, - enum TALER_ErrorCode ec); - - -/** - * This commands does not query the backend at all, - * but just makes up a fake authorization id that will - * be subsequently used by the "pick up" CMD in order - * to test against such a case. - * - * @param label command label. - * @return the command. - */ -struct TALER_TESTING_Command -TALER_TESTING_cmd_tip_authorize_fake (const char *label); - - -/** - * Create a /tip-authorize CMD. - * - * @param label this command label - * @param merchant_url the base URL of the merchant that will - * serve the /tip-authorize request. - * @param exchange_url the base URL of the exchange that owns - * the reserve from which the tip is going to be gotten. - * @param http_status the HTTP response code which is expected - * for this operation. - * @param justification human-readable justification for this - * tip authorization. - * @param amount the amount to authorize for tipping. - */ -struct TALER_TESTING_Command -TALER_TESTING_cmd_tip_authorize (const char *label, - const char *merchant_url, - const char *exchange_url, - unsigned int http_status, - const char *justification, - const char *amount); - -/** - * Define a /tip-query CMD. - * - * @param label the command label - * @param merchant_url base URL of the merchant which will - * server the /tip-query request. - * @param http_status expected HTTP response code for the - * /tip-query request. - */ -struct TALER_TESTING_Command -TALER_TESTING_cmd_tip_query (const char *label, - const char *merchant_url, - unsigned int http_status); - -/** - * Define a /tip-query CMD equipped with a expected amount. - * - * @param label the command label - * @param merchant_url base URL of the merchant which will - * server the /tip-query request. - * @param http_status expected HTTP response code for the - * /tip-query request. - * @param expected_amount_picked_up expected amount already - * picked up. - * @param expected_amount_authorized expected amount that was - * authorized in the first place. - * @param expected_amount_available FIXME what is this? - */ -struct TALER_TESTING_Command -TALER_TESTING_cmd_tip_query_with_amounts (const char *label, - const char *merchant_url, - unsigned int http_status, - const char *expected_amount_picked_up, - const char *expected_amount_authorized, - const char *expected_amount_available); - -/** - * Define a /tip-pickup CMD, equipped with the expected error - * code. - * - * @param label the command label - * @param merchant_url base URL of the backend which will serve - * the /tip-pickup request. - * @param http_status expected HTTP response code. - * @param authorize_reference reference to a /tip-autorize CMD - * that offers a tip id to pick up. - * @param amounts array of string-defined amounts that specifies - * which denominations will be accepted for tipping. - * @param ec expected Taler error code. - */ -struct TALER_TESTING_Command -TALER_TESTING_cmd_tip_pickup_with_ec (const char *label, - const char *merchant_url, - unsigned int http_status, - const char *authorize_reference, - const char **amounts, - enum TALER_ErrorCode ec); - -/** - * Define a /tip-pickup CMD. - * - * @param label the command label - * @param merchant_url base URL of the backend which will serve - * the /tip-pickup request. - * @param http_status expected HTTP response code. - * @param authorize_reference reference to a /tip-autorize CMD - * that offers a tip id to pick up. - * @param amounts array of string-defined amounts that specifies - * which denominations will be accepted for tipping. - */ -struct TALER_TESTING_Command -TALER_TESTING_cmd_tip_pickup (const char *label, - const char *merchant_url, - unsigned int http_status, - const char *authorize_reference, - const char **amounts); /** * Make the instruction pointer point to @a new_ip |