diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-10-20 15:09:18 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-10-20 15:09:18 +0200 |
commit | 8dbd57d61b5b6e02e9472a1d4c90597108b242fc (patch) | |
tree | e7ac41914a0c55cccb578a3fc5475cab14f6d96e /src/backend | |
parent | f02036b3cb59135c5df2fda57627e42f344b5a96 (diff) | |
parent | 28542396565a8c3feb9b8a34be68410373022b6e (diff) |
Merge branch 'master' of git+ssh://taler.net/merchant
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/taler-merchant-httpd_contract.c | 4 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_pay.c | 23 |
2 files changed, 25 insertions, 2 deletions
diff --git a/src/backend/taler-merchant-httpd_contract.c b/src/backend/taler-merchant-httpd_contract.c index d2ded00b..0e8c9426 100644 --- a/src/backend/taler-merchant-httpd_contract.c +++ b/src/backend/taler-merchant-httpd_contract.c @@ -156,7 +156,7 @@ MH_handler_contract (struct TMH_RequestHandler *rh, json_t *products; struct GNUNET_TIME_Absolute timestamp; struct GNUNET_TIME_Absolute refund_deadline; - struct GNUNET_TIME_Absolute expiry; + struct GNUNET_TIME_Absolute pay_deadline; struct GNUNET_JSON_Specification spec[] = { TALER_JSON_spec_amount ("amount", &total), TALER_JSON_spec_amount ("max_fee", &max_fee), @@ -166,7 +166,7 @@ MH_handler_contract (struct TMH_RequestHandler *rh, GNUNET_JSON_spec_json ("products", &products), GNUNET_JSON_spec_absolute_time ("timestamp", ×tamp), GNUNET_JSON_spec_absolute_time ("refund_deadline", &refund_deadline), - GNUNET_JSON_spec_absolute_time ("expiry", &expiry), + GNUNET_JSON_spec_absolute_time ("pay_deadline", &pay_deadline), GNUNET_JSON_spec_end() }; diff --git a/src/backend/taler-merchant-httpd_pay.c b/src/backend/taler-merchant-httpd_pay.c index 81f38a58..eeea4866 100644 --- a/src/backend/taler-merchant-httpd_pay.c +++ b/src/backend/taler-merchant-httpd_pay.c @@ -186,6 +186,11 @@ struct PayContext struct GNUNET_TIME_Absolute refund_deadline; /** + * Deadline for the customer to pay for this contract. + */ + struct GNUNET_TIME_Absolute pay_deadline; + + /** * "H_contract" from @e root. */ struct GNUNET_HashCode h_contract; @@ -869,6 +874,7 @@ MH_handler_pay (struct TMH_RequestHandler *rh, struct PayContext *pc; int res; json_t *root; + struct GNUNET_TIME_Absolute now; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "In handler for /pay.\n"); @@ -945,6 +951,7 @@ MH_handler_pay (struct TMH_RequestHandler *rh, GNUNET_JSON_spec_fixed_auto ("merchant_sig", &merchant_sig), GNUNET_JSON_spec_string ("exchange", &chosen_exchange), GNUNET_JSON_spec_absolute_time ("refund_deadline", &pc->refund_deadline), + GNUNET_JSON_spec_absolute_time ("pay_deadline", &pc->pay_deadline), GNUNET_JSON_spec_absolute_time ("timestamp", &pc->timestamp), GNUNET_JSON_spec_uint64 ("transaction_id", &pc->transaction_id), GNUNET_JSON_spec_end() @@ -1159,6 +1166,22 @@ MH_handler_pay (struct TMH_RequestHandler *rh, } if (GNUNET_NO == pc->transaction_exits) { + /* #4521 goes here: Check if the customer respects pay_deadline */ + now = GNUNET_TIME_absolute_get (); + if (now.abs_value_us > pc->pay_deadline.abs_value_us) + { + /* 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."); + } + if (GNUNET_OK != db->store_transaction (db->cls, pc->transaction_id, |