summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/taler_merchant_service.h5
-rw-r--r--src/include/taler_merchant_testing_lib.h1
-rw-r--r--src/lib/merchant_api_post_order_pay.c7
-rw-r--r--src/testing/testing_api_cmd_pay_order.c69
4 files changed, 21 insertions, 61 deletions
diff --git a/src/include/taler_merchant_service.h b/src/include/taler_merchant_service.h
index 42cecb9d..8cee7da4 100644
--- a/src/include/taler_merchant_service.h
+++ b/src/include/taler_merchant_service.h
@@ -1832,11 +1832,14 @@ struct TALER_MERCHANT_OrderPayHandle;
*
* @param cls closure
* @param hr HTTP response details
+ * @param merchant_sig signature from the merchant
+ * affirming payment, or NULL on errors
*/
typedef void
(*TALER_MERCHANT_OrderPayCallback) (
void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr);
+ const struct TALER_MERCHANT_HttpResponse *hr,
+ const struct TALER_MerchantSignatureP *merchant_sig);
/**
diff --git a/src/include/taler_merchant_testing_lib.h b/src/include/taler_merchant_testing_lib.h
index c5ca3909..1e36e279 100644
--- a/src/include/taler_merchant_testing_lib.h
+++ b/src/include/taler_merchant_testing_lib.h
@@ -514,6 +514,7 @@ TALER_TESTING_cmd_merchant_post_orders_no_claim (const char *label,
struct GNUNET_TIME_Absolute
pay_deadline,
const char *amount);
+
/**
* Make the "proposal" command.
*
diff --git a/src/lib/merchant_api_post_order_pay.c b/src/lib/merchant_api_post_order_pay.c
index 3675ca6d..12b3312c 100644
--- a/src/lib/merchant_api_post_order_pay.c
+++ b/src/lib/merchant_api_post_order_pay.c
@@ -248,6 +248,8 @@ handle_pay_finished (void *cls,
.http_status = (unsigned int) response_code,
.reply = json
};
+ struct TALER_MerchantSignatureP *merchant_sigp = NULL;
+ struct TALER_MerchantSignatureP merchant_sig;
oph->job = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -267,7 +269,6 @@ handle_pay_finished (void *cls,
.purpose.size = htonl (sizeof (pr)),
.h_contract_terms = oph->h_contract_terms
};
- struct TALER_MerchantSignatureP merchant_sig;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("sig",
&merchant_sig),
@@ -297,6 +298,7 @@ handle_pay_finished (void *cls,
hr.http_status = 0;
hr.hint = "signature invalid";
}
+ merchant_sigp = &merchant_sig;
}
break;
/* Tolerating Not Acceptable because sometimes
@@ -398,7 +400,8 @@ handle_pay_finished (void *cls,
break;
}
oph->pay_cb (oph->pay_cb_cls,
- &hr);
+ &hr,
+ merchant_sigp);
TALER_MERCHANT_order_pay_cancel (oph);
}
diff --git a/src/testing/testing_api_cmd_pay_order.c b/src/testing/testing_api_cmd_pay_order.c
index 62105b4c..dca44377 100644
--- a/src/testing/testing_api_cmd_pay_order.c
+++ b/src/testing/testing_api_cmd_pay_order.c
@@ -82,6 +82,10 @@ struct PayState
*/
struct TALER_MERCHANT_OrderPayHandle *oph;
+ /**
+ * Signature from the merchant, set on success.
+ */
+ struct TALER_MerchantSignatureP merchant_sig;
};
@@ -203,16 +207,15 @@ build_coins (struct TALER_MERCHANT_PayCoin **pc,
*
* @param cls closure with the interpreter state
* @param hr HTTP response
+ * @param merchant_sig signature affirming payment,
+ * NULL on errors
*/
static void
pay_cb (void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr)
+ const struct TALER_MERCHANT_HttpResponse *hr,
+ const struct TALER_MerchantSignatureP *merchant_sig)
{
struct PayState *ps = cls;
- struct GNUNET_CRYPTO_EddsaSignature sig;
- const char *error_name;
- unsigned int error_line;
- const struct TALER_MerchantPublicKeyP *merchant_pub;
ps->oph = NULL;
if (ps->http_status != hr->http_status)
@@ -226,60 +229,8 @@ pay_cb (void *cls,
}
if (MHD_HTTP_OK == hr->http_status)
{
- /* Check signature */
- struct PaymentResponsePS mr;
- struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_fixed_auto ("sig",
- &sig),
- GNUNET_JSON_spec_end ()
- };
- const struct TALER_TESTING_Command *proposal_cmd;
-
- if (GNUNET_OK !=
- GNUNET_JSON_parse (hr->reply,
- spec,
- &error_name,
- &error_line))
- {
- char *js;
-
- js = json_dumps (hr->reply,
- JSON_INDENT (1));
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Parser failed on %s:%u for input `%s'\n",
- error_name,
- error_line,
- js);
- free (js);
- TALER_TESTING_FAIL (ps->is);
- }
- mr.purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_PAYMENT_OK);
- mr.purpose.size = htonl (sizeof (mr));
- mr.h_contract_terms = ps->h_contract_terms;
-
- /* proposal reference was used at least once, at this point */
- GNUNET_assert (NULL !=
- (proposal_cmd =
- TALER_TESTING_interpreter_lookup_command (ps->is,
- ps->
- proposal_reference)));
- if (GNUNET_OK !=
- TALER_TESTING_get_trait_merchant_pub (proposal_cmd,
- 0,
- &merchant_pub))
- TALER_TESTING_FAIL (ps->is);
- if (GNUNET_OK !=
- GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MERCHANT_PAYMENT_OK,
- &mr,
- &sig,
- &merchant_pub->eddsa_pub))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Merchant signature given in response to /pay invalid\n");
- TALER_TESTING_FAIL (ps->is);
- }
+ ps->merchant_sig = *merchant_sig;
}
-
TALER_TESTING_interpreter_next (ps->is);
}
@@ -508,6 +459,8 @@ pay_traits (void *cls,
order_id),
TALER_TESTING_make_trait_merchant_pub (0,
merchant_pub),
+ TALER_TESTING_make_trait_merchant_sig (0,
+ &ps->merchant_sig),
TALER_TESTING_make_trait_string (0,
ps->amount_with_fee),
TALER_TESTING_trait_end ()