aboutsummaryrefslogtreecommitdiff
path: root/src/include/taler_merchantdb_plugin.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/taler_merchantdb_plugin.h')
-rw-r--r--src/include/taler_merchantdb_plugin.h210
1 files changed, 196 insertions, 14 deletions
diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h
index 1c0cd37c..14dedce5 100644
--- a/src/include/taler_merchantdb_plugin.h
+++ b/src/include/taler_merchantdb_plugin.h
@@ -96,20 +96,20 @@ struct TALER_MERCHANTDB_AccountDetails
/**
* Actual account address as a payto://-URI.
*/
- const char *payto_uri;
+ char *payto_uri;
/**
* Where can the taler-merchant-wirewatch helper
* download information about incoming transfers?
* NULL if not available.
*/
- const char *credit_facade_url;
+ char *credit_facade_url;
/**
* JSON with credentials to use to access the
* @e credit_facade_url.
*/
- const json_t *credit_facade_credentials;
+ json_t *credit_facade_credentials;
/**
* Is the account set for active use in new contracts?
@@ -219,9 +219,20 @@ typedef void
const struct TALER_MerchantPublicKeyP *merchant_pub,
const struct TALER_MerchantPrivateKeyP *merchant_priv,
const struct TALER_MERCHANTDB_InstanceSettings *is,
- const struct TALER_MERCHANTDB_InstanceAuthSettings *ias,
- unsigned int accounts_length,
- const struct TALER_MERCHANTDB_AccountDetails accounts[]);
+ const struct TALER_MERCHANTDB_InstanceAuthSettings *ias);
+
+
+/**
+ * Callback invoked with information about a bank account.
+ *
+ * @param cls closure
+ * @param ad details about the account
+ */
+typedef void
+(*TALER_MERCHANTDB_AccountCallback)(
+ void *cls,
+ const struct TALER_MERCHANTDB_AccountDetails *ad);
+
/**
* Typically called by `lookup_products`.
@@ -311,7 +322,7 @@ struct TALER_MERCHANTDB_ProductDetails
/**
* Typically called by `lookup_templates`.
*
- * @param cls a `json_t *` JSON array to build
+ * @param cls closure
* @param template_id ID of the template
* @param template_description description of the template
*/
@@ -322,6 +333,19 @@ typedef void
/**
+ * Typically called by `lookup_otp_devices`.
+ *
+ * @param cls closure
+ * @param otp_id ID of the OTP device
+ * @param otp_description description of the OTP device
+ */
+typedef void
+(*TALER_MERCHANTDB_OtpDeviceCallback)(void *cls,
+ const char *otp_id,
+ const char *otp_description);
+
+
+/**
* Details about a template.
*/
struct TALER_MERCHANTDB_TemplateDetails
@@ -332,19 +356,42 @@ struct TALER_MERCHANTDB_TemplateDetails
char *template_description;
/**
- * Base64-encoded key, or NULL.
+ * In this template contract, we can have additional information.
+ */
+ json_t *template_contract;
+
+ /**
+ * ID of the OTP device linked to the template, or NULL.
*/
- char *pos_key;
+ char *otp_id;
+};
+
+
+/**
+ * Details about an OTP device.
+ */
+struct TALER_MERCHANTDB_OtpDeviceDetails
+{
/**
- * In this template contract, we can have additional information.
+ * Description of the device.
*/
- json_t *template_contract;
+ char *otp_description;
+
+ /**
+ * Current usage counter value.
+ */
+ uint64_t otp_ctr;
+
+ /**
+ * Base64-encoded key.
+ */
+ char *otp_key;
/**
* Algorithm used to compute purchase confirmations.
*/
- enum TALER_MerchantConfirmationAlgorithm pos_algorithm;
+ enum TALER_MerchantConfirmationAlgorithm otp_algorithm;
};
@@ -1223,14 +1270,52 @@ struct TALER_MERCHANTDB_Plugin
*
* @param cls closure
* @param id identifier of the instance
- * @param account_details details about the account to update
+ * @param h_wire which account to update
+ * @param credit_facade_url new facade URL, can be NULL
+ * @param credit_facade_credentials new credentials, can be NULL
* @return database result code
*/
enum GNUNET_DB_QueryStatus
(*update_account)(
void *cls,
const char *id,
- const struct TALER_MERCHANTDB_AccountDetails *account_details);
+ const struct TALER_MerchantWireHashP *h_wire,
+ const char *credit_facade_url,
+ const json_t *credit_facade_credentials);
+
+
+ /**
+ * Obtain information about an instance's accounts.
+ *
+ * @param cls closure
+ * @param id identifier of the instance
+ * @param cb function to call on each account
+ * @param cb_cls closure for @a cb
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*select_accounts)(
+ void *cls,
+ const char *id,
+ TALER_MERCHANTDB_AccountCallback cb,
+ void *cb_cls);
+
+
+ /**
+ * Obtain detailed information about an instance's account.
+ *
+ * @param cls closure
+ * @param id identifier of the instance
+ * @param h_wire wire hash of the account
+ * @param[out] ad account details returned
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*select_account)(
+ void *cls,
+ const char *id,
+ const struct TALER_MerchantWireHashP *h_wire,
+ struct TALER_MERCHANTDB_AccountDetails *ad);
/**
@@ -2867,6 +2952,7 @@ struct TALER_MERCHANTDB_Plugin
* @param cls closure
* @param instance_id instance to insert template for
* @param template_id template identifier of template to insert
+ * @param otp_serial_id 0 if no OTP device is associated
* @param td the template details to insert
* @return database result code
*/
@@ -2874,10 +2960,106 @@ struct TALER_MERCHANTDB_Plugin
(*insert_template)(void *cls,
const char *instance_id,
const char *template_id,
+ uint64_t otp_serial_id,
const struct TALER_MERCHANTDB_TemplateDetails *td);
/**
+ * Delete information about an OTP device.
+ *
+ * @param cls closure
+ * @param instance_id instance to delete OTP device of
+ * @param otp_id otp device to delete
+ * @return DB status code, #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS
+ * if template unknown.
+ */
+ enum GNUNET_DB_QueryStatus
+ (*delete_otp) (void *cls,
+ const char *instance_id,
+ const char *otp_id);
+
+ /**
+ * Insert details about a particular OTP device.
+ *
+ * @param cls closure
+ * @param instance_id instance to insert OTP device for
+ * @param otp_id otp identifier of OTP device to insert
+ * @param td the OTP device details to insert
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_otp) (void *cls,
+ const char *instance_id,
+ const char *otp_id,
+ const struct TALER_MERCHANTDB_OtpDeviceDetails *td);
+
+
+ /**
+ * Update details about a particular OTP device.
+ *
+ * @param cls closure
+ * @param instance_id instance to update OTP device for
+ * @param otp_id OTP device to update
+ * @param td update to the OTP device details on success, can be NULL
+ * (in that case we only want to check if the template exists)
+ * @return database result code, #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if the template
+ * does not yet exist.
+ */
+ enum GNUNET_DB_QueryStatus
+ (*update_otp) (void *cls,
+ const char *instance_id,
+ const char *otp_id,
+ const struct TALER_MERCHANTDB_OtpDeviceDetails *td);
+
+ /**
+ * Lookup all of the OTP devices the given instance has configured.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup OTP devices for
+ * @param cb function to call on all OTP devices found
+ * @param cb_cls closure for @a cb
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_otp_devices) (void *cls,
+ const char *instance_id,
+ TALER_MERCHANTDB_OtpDeviceCallback cb,
+ void *cb_cls);
+
+
+ /**
+ * Lookup details about an OTP device.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup template for
+ * @param otp_id OTP device to lookup
+ * @param[out] td set to the OTP device details on success, can be NULL
+ * (in that case we only want to check if the template exists)
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*select_otp) (void *cls,
+ const char *instance_id,
+ const char *otp_id,
+ struct TALER_MERCHANTDB_OtpDeviceDetails *td);
+
+
+ /**
+ * Lookup serial number of an OTP device.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup template for
+ * @param otp_id OTP device to lookup
+ * @param[out] serial set to the OTP device serial number * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*select_otp_serial) (void *cls,
+ const char *instance_id,
+ const char *otp_id,
+ uint64_t *serial);
+
+
+ /**
* Update details about a particular template.
*
* @param cls closure