merchant

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

merchantdb_lib.h (22206B)


      1 /*
      2   This file is part of TALER
      3   Copyright (C) 2014, 2015, 2016, 2020 Taler Systems SA
      4 
      5   TALER is free software; you can redistribute it and/or modify it under the
      6   terms of the GNU Lesser General Public License as published by the Free Software
      7   Foundation; either version 3, or (at your option) any later version.
      8 
      9   TALER is distributed in the hope that it will be useful, but WITHOUT ANY
     10   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     11   A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     12 
     13   You should have received a copy of the GNU General Public License along with
     14   TALER; see the file COPYING.GPL.  If not, see <http://www.gnu.org/licenses/>
     15 */
     16 
     17 /**
     18  * @file src/include/merchantdb_lib.h
     19  * @brief database helper functions used by the merchant backend
     20  * @author Sree Harsha Totakura <sreeharsha@totakura.in>
     21  */
     22 #ifndef TALER_MERCHANTDB_LIB_H
     23 #define TALER_MERCHANTDB_LIB_H
     24 
     25 #include <gnunet/gnunet_pq_lib.h>
     26 #include <taler/taler_util.h>
     27 
     28 /**
     29  * Handle to interact with the database.
     30  */
     31 struct TALER_MERCHANTDB_PostgresContext;
     32 
     33 GNUNET_NETWORK_STRUCT_BEGIN
     34 
     35 /**
     36  * Format of the data hashed to generate the notification
     37  * string whenever the KYC status for an account has
     38  * changed.
     39  */
     40 struct TALER_MERCHANTDB_MerchantKycStatusChangeEventP
     41 {
     42   /**
     43    * Type is TALER_DBEVENT_MERCHANT_EXCHANGE_KYC_STATUS_CHANGED.
     44    */
     45   struct GNUNET_DB_EventHeaderP header;
     46 
     47   /**
     48    * Instance owning the account.
     49    */
     50   struct TALER_MerchantPublicKeyP merchant_pub;
     51 
     52   /**
     53    * Salted hash of the affected account.
     54    */
     55   struct TALER_MerchantWireHashP h_wire;
     56 };
     57 
     58 /**
     59  * Instance-wide KYC status notification. Type is
     60  * TALER_DBEVENT_MERCHANT_KYC_STATUS_CHANGED.
     61  */
     62 struct TALER_MERCHANTDB_InstanceKycStatusChangeEventP
     63 {
     64   struct GNUNET_DB_EventHeaderP header;
     65 
     66   struct TALER_MerchantPublicKeyP merchant_pub;
     67 };
     68 
     69 /**
     70  * Event triggered when an order is paid.
     71  */
     72 struct TMH_OrderPayEventP
     73 {
     74   /**
     75    * Type is #TALER_DBEVENT_MERCHANT_ORDER_PAID
     76    */
     77   struct GNUNET_DB_EventHeaderP header;
     78 
     79   /**
     80    * Always zero (for alignment).
     81    */
     82   uint32_t reserved GNUNET_PACKED;
     83 
     84   /**
     85    * Merchant's public key
     86    */
     87   struct TALER_MerchantPublicKeyP merchant_pub;
     88 
     89   /**
     90    * Hash of the order ID.
     91    */
     92   struct GNUNET_HashCode h_order_id;
     93 };
     94 
     95 
     96 GNUNET_NETWORK_STRUCT_END
     97 
     98 
     99 /**
    100  * Connect to postgresql database
    101  *
    102  * @param cfg the configuration handle
    103  * @return connection to the database; NULL upon error
    104  */
    105 struct TALER_MERCHANTDB_PostgresContext *
    106 TALER_MERCHANTDB_connect (
    107   const struct GNUNET_CONFIGURATION_Handle *cfg);
    108 
    109 /**
    110  * Connect to postgresql database for administration.
    111  * Disables the check that the database schema is current.
    112  *
    113  * @param cfg the configuration handle
    114  * @return connection to the database; NULL upon error
    115  */
    116 struct TALER_MERCHANTDB_PostgresContext *
    117 TALER_MERCHANTDB_connect_admin (
    118   const struct GNUNET_CONFIGURATION_Handle *cfg);
    119 
    120 
    121 /**
    122  * Disconnect from the database
    123  *
    124  * @param pg database handle to close
    125  */
    126 void
    127 TALER_MERCHANTDB_disconnect (struct TALER_MERCHANTDB_PostgresContext *pg);
    128 
    129 
    130 void
    131 check_connection (struct TALER_MERCHANTDB_PostgresContext *pg);
    132 
    133 
    134 /**
    135  * Possible token family kinds.
    136  */
    137 enum TALER_MERCHANTDB_TokenFamilyKind
    138 {
    139 
    140   /**
    141    * Token family representing a discount token
    142    */
    143   TALER_MERCHANTDB_TFK_Discount = 0,
    144 
    145   /**
    146    * Token family representing a subscription token
    147    */
    148   TALER_MERCHANTDB_TFK_Subscription = 1,
    149 
    150 };
    151 
    152 /**
    153  * Results from trying to increase a refund.
    154  */
    155 enum TALER_MERCHANTDB_RefundStatus
    156 {
    157 
    158   /**
    159    * Refund amount exceeds legal exchange limits.
    160    */
    161   TALER_MERCHANTDB_RS_LEGAL_FAILURE = -5,
    162 
    163   /**
    164    * Refund amount currency does not match original payment.
    165    */
    166   TALER_MERCHANTDB_RS_BAD_CURRENCY = -4,
    167 
    168   /**
    169    * Refund amount exceeds original payment.
    170    */
    171   TALER_MERCHANTDB_RS_TOO_HIGH = -3,
    172 
    173   /**
    174    * Hard database failure.
    175    */
    176   TALER_MERCHANTDB_RS_HARD_ERROR = -2,
    177 
    178   /**
    179    * Soft database failure.
    180    */
    181   TALER_MERCHANTDB_RS_SOFT_ERROR = -1,
    182 
    183   /**
    184    * Order not found.
    185    */
    186   TALER_MERCHANTDB_RS_NO_SUCH_ORDER = 0,
    187 
    188   /**
    189    * Refund is now at or above the requested amount.
    190    */
    191   TALER_MERCHANTDB_RS_SUCCESS = 1
    192 
    193 };
    194 
    195 /**
    196  * Results from trying to store a deposit confirmation.
    197  * Values that also exist in `enum GNUNET_DB_QueryStatus`
    198  * intentionally use the same numeric value.
    199  */
    200 enum TALER_MERCHANTDB_DepositConfirmationStatus
    201 {
    202 
    203   /**
    204    * A deposit confirmation for this order and exchange
    205    * exists, but with conflicting details (timestamp, wire
    206    * deadline, wire fee or target account).
    207    */
    208   TALER_MERCHANTDB_DCS_CONFLICT = -6,
    209 
    210   /**
    211    * The exchange signing key that signed the deposit
    212    * confirmation is not known to us.
    213    */
    214   TALER_MERCHANTDB_DCS_NO_SIGNKEY = -5,
    215 
    216   /**
    217    * The merchant account the deposit was made to is
    218    * not known to us.
    219    */
    220   TALER_MERCHANTDB_DCS_NO_ACCOUNT = -4,
    221 
    222   /**
    223    * The order (contract) the deposit is for is not
    224    * known to us.
    225    */
    226   TALER_MERCHANTDB_DCS_NO_ORDER = -3,
    227 
    228   /**
    229    * Hard database failure.
    230    */
    231   TALER_MERCHANTDB_DCS_HARD_ERROR = -2,
    232 
    233   /**
    234    * Soft database failure, retry.
    235    */
    236   TALER_MERCHANTDB_DCS_SOFT_ERROR = -1,
    237 
    238   /**
    239    * The stored procedure did not return a row at all.
    240    * Should be impossible.
    241    */
    242   TALER_MERCHANTDB_DCS_NO_RESULTS = 0,
    243 
    244   /**
    245    * Deposit confirmation is now in the database.
    246    */
    247   TALER_MERCHANTDB_DCS_SUCCESS = 1
    248 
    249 };
    250 
    251 /**
    252  * Results from associating a deposit with a wire transfer.
    253  * Values that also exist in `enum GNUNET_DB_QueryStatus`
    254  * intentionally use the same numeric value.
    255  */
    256 enum TALER_MERCHANTDB_DepositToTransferStatus
    257 {
    258 
    259   /**
    260    * Hard database failure.
    261    */
    262   TALER_MERCHANTDB_DTTS_HARD_ERROR = -2,
    263 
    264   /**
    265    * Soft database failure, retry.
    266    */
    267   TALER_MERCHANTDB_DTTS_SOFT_ERROR = -1,
    268 
    269   /**
    270    * The stored procedure did not return a row at all.
    271    * Should be impossible.
    272    */
    273   TALER_MERCHANTDB_DTTS_NO_RESULTS = 0,
    274 
    275   /**
    276    * The deposit was associated with the wire transfer.
    277    */
    278   TALER_MERCHANTDB_DTTS_SETTLED = 1,
    279 
    280   /**
    281    * The exchange signing key is (still) unknown to us; the
    282    * deposit was scheduled for a retry.
    283    */
    284   TALER_MERCHANTDB_DTTS_SIGNKEY_UNKNOWN = 2,
    285 
    286   /**
    287    * The exchange wired the money to an account we do not know.
    288    * This is a permanent failure: the deposit will never settle
    289    * and the order must not be considered wired.
    290    */
    291   TALER_MERCHANTDB_DTTS_ACCOUNT_UNKNOWN = 3
    292 
    293 };
    294 
    295 /**
    296  * Details about an OTP device.
    297  */
    298 struct TALER_MERCHANTDB_OtpDeviceDetails
    299 {
    300 
    301   /**
    302    * Description of the device.
    303    */
    304   char *otp_description;
    305 
    306   /**
    307    * Current usage counter value.
    308    */
    309   uint64_t otp_ctr;
    310 
    311   /**
    312    * Base64-encoded key.
    313    */
    314   char *otp_key;
    315 
    316   /**
    317    * Algorithm used to compute purchase confirmations.
    318    */
    319   enum TALER_MerchantConfirmationAlgorithm otp_algorithm;
    320 };
    321 
    322 
    323 /**
    324  * Details about a template.
    325  */
    326 struct TALER_MERCHANTDB_TemplateDetails
    327 {
    328   /**
    329    * Description of the template.
    330    */
    331   char *template_description;
    332 
    333   /**
    334    * In this template contract, we can have additional information.
    335    */
    336   json_t *template_contract;
    337 
    338   /**
    339    * ID of the OTP device linked to the template, or NULL.
    340    */
    341   char *otp_id;
    342 
    343   /**
    344    * Editable default values for fields not specified
    345    * in the @e template_contract. NULL if the user
    346    * cannot edit anything.
    347    */
    348   json_t *editable_defaults;
    349 
    350 };
    351 
    352 
    353 /**
    354  * Structure to hold Donau instance details from the database.
    355  */
    356 struct TALER_MERCHANTDB_DonauInstance
    357 {
    358   /**
    359    * Donau instance serial
    360    */
    361   uint64_t donau_instance_serial;
    362 
    363   /**
    364    * The URL for the Donau instance.
    365    */
    366   char *donau_url;
    367 
    368   /**
    369    * The name of the charity associated with the Donau instance.
    370    */
    371   char *charity_name;
    372 
    373   /**
    374    * Pointer to the public key of the charity, used for cryptographic operations.
    375    * This is represented as an EDDSA public key structure.
    376    */
    377   struct DONAU_CharityPublicKeyP *charity_pub_key;
    378 
    379   /**
    380    * A unique identifier for the charity in the Donau instance.
    381    */
    382   uint64_t charity_id;
    383 
    384   /**
    385    * The maximum allowable amount for donations to this charity in the current year.
    386    * This is tracked for regulatory or internal business constraints.
    387    */
    388   struct TALER_Amount charity_max_per_year;
    389 
    390   /**
    391    * The total amount of donations received by the charity in the current year.
    392    * This field helps track progress toward the yearly donation limit.
    393    */
    394   struct TALER_Amount charity_receipts_to_date;
    395 
    396   /**
    397    * The current year being tracked for donations.
    398    * This is used to differentiate donation data between years.
    399    */
    400   int64_t current_year;
    401 
    402   /**
    403    * A JSON object containing key information specific to the Donau instance,
    404    * such as cryptographic keys or other relevant details.
    405    */
    406   json_t *donau_keys_json;
    407 };
    408 
    409 
    410 /**
    411  * Details about a product.
    412  *
    413  * FIXME: reuse TALER_MERCHANT_Product as a member in this structure!
    414  */
    415 struct TALER_MERCHANTDB_ProductDetails
    416 {
    417   /**
    418    * Name of the product.
    419    */
    420   char *product_name;
    421 
    422   /**
    423    * Description of the product.
    424    */
    425   char *description;
    426 
    427   /**
    428    * Internationalized description.
    429    */
    430   json_t *description_i18n;
    431 
    432   /**
    433    * Unit in which the product is sold.
    434    */
    435   char *unit;
    436 
    437   /**
    438    * Optional list of per-unit prices. When NULL or empty, @e price
    439    * must be used as the canonical single price.
    440    */
    441   struct TALER_Amount *price_array;
    442 
    443   /**
    444    * Number of entries in @e price_array.
    445    */
    446   size_t price_array_length;
    447 
    448   /**
    449    * Base64-encoded product image, or an empty string.
    450    */
    451   char *image;
    452 
    453   /**
    454    * Hash of the product image data, or NULL.
    455    */
    456   char *image_hash;
    457 
    458   /**
    459    * List of taxes the merchant pays for this product. Never NULL,
    460    * but can be an empty array.
    461    */
    462   json_t *taxes;
    463 
    464   /**
    465    * Number of units of the product in stock in sum in total, including all
    466    * existing sales and lost product, in product-specific units. UINT64_MAX
    467    * indicates "infinite".
    468    */
    469   uint64_t total_stock;
    470 
    471   /**
    472    * Fractional part of stock in units of 1/1000000 of the base value.
    473    */
    474   uint32_t total_stock_frac;
    475 
    476   /**
    477    * Honor fractional stock if TRUE, else only integer stock.
    478    */
    479   bool allow_fractional_quantity;
    480 
    481   /**
    482    * Precision level (number of decimal places) to apply when
    483    * fractional quantities are enabled.
    484    */
    485   uint32_t fractional_precision_level;
    486 
    487   /**
    488    * Number of units of the product in sold, in product-specific units.
    489    */
    490   uint64_t total_sold;
    491 
    492   /**
    493    * Fractional part of units sold in units of 1/1000000 of the base value.
    494    */
    495   uint32_t total_sold_frac;
    496 
    497   /**
    498    * Number of units of stock lost.
    499    */
    500   uint64_t total_lost;
    501 
    502   /**
    503    * Fractional part of lost units in units of 1/1000000 of the base value.
    504    */
    505   uint32_t total_lost_frac;
    506 
    507   /**
    508    * Number of units currently reserved by locks (shopping cart locks and
    509    * locks held by unpaid orders).  These units are unavailable for new
    510    * orders.  Maintained by the database, not set by the application.
    511    */
    512   uint64_t total_locked;
    513 
    514   /**
    515    * Fractional part of locked units in units of 1/1000000 of the base value.
    516    */
    517   uint32_t total_locked_frac;
    518 
    519   /**
    520    * Identifies where the product is in stock, possibly an empty map.
    521    */
    522   json_t *address;
    523 
    524   /**
    525    * Identifies when the product will be restocked. 0 for unknown,
    526    * #GNUNET_TIME_UNIT_FOREVER_ABS for never.
    527    */
    528   struct GNUNET_TIME_Timestamp next_restock;
    529 
    530   /**
    531    * Minimum required age for consumers buying this product.
    532    * Default is 0. Only enforced of an exchange supports age
    533    * restrictions.
    534    */
    535   uint32_t minimum_age;
    536 
    537   /**
    538    * Group in which the product is in. 0 for default group.
    539    */
    540   uint64_t product_group_id;
    541 
    542   /**
    543    * Money pot into which sales of this product should go into by default.
    544    */
    545   uint64_t money_pot_id;
    546 
    547   /**
    548    * True if the price for this product is given in net,
    549    * False if its the gross price.
    550    */
    551   bool price_is_net;
    552 
    553 };
    554 
    555 
    556 /**
    557  * Details about a webhook.
    558  */
    559 struct TALER_MERCHANTDB_WebhookDetails
    560 {
    561 
    562   /**
    563    * event of the webhook.
    564    */
    565   char *event_type;
    566 
    567   /**
    568    * URL of the webhook. The customer will be redirected on this url.
    569    */
    570   char *url;
    571 
    572   /**
    573    * Http method used by the webhook.
    574    */
    575   char *http_method;
    576 
    577   /**
    578    * Header template of the webhook.
    579    */
    580   char *header_template;
    581 
    582   /**
    583    * Body template of the webhook.
    584    */
    585   char *body_template;
    586 
    587 };
    588 
    589 
    590 /**
    591  * Details about a product category.
    592  */
    593 struct TALER_MERCHANTDB_CategoryDetails
    594 {
    595 
    596   /**
    597    * Name of the category.
    598    */
    599   char *category_name;
    600 
    601   /**
    602    * Translations of the name of the category.
    603    */
    604   json_t *category_name_i18n;
    605 
    606 };
    607 
    608 
    609 /**
    610  * Details about the pending webhook.
    611  */
    612 struct TALER_MERCHANTDB_PendingWebhookDetails
    613 {
    614 
    615   /**
    616    * Identifies when we should make the next request to the webhook. 0 for unknown,
    617    * #GNUNET_TIME_UNIT_FOREVER_ABS for never.
    618    */
    619   struct GNUNET_TIME_Absolute next_attempt;
    620 
    621   /**
    622    * How often have we tried this request so far.
    623    */
    624   uint32_t retries;
    625 
    626   /**
    627    * URL of the webhook. The customer will be redirected on this url.
    628    */
    629   char *url;
    630 
    631   /**
    632    * Http method used for the webhook.
    633    */
    634   char *http_method;
    635 
    636   /**
    637    * Header of the webhook.
    638    */
    639   char *header;
    640 
    641   /**
    642    * Body of the webhook.
    643    */
    644   char *body;
    645 
    646 };
    647 
    648 
    649 /**
    650  * Details about a token family.
    651  */
    652 struct TALER_MERCHANTDB_TokenFamilyDetails
    653 {
    654   /**
    655    * Token family slug used for identification.
    656    */
    657   char *slug;
    658 
    659   /**
    660    * User readable name of the token family.
    661    */
    662   char *name;
    663 
    664   /**
    665    * Description of the token family.
    666    */
    667   char *description;
    668 
    669   /**
    670    * Internationalized token family description.
    671    */
    672   json_t *description_i18n;
    673 
    674   /**
    675    * Meta-data associated with the token family.
    676    * Includes information like "trusted_domains" or
    677    * "expected_domains", if set.
    678    */
    679   json_t *extra_data;
    680 
    681   /**
    682    * Cipher that should be used for this token family.  Note: We do not expose
    683    * this over the API and do not let clients set it. NULL for default (when
    684    * calling database).
    685    */
    686   char *cipher_spec;
    687 
    688   /**
    689    * Start time of the token family duration.
    690    */
    691   struct GNUNET_TIME_Timestamp valid_after;
    692 
    693   /**
    694    * End time of the token family duration.
    695    */
    696   struct GNUNET_TIME_Timestamp valid_before;
    697 
    698   /**
    699    * Validity duration of the token family. Must be larger or
    700    * equal to @a rounding plus @a start_offset_s.
    701    */
    702   struct GNUNET_TIME_Relative duration;
    703 
    704   /**
    705    * Rounding duration of the token family.
    706    */
    707   struct GNUNET_TIME_Relative validity_granularity;
    708 
    709   /**
    710    * Offset (in seconds) to subtract from the rounded
    711    * validity start period.
    712    */
    713   struct GNUNET_TIME_Relative start_offset;
    714 
    715   /**
    716    * Token family kind.
    717    */
    718   enum TALER_MERCHANTDB_TokenFamilyKind kind;
    719 
    720   /**
    721    * Counter for each issued token of this family.
    722    */
    723   uint64_t issued;
    724 
    725   /**
    726    * Counter for each used token of this family.
    727    */
    728   uint64_t used;
    729 };
    730 
    731 
    732 /**
    733  * Minimal product details for inventory templates.
    734  */
    735 struct TALER_MERCHANTDB_InventoryProductDetails
    736 {
    737   /**
    738    * Name of the product.
    739    */
    740   char *product_name;
    741 
    742   /**
    743    * Description of the product.
    744    */
    745   char *description;
    746 
    747   /**
    748    * Internationalized description.
    749    */
    750   json_t *description_i18n;
    751 
    752   /**
    753    * Unit in which the product is sold.
    754    */
    755   char *unit;
    756 
    757   /**
    758    * List of per-unit prices.
    759    */
    760   struct TALER_Amount *price_array;
    761 
    762   /**
    763    * Number of entries in @e price_array.
    764    */
    765   size_t price_array_length;
    766 
    767   /**
    768    * Hash of the product image data, or NULL.
    769    */
    770   char *image_hash;
    771 
    772   /**
    773    * Honor fractional stock if TRUE, else only integer stock.
    774    */
    775   bool allow_fractional_quantity;
    776 
    777   /**
    778    * Precision level (number of decimal places) to apply when
    779    * fractional quantities are enabled.
    780    */
    781   uint32_t fractional_precision_level;
    782 
    783   /**
    784    * Remaining units after sold/lost/locked deductions.
    785    */
    786   uint64_t remaining_stock;
    787 
    788   /**
    789    * Fractional part of remaining units in units of 1/1000000 of the base value.
    790    */
    791   uint32_t remaining_stock_frac;
    792 
    793   /**
    794    * List of taxes the merchant pays for this product. Never NULL,
    795    * but can be an empty array.
    796    */
    797   json_t *taxes;
    798 };
    799 
    800 
    801 /**
    802  * Details about an inventory measurement unit.
    803  */
    804 struct TALER_MERCHANTDB_UnitDetails
    805 {
    806 
    807   /**
    808    * Database serial.
    809    */
    810   uint64_t unit_serial;
    811 
    812   /**
    813    * Backend identifier used in product payloads.
    814    */
    815   char *unit;
    816 
    817   /**
    818    * Default long label (fallback string).
    819    */
    820   char *unit_name_long;
    821 
    822   /**
    823    * Default short label (fallback string).
    824    */
    825   char *unit_name_short;
    826 
    827   /**
    828    * Internationalised long labels.
    829    */
    830   json_t *unit_name_long_i18n;
    831 
    832   /**
    833    * Internationalised short labels.
    834    */
    835   json_t *unit_name_short_i18n;
    836 
    837   /**
    838    * Whether fractional quantities are enabled by default.
    839    */
    840   bool unit_allow_fraction;
    841 
    842   /**
    843    * Maximum number of fractional digits honoured by default.
    844    */
    845   uint32_t unit_precision_level;
    846 
    847   /**
    848    * Hidden from selectors when false.
    849    */
    850   bool unit_active;
    851 
    852   /**
    853    * Built-in units cannot be deleted.
    854    */
    855   bool unit_builtin;
    856 };
    857 
    858 
    859 /**
    860  * Details about a wire account of the merchant.
    861  */
    862 struct TALER_MERCHANTDB_AccountDetails
    863 {
    864   /**
    865    * Hash of the wire details (@e payto_uri and @e salt).
    866    */
    867   struct TALER_MerchantWireHashP h_wire;
    868 
    869   /**
    870    * Salt value used for hashing @e payto_uri.
    871    */
    872   struct TALER_WireSaltP salt;
    873 
    874   /**
    875    * Instance ID. Do not free (may be aliased with
    876    * the instance ID given in the query!).
    877    * FIXME: set in all functions involving this struct!
    878    */
    879   const char *instance_id;
    880 
    881   /**
    882    * Actual account address as a payto://-URI.
    883    */
    884   struct TALER_FullPayto payto_uri;
    885 
    886   /**
    887    * Where can the taler-merchant-wirewatch helper
    888    * download information about incoming transfers?
    889    * NULL if not available.
    890    */
    891   char *credit_facade_url;
    892 
    893   /**
    894    * JSON with credentials to use to access the
    895    * @e credit_facade_url.
    896    */
    897   json_t *credit_facade_credentials;
    898 
    899   /**
    900    * Additional meta data to include in wire transfers to this
    901    * account. Can be NULL if not used.
    902    */
    903   char *extra_wire_subject_metadata;
    904 
    905   /**
    906    * Is the account set for active use in new contracts?
    907    */
    908   bool active;
    909 
    910 };
    911 
    912 
    913 /**
    914  * Binary login token. Just a vanilla token made out
    915  * of random bits.
    916  */
    917 struct TALER_MERCHANTDB_LoginTokenP
    918 {
    919   /**
    920    * 32 bytes of entropy.
    921    */
    922   uint64_t data[32 / 8];
    923 };
    924 
    925 /**
    926  * Authentication settings for an instance.
    927  */
    928 struct TALER_MERCHANTDB_InstanceAuthSettings
    929 {
    930   /**
    931    * Hash used for authentication.  All zero if authentication is off.
    932    */
    933   struct TALER_MerchantAuthenticationHashP auth_hash;
    934 
    935   /**
    936    * Salt used to hash the "Authentication" header, the result must then
    937    * match the @e auth_hash.
    938    */
    939   struct TALER_MerchantAuthenticationSaltP auth_salt;
    940 };
    941 
    942 
    943 /**
    944  * General settings for an instance.
    945  */
    946 struct TALER_MERCHANTDB_InstanceSettings
    947 {
    948   /**
    949    * prefix for the instance under "/instances/"
    950    */
    951   char *id;
    952 
    953   /**
    954    * legal name of the instance
    955    */
    956   char *name;
    957 
    958   /**
    959    * merchant's site url
    960    */
    961   char *website;
    962 
    963   /**
    964    * email contact for password reset / possibly admin / customers
    965    */
    966   char *email;
    967 
    968   /**
    969    * phone contact for password reset / possibly admin / customers
    970    */
    971   char *phone;
    972 
    973   /**
    974    * merchant's logo data uri
    975    */
    976   char *logo;
    977 
    978   /**
    979    * Address of the business
    980    */
    981   json_t *address;
    982 
    983   /**
    984    * jurisdiction of the business
    985    */
    986   json_t *jurisdiction;
    987 
    988   /**
    989    * Use STEFAN curves to determine acceptable
    990    * fees by default (otherwise: accept no fees by default).
    991    */
    992   bool use_stefan;
    993 
    994   /**
    995    * True of @e phone was validated.
    996    */
    997   bool phone_validated;
    998 
    999   /**
   1000    * True of @e email was validated.
   1001    */
   1002   bool email_validated;
   1003 
   1004   /**
   1005    * If the frontend does NOT specify an execution date, how long should
   1006    * we tell the exchange to wait to aggregate transactions before
   1007    * executing the wire transfer?  This delay is added to the current
   1008    * time when we generate the advisory execution time for the exchange.
   1009    */
   1010   struct GNUNET_TIME_Relative default_wire_transfer_delay;
   1011 
   1012   /**
   1013    * If the frontend does NOT specify a payment deadline, how long should
   1014    * offers we make be valid by default?
   1015    */
   1016   struct GNUNET_TIME_Relative default_pay_delay;
   1017 
   1018   /**
   1019    * If the frontend does NOT specify a refund deadline, how long should
   1020    * refunds be possible?
   1021    */
   1022   struct GNUNET_TIME_Relative default_refund_delay;
   1023 
   1024   /**
   1025    * How much should we round up the wire transfer deadline computed by
   1026    * adding the @e default_wire_transfer_delay to the refund deadline.
   1027    */
   1028   enum GNUNET_TIME_RounderInterval default_wire_transfer_rounding_interval;
   1029 
   1030 };
   1031 
   1032 
   1033 /**
   1034  * Free members of @a pd, but not @a pd itself.
   1035  *
   1036  * @param[in] pd product details to clean up
   1037  */
   1038 void
   1039 TALER_MERCHANTDB_product_details_free (
   1040   struct TALER_MERCHANTDB_ProductDetails *pd);
   1041 
   1042 
   1043 /**
   1044  * Free members of @a tp, but not @a tp itself.
   1045  *
   1046  * @param[in] tp template details to clean up
   1047  */
   1048 void
   1049 TALER_MERCHANTDB_template_details_free (
   1050   struct TALER_MERCHANTDB_TemplateDetails *tp);
   1051 
   1052 
   1053 /**
   1054  * Free members of @a wb, but not @a wb itself.
   1055  *
   1056  * @param[in] wb webhook details to clean up
   1057  */
   1058 void
   1059 TALER_MERCHANTDB_webhook_details_free (
   1060   struct TALER_MERCHANTDB_WebhookDetails *wb);
   1061 
   1062 /**
   1063  * Free members of @a pwb, but not @a pwb itself.
   1064  *
   1065  * @param[in] pwb pending webhook details to clean up
   1066  */
   1067 void
   1068 TALER_MERCHANTDB_pending_webhook_details_free (
   1069   struct TALER_MERCHANTDB_PendingWebhookDetails *pwb);
   1070 
   1071 
   1072 /**
   1073  * Free members of @a tf, but not @a tf itself.
   1074  *
   1075  * @param[in] tf token family details to clean up
   1076  */
   1077 void
   1078 TALER_MERCHANTDB_token_family_details_free (
   1079   struct TALER_MERCHANTDB_TokenFamilyDetails *tf);
   1080 
   1081 
   1082 /**
   1083  * Free members of @a cd, but not @a cd itself.
   1084  *
   1085  * @param[in] cd token family details to clean up
   1086  */
   1087 void
   1088 TALER_MERCHANTDB_category_details_free (
   1089   struct TALER_MERCHANTDB_CategoryDetails *cd);
   1090 
   1091 /**
   1092  * Free members of @a ud, but not @a ud itself.
   1093  *
   1094  * @param[in] ud unit details to clean up
   1095  */
   1096 void
   1097 TALER_MERCHANTDB_unit_details_free (
   1098   struct TALER_MERCHANTDB_UnitDetails *ud);
   1099 
   1100 #endif  /* MERCHANT_DB_H */
   1101 
   1102 /* end of taler_merchantdb_lib.h */