merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit 4635696452030932c2ecf74f2ff35ad4ddc87d9f
parent cebac2a50cd319c670b51eeddb7787ecb5459a00
Author: Christian Grothoff <christian@grothoff.org>
Date:   Tue, 24 Mar 2026 00:30:14 +0100

fix some discrepancies in libtalermerchant with respect to actual latest REST API implemented by the server

Diffstat:
Msrc/include/taler/taler-merchant/delete-management-instances-INSTANCE.h | 11+++++++++++
Msrc/include/taler/taler-merchant/get-management-instances-INSTANCE.h | 32++++++++++++++++++++++++++++++++
Msrc/include/taler/taler-merchant/get-management-instances.h | 15+++++++++++++++
Msrc/include/taler/taler-merchant/get-orders-ORDER_ID.h | 10++++++++++
Msrc/include/taler/taler-merchant/get-private-accounts.h | 5+++++
Msrc/include/taler/taler-merchant/get-private-kyc.h | 15+++++++++++++++
Msrc/include/taler/taler-merchant/get-private-templates-TEMPLATE_ID.h | 10++++++++++
Msrc/include/taler/taler-merchant/get-templates-TEMPLATE_ID.h | 11+++++++++++
Msrc/include/taler/taler-merchant/post-management-instances-INSTANCE-auth.h | 11+++++++++++
Msrc/include/taler/taler-merchant/post-management-instances.h | 11+++++++++++
Msrc/include/taler/taler-merchant/post-private-accounts.h | 5+++++
Msrc/include/taler/taler-merchant/post-private-donau.h | 11+++++++++++
Msrc/include/taler/taler-merchant/post-private-token.h | 11+++++++++++
Msrc/lib/Makefile.am | 1+
Msrc/lib/merchant_api_common.h | 13+++++++++++++
Asrc/lib/merchant_api_common_mfa_challenge.c | 101+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/lib/merchant_api_delete-management-instances-INSTANCE.c | 15+++++++++++++++
Msrc/lib/merchant_api_get-management-instances-INSTANCE.c | 30++++++++++++++++++++++++++++++
Msrc/lib/merchant_api_get-management-instances.c | 13+++++++++++++
Msrc/lib/merchant_api_get-orders-ORDER_ID.c | 32+++++++++++++++++++++++++-------
Msrc/lib/merchant_api_get-private-accounts.c | 2++
Msrc/lib/merchant_api_get-private-kyc.c | 14++++++++++++++
Msrc/lib/merchant_api_get-private-orders-ORDER_ID.c | 5+++++
Msrc/lib/merchant_api_get-private-templates-TEMPLATE_ID.c | 8++++++++
Msrc/lib/merchant_api_get-private-webhooks.c | 2++
Msrc/lib/merchant_api_get-templates-TEMPLATE_ID.c | 26++++++++++++++++----------
Msrc/lib/merchant_api_post-management-instances-INSTANCE-auth.c | 14++++++++++++++
Msrc/lib/merchant_api_post-management-instances.c | 14++++++++++++++
Msrc/lib/merchant_api_post-private-accounts.c | 14++++++++++++++
Msrc/lib/merchant_api_post-private-donau.c | 22++++++++++++++++++++++
Msrc/lib/merchant_api_post-private-token.c | 14++++++++++++++
31 files changed, 481 insertions(+), 17 deletions(-)

