merchant

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

merchantdb_lib.h (22747B)


      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    * Database identity of the device, set when reading its details.
    303    */
    304   uint64_t otp_serial;
    305 
    306   /**
    307    * Description of the device.
    308    */
    309   char *otp_description;
    310 
    311   /**
    312    * Current usage counter value.
    313    */
    314   uint64_t otp_ctr;
    315 
    316   /**
    317    * RFC 3548 Base32-encoded key for TOTP.  For the challenge-signature
    318    * algorithms this is the Crockford Base32-encoded private key the
    319    * backend generated, and it never leaves the backend.  NULL if the
    320    * device has no key.
    321    */
    322   char *otp_key;
    323 
    324   /**
    325    * Crockford base32-encoded public key of a challenge-signature
    326    * device, NULL for the TOTP algorithms.  This is the only part of
    327    * the key pair that is handed back to the merchant.
    328    */
    329   char *otp_device_pub;
    330 
    331   /**
    332    * Algorithm used to compute purchase confirmations.
    333    */
    334   enum TALER_MerchantConfirmationAlgorithm otp_algorithm;
    335 };
    336 
    337 
    338 /**
    339  * Details about a template.
    340  */
    341 struct TALER_MERCHANTDB_TemplateDetails
    342 {
    343   /**
    344    * Description of the template.
    345    */
    346   char *template_description;
    347 
    348   /**
    349    * In this template contract, we can have additional information.
    350    */
    351   json_t *template_contract;
    352 
    353   /**
    354    * ID of the OTP device linked to the template, or NULL.
    355    */
    356   char *otp_id;
    357 
    358   /**
    359    * Editable default values for fields not specified
    360    * in the @e template_contract. NULL if the user
    361    * cannot edit anything.
    362    */
    363   json_t *editable_defaults;
    364 
    365 };
    366 
    367 
    368 /**
    369  * Structure to hold Donau instance details from the database.
    370  */
    371 struct TALER_MERCHANTDB_DonauInstance
    372 {
    373   /**
    374    * Donau instance serial
    375    */
    376   uint64_t donau_instance_serial;
    377 
    378   /**
    379    * The URL for the Donau instance.
    380    */
    381   char *donau_url;
    382 
    383   /**
    384    * The name of the charity associated with the Donau instance.
    385    */
    386   char *charity_name;
    387 
    388   /**
    389    * Pointer to the public key of the charity, used for cryptographic operations.
    390    * This is represented as an EDDSA public key structure.
    391    */
    392   struct DONAU_CharityPublicKeyP *charity_pub_key;
    393 
    394   /**
    395    * A unique identifier for the charity in the Donau instance.
    396    */
    397   uint64_t charity_id;
    398 
    399   /**
    400    * The maximum allowable amount for donations to this charity in the current year.
    401    * This is tracked for regulatory or internal business constraints.
    402    */
    403   struct TALER_Amount charity_max_per_year;
    404 
    405   /**
    406    * The total amount of donations received by the charity in the current year.
    407    * This field helps track progress toward the yearly donation limit.
    408    */
    409   struct TALER_Amount charity_receipts_to_date;
    410 
    411   /**
    412    * The current year being tracked for donations.
    413    * This is used to differentiate donation data between years.
    414    */
    415   int64_t current_year;
    416 
    417   /**
    418    * A JSON object containing key information specific to the Donau instance,
    419    * such as cryptographic keys or other relevant details.
    420    */
    421   json_t *donau_keys_json;
    422 };
    423 
    424 
    425 /**
    426  * Details about a product.
    427  *
    428  * FIXME: reuse TALER_MERCHANT_Product as a member in this structure!
    429  */
    430 struct TALER_MERCHANTDB_ProductDetails
    431 {
    432   /**
    433    * Name of the product.
    434    */
    435   char *product_name;
    436 
    437   /**
    438    * Description of the product.
    439    */
    440   char *description;
    441 
    442   /**
    443    * Internationalized description.
    444    */
    445   json_t *description_i18n;
    446 
    447   /**
    448    * Unit in which the product is sold.
    449    */
    450   char *unit;
    451 
    452   /**
    453    * Optional list of per-unit prices. When NULL or empty, @e price
    454    * must be used as the canonical single price.
    455    */
    456   struct TALER_Amount *price_array;
    457 
    458   /**
    459    * Number of entries in @e price_array.
    460    */
    461   size_t price_array_length;
    462 
    463   /**
    464    * Base64-encoded product image, or an empty string.
    465    */
    466   char *image;
    467 
    468   /**
    469    * Hash of the product image data, or NULL.
    470    */
    471   char *image_hash;
    472 
    473   /**
    474    * List of taxes the merchant pays for this product. Never NULL,
    475    * but can be an empty array.
    476    */
    477   json_t *taxes;
    478 
    479   /**
    480    * Number of units of the product in stock in sum in total, including all
    481    * existing sales and lost product, in product-specific units. UINT64_MAX
    482    * indicates "infinite".
    483    */
    484   uint64_t total_stock;
    485 
    486   /**
    487    * Fractional part of stock in units of 1/1000000 of the base value.
    488    */
    489   uint32_t total_stock_frac;
    490 
    491   /**
    492    * Honor fractional stock if TRUE, else only integer stock.
    493    */
    494   bool allow_fractional_quantity;
    495 
    496   /**
    497    * Precision level (number of decimal places) to apply when
    498    * fractional quantities are enabled.
    499    */
    500   uint32_t fractional_precision_level;
    501 
    502   /**
    503    * Number of units of the product in sold, in product-specific units.
    504    */
    505   uint64_t total_sold;
    506 
    507   /**
    508    * Fractional part of units sold in units of 1/1000000 of the base value.
    509    */
    510   uint32_t total_sold_frac;
    511 
    512   /**
    513    * Number of units of stock lost.
    514    */
    515   uint64_t total_lost;
    516 
    517   /**
    518    * Fractional part of lost units in units of 1/1000000 of the base value.
    519    */
    520   uint32_t total_lost_frac;
    521 
    522   /**
    523    * Number of units currently reserved by locks (shopping cart locks and
    524    * locks held by unpaid orders).  These units are unavailable for new
    525    * orders.  Maintained by the database, not set by the application.
    526    */
    527   uint64_t total_locked;
    528 
    529   /**
    530    * Fractional part of locked units in units of 1/1000000 of the base value.
    531    */
    532   uint32_t total_locked_frac;
    533 
    534   /**
    535    * Identifies where the product is in stock, possibly an empty map.
    536    */
    537   json_t *address;
    538 
    539   /**
    540    * Identifies when the product will be restocked. 0 for unknown,
    541    * #GNUNET_TIME_UNIT_FOREVER_ABS for never.
    542    */
    543   struct GNUNET_TIME_Timestamp next_restock;
    544 
    545   /**
    546    * Minimum required age for consumers buying this product.
    547    * Default is 0. Only enforced of an exchange supports age
    548    * restrictions.
    549    */
    550   uint32_t minimum_age;
    551 
    552   /**
    553    * Group in which the product is in. 0 for default group.
    554    */
    555   uint64_t product_group_id;
    556 
    557   /**
    558    * Money pot into which sales of this product should go into by default.
    559    */
    560   uint64_t money_pot_id;
    561 
    562   /**
    563    * True if the price for this product is given in net,
    564    * False if its the gross price.
    565    */
    566   bool price_is_net;
    567 
    568 };
    569 
    570 
    571 /**
    572  * Details about a webhook.
    573  */
    574 struct TALER_MERCHANTDB_WebhookDetails
    575 {
    576 
    577   /**
    578    * event of the webhook.
    579    */
    580   char *event_type;
    581 
    582   /**
    583    * URL of the webhook. The customer will be redirected on this url.
    584    */
    585   char *url;
    586 
    587   /**
    588    * Http method used by the webhook.
    589    */
    590   char *http_method;
    591 
    592   /**
    593    * Header template of the webhook.
    594    */
    595   char *header_template;
    596 
    597   /**
    598    * Body template of the webhook.
    599    */
    600   char *body_template;
    601 
    602 };
    603 
    604 
    605 /**
    606  * Details about a product category.
    607  */
    608 struct TALER_MERCHANTDB_CategoryDetails
    609 {
    610 
    611   /**
    612    * Name of the category.
    613    */
    614   char *category_name;
    615 
    616   /**
    617    * Translations of the name of the category.
    618    */
    619   json_t *category_name_i18n;
    620 
    621 };
    622 
    623 
    624 /**
    625  * Details about the pending webhook.
    626  */
    627 struct TALER_MERCHANTDB_PendingWebhookDetails
    628 {
    629 
    630   /**
    631    * Identifies when we should make the next request to the webhook. 0 for unknown,
    632    * #GNUNET_TIME_UNIT_FOREVER_ABS for never.
    633    */
    634   struct GNUNET_TIME_Absolute next_attempt;
    635 
    636   /**
    637    * How often have we tried this request so far.
    638    */
    639   uint32_t retries;
    640 
    641   /**
    642    * URL of the webhook. The customer will be redirected on this url.
    643    */
    644   char *url;
    645 
    646   /**
    647    * Http method used for the webhook.
    648    */
    649   char *http_method;
    650 
    651   /**
    652    * Header of the webhook.
    653    */
    654   char *header;
    655 
    656   /**
    657    * Body of the webhook.
    658    */
    659   char *body;
    660 
    661 };
    662 
    663 
    664 /**
    665  * Details about a token family.
    666  */
    667 struct TALER_MERCHANTDB_TokenFamilyDetails
    668 {
    669   /**
    670    * Token family slug used for identification.
    671    */
    672   char *slug;
    673 
    674   /**
    675    * User readable name of the token family.
    676    */
    677   char *name;
    678 
    679   /**
    680    * Description of the token family.
    681    */
    682   char *description;
    683 
    684   /**
    685    * Internationalized token family description.
    686    */
    687   json_t *description_i18n;
    688 
    689   /**
    690    * Meta-data associated with the token family.
    691    * Includes information like "trusted_domains" or
    692    * "expected_domains", if set.
    693    */
    694   json_t *extra_data;
    695 
    696   /**
    697    * Cipher that should be used for this token family.  Note: We do not expose
    698    * this over the API and do not let clients set it. NULL for default (when
    699    * calling database).
    700    */
    701   char *cipher_spec;
    702 
    703   /**
    704    * Start time of the token family duration.
    705    */
    706   struct GNUNET_TIME_Timestamp valid_after;
    707 
    708   /**
    709    * End time of the token family duration.
    710    */
    711   struct GNUNET_TIME_Timestamp valid_before;
    712 
    713   /**
    714    * Validity duration of the token family. Must be larger or
    715    * equal to @a rounding plus @a start_offset_s.
    716    */
    717   struct GNUNET_TIME_Relative duration;
    718 
    719   /**
    720    * Rounding duration of the token family.
    721    */
    722   struct GNUNET_TIME_Relative validity_granularity;
    723 
    724   /**
    725    * Offset (in seconds) to subtract from the rounded
    726    * validity start period.
    727    */
    728   struct GNUNET_TIME_Relative start_offset;
    729 
    730   /**
    731    * Token family kind.
    732    */
    733   enum TALER_MERCHANTDB_TokenFamilyKind kind;
    734 
    735   /**
    736    * Counter for each issued token of this family.
    737    */
    738   uint64_t issued;
    739 
    740   /**
    741    * Counter for each used token of this family.
    742    */
    743   uint64_t used;
    744 };
    745 
    746 
    747 /**
    748  * Minimal product details for inventory templates.
    749  */
    750 struct TALER_MERCHANTDB_InventoryProductDetails
    751 {
    752   /**
    753    * Name of the product.
    754    */
    755   char *product_name;
    756 
    757   /**
    758    * Description of the product.
    759    */
    760   char *description;
    761 
    762   /**
    763    * Internationalized description.
    764    */
    765   json_t *description_i18n;
    766 
    767   /**
    768    * Unit in which the product is sold.
    769    */
    770   char *unit;
    771 
    772   /**
    773    * List of per-unit prices.
    774    */
    775   struct TALER_Amount *price_array;
    776 
    777   /**
    778    * Number of entries in @e price_array.
    779    */
    780   size_t price_array_length;
    781 
    782   /**
    783    * Hash of the product image data, or NULL.
    784    */
    785   char *image_hash;
    786 
    787   /**
    788    * Honor fractional stock if TRUE, else only integer stock.
    789    */
    790   bool allow_fractional_quantity;
    791 
    792   /**
    793    * Precision level (number of decimal places) to apply when
    794    * fractional quantities are enabled.
    795    */
    796   uint32_t fractional_precision_level;
    797 
    798   /**
    799    * Remaining units after sold/lost/locked deductions.
    800    */
    801   uint64_t remaining_stock;
    802 
    803   /**
    804    * Fractional part of remaining units in units of 1/1000000 of the base value.
    805    */
    806   uint32_t remaining_stock_frac;
    807 
    808   /**
    809    * List of taxes the merchant pays for this product. Never NULL,
    810    * but can be an empty array.
    811    */
    812   json_t *taxes;
    813 };
    814 
    815 
    816 /**
    817  * Details about an inventory measurement unit.
    818  */
    819 struct TALER_MERCHANTDB_UnitDetails
    820 {
    821 
    822   /**
    823    * Database serial.
    824    */
    825   uint64_t unit_serial;
    826 
    827   /**
    828    * Backend identifier used in product payloads.
    829    */
    830   char *unit;
    831 
    832   /**
    833    * Default long label (fallback string).
    834    */
    835   char *unit_name_long;
    836 
    837   /**
    838    * Default short label (fallback string).
    839    */
    840   char *unit_name_short;
    841 
    842   /**
    843    * Internationalised long labels.
    844    */
    845   json_t *unit_name_long_i18n;
    846 
    847   /**
    848    * Internationalised short labels.
    849    */
    850   json_t *unit_name_short_i18n;
    851 
    852   /**
    853    * Whether fractional quantities are enabled by default.
    854    */
    855   bool unit_allow_fraction;
    856 
    857   /**
    858    * Maximum number of fractional digits honoured by default.
    859    */
    860   uint32_t unit_precision_level;
    861 
    862   /**
    863    * Hidden from selectors when false.
    864    */
    865   bool unit_active;
    866 
    867   /**
    868    * Built-in units cannot be deleted.
    869    */
    870   bool unit_builtin;
    871 };
    872 
    873 
    874 /**
    875  * Details about a wire account of the merchant.
    876  */
    877 struct TALER_MERCHANTDB_AccountDetails
    878 {
    879   /**
    880    * Hash of the wire details (@e payto_uri and @e salt).
    881    */
    882   struct TALER_MerchantWireHashP h_wire;
    883 
    884   /**
    885    * Salt value used for hashing @e payto_uri.
    886    */
    887   struct TALER_WireSaltP salt;
    888 
    889   /**
    890    * Instance ID. Do not free (may be aliased with
    891    * the instance ID given in the query!).
    892    * FIXME: set in all functions involving this struct!
    893    */
    894   const char *instance_id;
    895 
    896   /**
    897    * Actual account address as a payto://-URI.
    898    */
    899   struct TALER_FullPayto payto_uri;
    900 
    901   /**
    902    * Where can the taler-merchant-wirewatch helper
    903    * download information about incoming transfers?
    904    * NULL if not available.
    905    */
    906   char *credit_facade_url;
    907 
    908   /**
    909    * JSON with credentials to use to access the
    910    * @e credit_facade_url.
    911    */
    912   json_t *credit_facade_credentials;
    913 
    914   /**
    915    * Additional meta data to include in wire transfers to this
    916    * account. Can be NULL if not used.
    917    */
    918   char *extra_wire_subject_metadata;
    919 
    920   /**
    921    * Is the account set for active use in new contracts?
    922    */
    923   bool active;
    924 
    925 };
    926 
    927 
    928 /**
    929  * Binary login token. Just a vanilla token made out
    930  * of random bits.
    931  */
    932 struct TALER_MERCHANTDB_LoginTokenP
    933 {
    934   /**
    935    * 32 bytes of entropy.
    936    */
    937   uint64_t data[32 / 8];
    938 };
    939 
    940 /**
    941  * Authentication settings for an instance.
    942  */
    943 struct TALER_MERCHANTDB_InstanceAuthSettings
    944 {
    945   /**
    946    * Hash used for authentication.  All zero if authentication is off.
    947    */
    948   struct TALER_MerchantAuthenticationHashP auth_hash;
    949 
    950   /**
    951    * Salt used to hash the "Authentication" header, the result must then
    952    * match the @e auth_hash.
    953    */
    954   struct TALER_MerchantAuthenticationSaltP auth_salt;
    955 };
    956 
    957 
    958 /**
    959  * General settings for an instance.
    960  */
    961 struct TALER_MERCHANTDB_InstanceSettings
    962 {
    963   /**
    964    * prefix for the instance under "/instances/"
    965    */
    966   char *id;
    967 
    968   /**
    969    * legal name of the instance
    970    */
    971   char *name;
    972 
    973   /**
    974    * merchant's site url
    975    */
    976   char *website;
    977 
    978   /**
    979    * email contact for password reset / possibly admin / customers
    980    */
    981   char *email;
    982 
    983   /**
    984    * phone contact for password reset / possibly admin / customers
    985    */
    986   char *phone;
    987 
    988   /**
    989    * merchant's logo data uri
    990    */
    991   char *logo;
    992 
    993   /**
    994    * Address of the business
    995    */
    996   json_t *address;
    997 
    998   /**
    999    * jurisdiction of the business
   1000    */
   1001   json_t *jurisdiction;
   1002 
   1003   /**
   1004    * Use STEFAN curves to determine acceptable
   1005    * fees by default (otherwise: accept no fees by default).
   1006    */
   1007   bool use_stefan;
   1008 
   1009   /**
   1010    * True of @e phone was validated.
   1011    */
   1012   bool phone_validated;
   1013 
   1014   /**
   1015    * True of @e email was validated.
   1016    */
   1017   bool email_validated;
   1018 
   1019   /**
   1020    * If the frontend does NOT specify an execution date, how long should
   1021    * we tell the exchange to wait to aggregate transactions before
   1022    * executing the wire transfer?  This delay is added to the current
   1023    * time when we generate the advisory execution time for the exchange.
   1024    */
   1025   struct GNUNET_TIME_Relative default_wire_transfer_delay;
   1026 
   1027   /**
   1028    * If the frontend does NOT specify a payment deadline, how long should
   1029    * offers we make be valid by default?
   1030    */
   1031   struct GNUNET_TIME_Relative default_pay_delay;
   1032 
   1033   /**
   1034    * If the frontend does NOT specify a refund deadline, how long should
   1035    * refunds be possible?
   1036    */
   1037   struct GNUNET_TIME_Relative default_refund_delay;
   1038 
   1039   /**
   1040    * How much should we round up the wire transfer deadline computed by
   1041    * adding the @e default_wire_transfer_delay to the refund deadline.
   1042    */
   1043   enum GNUNET_TIME_RounderInterval default_wire_transfer_rounding_interval;
   1044 
   1045 };
   1046 
   1047 
   1048 /**
   1049  * Free members of @a pd, but not @a pd itself.
   1050  *
   1051  * @param[in] pd product details to clean up
   1052  */
   1053 void
   1054 TALER_MERCHANTDB_product_details_free (
   1055   struct TALER_MERCHANTDB_ProductDetails *pd);
   1056 
   1057 
   1058 /**
   1059  * Free members of @a tp, but not @a tp itself.
   1060  *
   1061  * @param[in] tp template details to clean up
   1062  */
   1063 void
   1064 TALER_MERCHANTDB_template_details_free (
   1065   struct TALER_MERCHANTDB_TemplateDetails *tp);
   1066 
   1067 
   1068 /**
   1069  * Free members of @a wb, but not @a wb itself.
   1070  *
   1071  * @param[in] wb webhook details to clean up
   1072  */
   1073 void
   1074 TALER_MERCHANTDB_webhook_details_free (
   1075   struct TALER_MERCHANTDB_WebhookDetails *wb);
   1076 
   1077 /**
   1078  * Free members of @a pwb, but not @a pwb itself.
   1079  *
   1080  * @param[in] pwb pending webhook details to clean up
   1081  */
   1082 void
   1083 TALER_MERCHANTDB_pending_webhook_details_free (
   1084   struct TALER_MERCHANTDB_PendingWebhookDetails *pwb);
   1085 
   1086 
   1087 /**
   1088  * Free members of @a tf, but not @a tf itself.
   1089  *
   1090  * @param[in] tf token family details to clean up
   1091  */
   1092 void
   1093 TALER_MERCHANTDB_token_family_details_free (
   1094   struct TALER_MERCHANTDB_TokenFamilyDetails *tf);
   1095 
   1096 
   1097 /**
   1098  * Free members of @a cd, but not @a cd itself.
   1099  *
   1100  * @param[in] cd token family details to clean up
   1101  */
   1102 void
   1103 TALER_MERCHANTDB_category_details_free (
   1104   struct TALER_MERCHANTDB_CategoryDetails *cd);
   1105 
   1106 /**
   1107  * Free members of @a ud, but not @a ud itself.
   1108  *
   1109  * @param[in] ud unit details to clean up
   1110  */
   1111 void
   1112 TALER_MERCHANTDB_unit_details_free (
   1113   struct TALER_MERCHANTDB_UnitDetails *ud);
   1114 
   1115 #endif  /* MERCHANT_DB_H */
   1116 
   1117 /* end of taler_merchantdb_lib.h */