merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit d64edbd2352dee0b6cf2733b92e86068c827b0c4
parent 165ed03d36bdf9bc945f27f48e12d8ffdaad6a67
Author: Christian Grothoff <christian@grothoff.org>
Date:   Wed, 27 Jan 2016 15:06:01 +0100

implement #4159

Diffstat:
Msrc/backend/taler-merchant-httpd_contract.c | 24++++++++++++++++++++++++
Msrc/backend/taler-merchant-httpd_parsing.h | 2++
2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_contract.c b/src/backend/taler-merchant-httpd_contract.c @@ -56,6 +56,15 @@ MH_handler_contract (struct TMH_RequestHandler *rh, int res; struct TALER_ContractPS contract; struct GNUNET_CRYPTO_EddsaSignature contract_sig; + struct TALER_Amount total; + struct TALER_Amount max_fee; + uint64_t transaction_id; + struct TMH_PARSE_FieldSpecification spec[] = { + TMH_PARSE_member_amount ("amount", &total), + TMH_PARSE_member_amount ("max_fee", &total), + TMH_PARSE_member_uint64 ("transaction_id", &transaction_id), + TMH_PARSE_MEMBER_END + }; res = TMH_PARSE_post_json (connection, connection_cls, @@ -75,6 +84,15 @@ MH_handler_contract (struct TMH_RequestHandler *rh, return TMH_RESPONSE_reply_internal_error (connection, "contract request malformed"); } + /* extract fields we need to sign separately */ + res = TMH_PARSE_json_data (connection, + jcontract, + spec); + if (GNUNET_NO == res) + return MHD_YES; + if (GNUNET_SYSERR == res) + return TMH_RESPONSE_reply_internal_error (connection, + "contract request malformed"); /* add fields to the contract that the backend should provide */ json_object_set (jcontract, @@ -91,12 +109,18 @@ MH_handler_contract (struct TMH_RequestHandler *rh, "merchant_pub", TALER_json_from_data (&pubkey, sizeof (pubkey))); + /* create contract signature */ GNUNET_assert (GNUNET_OK == TALER_hash_json (jcontract, &contract.h_contract)); contract.purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_CONTRACT); contract.purpose.size = htonl (sizeof (contract)); + contract.transaction_id = GNUNET_htonll (transaction_id); + TALER_amount_hton (&contract.total_amount, + &total); + TALER_amount_hton (&contract.max_fee, + &max_fee); GNUNET_CRYPTO_eddsa_sign (privkey, &contract.purpose, &contract_sig); diff --git a/src/backend/taler-merchant-httpd_parsing.h b/src/backend/taler-merchant-httpd_parsing.h @@ -283,6 +283,8 @@ TMH_PARSE_member_variable (const char *field, struct TMH_PARSE_FieldSpecification TMH_PARSE_member_string (const char *field, char **out); + + /** * Generate line in parser specification for 64-bit integer * given as an integer in JSON.