aboutsummaryrefslogtreecommitdiff
path: root/src/lib/merchant_api_post_using_templates.c
diff options
context:
space:
mode:
authorpriscilla <priscilla.huang@efrei.net>2022-12-30 08:50:16 -0500
committerpriscilla <priscilla.huang@efrei.net>2022-12-30 08:50:16 -0500
commit73fdf47728e26d8625a85441b8523bca0176868f (patch)
treed557bd0c220db03fb9a4af67c36d22803eff0f5b /src/lib/merchant_api_post_using_templates.c
parent2c19f6a6fb180f059fcaeb193dd387c4d6af21b1 (diff)
testing using templates
Diffstat (limited to 'src/lib/merchant_api_post_using_templates.c')
-rw-r--r--src/lib/merchant_api_post_using_templates.c75
1 files changed, 4 insertions, 71 deletions
diff --git a/src/lib/merchant_api_post_using_templates.c b/src/lib/merchant_api_post_using_templates.c
index ded88e75..372f5eb5 100644
--- a/src/lib/merchant_api_post_using_templates.c
+++ b/src/lib/merchant_api_post_using_templates.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2020-2021 Taler Systems SA
+ Copyright (C) 2022 Taler Systems SA
TALER is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
@@ -52,7 +52,7 @@ struct TALER_MERCHANT_UsingTemplatesPostHandle
/**
* Function to call with the result.
*/
- TALER_MERCHANT_UsingTemplatesPostCallback cb;
+ TALER_MERCHANT_PostOrdersCallback cb;
/**
* Closure for @a cb.
@@ -85,75 +85,8 @@ handle_post_using_templates_finished (void *cls,
{
struct TALER_MERCHANT_UsingTemplatesPostHandle *utph = cls;
const json_t *json = response;
- struct TALER_MERCHANT_HttpResponse hr = {
- .http_status = (unsigned int) response_code,
- .reply = json
- };
-
utph->job = NULL;
- // to_be_written_new_function (utph->cb, utph->cb_cls, response_code, json);
- // start of code to be removed
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "POST /using-templates completed with response code %u\n",
- (unsigned int) response_code);
- switch (response_code)
- {
- case 0:
- hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
- break;
- case MHD_HTTP_NO_CONTENT:
- break;
- case MHD_HTTP_NOT_ACCEPTABLE:
- hr.ec = TALER_JSON_get_error_code (json);
- hr.hint = TALER_JSON_get_error_hint (json);
- break;
- case MHD_HTTP_BAD_REQUEST:
- hr.ec = TALER_JSON_get_error_code (json);
- hr.hint = TALER_JSON_get_error_hint (json);
- /* This should never happen, either us
- * or the merchant is buggy (or API version conflict);
- * just pass JSON reply to the application */
- break;
- case MHD_HTTP_FORBIDDEN:
- hr.ec = TALER_JSON_get_error_code (json);
- hr.hint = TALER_JSON_get_error_hint (json);
- /* Nothing really to verify, merchant says we tried to abort the payment
- * after it was successful. We should pass the JSON reply to the
- * application */
- break;
- case MHD_HTTP_NOT_FOUND:
- hr.ec = TALER_JSON_get_error_code (json);
- hr.hint = TALER_JSON_get_error_hint (json);
- /* Nothing really to verify, this should never
- happen, we should pass the JSON reply to the
- application */
- break;
- case MHD_HTTP_CONFLICT:
- hr.ec = TALER_JSON_get_error_code (json);
- hr.hint = TALER_JSON_get_error_hint (json);
- break;
- case MHD_HTTP_INTERNAL_SERVER_ERROR:
- hr.ec = TALER_JSON_get_error_code (json);
- hr.hint = TALER_JSON_get_error_hint (json);
- /* Server had an internal issue; we should retry,
- but this API leaves this to the application */
- break;
- default:
- TALER_MERCHANT_parse_error_details_ (json,
- response_code,
- &hr);
- /* unexpected response code */
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected response code %u/%d\n",
- (unsigned int) response_code,
- (int) hr.ec);
- GNUNET_break_op (0);
- break;
- } /* end of the switch */
- utph->cb (utph->cb_cls,
- &hr);
- // end of code to be removed
-
+ TALER_MERCHANT_handle_post_using_templates_create_order (utph->cb_cls, utph->cb, response_code, json);
TALER_MERCHANT_using_templates_post_cancel (utph);
}
@@ -165,7 +98,7 @@ TALER_MERCHANT_using_templates_post (
const char *template_id,
const char *summary,
const struct TALER_Amount *amount,
- TALER_MERCHANT_UsingTemplatesPostCallback cb,
+ TALER_MERCHANT_PostOrdersCallback cb,
void *cb_cls)
{
struct TALER_MERCHANT_UsingTemplatesPostHandle *utph;