summaryrefslogtreecommitdiff
path: root/src/merchant-tools/taler-merchant-setup-reserve.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/merchant-tools/taler-merchant-setup-reserve.c')
-rw-r--r--src/merchant-tools/taler-merchant-setup-reserve.c91
1 files changed, 63 insertions, 28 deletions
diff --git a/src/merchant-tools/taler-merchant-setup-reserve.c b/src/merchant-tools/taler-merchant-setup-reserve.c
index 1ed50530..46888171 100644
--- a/src/merchant-tools/taler-merchant-setup-reserve.c
+++ b/src/merchant-tools/taler-merchant-setup-reserve.c
@@ -156,46 +156,81 @@ do_request (void *cls);
* POST /reserves request to a merchant
*
* @param cls closure
- * @param hr HTTP response details
- * @param reserve_pub public key of the created reserve, NULL on error
- * @param payto_uri where to make the payment to for filling the reserve, NULL on error
+ * @param prr response details
*/
static void
result_cb (void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- const struct TALER_ReservePublicKeyP *reserve_pub,
- const char *payto_uri)
+ const struct TALER_MERCHANT_PostReservesResponse *prr)
{
(void) cls;
prh = NULL;
- switch (hr->http_status)
+ switch (prr->hr.http_status)
{
case MHD_HTTP_OK:
{
- char res_str[sizeof (*reserve_pub) * 2 + 1];
+ char res_str[sizeof (prr->details.ok.reserve_pub) * 2 + 1];
- GNUNET_STRINGS_data_to_string (reserve_pub,
- sizeof (*reserve_pub),
+ GNUNET_STRINGS_data_to_string (&prr->details.ok.reserve_pub,
+ sizeof (prr->details.ok.reserve_pub),
res_str,
sizeof (res_str));
- if (NULL != strchr (payto_uri, '?'))
- fprintf (stdout,
- "%s&message=%s\n",
- payto_uri,
- res_str);
- else
- fprintf (stdout,
- "%s?message=%s\n",
- payto_uri,
- res_str);
+ for (unsigned int i = 0; i<prr->details.ok.accounts_len; i++)
+ {
+ const struct TALER_EXCHANGE_WireAccount *wa
+ = &prr->details.ok.accounts[i];
+ const char *payto_uri = wa->payto_uri;
+ bool skip = false;
+
+ for (unsigned int j = 0; j<wa->credit_restrictions_length; j++)
+ if (TALER_EXCHANGE_AR_DENY ==
+ wa->credit_restrictions[j].type)
+ skip = true;
+ if (skip)
+ continue;
+ if (NULL != strchr (payto_uri, '?'))
+ fprintf (stdout,
+ "%s&message=%s\n",
+ payto_uri,
+ res_str);
+ else
+ fprintf (stdout,
+ "%s?message=%s\n",
+ payto_uri,
+ res_str);
+ if (NULL != wa->conversion_url)
+ fprintf (stdout,
+ "\tConversion needed: %s\n",
+ wa->conversion_url);
+ for (unsigned int j = 0; j<wa->credit_restrictions_length; j++)
+ {
+ const struct TALER_EXCHANGE_AccountRestriction *cr
+ = &wa->credit_restrictions[j];
+
+ switch (cr->type)
+ {
+ case TALER_EXCHANGE_AR_INVALID:
+ GNUNET_assert (0);
+ break;
+ case TALER_EXCHANGE_AR_DENY:
+ GNUNET_assert (0);
+ break;
+ case TALER_EXCHANGE_AR_REGEX:
+ fprintf (stdout,
+ "\tCredit restriction: %s (%s)\n",
+ cr->details.regex.human_hint,
+ cr->details.regex.posix_egrep);
+ break;
+ }
+ }
+ }
}
break;
case MHD_HTTP_CONFLICT:
fprintf (stderr,
"Conflict trying to setup reserve: %u/%d\nHint: %s\n",
- hr->http_status,
- (int) hr->ec,
- hr->hint);
+ prr->hr.http_status,
+ (int) prr->hr.ec,
+ prr->hr.hint);
global_ret = 1;
break;
case MHD_HTTP_INTERNAL_SERVER_ERROR:
@@ -212,16 +247,16 @@ result_cb (void *cls,
}
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Merchant failed too often (%u/%d), giving up\n",
- hr->http_status,
- hr->ec);
+ prr->hr.http_status,
+ prr->hr.ec);
global_ret = 1;
break;
default:
fprintf (stderr,
"Unexpected backend failure: %u/%d\nHint: %s\n",
- hr->http_status,
- (int) hr->ec,
- hr->hint);
+ prr->hr.http_status,
+ (int) prr->hr.ec,
+ prr->hr.hint);
global_ret = 1;
break;
}