summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcello Stanisci <marcello.stanisci@inria.fr>2016-06-23 16:00:18 +0200
committerMarcello Stanisci <marcello.stanisci@inria.fr>2016-06-23 16:00:18 +0200
commitf8b0485a4d9aea856b6e33d6f5640ca3652babf4 (patch)
treecb11b02fa4291e085de01bf34cc39ad33867f46f
parent7995b55ebf7786719afb4fec95a9b7c2c3111149 (diff)
downloadmerchant-f8b0485a4d9aea856b6e33d6f5640ca3652babf4.tar.gz
merchant-f8b0485a4d9aea856b6e33d6f5640ca3652babf4.tar.bz2
merchant-f8b0485a4d9aea856b6e33d6f5640ca3652babf4.zip
picking receiver wireformat according to
what the frontend specified in the JSON
-rw-r--r--src/backend/taler-merchant-httpd.c1
-rw-r--r--src/backend/taler-merchant-httpd_pay.c27
2 files changed, 26 insertions, 2 deletions
diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c
index 3b253a9a..7a6a16a0 100644
--- a/src/backend/taler-merchant-httpd.c
+++ b/src/backend/taler-merchant-httpd.c
@@ -287,6 +287,7 @@ do_shutdown (void *cls)
for (i=0; NULL != instances[i]; i++)
{
+ json_decref (instances[i]->j_wire);
GNUNET_free (instances[i]);
}
}
diff --git a/src/backend/taler-merchant-httpd_pay.c b/src/backend/taler-merchant-httpd_pay.c
index a1320fa1..b40c1dbc 100644
--- a/src/backend/taler-merchant-httpd_pay.c
+++ b/src/backend/taler-merchant-httpd_pay.c
@@ -38,6 +38,8 @@
*/
#define PAY_TIMEOUT (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30))
+extern struct MerchantInstance **instances;
+
/**
* Information we keep for an individual call to the /pay handler.
@@ -232,6 +234,11 @@ struct PayContext
* transaction in our database.
*/
int transaction_exits;
+
+ /**
+ * Bank details of the payment's receiver (in JSON format)
+ */
+ struct json_t *receiver_j_wire;
};
@@ -642,6 +649,9 @@ process_pay_with_exchange (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Exchange and fee structure OK. Initiating deposit operation for coins\n");
+
+
+
/* Initiate /deposit operation for all coins */
for (i=0;i<pc->coins_cnt;i++)
{
@@ -649,11 +659,11 @@ process_pay_with_exchange (void *cls,
if (GNUNET_YES == dc->found_in_db)
continue;
- GNUNET_assert (NULL != j_wire);
+ GNUNET_assert (NULL != pc->receiver_j_wire);
dc->dh = TALER_EXCHANGE_deposit (mh,
&dc->amount_with_fee,
pc->wire_transfer_deadline,
- j_wire,
+ pc->receiver_j_wire,
&pc->h_contract,
&dc->coin_pub,
&dc->ub_sig,
@@ -818,6 +828,8 @@ MH_handler_pay (struct TMH_RequestHandler *rh,
struct PayContext *pc;
int res;
json_t *root;
+ struct json_t *receiver;
+ unsigned int i;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"In handler for /pay.\n");
@@ -1094,6 +1106,17 @@ MH_handler_pay (struct TMH_RequestHandler *rh,
}
MHD_suspend_connection (connection);
+
+
+ if (NULL == (receiver = json_object_get (root, "receiver")))
+ receiver = json_string ("default");
+
+ for (i=0; NULL != instances[i]; i++)
+ {
+ if (0 == strcmp (json_string_value (receiver), instances[i]->id))
+ pc->receiver_j_wire = instances[i]->j_wire;
+ }
+
/* Find the responsible exchange, this may take a while... */
pc->fo = TMH_EXCHANGES_find_exchange (pc->chosen_exchange,
&process_pay_with_exchange,