aboutsummaryrefslogtreecommitdiff
path: root/src/lib/merchant_api_post_account.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/merchant_api_post_account.c')
-rw-r--r--src/lib/merchant_api_post_account.c62
1 files changed, 42 insertions, 20 deletions
diff --git a/src/lib/merchant_api_post_account.c b/src/lib/merchant_api_post_account.c
index 5ed3f3b3..690aef17 100644
--- a/src/lib/merchant_api_post_account.c
+++ b/src/lib/merchant_api_post_account.c
@@ -35,9 +35,9 @@
/**
- * Handle for a POST /private/account operation.
+ * Handle for a POST /private/accounts operation.
*/
-struct TALER_MERCHANT_AccountPostHandle
+struct TALER_MERCHANT_AccountsPostHandle
{
/**
@@ -53,7 +53,7 @@ struct TALER_MERCHANT_AccountPostHandle
/**
* Function to call with the result.
*/
- TALER_MERCHANT_AccountPostCallback cb;
+ TALER_MERCHANT_AccountsPostCallback cb;
/**
* Closure for @a cb.
@@ -86,23 +86,43 @@ handle_post_account_finished (void *cls,
long response_code,
const void *response)
{
- struct TALER_MERCHANT_AccountPostHandle *aph = cls;
+ struct TALER_MERCHANT_AccountsPostHandle *aph = cls;
const json_t *json = response;
- struct TALER_MERCHANT_AccountPostResponse apr = {
+ struct TALER_MERCHANT_AccountsPostResponse apr = {
.hr.http_status = (unsigned int) response_code,
.hr.reply = json
};
aph->job = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "POST /account completed with response code %u\n",
+ "POST /accounts completed with response code %u\n",
(unsigned int) response_code);
switch (response_code)
{
case 0:
apr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
break;
- case MHD_HTTP_NO_CONTENT:
+ case MHD_HTTP_OK:
+ {
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_fixed_auto ("h_wire",
+ &apr.details.ok.h_wire),
+ GNUNET_JSON_spec_fixed_auto ("salt",
+ &apr.details.ok.salt),
+ GNUNET_JSON_spec_end ()
+ };
+
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (json,
+ spec,
+ NULL, NULL))
+ {
+ GNUNET_break_op (0);
+ apr.hr.http_status = 0;
+ apr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
+ break;
+ }
+ }
break;
case MHD_HTTP_BAD_REQUEST:
GNUNET_break_op (0);
@@ -147,40 +167,42 @@ handle_post_account_finished (void *cls,
}
aph->cb (aph->cb_cls,
&apr);
- TALER_MERCHANT_account_post_cancel (aph);
+ TALER_MERCHANT_accounts_post_cancel (aph);
}
-struct TALER_MERCHANT_AccountPostHandle *
-TALER_MERCHANT_account_post (
+struct TALER_MERCHANT_AccountsPostHandle *
+TALER_MERCHANT_accounts_post (
struct GNUNET_CURL_Context *ctx,
const char *backend_url,
- const struct TALER_MERCHANT_AccountConfig *account,
- TALER_MERCHANT_AccountPostCallback cb,
+ const char *payto_uri,
+ const char *credit_facade_url,
+ const json_t *credit_facade_credentials,
+ TALER_MERCHANT_AccountsPostCallback cb,
void *cb_cls)
{
- struct TALER_MERCHANT_AccountPostHandle *aph;
+ struct TALER_MERCHANT_AccountsPostHandle *aph;
json_t *req_obj;
req_obj = GNUNET_JSON_PACK (
GNUNET_JSON_pack_string (
"payto_uri",
- account->payto_uri),
+ payto_uri),
GNUNET_JSON_pack_allow_null (
GNUNET_JSON_pack_string (
"credit_facade_url",
- account->credit_facade_url)),
+ credit_facade_url)),
GNUNET_JSON_pack_allow_null (
GNUNET_JSON_pack_object_incref (
"credit_facade_credentials",
- account->credit_facade_credentials))
+ (json_t *) credit_facade_credentials))
);
- aph = GNUNET_new (struct TALER_MERCHANT_AccountPostHandle);
+ aph = GNUNET_new (struct TALER_MERCHANT_AccountsPostHandle);
aph->ctx = ctx;
aph->cb = cb;
aph->cb_cls = cb_cls;
aph->url = TALER_url_join (backend_url,
- "private/account",
+ "private/accounts",
NULL);
if (NULL == aph->url)
{
@@ -211,8 +233,8 @@ TALER_MERCHANT_account_post (
void
-TALER_MERCHANT_account_post_cancel (
- struct TALER_MERCHANT_AccountPostHandle *aph)
+TALER_MERCHANT_accounts_post_cancel (
+ struct TALER_MERCHANT_AccountsPostHandle *aph)
{
if (NULL != aph->job)
{