[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] branch master updated: payment backend
From: |
gnunet |
Subject: |
[taler-anastasis] branch master updated: payment backend |
Date: |
Mon, 16 Nov 2020 17:12:45 +0100 |
This is an automated email from the git hooks/post-receive script.
ds-meister pushed a commit to branch master
in repository anastasis.
The following commit(s) were added to refs/heads/master by this push:
new c6669ab payment backend
c6669ab is described below
commit c6669ab900a10c32dd495a728c364e2c67d68c33
Author: Dominik Meister <dominik.meister@hotmail.ch>
AuthorDate: Mon Nov 16 17:12:38 2020 +0100
payment backend
---
src/backend/anastasis.conf | 2 +-
src/include/anastasis_service.h | 7 -------
src/lib/anastasis_api_challenge_run.c | 35 +++++++++++++++++++++++----------
src/lib/testing_api_cmd_challenge_run.c | 15 +++++++-------
src/stasis/anastasis_db_postgres.conf | 2 +-
5 files changed, 35 insertions(+), 26 deletions(-)
diff --git a/src/backend/anastasis.conf b/src/backend/anastasis.conf
index c76e94a..1e7ea1c 100644
--- a/src/backend/anastasis.conf
+++ b/src/backend/anastasis.conf
@@ -51,7 +51,7 @@ SERVER_SALT = gUfO1KGOKYIFlFQg
SUPPORTED_METHODS = question
# Configuration for postgres database.
-[anastasisdb-postgres]
+[stasis-postgres]
CONFIG = postgres:///anastasis
[taler]
diff --git a/src/include/anastasis_service.h b/src/include/anastasis_service.h
index 4da46e2..3ed64f7 100644
--- a/src/include/anastasis_service.h
+++ b/src/include/anastasis_service.h
@@ -237,13 +237,6 @@ struct ANASTASIS_UploadDetails
} details;
};
-struct ANASTASIS_ChallengeRunDetails
-{
- const char *response_string;
- const char *payment_request;
-};
-
-
typedef void
(*ANASTASIS_ConfigCallback)(void *cls,
unsigned int http_status,
diff --git a/src/lib/anastasis_api_challenge_run.c
b/src/lib/anastasis_api_challenge_run.c
index d72418b..6a5d2ba 100644
--- a/src/lib/anastasis_api_challenge_run.c
+++ b/src/lib/anastasis_api_challenge_run.c
@@ -77,6 +77,11 @@ struct ANASTASIS_ChallengeRunOperation
* challenge run response from server(look at number xxx, look at email xxx)
*/
char *response_string;
+ /**
+ * Payment URI we received from the service, or NULL.
+ */
+ char *pay_uri;
+
};
@@ -132,6 +137,14 @@ handle_challenge_run_finished (void *cls,
ANASTASIS_challenge_run_cancel (cro);
return;
}
+ case MHD_HTTP_PAYMENT_REQUIRED:
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Payment URL offered: %s",cro->pay_uri);
+ cro->cb (cro->cb_cls,
+ response_code,
+ cro->pay_uri);
+ ANASTASIS_challenge_run_cancel (cro);
+ return;
case MHD_HTTP_BAD_REQUEST:
/* This should never happen, either us or the anastasis server is buggy
(or API version conflict); just pass JSON reply to the application */
@@ -205,19 +218,21 @@ handle_header (char *buffer,
}
if (' ' == *hdr_val)
hdr_val++;
+
if (0 == strcasecmp (hdr_type,
- "Truth-Decryption-Key"))
+ "Taler"))
{
- if (GNUNET_OK !=
- GNUNET_STRINGS_string_to_data (hdr_val,
- strlen (hdr_val),
- &cro->truth_key,
- sizeof (struct
- ANASTASIS_CRYPTO_TruthKeyP)))
+ size_t len;
+
+ /* found payment URI we care about! */
+ cro->pay_uri = GNUNET_strdup (hdr_val);
+ len = strlen (cro->pay_uri);
+ while ( (len > 0) &&
+ ( ('\n' == cro->pay_uri[len - 1]) ||
+ ('\r' == cro->pay_uri[len - 1]) ) )
{
- GNUNET_break_op (0);
- GNUNET_free (ndup);
- return 0;
+ len--;
+ cro->pay_uri[len] = '\0';
}
}
GNUNET_free (ndup);
diff --git a/src/lib/testing_api_cmd_challenge_run.c
b/src/lib/testing_api_cmd_challenge_run.c
index 47ce2ad..4162855 100644
--- a/src/lib/testing_api_cmd_challenge_run.c
+++ b/src/lib/testing_api_cmd_challenge_run.c
@@ -101,7 +101,7 @@ struct ChallengeRunState
static void
challenge_run_cb (void *cls,
unsigned int http_status,
- const struct ANASTASIS_ChallengeRunDetails *crd)
+ const char *response_string)
{
struct ChallengeRunState *crs = cls;
crs->cro = NULL;
@@ -121,24 +121,24 @@ challenge_run_cb (void *cls,
{
const char *m;
- if (0 != strncmp (crd->payment_request,
+ if (0 != strncmp (response_string,
"taler://pay/http",
strlen ("taler://pay/http")))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Did not find `%s' in `%s'\n",
"/-/-/",
- crd->payment_request);
+ response_string);
TALER_TESTING_interpreter_fail (crs->is);
return;
}
- m = strstr (crd->payment_request, "/-/-/");
+ m = strstr (response_string, "/-/-/");
if (NULL == m)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Did not find `%s' in `%s'\n",
"/-/-/",
- crd->payment_request);
+ response_string);
TALER_TESTING_interpreter_fail (crs->is);
/* NOTE: The above is a simplifying assumption for the
test-logic, hitting this code merely means that
@@ -154,18 +154,19 @@ challenge_run_cb (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Order ID from Anastasis service is `%s'\n",
crs->payment_order_id);
+ TALER_TESTING_interpreter_next (crs->is);
}
FILE *file;
crs->code = malloc (sizeof(char) * 22);
- file = fopen (crd->response_string, "r");
+ file = fopen (response_string, "r");
if (file == NULL)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"could not find file: %s to command %s in %s:%u\n",
- crd->response_string,
+ response_string,
crs->is->commands[crs->is->ip].label,
__FILE__,
__LINE__);
diff --git a/src/stasis/anastasis_db_postgres.conf
b/src/stasis/anastasis_db_postgres.conf
index 0460bd2..71a21ac 100644
--- a/src/stasis/anastasis_db_postgres.conf
+++ b/src/stasis/anastasis_db_postgres.conf
@@ -2,6 +2,6 @@
#The DB plugin to use
DB = postgres
-[anastasisdb-postgres]
+[stasis-postgres]
#The connection string the plugin has to use for connecting to the database
CONFIG = postgres:///anastasis
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-anastasis] branch master updated: payment backend,
gnunet <=