aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-10-20 21:23:14 +0200
committerChristian Grothoff <christian@grothoff.org>2016-10-20 21:23:20 +0200
commit1de87fc27f26ce5e1d54526ae66d45f9e35b13ac (patch)
treecc9a6dc2b59c1615d5742f75d6c2ad16a170451b /src/lib
parentb9b230e7079bb9e1eb937ef07e1b6b7408176f3d (diff)
have merchant C API also return taler error codes (at least those from the merchant for now)
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/merchant_api_contract.c1
-rw-r--r--src/lib/merchant_api_history.c16
-rw-r--r--src/lib/merchant_api_pay.c1
-rw-r--r--src/lib/merchant_api_track_transaction.c2
-rw-r--r--src/lib/merchant_api_track_transfer.c2
-rw-r--r--src/lib/test_merchant_api.c13
6 files changed, 28 insertions, 7 deletions
diff --git a/src/lib/merchant_api_contract.c b/src/lib/merchant_api_contract.c
index 23c13e41..469539bf 100644
--- a/src/lib/merchant_api_contract.c
+++ b/src/lib/merchant_api_contract.c
@@ -148,6 +148,7 @@ handle_contract_finished (void *cls,
}
co->cb (co->cb_cls,
response_code,
+ TALER_JSON_get_error_code (json),
json,
contract,
sigp,
diff --git a/src/lib/merchant_api_history.c b/src/lib/merchant_api_history.c
index 8cce49ed..bf7505f4 100644
--- a/src/lib/merchant_api_history.c
+++ b/src/lib/merchant_api_history.c
@@ -81,7 +81,7 @@ TALER_MERCHANT_history_cancel (struct TALER_MERCHANT_HistoryOperation *ho)
/**
* Function called when we're done processing the
- * HTTP /track/transaction request.
+ * HTTP /history request.
*
* @param cls the `struct TALER_MERCHANT_TrackTransactionHandle`
* @param response_code HTTP response code, 0 on error
@@ -102,16 +102,18 @@ history_raw_cb (void *cls,
break;
case MHD_HTTP_OK:
ho->cb (ho->cb_cls,
- response_code,
+ MHD_HTTP_OK,
+ TALER_EC_NONE,
json);
return;
break;
case MHD_HTTP_INTERNAL_SERVER_ERROR:
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "history URI not found\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "/history URI not found\n");
break;
-
case MHD_HTTP_BAD_REQUEST:
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Wrong parameter passed in URL\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Wrong parameter passed in URL\n");
break;
default:
/* unexpected response code */
@@ -124,10 +126,12 @@ history_raw_cb (void *cls,
}
ho->cb (ho->cb_cls,
response_code,
+ TALER_JSON_get_error_code (json),
json);
TALER_MERCHANT_history_cancel (ho);
}
+
/**
* Issue a /history request to the backend.
*
@@ -135,7 +139,7 @@ history_raw_cb (void *cls,
* @param backend_uri base URL of the merchant backend
* @param date only transactions younger than/equals to date will be returned
* @param history_cb callback which will work the response gotten from the backend
- * @param history_cb_cls closure to pass to history_cb
+ * @param history_cb_cls closure to pass to @a history_cb
* @return handle for this operation, NULL upon errors
*/
struct TALER_MERCHANT_HistoryOperation *
diff --git a/src/lib/merchant_api_pay.c b/src/lib/merchant_api_pay.c
index c2511169..821534a7 100644
--- a/src/lib/merchant_api_pay.c
+++ b/src/lib/merchant_api_pay.c
@@ -241,6 +241,7 @@ handle_pay_finished (void *cls,
(unsigned int) response_code);
ph->cb (ph->cb_cls,
response_code,
+ TALER_JSON_get_error_code (json),
json);
TALER_MERCHANT_pay_cancel (ph);
}
diff --git a/src/lib/merchant_api_track_transaction.c b/src/lib/merchant_api_track_transaction.c
index 82e2d0f4..c42b1128 100644
--- a/src/lib/merchant_api_track_transaction.c
+++ b/src/lib/merchant_api_track_transaction.c
@@ -155,6 +155,7 @@ parse_track_transaction_ok (struct TALER_MERCHANT_TrackTransactionHandle *tdo,
}
tdo->cb (tdo->cb_cls,
MHD_HTTP_OK,
+ TALER_EC_NONE,
json,
num_transfers,
transfers);
@@ -218,6 +219,7 @@ handle_track_transaction_finished (void *cls,
}
tdo->cb (tdo->cb_cls,
response_code,
+ TALER_JSON_get_error_code (json),
json,
0,
NULL);
diff --git a/src/lib/merchant_api_track_transfer.c b/src/lib/merchant_api_track_transfer.c
index c9484ff9..0c1b3af9 100644
--- a/src/lib/merchant_api_track_transfer.c
+++ b/src/lib/merchant_api_track_transfer.c
@@ -138,6 +138,7 @@ check_track_transfer_response_ok (struct TALER_MERCHANT_TrackTransferHandle *wdh
}
wdh->cb (wdh->cb_cls,
MHD_HTTP_OK,
+ TALER_EC_NONE,
&exchange_pub,
json,
&h_wire,
@@ -198,6 +199,7 @@ handle_track_transfer_finished (void *cls,
}
tdo->cb (tdo->cb_cls,
response_code,
+ TALER_JSON_get_error_code (json),
NULL,
json,
NULL,
diff --git a/src/lib/test_merchant_api.c b/src/lib/test_merchant_api.c
index e68c4b8b..b81678a4 100644
--- a/src/lib/test_merchant_api.c
+++ b/src/lib/test_merchant_api.c
@@ -744,11 +744,13 @@ add_incoming_cb (void *cls,
*
* @param cls closure
* @param http_status HTTP status returned by the merchant backend
+ * @param ec taler-specific error code
* @param json actual body containing history
*/
-void
+static void
history_cb (void *cls,
unsigned int http_status,
+ enum TALER_ErrorCode ec,
const json_t *json)
{
struct InterpreterState *is = cls;
@@ -962,6 +964,7 @@ reserve_status_cb (void *cls,
* @param cls closure with the interpreter state
* @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful status request
* 0 if the exchange's reply is bogus (fails to follow the protocol)
+ * @param ec taler-specific error code
* @param sig signature over the coin, NULL on error
* @param full_response full response from the exchange (for logging, in case of errors)
*/
@@ -1018,6 +1021,7 @@ reserve_withdraw_cb (void *cls,
* @param cls closure
* @param http_status HTTP response code, 200 indicates success;
* 0 if the backend's reply is bogus (fails to follow the protocol)
+ * @param ec taler-specific error code
* @param obj the full received JSON reply, or
* error details if the request failed
* @param contract completed contract, NULL on error
@@ -1027,6 +1031,7 @@ reserve_withdraw_cb (void *cls,
static void
contract_cb (void *cls,
unsigned int http_status,
+ enum TALER_ErrorCode ec,
const json_t *obj,
const json_t *contract,
const struct TALER_MerchantSignatureP *sig,
@@ -1063,12 +1068,14 @@ contract_cb (void *cls,
* @param cls closure with the interpreter state
* @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful deposit;
* 0 if the exchange's reply is bogus (fails to follow the protocol)
+ * @param ec taler-specific error code
* @param obj the received JSON reply, should be kept as proof (and, in case of errors,
* be forwarded to the customer)
*/
static void
pay_cb (void *cls,
unsigned int http_status,
+ enum TALER_ErrorCode ec,
const json_t *obj)
{
struct InterpreterState *is = cls;
@@ -1162,6 +1169,7 @@ maint_child_death (void *cls)
*
* @param cls closure for this function
* @param http_status HTTP response code returned by the server
+ * @param ec taler-specific error code
* @param sign_key exchange key used to sign @a json, or NULL
* @param json original json reply (may include signatures, those have then been
* validated already)
@@ -1174,6 +1182,7 @@ maint_child_death (void *cls)
static void
track_transfer_cb (void *cls,
unsigned int http_status,
+ enum TALER_ErrorCode ec,
const struct TALER_ExchangePublicKeyP *sign_key,
const json_t *json,
const struct GNUNET_HashCode *h_wire,
@@ -1270,6 +1279,7 @@ track_transfer_cb (void *cls,
*
* @param cls closure
* @param http_status HTTP status code we got, 0 on exchange protocol violation
+ * @param ec taler-specific error code
* @param json original json reply
* @param num_transfers number of wire transfers involved in setting the transaction
* @param transfers detailed list of transfers involved and their coins
@@ -1277,6 +1287,7 @@ track_transfer_cb (void *cls,
static void
track_transaction_cb (void *cls,
unsigned int http_status,
+ enum TALER_ErrorCode ec,
const json_t *json,
unsigned int num_transfers,
const struct TALER_MERCHANT_TransactionWireTransfer *transfers)