merchant

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

commit 4a41e898d281377d5b0b7ff822f2bfa14485b686
parent 4a435a29de050d17ef5de531cc2e61a366998422
Author: Marcello Stanisci <marcello.stanisci@inria.fr>
Date:   Thu, 29 Oct 2015 16:47:28 +0100

Adding /pay skeleton

Diffstat:
Msrc/backend/taler-merchant-httpd.c | 14+++++++++++++-
Asrc/backend/taler-merchant-httpd_pay.c | 62++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/frontend/checkout.php | 2+-
Msrc/frontend/generate_taler_contract.php | 2+-
Asrc/tests/test_contract_README | 10++++++++++
5 files changed, 87 insertions(+), 3 deletions(-)

diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c @@ -62,6 +62,12 @@ char *keyfile; static struct TALER_MINT_Context *mctx; /** + * This value tells the mint by which date this merchant would like + * to receive the funds for a deposited payment + */ +struct GNUNET_TIME_Relative edate; + +/** * To make 'TMH_PARSE_navigate_json ()' compile */ char *TMH_mint_currency_string; @@ -177,7 +183,7 @@ url_handler (void *cls, "Hello, Customer.\n", 0, &TMH_MHD_handler_static_response, MHD_HTTP_OK }, - { "/contract", MHD_HTTP_METHOD_POST, "application/json", + { "/contract", MHD_HTTP_METHOD_GET, "application/json", NULL, 0, &MH_handler_contract, MHD_HTTP_OK }, @@ -438,6 +444,12 @@ run (void *cls, char *const *args, const char *cfgfile, "CURRENCY", &TMH_mint_currency_string)); + EXITIF (GNUNET_SYSERR == + GNUNET_CONFIGURATION_get_value_string (config, + "merchant", + "EDATE", + &edate)); + salt = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_NONCE, UINT64_MAX); diff --git a/src/backend/taler-merchant-httpd_pay.c b/src/backend/taler-merchant-httpd_pay.c @@ -0,0 +1,62 @@ +/* + This file is part of TALER + (C) 2014 Christian Grothoff (and other contributing authors) + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/> +*/ + +/** + * @file merchant/backend/taler-merchant-httpd.c + * @brief HTTP serving layer mainly intended to communicate with the frontend + * @author Marcello Stanisci + */ + +#include "platform.h" +#include <microhttpd.h> +#include <jansson.h> +#include <gnunet/gnunet_util_lib.h> +#include <curl/curl.h> +#include <taler/taler_signatures.h> +#include <taler/taler_amount_lib.h> +#include <taler/taler_json_lib.h> +#include <taler/taler_mint_service.h> +#include "taler-mint-httpd.h" +#include "taler-mint-httpd_parsing.h" +#include "taler-mint-httpd_responses.h" +#include "merchant_db.h" +#include "merchant.h" +#include "taler_merchant_lib.h" + +extern struct MERCHANT_Mint *mints; +extern const struct MERCHANT_WIREFORMAT_Sepa *wire; +extern PGconn *db_conn; +extern long long salt; + +/** + * Accomplish this payment. + * @param rh context of the handler + * @param connection the MHD connection to handle + * @param[in,out] connection_cls the connection's closure (can be updated) + * @param upload_data upload data + * @param[in,out] upload_data_size number of bytes (left) in @a upload_data + * @return MHD result code + */ +int +MH_handler_pay (struct TMH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size) +{ + json_t *root; + json_t *j_wire; +} diff --git a/src/frontend/checkout.php b/src/frontend/checkout.php @@ -89,7 +89,7 @@ function handle_contract(json_contract) function taler_pay(form) { var contract_request = new XMLHttpRequest(); - contract_request.open("POST", "/generate_taler_contract.php", true); + contract_request.open("GET", "/generate_taler_contract.php", true); contract_request.onload = function (e) { if (contract_request.readyState == 4) diff --git a/src/frontend/generate_taler_contract.php b/src/frontend/generate_taler_contract.php @@ -151,7 +151,7 @@ if ($cli_debug && !$backend_test) // Craft the HTTP request, note that the backend // could be on an entirely different machine if // desired. -$req = new http\Client\Request ("POST", +$req = new http\Client\Request ("GET", "http://" . $_SERVER["SERVER_NAME"] . "/backend/contract", array ("Content-Type" => "application/json")); $req->getBody()->append ($json); diff --git a/src/tests/test_contract_README b/src/tests/test_contract_README @@ -0,0 +1,10 @@ +- In order to test the "/contract" facility of the merchant, + just issue + + - curl http://merchant-url/generate_taler_contract.php?cli_debug=yes + (this form tests the whole communication between frontend and backend) + + - curl http://merchant-url/generate_taler_contract.php?cli_debug=yes + (this form test only the contract proposition generation of the frontend, + so it doesn't further connect to the backend to get the proposition JSON + enhanced)