summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcello Stanisci <marcello.stanisci@inria.fr>2016-10-20 14:18:55 +0200
committerMarcello Stanisci <marcello.stanisci@inria.fr>2016-10-20 14:18:55 +0200
commit28542396565a8c3feb9b8a34be68410373022b6e (patch)
treec6f6c444e4065a37d35d4b6eab9656ec14b7164a
parent50959df54ff84280593f66453a998e83e81c75d8 (diff)
downloadmerchant-28542396565a8c3feb9b8a34be68410373022b6e.tar.gz
merchant-28542396565a8c3feb9b8a34be68410373022b6e.tar.bz2
merchant-28542396565a8c3feb9b8a34be68410373022b6e.zip
finishing with #4521
-rw-r--r--src/backend/taler-merchant-httpd_pay.c11
-rw-r--r--src/include/taler_merchant_service.h4
-rw-r--r--src/lib/merchant_api_pay.c17
-rw-r--r--src/lib/test_merchant_api.c7
4 files changed, 34 insertions, 5 deletions
diff --git a/src/backend/taler-merchant-httpd_pay.c b/src/backend/taler-merchant-httpd_pay.c
index 7f84eb9f..c07d1270 100644
--- a/src/backend/taler-merchant-httpd_pay.c
+++ b/src/backend/taler-merchant-httpd_pay.c
@@ -1145,9 +1145,16 @@ MH_handler_pay (struct TMH_RequestHandler *rh,
now = GNUNET_TIME_absolute_get ();
if (now.abs_value_us > pc->pay_deadline.abs_value_us)
{
- /* Time expired, the customer cannot pay! */
+ /* Time expired, we don't accept this payment now! */
+ const char *pd_str;
+ pd_str = GNUNET_STRINGS_absolute_time_to_string (pc->pay_deadline);
+
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Attempt to get coins for expired contract. Deadline: '%s'\n",
+ pd_str);
+
return TMH_RESPONSE_reply_bad_request (connection,
- "The time to pay for this contract has expired");
+ "The time to pay for this contract has expired.");
}
if (GNUNET_OK !=
diff --git a/src/include/taler_merchant_service.h b/src/include/taler_merchant_service.h
index b61b9cb7..dac6c766 100644
--- a/src/include/taler_merchant_service.h
+++ b/src/include/taler_merchant_service.h
@@ -171,6 +171,7 @@ struct TALER_MERCHANT_PayCoin
* @param merchant_sig signature from the merchant over the original contract
* @param timestamp timestamp when the contract was finalized, must match approximately the current time of the merchant
* @param refund_deadline date until which the merchant can issue a refund to the customer via the merchant (can be zero if refunds are not allowed)
+ * @param pay_deadline maximum time limit to pay for this contract
* @param exchange_uri URI of the exchange that the coins belong to
* @param num_coins number of coins used to pay
* @param coins array of coins we use to pay
@@ -191,6 +192,7 @@ TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context *ctx,
const struct TALER_MerchantSignatureP *merchant_sig,
struct GNUNET_TIME_Absolute timestamp,
struct GNUNET_TIME_Absolute refund_deadline,
+ struct GNUNET_TIME_Absolute pay_deadline,
const struct GNUNET_HashCode *h_wire,
const char *exchange_uri,
unsigned int num_coins,
@@ -258,6 +260,7 @@ struct TALER_MERCHANT_PaidCoin
* @param transaction_id transaction id for the transaction between merchant and customer
* @param merchant_sig the signature of the merchant over the original contract
* @param refund_deadline date until which the merchant can issue a refund to the customer via the merchant (can be zero if refunds are not allowed)
+ * @param pay_deadline maximum time limit to pay for this contract
* @param timestamp timestamp when the contract was finalized, must match approximately the current time of the merchant
* @param wire_transfer_deadline date by which the merchant would like the exchange to execute the wire transfer (can be zero if there is no specific date desired by the frontend). If non-zero, must be larger than @a refund_deadline.
* @param exchange_uri URI of the exchange that the coins belong to
@@ -278,6 +281,7 @@ TALER_MERCHANT_pay_frontend (struct GNUNET_CURL_Context *ctx,
uint64_t transaction_id,
const struct TALER_MerchantSignatureP *merchant_sig,
struct GNUNET_TIME_Absolute refund_deadline,
+ struct GNUNET_TIME_Absolute pay_deadline,
struct GNUNET_TIME_Absolute timestamp,
struct GNUNET_TIME_Absolute wire_transfer_deadline,
const char *exchange_uri,
diff --git a/src/lib/merchant_api_pay.c b/src/lib/merchant_api_pay.c
index d65eb254..c2511169 100644
--- a/src/lib/merchant_api_pay.c
+++ b/src/lib/merchant_api_pay.c
@@ -263,6 +263,7 @@ handle_pay_finished (void *cls,
* @param transaction_id transaction id for the transaction between merchant and customer
* @param merchant_pub the public key of the merchant (used to identify the merchant for refund requests)
* @param refund_deadline date until which the merchant can issue a refund to the customer via the merchant (can be zero if refunds are not allowed)
+ * @param pay_deadline maximum time limit to pay for this contract
* @param exchange_uri URI of the exchange that the coins belong to
* @param num_coins number of coins used to pay
* @param coins array of coins we use to pay
@@ -285,6 +286,7 @@ TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context *ctx,
const struct TALER_MerchantSignatureP *merchant_sig,
struct GNUNET_TIME_Absolute timestamp,
struct GNUNET_TIME_Absolute refund_deadline,
+ struct GNUNET_TIME_Absolute pay_deadline,
const struct GNUNET_HashCode *h_wire,
const char *exchange_uri,
unsigned int num_coins,
@@ -296,6 +298,10 @@ TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context *ctx,
struct TALER_DepositRequestPS dr;
struct TALER_MERCHANT_PaidCoin pc[num_coins];
+ (void) GNUNET_TIME_round_abs (&timestamp);
+ (void) GNUNET_TIME_round_abs (&pay_deadline);
+ (void) GNUNET_TIME_round_abs (&refund_deadline);
+
dr.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_DEPOSIT);
dr.purpose.size = htonl (sizeof (struct TALER_DepositRequestPS));
dr.h_contract = *h_contract;
@@ -346,6 +352,7 @@ TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context *ctx,
transaction_id,
merchant_sig,
refund_deadline,
+ pay_deadline,
timestamp,
GNUNET_TIME_UNIT_ZERO_ABS,
exchange_uri,
@@ -369,6 +376,7 @@ TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context *ctx,
* @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
* @param refund_deadline date until which the merchant can issue a refund to the customer via the merchant (can be zero if refunds are not allowed)
+ * @param deadline to pay for this contract
* @param wire_transfer_deadline date by which the merchant would like the exchange to execute the wire transfer (can be zero if there is no specific date desired by the frontend). If non-zero, must be larger than @a refund_deadline.
* @param exchange_uri URI of the exchange that the coins belong to
* @param num_coins number of coins used to pay
@@ -390,6 +398,7 @@ TALER_MERCHANT_pay_frontend (struct GNUNET_CURL_Context *ctx,
uint64_t transaction_id,
const struct TALER_MerchantSignatureP *merchant_sig,
struct GNUNET_TIME_Absolute refund_deadline,
+ struct GNUNET_TIME_Absolute pay_deadline,
struct GNUNET_TIME_Absolute timestamp,
struct GNUNET_TIME_Absolute wire_transfer_deadline,
const char *exchange_uri,
@@ -406,6 +415,10 @@ TALER_MERCHANT_pay_frontend (struct GNUNET_CURL_Context *ctx,
struct TALER_Amount total_amount;
unsigned int i;
+ (void) GNUNET_TIME_round_abs (&timestamp);
+ (void) GNUNET_TIME_round_abs (&refund_deadline);
+ (void) GNUNET_TIME_round_abs (&wire_transfer_deadline);
+
if (GNUNET_YES !=
TALER_amount_cmp_currency (amount,
max_fee))
@@ -550,13 +563,15 @@ TALER_MERCHANT_pay_frontend (struct GNUNET_CURL_Context *ctx,
pay_obj = json_pack ("{s:o," /* H_contract */
" s:I, s:o," /* transaction id, timestamp */
- " s:o, s:s," /* refund_deadline, exchange */
+ " s:o, s:o," /* refund_deadline, pay_deadline */
+ " s:s," /* exchange */
" s:o, s:o," /* coins, max_fee */
" s:o, s:o}",/* amount, signature */
"H_contract", GNUNET_JSON_from_data_auto (h_contract),
"transaction_id", (json_int_t) transaction_id,
"timestamp", GNUNET_JSON_from_time_abs (timestamp),
"refund_deadline", GNUNET_JSON_from_time_abs (refund_deadline),
+ "pay_deadline", GNUNET_JSON_from_time_abs (pay_deadline),
"exchange", exchange_uri,
"coins", j_coins,
"max_fee", TALER_JSON_from_amount (max_fee),
diff --git a/src/lib/test_merchant_api.c b/src/lib/test_merchant_api.c
index 477b81b0..60762062 100644
--- a/src/lib/test_merchant_api.c
+++ b/src/lib/test_merchant_api.c
@@ -1661,6 +1661,7 @@ interpreter_run (void *cls)
struct TALER_MERCHANT_PayCoin pc;
uint64_t transaction_id;
struct GNUNET_TIME_Absolute refund_deadline;
+ struct GNUNET_TIME_Absolute pay_deadline;
struct GNUNET_TIME_Absolute timestamp;
struct GNUNET_HashCode h_wire;
struct TALER_MerchantPublicKeyP merchant_pub;
@@ -1682,6 +1683,7 @@ interpreter_run (void *cls)
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_uint64 ("transaction_id", &transaction_id),
GNUNET_JSON_spec_absolute_time ("refund_deadline", &refund_deadline),
+ GNUNET_JSON_spec_absolute_time ("pay_deadline", &pay_deadline),
GNUNET_JSON_spec_absolute_time ("timestamp", &timestamp),
GNUNET_JSON_spec_fixed_auto ("merchant_pub", &merchant_pub),
GNUNET_JSON_spec_fixed_auto ("H_wire", &h_wire),
@@ -1765,6 +1767,7 @@ interpreter_run (void *cls)
&merchant_sig,
timestamp,
refund_deadline,
+ pay_deadline,
&h_wire,
EXCHANGE_URI,
1 /* num_coins */,
@@ -2176,7 +2179,7 @@ run (void *cls)
\"transaction_id\":1,\
\"timestamp\":\"\\/Date(42)\\/\",\
\"refund_deadline\":\"\\/Date(0)\\/\",\
- \"pay_deadline\":\"\\/Date(999999999)\\/\",\
+ \"pay_deadline\":\"\\/Date(9999999999)\\/\",\
\"amount\":{\"currency\":\"EUR\", \"value\":5, \"fraction\":0},\
\"summary\": \"merchant-lib testcase\",\
\"products\":\
@@ -2199,7 +2202,7 @@ run (void *cls)
\"transaction_id\":2,\
\"timestamp\":\"\\/Date(42)\\/\",\
\"refund_deadline\":\"\\/Date(0)\\/\",\
- \"pay_deadline\":\"\\/Date(999999999)\\/\",\
+ \"pay_deadline\":\"\\/Date(9999999999)\\/\",\
\"amount\":{\"currency\":\"EUR\", \"value\":5, \"fraction\":0},\
\"products\":\
[ {\"description\":\"ice cream\", \"value\":\"{EUR:5}\"} ] }" },