diff --git a/src/include/taler/taler-merchant/delete-management-instances-INSTANCE.h b/src/include/taler/taler-merchant/delete-management-instances-INSTANCE.h @@ -127,6 +127,17 @@ struct TALER_MERCHANT_DeleteManagementInstanceResponse * HTTP response details. */ struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on HTTP status code. + */ + union + { + /** + * Details in case HTTP status code is #MHD_HTTP_ACCEPTED. + */ + struct TALER_MERCHANT_MfaChallengeResponse accepted; + } details; }; diff --git a/src/include/taler/taler-merchant/get-management-instances-INSTANCE.h b/src/include/taler/taler-merchant/get-management-instances-INSTANCE.h @@ -82,6 +82,38 @@ struct TALER_MERCHANT_GetManagementInstanceDetails */ const json_t *jurisdiction; + /** + * Email address of the merchant (optional, may be NULL). + */ + const char *email; + + /** + * Whether the email address has been validated. + * Only meaningful if @e email is not NULL. + */ + bool email_validated; + + /** + * Phone number of the merchant (optional, may be NULL). + */ + const char *phone_number; + + /** + * Whether the phone number has been validated. + * Only meaningful if @e phone_number is not NULL. + */ + bool phone_validated; + + /** + * Website URL of the merchant (optional, may be NULL). + */ + const char *website; + + /** + * Logo of the merchant (optional, may be NULL). + */ + const char *logo; + }; diff --git a/src/include/taler/taler-merchant/get-management-instances.h b/src/include/taler/taler-merchant/get-management-instances.h @@ -57,6 +57,21 @@ struct TALER_MERCHANT_GetManagementInstancesInstanceInfo */ const json_t *payment_targets; + /** + * Website URL of the instance, or NULL if not set. + */ + const char *website; + + /** + * Logo (data URL) of the instance, or NULL if not set. + */ + const char *logo; + + /** + * True if this instance has been deleted. + */ + bool deleted; + }; diff --git a/src/include/taler/taler-merchant/get-orders-ORDER_ID.h b/src/include/taler/taler-merchant/get-orders-ORDER_ID.h @@ -279,6 +279,11 @@ struct TALER_MERCHANT_GetOrdersResponse */ struct TALER_Amount refund_amount; + /** + * Total amount of refunds taken by the wallet so far. + */ + struct TALER_Amount refund_taken; + } ok; /** @@ -298,6 +303,11 @@ struct TALER_MERCHANT_GetOrdersResponse */ const char *already_paid_order_id; + /** + * Fulfillment URL of the order, or NULL if not available. + */ + const char *fulfillment_url; + } payment_required; } details; diff --git a/src/include/taler/taler-merchant/get-private-accounts.h b/src/include/taler/taler-merchant/get-private-accounts.h @@ -47,6 +47,11 @@ struct TALER_MERCHANT_GetPrivateAccountsAccountEntry */ struct TALER_FullPayto payto_uri; + /** + * True if the account is active. + */ + bool active; + }; diff --git a/src/include/taler/taler-merchant/get-private-kyc.h b/src/include/taler/taler-merchant/get-private-kyc.h @@ -335,6 +335,21 @@ struct TALER_MERCHANT_GetPrivateKycRedirectDetail bool no_access_token; /** + * Hash of the wire account this entry is about. + */ + struct TALER_MerchantWireHashP h_wire; + + /** + * KYC status string, or NULL if not provided. + */ + const char *status; + + /** + * Currency used by the exchange, or NULL if not provided. + */ + const char *exchange_currency; + + /** * Set to true if the merchant backend could not * get the exchanges ``/keys`` and thus could not * determine default limits or determine an diff --git a/src/include/taler/taler-merchant/get-private-templates-TEMPLATE_ID.h b/src/include/taler/taler-merchant/get-private-templates-TEMPLATE_ID.h @@ -69,6 +69,16 @@ struct TALER_MERCHANT_GetPrivateTemplateResponse */ const json_t *template_contract; + /** + * Editable defaults (JSON), or NULL if not set. + */ + const json_t *editable_defaults; + + /** + * Required currency, or NULL if not set. + */ + const char *required_currency; + } ok; } details; diff --git a/src/include/taler/taler-merchant/get-templates-TEMPLATE_ID.h b/src/include/taler/taler-merchant/get-templates-TEMPLATE_ID.h @@ -59,6 +59,17 @@ struct TALER_MERCHANT_GetTemplatesResponse */ const json_t *template_contract; + /** + * Editable defaults (JSON object), or NULL if not provided. + */ + const json_t *editable_defaults; + + /** + * Required currency, or NULL if not provided. + * FIXME: currently not provided by the backend. Fix backend! + */ + const char *required_currency; + } ok; } details; diff --git a/src/include/taler/taler-merchant/post-management-instances-INSTANCE-auth.h b/src/include/taler/taler-merchant/post-management-instances-INSTANCE-auth.h @@ -42,6 +42,17 @@ struct TALER_MERCHANT_PostManagementInstancesAuthResponse */ struct TALER_MERCHANT_HttpResponse hr; + /** + * Details depending on the HTTP status code. + */ + union + { + /** + * Details on #MHD_HTTP_ACCEPTED. + */ + struct TALER_MERCHANT_MfaChallengeResponse accepted; + } details; + }; diff --git a/src/include/taler/taler-merchant/post-management-instances.h b/src/include/taler/taler-merchant/post-management-instances.h @@ -42,6 +42,17 @@ struct TALER_MERCHANT_PostManagementInstancesResponse */ struct TALER_MERCHANT_HttpResponse hr; + /** + * Details depending on the HTTP status code. + */ + union + { + /** + * Details on #MHD_HTTP_ACCEPTED. + */ + struct TALER_MERCHANT_MfaChallengeResponse accepted; + } details; + }; diff --git a/src/include/taler/taler-merchant/post-private-accounts.h b/src/include/taler/taler-merchant/post-private-accounts.h @@ -123,6 +123,11 @@ struct TALER_MERCHANT_PostPrivateAccountsResponse } ok; + /** + * Details on #MHD_HTTP_ACCEPTED. + */ + struct TALER_MERCHANT_MfaChallengeResponse accepted; + } details; }; diff --git a/src/include/taler/taler-merchant/post-private-donau.h b/src/include/taler/taler-merchant/post-private-donau.h @@ -107,6 +107,17 @@ struct TALER_MERCHANT_PostPrivateDonauResponse */ struct TALER_MERCHANT_HttpResponse hr; + /** + * Details depending on the HTTP status code. + */ + union + { + /** + * Details on #MHD_HTTP_ACCEPTED. + */ + struct TALER_MERCHANT_MfaChallengeResponse accepted; + } details; + }; diff --git a/src/include/taler/taler-merchant/post-private-token.h b/src/include/taler/taler-merchant/post-private-token.h @@ -42,6 +42,17 @@ struct TALER_MERCHANT_PostPrivateTokenResponse */ struct TALER_MERCHANT_HttpResponse hr; + /** + * Details depending on the HTTP status code. + */ + union + { + /** + * Details on #MHD_HTTP_ACCEPTED. + */ + struct TALER_MERCHANT_MfaChallengeResponse accepted; + } details; + }; diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am @@ -16,6 +16,7 @@ libtalermerchant_la_LDFLAGS = \ libtalermerchant_la_SOURCES = \ merchant_api_curl_defaults.c merchant_api_curl_defaults.h \ merchant_api_common.c merchant_api_common.h \ + merchant_api_common_mfa_challenge.c \ merchant_api_delete-management-instances-INSTANCE.c \ merchant_api_delete-private-accounts-H_WIRE.c \ merchant_api_delete-private-orders-ORDER_ID.c \ diff --git a/src/lib/merchant_api_common.h b/src/lib/merchant_api_common.h @@ -58,6 +58,19 @@ TALER_MERCHANT_parse_error_details_ (const json_t *response, struct TALER_MERCHANT_HttpResponse *hr); +/** + * Parse a 202 Accepted MFA challenge response from JSON. + * + * @param json the JSON response body + * @param[out] cr challenge response to fill in + * @return #GNUNET_OK on success, #GNUNET_SYSERR on parse error + */ +enum GNUNET_GenericReturnValue +TALER_MERCHANT_parse_mfa_challenge_response_ ( + const json_t *json, + struct TALER_MERCHANT_MfaChallengeResponse *cr); + + enum GNUNET_GenericReturnValue TALER_MERCHANT_parse_fractional_string (bool allow_negative, const char *value, diff --git a/src/lib/merchant_api_common_mfa_challenge.c b/src/lib/merchant_api_common_mfa_challenge.c @@ -0,0 +1,101 @@ +/* + This file is part of TALER + Copyright (C) 2025-2026 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 published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with + TALER; see the file COPYING.LGPL. If not, see + <http://www.gnu.org/licenses/> +*/ +/** + * @file merchant_api_common_mfa_challenge.c + * @brief Shared parsing of HTTP 202 MFA challenge responses + * @author Christian Grothoff + */ +#include "taler/platform.h" +#include "taler/taler_merchant_service.h" +#include <gnunet/gnunet_json_lib.h> +#include "merchant_api_common.h" + + +enum GNUNET_GenericReturnValue +TALER_MERCHANT_parse_mfa_challenge_response_ ( + const json_t *json, + struct TALER_MERCHANT_MfaChallengeResponse *cr) +{ + const json_t *challenges; + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_bool ("combi_and", + &cr->combi_and), + GNUNET_JSON_spec_array_const ("challenges", + &challenges), + GNUNET_JSON_spec_end () + }; + + memset (cr, + 0, + sizeof (*cr)); + if (GNUNET_OK != + GNUNET_JSON_parse (json, + spec, + NULL, NULL)) + { + GNUNET_break_op (0); + return GNUNET_SYSERR; + } + cr->challenges_length = (unsigned int) json_array_size (challenges); + if (0 == cr->challenges_length) + { + GNUNET_break_op (0); + return GNUNET_SYSERR; + } + cr->challenges = GNUNET_new_array ( + cr->challenges_length, + struct TALER_MERCHANT_MfaChallengeEntry); + for (unsigned int i = 0; i < cr->challenges_length; i++) + { + const json_t *jentry = json_array_get (challenges, + i); + struct TALER_MERCHANT_MfaChallengeEntry *entry = &cr->challenges[i]; + struct GNUNET_JSON_Specification espec[] = { + GNUNET_JSON_spec_string ("tan_info", + &entry->tan_info), + GNUNET_JSON_spec_string ("tan_channel", + &entry->tan_channel), + GNUNET_JSON_spec_string ("challenge_id", + &entry->challenge_id), + GNUNET_JSON_spec_end () + }; + + if (GNUNET_OK != + GNUNET_JSON_parse (jentry, + espec, + NULL, NULL)) + { + GNUNET_break_op (0); + GNUNET_free (cr->challenges); + cr->challenges_length = 0; + return GNUNET_SYSERR; + } + } + return GNUNET_OK; +} + + +void +TALER_MERCHANT_mfa_challenge_response_free ( + struct TALER_MERCHANT_MfaChallengeResponse *cr) +{ + GNUNET_free (cr->challenges); + cr->challenges_length = 0; +} + + +/* end of merchant_api_common_mfa_challenge.c */ diff --git a/src/lib/merchant_api_delete-management-instances-INSTANCE.c b/src/lib/merchant_api_delete-management-instances-INSTANCE.c @@ -28,6 +28,7 @@ #include <taler/taler-merchant/delete-management-instances-INSTANCE.h> #include "merchant_api_curl_defaults.h" #include <taler/taler_json_lib.h> +#include "merchant_api_common.h" /** @@ -105,6 +106,17 @@ handle_delete_instance_finished (void *cls, { case MHD_HTTP_NO_CONTENT: break; + case MHD_HTTP_ACCEPTED: + if (GNUNET_OK != + TALER_MERCHANT_parse_mfa_challenge_response_ ( + json, + &dir.details.accepted)) + { + GNUNET_break_op (0); + dir.hr.http_status = 0; + dir.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; + } + break; case MHD_HTTP_UNAUTHORIZED: dir.hr.ec = TALER_JSON_get_error_code (json); dir.hr.hint = TALER_JSON_get_error_hint (json); @@ -128,6 +140,9 @@ handle_delete_instance_finished (void *cls, } dih->cb (dih->cb_cls, &dir); + if (MHD_HTTP_ACCEPTED == response_code) + TALER_MERCHANT_mfa_challenge_response_free ( + &dir.details.accepted); TALER_MERCHANT_delete_management_instance_cancel (dih); } diff --git a/src/lib/merchant_api_get-management-instances-INSTANCE.c b/src/lib/merchant_api_get-management-instances-INSTANCE.c @@ -134,6 +134,36 @@ handle_get_instance_finished (void *cls, "default_wire_transfer_rounding_interval", &igr.details.ok.details.default_wire_transfer_rounding_interval), NULL), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_string ( + "email", + &igr.details.ok.details.email), + NULL), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_bool ( + "email_validated", + &igr.details.ok.details.email_validated), + NULL), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_string ( + "phone_number", + &igr.details.ok.details.phone_number), + NULL), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_bool ( + "phone_validated", + &igr.details.ok.details.phone_validated), + NULL), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_string ( + "website", + &igr.details.ok.details.website), + NULL), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_string ( + "logo", + &igr.details.ok.details.logo), + NULL), GNUNET_JSON_spec_end () }; diff --git a/src/lib/merchant_api_get-management-instances.c b/src/lib/merchant_api_get-management-instances.c @@ -99,6 +99,9 @@ parse_instances (const json_t *ia, size_t index; json_t *value; + memset (iis, + 0, + sizeof (iis)); json_array_foreach (ia, index, value) { struct TALER_MERCHANT_GetManagementInstancesInstanceInfo *ii = &iis[index]; @@ -111,6 +114,16 @@ parse_instances (const json_t *ia, &ii->merchant_pub), GNUNET_JSON_spec_array_const ("payment_targets", &ii->payment_targets), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_string ("website", + &ii->website), + NULL), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_string ("logo", + &ii->logo), + NULL), + GNUNET_JSON_spec_bool ("deleted", + &ii->deleted), GNUNET_JSON_spec_end () }; diff --git a/src/lib/merchant_api_get-orders-ORDER_ID.c b/src/lib/merchant_api_get-orders-ORDER_ID.c @@ -137,6 +137,10 @@ handle_get_order_finished (void *cls, &owgr.details.ok.refund_pending), TALER_JSON_spec_amount_any ("refund_amount", &owgr.details.ok.refund_amount), + GNUNET_JSON_spec_mark_optional ( + TALER_JSON_spec_amount_any ("refund_taken", + &owgr.details.ok.refund_taken), + NULL), GNUNET_JSON_spec_end () }; @@ -156,13 +160,27 @@ handle_get_order_finished (void *cls, } case MHD_HTTP_PAYMENT_REQUIRED: { - owgr.details.payment_required.taler_pay_uri - = json_string_value (json_object_get (json, - "taler_pay_uri")); - owgr.details.payment_required.already_paid_order_id - = json_string_value (json_object_get (json, - "already_paid_order_id")); - if (NULL == owgr.details.payment_required.taler_pay_uri) + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_string ( + "taler_pay_uri", + &owgr.details.payment_required.taler_pay_uri), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_string ( + "already_paid_order_id", + &owgr.details.payment_required.already_paid_order_id), + NULL), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_string ( + "fulfillment_url", + &owgr.details.payment_required.fulfillment_url), + NULL), + GNUNET_JSON_spec_end () + }; + + if (GNUNET_OK != + GNUNET_JSON_parse (json, + spec, + NULL, NULL)) { owgr.hr.http_status = 0; owgr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; diff --git a/src/lib/merchant_api_get-private-accounts.c b/src/lib/merchant_api_get-private-accounts.c @@ -107,6 +107,8 @@ parse_accounts (const json_t *ia, &ae->payto_uri), GNUNET_JSON_spec_fixed_auto ("h_wire", &ae->h_wire), + GNUNET_JSON_spec_bool ("active", + &ae->active), GNUNET_JSON_spec_end () }; diff --git a/src/lib/merchant_api_get-private-kyc.c b/src/lib/merchant_api_get-private-kyc.c @@ -209,6 +209,20 @@ parse_kyc (struct TALER_MERCHANT_GetPrivateKycHandle *kyc, "access_token", &rd->access_token), &rd->no_access_token), + GNUNET_JSON_spec_fixed_auto ( + "h_wire", + &rd->h_wire), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_string ( + "status", + &rd->status), + NULL), + /* Mandatory since **v25** */ + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_string ( + "exchange_currency", + &rd->exchange_currency), + NULL), GNUNET_JSON_spec_mark_optional ( GNUNET_JSON_spec_array_const ( "limits", diff --git a/src/lib/merchant_api_get-private-orders-ORDER_ID.c b/src/lib/merchant_api_get-private-orders-ORDER_ID.c @@ -365,6 +365,11 @@ handle_get_private_order_finished (void *cls, case MHD_HTTP_OK: /* see below */ break; + case MHD_HTTP_NOT_MODIFIED: + oph->cb (oph->cb_cls, + &osr); + TALER_MERCHANT_get_private_order_cancel (oph); + return; case MHD_HTTP_ACCEPTED: oph->cb (oph->cb_cls, &osr); diff --git a/src/lib/merchant_api_get-private-templates-TEMPLATE_ID.c b/src/lib/merchant_api_get-private-templates-TEMPLATE_ID.c @@ -110,6 +110,14 @@ handle_get_template_finished (void *cls, NULL), GNUNET_JSON_spec_object_const ("template_contract", &contract), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_object_const ("editable_defaults", + &tgr.details.ok.editable_defaults), + NULL), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_string ("required_currency", + &tgr.details.ok.required_currency), + NULL), GNUNET_JSON_spec_end () }; diff --git a/src/lib/merchant_api_get-private-webhooks.c b/src/lib/merchant_api_get-private-webhooks.c @@ -106,6 +106,8 @@ parse_webhooks (const json_t *ia, struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_string ("webhook_id", &ie->webhook_id), + GNUNET_JSON_spec_string ("event_type", + &ie->event_type), GNUNET_JSON_spec_end () }; diff --git a/src/lib/merchant_api_get-templates-TEMPLATE_ID.c b/src/lib/merchant_api_get-templates-TEMPLATE_ID.c @@ -100,26 +100,32 @@ handle_get_template_finished (void *cls, { case MHD_HTTP_OK: { - const json_t *contract; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_object_const ("template_contract", - &contract), + &wtgr.details.ok.template_contract), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_object_const ( + "editable_defaults", + &wtgr.details.ok.editable_defaults), + NULL), + /* FIXME: never actually set by the merchant in the current code! */ + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_string ( + "required_currency", + &wtgr.details.ok.required_currency), + NULL), GNUNET_JSON_spec_end () }; - if (GNUNET_OK == + if (GNUNET_OK != GNUNET_JSON_parse (json, spec, NULL, NULL)) { - wtgr.details.ok.template_contract = contract; - gth->cb (gth->cb_cls, - &wtgr); - TALER_MERCHANT_get_templates_cancel (gth); - return; + wtgr.hr.http_status = 0; + wtgr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; + break; } - wtgr.hr.http_status = 0; - wtgr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; } case MHD_HTTP_UNAUTHORIZED: diff --git a/src/lib/merchant_api_post-management-instances-INSTANCE-auth.c b/src/lib/merchant_api_post-management-instances-INSTANCE-auth.c @@ -113,6 +113,17 @@ handle_post_management_instances_auth_finished (void *cls, { case MHD_HTTP_NO_CONTENT: break; + case MHD_HTTP_ACCEPTED: + if (GNUNET_OK != + TALER_MERCHANT_parse_mfa_challenge_response_ ( + json, + &iar.details.accepted)) + { + GNUNET_break_op (0); + iar.hr.http_status = 0; + iar.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; + } + break; case MHD_HTTP_BAD_REQUEST: iar.hr.ec = TALER_JSON_get_error_code (json); iar.hr.hint = TALER_JSON_get_error_hint (json); @@ -132,6 +143,9 @@ handle_post_management_instances_auth_finished (void *cls, } piah->cb (piah->cb_cls, &iar); + if (MHD_HTTP_ACCEPTED == response_code) + TALER_MERCHANT_mfa_challenge_response_free ( + &iar.details.accepted); TALER_MERCHANT_post_management_instances_auth_cancel (piah); } diff --git a/src/lib/merchant_api_post-management-instances.c b/src/lib/merchant_api_post-management-instances.c @@ -152,6 +152,17 @@ handle_post_management_instances_finished (void *cls, break; case MHD_HTTP_NO_CONTENT: break; + case MHD_HTTP_ACCEPTED: + if (GNUNET_OK != + TALER_MERCHANT_parse_mfa_challenge_response_ ( + json, + &mir.details.accepted)) + { + GNUNET_break_op (0); + mir.hr.http_status = 0; + mir.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; + } + break; case MHD_HTTP_BAD_REQUEST: mir.hr.ec = TALER_JSON_get_error_code (json); mir.hr.hint = TALER_JSON_get_error_hint (json); @@ -189,6 +200,9 @@ handle_post_management_instances_finished (void *cls, } pmih->cb (pmih->cb_cls, &mir); + if (MHD_HTTP_ACCEPTED == response_code) + TALER_MERCHANT_mfa_challenge_response_free ( + &mir.details.accepted); TALER_MERCHANT_post_management_instances_cancel (pmih); } diff --git a/src/lib/merchant_api_post-private-accounts.c b/src/lib/merchant_api_post-private-accounts.c @@ -142,6 +142,17 @@ handle_post_account_finished (void *cls, } } break; + case MHD_HTTP_ACCEPTED: + if (GNUNET_OK != + TALER_MERCHANT_parse_mfa_challenge_response_ ( + json, + &apr.details.accepted)) + { + GNUNET_break_op (0); + apr.hr.http_status = 0; + apr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; + } + break; case MHD_HTTP_BAD_REQUEST: GNUNET_break_op (0); apr.hr.ec = TALER_JSON_get_error_code (json); @@ -176,6 +187,9 @@ handle_post_account_finished (void *cls, } pah->cb (pah->cb_cls, &apr); + if (MHD_HTTP_ACCEPTED == response_code) + TALER_MERCHANT_mfa_challenge_response_free ( + &apr.details.accepted); TALER_MERCHANT_post_private_accounts_cancel (pah); } diff --git a/src/lib/merchant_api_post-private-donau.c b/src/lib/merchant_api_post-private-donau.c @@ -120,16 +120,35 @@ handle_post_donau_finished (void *cls, case 0: pdr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; + case MHD_HTTP_ACCEPTED: + if (GNUNET_OK != + TALER_MERCHANT_parse_mfa_challenge_response_ ( + json, + &pdr.details.accepted)) + { + GNUNET_break_op (0); + pdr.hr.http_status = 0; + pdr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; + } + break; case MHD_HTTP_NO_CONTENT: break; case MHD_HTTP_BAD_REQUEST: pdr.hr.ec = TALER_JSON_get_error_code (json); pdr.hr.hint = TALER_JSON_get_error_hint (json); break; + case MHD_HTTP_CONFLICT: + pdr.hr.ec = TALER_JSON_get_error_code (json); + pdr.hr.hint = TALER_JSON_get_error_hint (json); + break; case MHD_HTTP_INTERNAL_SERVER_ERROR: pdr.hr.ec = TALER_JSON_get_error_code (json); pdr.hr.hint = TALER_JSON_get_error_hint (json); break; + case MHD_HTTP_BAD_GATEWAY: + pdr.hr.ec = TALER_JSON_get_error_code (json); + pdr.hr.hint = TALER_JSON_get_error_hint (json); + break; default: TALER_MERCHANT_parse_error_details_ (json, response_code, @@ -143,6 +162,9 @@ handle_post_donau_finished (void *cls, } ppdh->cb (ppdh->cb_cls, &pdr); + if (MHD_HTTP_ACCEPTED == response_code) + TALER_MERCHANT_mfa_challenge_response_free ( + &pdr.details.accepted); TALER_MERCHANT_post_private_donau_cancel (ppdh); } diff --git a/src/lib/merchant_api_post-private-token.c b/src/lib/merchant_api_post-private-token.c @@ -128,6 +128,17 @@ handle_post_token_finished (void *cls, ptr.hr.ec = TALER_JSON_get_error_code (json); ptr.hr.hint = TALER_JSON_get_error_hint (json); break; + case MHD_HTTP_ACCEPTED: + if (GNUNET_OK != + TALER_MERCHANT_parse_mfa_challenge_response_ ( + json, + &ptr.details.accepted)) + { + GNUNET_break_op (0); + ptr.hr.http_status = 0; + ptr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; + } + break; case MHD_HTTP_UNAUTHORIZED: ptr.hr.ec = TALER_JSON_get_error_code (json); ptr.hr.hint = TALER_JSON_get_error_hint (json); @@ -143,6 +154,9 @@ handle_post_token_finished (void *cls, } ppth->cb (ppth->cb_cls, &ptr); + if (MHD_HTTP_ACCEPTED == response_code) + TALER_MERCHANT_mfa_challenge_response_free ( + &ptr.details.accepted); TALER_MERCHANT_post_private_token_cancel (ppth); }