summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcello Stanisci <marcello.stanisci@inria.fr>2016-06-24 16:17:53 +0200
committerMarcello Stanisci <marcello.stanisci@inria.fr>2016-06-24 16:17:53 +0200
commitc7cb7f925cabba012bf25160b14e65f287059b18 (patch)
tree818f0f9b81051dcca84dd8646dac8368b7cb40f6
parent3d95ff831163d714a9bd1d7f112d0c2be87948f0 (diff)
downloadmerchant-c7cb7f925cabba012bf25160b14e65f287059b18.tar.gz
merchant-c7cb7f925cabba012bf25160b14e65f287059b18.tar.bz2
merchant-c7cb7f925cabba012bf25160b14e65f287059b18.zip
adapting merchant-lib to use merchants instances
-rw-r--r--src/include/taler_merchant_service.h4
-rw-r--r--src/lib/merchant_api_pay.c9
-rw-r--r--src/lib/test_merchant_api.c16
-rw-r--r--src/lib/test_merchant_api.conf9
4 files changed, 38 insertions, 0 deletions
diff --git a/src/include/taler_merchant_service.h b/src/include/taler_merchant_service.h
index dbcd3104..4ec64322 100644
--- a/src/include/taler_merchant_service.h
+++ b/src/include/taler_merchant_service.h
@@ -161,6 +161,7 @@ struct TALER_MERCHANT_PayCoin
*
* @param ctx execution context
* @param merchant_uri base URI of the merchant
+ * @param receiver which merchant instance will receive this payment
* @param h_wire hash of the merchant’s account details
* @param h_contract hash of the contact of the merchant with the customer
* @param transaction_id transaction id for the transaction between merchant and customer
@@ -181,6 +182,7 @@ struct TALER_MERCHANT_PayCoin
struct TALER_MERCHANT_Pay *
TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context *ctx,
const char *merchant_uri,
+ const char *receiver,
const struct GNUNET_HashCode *h_contract,
uint64_t transaction_id,
const struct TALER_Amount *amount,
@@ -249,6 +251,7 @@ struct TALER_MERCHANT_PaidCoin
*
* @param ctx execution context
* @param merchant_uri base URI of the merchant
+ * @param receiver which merchant instance will receive this payment
* @param h_contract hash of the contact of the merchant with the customer
* @param amount total value of the contract to be paid to the merchant
* @param max_fee maximum fee covered by the merchant (according to the contract)
@@ -268,6 +271,7 @@ struct TALER_MERCHANT_PaidCoin
struct TALER_MERCHANT_Pay *
TALER_MERCHANT_pay_frontend (struct GNUNET_CURL_Context *ctx,
const char *merchant_uri,
+ const char *receiver,
const struct GNUNET_HashCode *h_contract,
const struct TALER_Amount *amount,
const struct TALER_Amount *max_fee,
diff --git a/src/lib/merchant_api_pay.c b/src/lib/merchant_api_pay.c
index 7dcc5fe7..56035afe 100644
--- a/src/lib/merchant_api_pay.c
+++ b/src/lib/merchant_api_pay.c
@@ -251,6 +251,7 @@ handle_pay_finished (void *cls,
*
* @param ctx the execution loop context
* @param merchant_uri base URI of the merchant's backend
+ * @param receiver which merchant instance will receive this payment
* @param h_wire hash of the merchant’s account details
* @param h_contract hash of the contact of the merchant with the customer
* @param transaction_id transaction id for the transaction between merchant and customer
@@ -275,6 +276,7 @@ handle_pay_finished (void *cls,
struct TALER_MERCHANT_Pay *
TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context *ctx,
const char *merchant_uri,
+ const char *receiver,
const struct GNUNET_HashCode *h_contract,
uint64_t transaction_id,
const struct TALER_Amount *amount,
@@ -337,6 +339,7 @@ TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context *ctx,
}
return TALER_MERCHANT_pay_frontend (ctx,
merchant_uri,
+ receiver,
h_contract,
amount,
max_fee,
@@ -361,6 +364,7 @@ TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context *ctx,
*
* @param ctx the execution loop context
* @param merchant_uri base URI of the merchant's backend
+ * @param receiver which merchant instance will receive this payment
* @param h_contract hash of the contact of the merchant with the customer
* @param timestamp timestamp when the contract was finalized, must match approximately the current time of the merchant
* @param transaction_id transaction id for the transaction between merchant and customer
@@ -379,6 +383,7 @@ TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context *ctx,
struct TALER_MERCHANT_Pay *
TALER_MERCHANT_pay_frontend (struct GNUNET_CURL_Context *ctx,
const char *merchant_uri,
+ const char *receiver,
const struct GNUNET_HashCode *h_contract,
const struct TALER_Amount *amount,
const struct TALER_Amount *max_fee,
@@ -557,6 +562,10 @@ TALER_MERCHANT_pay_frontend (struct GNUNET_CURL_Context *ctx,
"max_fee", TALER_JSON_from_amount (max_fee),
"amount", TALER_JSON_from_amount (amount),
"merchant_sig", GNUNET_JSON_from_data_auto (merchant_sig));
+ if (NULL != receiver)
+ json_object_set_new (pay_obj,
+ "receiver",
+ json_string (receiver));
if (0 != wire_transfer_deadline.abs_value_us)
{
diff --git a/src/lib/test_merchant_api.c b/src/lib/test_merchant_api.c
index ee47f07a..d3300605 100644
--- a/src/lib/test_merchant_api.c
+++ b/src/lib/test_merchant_api.c
@@ -61,6 +61,12 @@ static struct TALER_EXCHANGE_Handle *exchange;
static struct GNUNET_CURL_Context *ctx;
/**
+ * Which merchant instance we will run the testcase for
+ */
+static char *instance;
+
+
+/**
* Public key of the merchant, matches the private
* key from "test_merchant.priv".
*/
@@ -1562,6 +1568,7 @@ interpreter_run (void *cls)
cmd->details.pay.ph
= TALER_MERCHANT_pay_wallet (ctx,
MERCHANT_URI,
+ NULL,
&h_contract,
transaction_id,
&total_amount,
@@ -1838,6 +1845,7 @@ do_shutdown (void *cls)
is->task = NULL;
}
GNUNET_free (is);
+ GNUNET_free_non_null (instance);
if (NULL != exchange)
{
TALER_EXCHANGE_disconnect (exchange);
@@ -2150,6 +2158,14 @@ main (int argc,
GNUNET_assert (GNUNET_OK ==
GNUNET_CONFIGURATION_load (cfg,
"test_merchant_api.conf"));
+ if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg,
+ "merchant",
+ "INSTANCE",
+ &instance))
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Using non default instance '%s'\n",
+ instance);
+
db = TALER_MERCHANTDB_plugin_load (cfg);
if (NULL == db)
{
diff --git a/src/lib/test_merchant_api.conf b/src/lib/test_merchant_api.conf
index 4b98bde9..3f01f757 100644
--- a/src/lib/test_merchant_api.conf
+++ b/src/lib/test_merchant_api.conf
@@ -36,11 +36,20 @@ DB = postgres
# Which wireformat do we use?
WIREFORMAT = test
+# If set, this option will drive the testcase so that
+# `INSTANCE' will be the used merchant instance. Otherwise
+# we use the 'default' instance
+INSTANCE = tor
+
[merchant-exchange-test]
URI = http://localhost:8081/
MASTER_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
+[merchant-instance-default]
+KEYFILE = test_merchant.priv
+[default-wireformat]
+TEST_RESPONSE_FILE = ${TALER_CONFIG_HOME}/merchant/wire/test.json
# Auditors must be in sections "auditor-", the rest of the section
# name could be anything.