merchant

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

merchantdb_lib.h (21858B)


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