taler-docs

Documentation for GNU Taler components, APIs and protocols
Log | Files | Refs | README | LICENSE

taler-merchant-manual.rst (74126B)


      1 ..
      2   This file is part of GNU TALER.
      3 
      4   Copyright (C) 2014-2023 Taler Systems SA
      5 
      6   TALER is free software; you can redistribute it and/or modify it under the
      7   terms of the GNU Affero General Public License as published by the Free Software
      8   Foundation; either version 2.1, or (at your option) any later version.
      9 
     10   TALER is distributed in the hope that it will be useful, but WITHOUT ANY
     11   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     12   A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more details.
     13 
     14   You should have received a copy of the GNU Affero General Public License along with
     15   TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
     16 
     17   @author Christian Grothoff
     18 
     19 .. _taler-merchant-backend-operator-manual:
     20 
     21 Merchant Backend Operator Manual
     22 ################################
     23 
     24 
     25 Introduction
     26 ============
     27 
     28 About GNU Taler
     29 ---------------
     30 
     31 .. include:: frags/about-taler.rst
     32 
     33 
     34 .. _About-this-manual:
     35 
     36 About this manual
     37 -----------------
     38 
     39 This manual targets system administrators who want to install a GNU
     40 Taler merchant *backend*.
     41 
     42 We expect some moderate familiarity with the compilation and
     43 installation of Free Software packages. An understanding of cryptography
     44 is not required.
     45 
     46 .. _Architecture-overview:
     47 
     48 Architecture overview
     49 ---------------------
     50 
     51 .. index:: crypto-currency
     52 .. index:: KUDOS
     53 
     54 Taler is a pure payment system, not a new crypto-currency. As such, it
     55 operates in a traditional banking context. In particular, this means that in
     56 order to receive funds via Taler, the merchant must have a regular bank
     57 account, and payments can be executed in ordinary currencies such as USD or
     58 EUR.  Taler can also be used as a regional currency; for such scenarios, the
     59 Taler system also includes its own stand-alone bank.
     60 
     61 .. index:: frontend
     62 .. index:: back-office
     63 .. index:: backend
     64 .. index:: DBMS
     65 .. index:: PostgreSQL
     66 
     67 The Taler software stack for a merchant consists of four main components:
     68 
     69 -  A *frontend* which interacts with the customer’s browser. The frontend
     70    enables the customer to build a shopping cart and place an order.
     71    Upon payment, it triggers the respective business logic to satisfy
     72    the order. This component is not included with Taler, but rather
     73    assumed to exist at the merchant.
     74    The `Merchant API Tutorial <https://tutorials.taler.net/dev/merchant-api/>`_ gives an
     75    introduction for how to integrate Taler with Web shop frontends.
     76 -  A *back-office* application that enables the shop operators to view
     77    customer orders, match them to financial transfers, and possibly
     78    approve refunds if an order cannot be satisfied. This component is
     79    not included with Taler, but rather assumed to exist at the
     80    merchant. The :ref:`Merchant Backend API <merchant-api>` provides
     81    the API specification that should be reviewed to integrate such a
     82    back-office with the Taler backend.
     83 -  A Taler-specific payment *backend* which makes it easy for the frontend
     84    to process financial transactions with Taler. This manual primarily
     85    describes how to install and configure this backend.
     86 -  A *DBMS* which stores the transaction history for the Taler backend.
     87    For now, the GNU Taler reference implementation only supports
     88    PostgreSQL, but the code could be easily extended to support another
     89    DBMS.  Please review the PostgreSQL documentation for details on
     90    how to configure the database.
     91 
     92 The following image illustrates the various interactions of these key
     93 components:
     94 
     95 .. image:: images/arch-api.png
     96 
     97 .. index:: RESTful
     98 
     99 Basically, the backend provides the cryptographic protocol support, stores
    100 Taler-specific financial information in a DBMS and communicates with the GNU
    101 Taler exchange over the Internet. The frontend accesses the backend via a
    102 RESTful API. As a result, the frontend never has to directly communicate with
    103 the exchange, and also does not deal with sensitive data. In particular, the
    104 merchant’s signing keys and bank account information are encapsulated within
    105 the Taler merchant backend.
    106 
    107 A typical deployment will additionally include a full-blown Web server (like
    108 Apache or Nginx). Such a Web server would be responsible for TLS termination and
    109 access control to the ``/private/`` and ``/management/`` API endpoints of the
    110 merchant backend. Please carefully review the section on :ref:`secure setup
    111 <Secure-setup>` before deploying a Taler merchant backend into production.
    112 
    113 
    114 Terminology
    115 ===========
    116 
    117 This chapter describes some of the key concepts used throughout the manual.
    118 
    119 Instances
    120 ---------
    121 
    122 .. index:: instance
    123 
    124 The backend allows a single HTTP server to support multiple independent shops
    125 with distinct business entities sharing a single backend.  An *instance* is
    126 the name or identifier that allows the single HTTP server to determine which
    127 shop a request is intended for.  Each instance has its own base URL in the
    128 REST API of the merchant backend (``/instances/$INSTANCE/``).  Each instance
    129 can use its own bank accounts and keys for signing contracts. All major
    130 accounting functionality is separate per instance.  Access to each instance is
    131 controlled via a bearer token (to be set in the HTTP "Authorization" header).
    132 All instances share the same *database*, top-level HTTP(S) address and the
    133 main Taler configuration (especially the accepted *currency* and *exchanges*).
    134 
    135   .. note::
    136 
    137     This documentation does not use the term "user" or "username" in
    138     conjunction with instances as that might create confusion between
    139     instances with paying customers using the system.  We also do not use the
    140     term "account" in conjunction with instances, as that might cause
    141     confusion with bank accounts.  That said, conceptually it is of course
    142     acceptable to consider instances to be the "users" or "accounts" of a
    143     merchant backend and the bearer token is equivalent to a passphrase.
    144 
    145 .. _instance-bank-account:
    146 
    147 Instance Bank Accounts
    148 ----------------------
    149 
    150 .. index:: Bank account
    151 
    152 To receive payments, an instance must have configured one or more bank
    153 *accounts*.  When configuring the bank account of an instance, one should
    154 ideally also provide the address and credentials of an HTTP service
    155 implementing the :ref:`Taler Bank Revenue HTTP API
    156 <taler-bank-merchant-http-api>`.  Given such a service, the GNU Taler merchant
    157 backend can automatically reconcile wire transfers from the exchange to the
    158 merchant's bank account with the orders that are being settled.
    159 
    160 This documentation exclusively uses the term *account* for the bank
    161 accounts of a merchant or shop that may be associated with an instance.
    162 
    163 Inventory
    164 ---------
    165 
    166 .. index:: inventory
    167 .. index:: product
    168 .. index:: lock
    169 .. index:: unit
    170 .. index:: order
    171 
    172 The Taler backend offers inventory management as an optional function.
    173 Inventory is tracked per instance and consists of *products* sold in
    174 *units*. Inventory can be finite (physical stock) or infinite (for digital
    175 products).  Products may include previews (images) to be shown to the user as
    176 well as other meta-data. Inventory management allows the frontend to *lock*
    177 products, reserving a number of units from stock for a particular (unpaid)
    178 *order*. The backend can keep track of how many units of a product remain in
    179 stock and ensure that the number of units sold does not exceed the number of
    180 units in stock.
    181 
    182 Inventory management is optional, and it is possible for the frontend to
    183 include products in orders that are not in the inventory. The frontend
    184 can also override prices of products in the inventory or set a total price
    185 for an order that is different from the price of the sum of the products
    186 in the order.
    187 
    188 
    189 Orders and Contracts
    190 --------------------
    191 
    192 .. index:: order
    193 .. index:: terms
    194 .. index:: contract
    195 .. index:: claim
    196 .. index:: pay
    197 .. index:: refund
    198 .. index:: wire deadline
    199 .. index:: lock
    200 .. index:: legal expiration
    201 
    202 In Taler, users pay merchants for *orders*. An order is first created by the
    203 merchant. To create an order, the merchant must specify the specific *terms*
    204 of the order.  Order *terms* include details such as the total amount to be
    205 paid, payment fees the merchant is willing to cover, the set of products to
    206 deliver, a delivery location and many other details.  The :ref:`merchant API
    207 specification <contract-terms>` specifies the full set of possible order
    208 terms.
    209 
    210 After an order is created, it is *claimed* by a wallet. Once an order is
    211 claimed by a specific wallet, only that wallet will be able to pay for this
    212 order, to the exclusion of other wallets even if they see the same order URL.
    213 Sharing order URLs is explicitly allowed: if a user shares an order URL
    214 with another user, that other user should be given the opportunity to
    215 purchase the same product.
    216 
    217 To prevent unauthorized wallets from claiming an order, merchants can specify
    218 that claims require authorization in the form of a *claim token*. This is
    219 useful in case the order ID is predictable (say because an existing order ID
    220 scheme with predictable order IDs from the merchant frontend is used) and at
    221 the same time malicious actors claiming orders is problematic (say because of
    222 limited stocks). The use of claim tokens is optional, but if a claim token is
    223 used, it must be provided to the wallet as part of the order URI.
    224 
    225 Additionally, when stocks are limited, you can configure Taler to set a
    226 *product lock* on items (say, while composing the shopping cart).  These
    227 locks will ensure that the limited stock is respected when making offers
    228 to consumers.
    229 
    230 A wallet may *pay* for a claimed order, at which point the order turns into a
    231 (paid) *contract*.  Orders have a configurable expiration date (the
    232 ``pay_deadline``) after which the commercial offer expires and any stock of
    233 products *locked* by the order will be automatically released, allowing the
    234 stock to be sold in other orders.  When an unpaid order expires, the customer
    235 must request a fresh order if they still want to make a purchase.
    236 
    237 Once a contract has been paid, the merchant should fulfill the contract.  It
    238 is possible for the merchant to *refund* a contract order, for example if the
    239 contract cannot be fulfilled after all. Refunds are only possible after the
    240 customer paid and before the exchange has *wired* the payment to the
    241 merchant. Once the funds have been wired, refunds are no longer allowed by the
    242 Taler exchange.  The *wire deadline* specifies the latest point in time by
    243 which an exchange must wire the funds, while the (earlier) *refund deadline*
    244 specifies the earliest point in time when an exchange may wire the funds.
    245 Thus, refunds are always possible between the time of purchase and the
    246 refund deadline, but may remain possible until the wire deadline.
    247 
    248 Contract information is kept for legal reasons in the merchant database.  The
    249 main legal reason is typically to provide tax records in case of a tax audit.
    250 After the *legal expiration* (by default: a decade), contract information is
    251 deleted when running the garbage collector using ``taler-merchant-dbinit``.
    252 
    253 
    254 .. _template:
    255 
    256 Templates
    257 ---------
    258 
    259 .. index:: Template
    260 
    261 Usually, a merchant must use an authenticated endpoint to create an order and
    262 then share the link to the order with a wallet. Templates are a mechanism that
    263 allows wallets to create their own orders directly, using a public endpoint.
    264 The template fixes some properties of the contracts created from it, while
    265 other details may be left for the customer to provide.  Templates are useful
    266 in cases where the point-of-sale of a merchant is offline (and thus cannot
    267 setup an order), or even in cases where a simple static QR code is desired to
    268 accept payments or donations.
    269 
    270 When generating a template, the "summary" text of the contract and the
    271 "amount" to be paid by the customer can be fixed or left for the customer to
    272 specify.  If the customer is expected to provide either or both of these
    273 values, the template link (or QR code) can specify a default value. For
    274 example, a cafeteria with a fixed price lunch may use a "lunch" template with
    275 both values fixed to the lunch price and the "lunch" product, a bakery might
    276 fix the summary to "baked goods" but allow the customer to enter the amount
    277 based on the total price of the items being bought, and a charity may allow
    278 donating an arbitrary amount and summary message while also suggesting default
    279 values.
    280 
    281 If an offline merchant wants to confirm that a customer did actually pay the
    282 agreed amount using an order derived from a template, they can associate an
    283 OTP device with the template.
    284 
    285 
    286 .. _otp-device:
    287 
    288 OTP Devices
    289 -----------
    290 
    291 .. index:: OTP
    292 .. index:: TOTP
    293 
    294 A One-Time-Password (OTP) generator is a device or application that generates
    295 a 4 to 8 digit code typically used for authentication. The widely used TOTP
    296 standard is described in `RFC 6238 <https://www.rfc-editor.org/rfc/rfc6238>`_.
    297 For GNU Taler merchant backends, OTP devices are used as a way to assure a
    298 merchant without network connectivity that a customer made a digital
    299 payment. The idea is described in depth in our `SUERF Policy Brief
    300 <https://www.suerf.org/suer-policy-brief/69851/practical-offline-payments-using-one-time-passcodes>`_.
    301 To use this method, a merchant must configure the OTP device's shared secret
    302 in the merchant backend, and then associate the OTP device with a
    303 :ref:`template`.  Once the customer has paid, they are given a list of OTP
    304 codes which must be shown to the merchant who can check that at least one of
    305 the codes matches their OTP device, proving that the customer made the
    306 payment.
    307 
    308 
    309 Transfers
    310 ---------
    311 
    312 .. index:: transfer
    313 .. index:: wire transfer
    314 
    315 The Taler backend can be used to verify that the exchange correctly wired all
    316 of the funds to the merchant. However, if no :ref:`Taler Bank Revenue HTTP API
    317 <taler-bank-merchant-http-api>` was provided for the respective bank account,
    318 the backend does not have access to the incoming wire transfers of the
    319 merchant's bank account. In this case, merchants should manually provide the
    320 backend with wire *transfer* data that specifies the *wire transfer subject*
    321 and the amount that was received. Given this information, the backend can
    322 detect and report any irregularities that might arise.
    323 
    324 
    325 Webhooks
    326 --------
    327 
    328 .. index:: webhook
    329 
    330 A webhook is a pre-defined HTTP request that the GNU Taler merchant backend
    331 will make upon certain events, such as an order being paid or refunded. When
    332 the configured event happens, the merchant backend will make an HTTP request
    333 to the endpoint configured in the webhook configuration, possibly sending
    334 selected data about the event to the respective Web service. Webhooks can be
    335 used to trigger additional business logic outside of the GNU Taler merchant
    336 backend.
    337 
    338 
    339 Installation
    340 ============
    341 
    342 This chapter describes how to install the GNU Taler merchant backend.
    343 
    344 .. _Generic-instructions:
    345 
    346 Installing the GNU Taler binary packages on Debian
    347 --------------------------------------------------
    348 
    349 .. include:: frags/installing-debian.rst
    350 
    351 .. include:: frags/apt-install-taler-merchant.rst
    352 
    353 
    354 Installing the GNU Taler binary packages on Ubuntu
    355 --------------------------------------------------
    356 
    357 .. include:: frags/installing-ubuntu.rst
    358 
    359 .. include:: frags/apt-install-taler-merchant.rst
    360 
    361 
    362 Installing from source
    363 ----------------------
    364 
    365 The following instructions will show how to install a GNU Taler
    366 merchant backend from source.
    367 
    368 The package sources can be find in our
    369 `download directory <http://ftpmirror.gnu.org/taler/>`__.
    370 
    371 .. include:: frags/semver.rst
    372 
    373 First, the following packages need to be installed before we can compile the
    374 backend:
    375 
    376 .. include:: frags/list-of-dependencies.rst
    377 
    378 .. include:: frags/installing-gnunet.rst
    379 
    380 .. include:: frags/install-before-check.rst
    381 
    382 There is no need to actually run a GNUnet peer to use the Taler merchant
    383 backend -- all the merchant needs from GNUnet is a number of headers and
    384 libraries!
    385 
    386 .. include:: frags/installing-taler-exchange.rst
    387 
    388 There is no need to actually run a Taler exchange to use the Taler merchant
    389 backend -- all the merchant needs from the Taler exchange is a few headers and
    390 libraries!
    391 
    392 .. note::
    393 
    394   There is an additional **optional** dependency that you could install to
    395   obtain support for tax-deductable donations. This is only useful for
    396   charities and only in countries with tax authorities that operate a Donau to
    397   register charities and accept Taler-style digitally signed donation
    398   statements.  As of right now, we are pretty sure that list is right now
    399   empty. But, if you want to experiment with Taler-style donation statmenets,
    400   you need to install Donau after the exchange and before the merchant.
    401 
    402 .. include:: frags/install-before-check.rst
    403 
    404 .. include:: frags/installing-taler-merchant.rst
    405 
    406 .. include:: frags/install-before-check.rst
    407 
    408 
    409 
    410 How to configure the merchant backend
    411 =====================================
    412 
    413 .. index:: taler-merchant.conf
    414 
    415 The installation already provides reasonable defaults for most of the
    416 configuration options. However, some must be provided, in particular the
    417 database that the backend should use. By default, the file
    418 ``$HOME/.config/taler-merchant.conf`` is where the Web shop administrator specifies
    419 configuration values that augment or override the defaults.
    420 Note that when using our binary packages, the systemd service files
    421 force the use of ``/etc/taler-merchant/taler-merchant.conf`` as the main configuration file.
    422 
    423 
    424 .. include:: frags/configuration-format.rst
    425 
    426 
    427 .. _Backend-options:
    428 
    429 Backend options
    430 ---------------
    431 
    432 .. index:: DBMS
    433 .. index:: PostgreSQL
    434 .. index:: UNIX domain socket
    435 .. index:: TCP
    436 .. index:: port
    437 .. index:: currency
    438 .. index:: KUDOS
    439 .. index:: exchange
    440 .. index:: instance
    441 .. index:: wire format
    442 
    443 The following table describes the options that commonly need to be
    444 modified. Here, the notation ``[$SECTION]/$OPTION`` denotes the option
    445 ``$OPTION`` under the section ``[$SECTION]`` in the configuration file.
    446 
    447 
    448 Service address
    449 ^^^^^^^^^^^^^^^
    450 
    451 The service address specifies where the taler-merchant-httpd should listen for
    452 requests. When using the Debian/Ubuntu packages, these options will already be
    453 configured correctly for the included Nginx and Apache configurations and will
    454 not need any changes.
    455 
    456 The following option sets the transport protocol used by the merchant backend:
    457 
    458 .. code-block:: ini
    459 
    460       [MERCHANT]
    461       SERVE = unix # or tcp
    462 
    463 If this option is set to
    464 
    465 -  ``tcp`` then we need to set the TCP port in ``[MERCHANT]/PORT``;
    466 
    467 -  ``unix`` then we need to set the unix domain socket path and mode
    468    in ``[MERCHANT]/UNIXPATH`` and ``[MERCHANT]/UNIXPATH_MODE``. The
    469    latter takes the usual permission mask given as a number, e.g. 660
    470    for user/group read-write access.
    471 
    472 The frontend can then connect to the backend over HTTP using the specified
    473 address. If frontend and backend run within the same operating system, the
    474 use of a UNIX domain socket is recommended to avoid accidentally exposing
    475 the backend to the network.
    476 
    477 To run the Taler backend on TCP port 9966 (the default), use:
    478 
    479 .. code-block:: ini
    480 
    481    [MERCHANT]
    482    SERVE = tcp
    483    PORT = 9966
    484 
    485 .. note::
    486 
    487    If you need to change where the taler-merchant-httpd listens for requests,
    488    you should edit ``/etc/taler-merchant/merchant-overrides.conf``.  By default, the
    489    Taler merchant package will use a UNIX domain socket at
    490    ``/run/taler-merchant/merchant-httpd/merchant-http.sock``. For the best possible
    491    security it is recommended to leave this in place and configure a reverse
    492    proxy (Nginx or Apache) as described below.
    493 
    494    When using the Debian/Ubuntu packages, the use of a UNIX domain socket
    495    is already pre-configured in the ``/etc/taler-merchant/conf.d/merchant.conf``
    496    configuration file.  Suitable reverse proxy configuration
    497    file templates (``taler-merchant``) are be installed in the
    498    respective ``sites-available`` directories of Apache and Nginx.
    499 
    500 
    501 
    502 Currency
    503 ^^^^^^^^
    504 
    505 Which currency the SPA uses by default is
    506 specified using the option:
    507 
    508 .. code-block:: ini
    509 
    510       [MERCHANT]
    511       CURRENCY = EUR # or USD, ...
    512 
    513 When testing with the Taler demonstration exchange at
    514 https://exchange.demo.taler.net/ you probably want to set this
    515 value to ``KUDOS``:
    516 
    517 .. code-block:: ini
    518 
    519        [MERCHANT]
    520        CURRENCY = KUDOS
    521 
    522 The merchant backend is already multi-currency capable, and will allow you to
    523 create orders in all currencies for which an exchange is configured, not just
    524 the default currency.  However, the Web interface does not yet offer
    525 multi-currency support and often only supports using the default currency.
    526 
    527 .. note::
    528 
    529    When using the Debian/Ubuntu packages, these options should be
    530    configured in the ``/etc/taler-merchant/taler-merchant.conf`` configuration file
    531    (alternatively, you can also edit ``/etc/taler-merchant/merchant-overrides.conf``).
    532    However, you must edit the ``taler-merchant.conf`` file manually and **must not**
    533    use ``taler-merchant-config`` to do this, as that would inline the include
    534    directives and destroy the carefully setup path structure.
    535 
    536 
    537 Database
    538 ^^^^^^^^
    539 
    540 In principle it is possible for the backend to support different DBMSs.
    541 The option
    542 
    543 .. code-block:: ini
    544 
    545       [MERCHANT]
    546       DB = postgres
    547 
    548 specifies which DBMS is to be used. However, currently only the value
    549 ``postgres`` is supported. This is also the default.
    550 
    551 In addition to selecting the DBMS software, the backend requires
    552 DBMS-specific options to access the database.
    553 
    554 .. note::
    555 
    556    The **taler-merchant-dbconfig** tool can be used to automate the database
    557    setup. When using the Debian/Ubuntu packages, the user should already have
    558    been created, so you can just run the tool without any arguments and should
    559    have a working database configuration.
    560 
    561    Please make sure you did not create a taler merchant database manually before running
    562    this command or it will fail with SQL errors.
    563 
    564 
    565 For the ``postgres`` backend, you need to specify:
    566 
    567 .. code-block:: ini
    568 
    569       [merchantdb-postgres]
    570       CONFIG = "postgres:///taler-merchant"
    571 
    572 This option specifies a PostgreSQL access path, typically using the format
    573 ``postgres:///$DBNAME``, where ``$DBNAME`` is the name of the PostgreSQL
    574 database you want to use (here, ``taler-merchant`` on the local machine).
    575 Suppose ``$USER`` is the name of the user who will run the backend process
    576 (usually ``taler-merchant-httpd``). Then, you need to first run:
    577 
    578 .. code-block:: console
    579 
    580    $ sudo -u postgres createuser -d $USER
    581 
    582 as the PostgreSQL database administrator (usually ``postgres``) to
    583 grant ``$USER`` the ability to create new databases. Next, you should
    584 as ``$USER`` run:
    585 
    586 .. code-block:: console
    587 
    588    $ createdb $DBNAME
    589 
    590 to create the backend’s database. Here, ``$DBNAME`` must match the
    591 database name given in the configuration file.
    592 
    593 Now you should be able to create the tables and indices. To do this, run as
    594 ``$USER`` (usually ``taler-merchant-httpd``):
    595 
    596 .. code-block:: console
    597 
    598    $ taler-merchant-dbinit
    599 
    600 You may improve your security posture if you now REVOKE the rights to CREATE,
    601 DROP or ALTER tables from ``$USER``. However, if you do so, please be aware
    602 that you may have to temporarily GRANT those rights again when you update the
    603 merchant backend.  For details on how to REVOKE or GRANT these rights, consult
    604 the PostgreSQL documentation.
    605 
    606 .. include:: frags/db-stores-sensitive-data.rst
    607 
    608 
    609 .. index: MASTER_KEY
    610 
    611 Exchange
    612 ^^^^^^^^
    613 
    614 To add an exchange to the list of trusted payment service providers, you
    615 create a section with a name that starts with “MERCHANT-EXCHANGE-”. In that
    616 section, the following options need to be configured:
    617 
    618 -  The ``EXCHANGE_BASE_URL`` option specifies the exchange’s base URL.
    619    For example, to use the Taler demonstrator, specify:
    620 
    621    .. code-block:: ini
    622 
    623       [merchant-exchange-kudos]
    624       EXCHANGE_BASE_URL = "https://exchange.demo.taler.net/"
    625 
    626 -  The KUDOS demo exchange and others are usually enabled by default
    627    in the distribution so you can easily test your backend. If you want
    628    to disable KUDOS, for example because you only want to support
    629    CHF or EUR, do not delete the "kudos.conf", but instead disable
    630    it explicitly in your main taler-merchant.conf configuration
    631    file using:
    632 
    633    .. code-block:: ini
    634 
    635       [merchant-exchange-kudos]
    636       DISABLED = YES
    637 
    638    This is also the preferred way to disable any other exchange that
    639    may be enabled by default. You can get a list of all of these
    640    exchange configuration sections using
    641    ``taler-merchant-config -S | grep merchant-exchange-``.
    642 
    643 -  The ``MASTER_KEY`` option specifies the exchange’s master public key
    644    in base32 encoding. For the Taler demonstrator, use:
    645 
    646    .. code-block:: ini
    647 
    648       [merchant-exchange-kudos]
    649       MASTER_KEY = "GNRJCH0HYKN59939JC0CJ2JDC7ZNEBSATJFF00CVS3WPG4TQEA7G"
    650 
    651   You can find out this key by running ``curl https://exchange.demo.taler.net/keys | jq .master_public_key``.
    652 
    653 -  The ``CURRENCY`` option specifies the exchange’s currency.
    654    For the Taler demonstrator, use:
    655 
    656    .. code-block:: ini
    657 
    658       [merchant-exchange-kudos]
    659       CURRENCY = "KUDOS"
    660 
    661 
    662 Note that multiple exchanges can be added to the system by using different
    663 identifiers in place of ``KUDOS`` in the example above. One exchange will only
    664 ever support a single currency; thus, if you need support for multiple
    665 currencies, you must add multiple exchanges.
    666 
    667 The merchant already ships with a default configuration that contains the
    668 ``merchant-exchange-kudos`` section from above.
    669 
    670 .. note::
    671 
    672    Manually setting up exchanges is only recommended under special
    673    circumstances. In general, GNU Taler distributions will include trustworthy
    674    exchanges (for each currency) in the default configuration, and there is
    675    rarely a good reason for trusting an exchange that has no relationship
    676    with the GNU Taler development team.
    677 
    678 
    679 .. _Sample-backend-configuration:
    680 
    681 Sample backend configuration
    682 ----------------------------
    683 
    684 .. index:: configuration
    685 
    686 The following is an example for a complete backend configuration:
    687 
    688 .. code-block:: ini
    689 
    690    [taler]
    691    CURRENCY = KUDOS
    692 
    693    [merchant]
    694    SERVE = TCP
    695    PORT = 9966
    696    DATABASE = postgres
    697 
    698    [merchantdb-postgres]
    699    CONFIG = postgres:///taler-merchant
    700 
    701    [merchant-exchange-kudos]
    702    EXCHANGE_BASE_URL = https://exchange.demo.taler.net/
    703    MASTER_KEY = FH1Y8ZMHCTPQ0YFSZECDH8C9407JR3YN0MF1706PTG24Q4NEWGV0
    704    # If currency does not match [taler] section, the exchange
    705    # will be ignored!
    706    CURRENCY = KUDOS
    707 
    708 Given the above configuration, the backend will use a PostgreSQL database
    709 named ``donations`` running on the same host.
    710 
    711 The backend will deposit the coins it receives to the exchange at
    712 https://exchange.demo.taler.net/, which has the master key
    713 ``FH1Y8ZMHCTPQ0YFSZECDH8C9407JR3YN0MF1706PTG24Q4NEWGV0``.
    714 
    715 
    716 .. _Launching-the-backend:
    717 
    718 Launching the backend
    719 ---------------------
    720 
    721 .. index:: backend
    722 .. index:: taler-merchant-httpd
    723 
    724 Assuming you have configured everything correctly, you can launch the
    725 merchant backend as ``$USER`` using (to provide a trivial example):
    726 
    727 .. code-block:: console
    728 
    729    $ taler-merchant-httpd &
    730    $ taler-merchant-webhook &
    731    $ taler-merchant-kyccheck &
    732    $ taler-merchant-wirewatch &
    733    $ taler-merchant-depositcheck &
    734    $ taler-merchant-exchangekeyupdate &
    735    $ taler-merchant-reconciliation &
    736 
    737 .. note::
    738 
    739   If you compiled the merchant backend with support for donation
    740   statements via Donau, you need to additionally launch
    741   ``taler-merchant-donaukeyupdate``.
    742 
    743 To ensure these processes run always in the background and also after
    744 rebooting, you should use systemd, cron or some other init system of your
    745 operating system to launch the process.  You should also periodically re-start
    746 these services to prevent them from exhausing the memory utilization of the
    747 PostgreSQL database.  Consult the documentation of your operating system for
    748 how to start and stop daemons.
    749 
    750 .. note::
    751 
    752    When using the Debian/Ubuntu packages, the systemd configuration
    753    will already exist. You only need to enable and start the service
    754    using ``systemctl enable taler-merchant.target`` and
    755    ``systemctl start taler-merchant.target``. Additionally, you should
    756    review the ``/etc/apache2/sites-available/taler-merchant.conf``
    757    or ``/etc/nginx/sites-available/taler-merchant`` (these files
    758    contain additional instructions to follow), symlink it to
    759    ``sites-enabled/`` and restart your HTTP server. After that, you
    760    should be able to visit the merchant backend at the respective
    761    HTTP(S) endpoint.
    762 
    763 If everything worked as expected, the command
    764 
    765 .. code-block:: console
    766 
    767    $ wget -O - http://localhost:9966/config
    768 
    769 should return some basic configuration status data about the service.
    770 
    771 Please note that your backend might then be globally reachable without
    772 any access control.  You can either:
    773 
    774   * Use the ``--auth=$TOKEN`` command-line option to **taler-merchant-httpd** to set an access token to be provided in an ``Authorize: Bearer $TOKEN`` HTTP header. Note that this can be used at anytime to override access control, but remains only in effect until a first instance is created or an existing instance authentication setting is modified.
    775   * Set the ``TALER_MERCHANT_TOKEN`` environment variable to ``$TOKEN`` for the same effect. This method has the advantage of ``$TOKEN`` not being visible as a command-line interface to other local users on the same machine.
    776   * Set up an instance with an authentication token before some unauthorized person has a chance to access the backend.  As the backend is useless without any instance and the chances of remote attackers during the initial configuration is low, this is probably sufficient for most use-cases. Still, keep the first two scenarios in mind in case you ever forget your access token!
    777 
    778 Production systems should additionally be configured to bind to a UNIX domain socket
    779 and use TLS for improved network privacy, see :ref:`Secure setup <Secure-setup>`.
    780 
    781 
    782 Multi-factor authentication
    783 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    784 
    785 The merchant backend supports multi-factor authentication for critical
    786 endpoints, including issuing access token, changing login credentials,
    787 modifying the bank account and deleting the instance. To use
    788 multi-factor authentication, the merchant backend must be configured
    789 with helper programs that can be used to send e-mails or SMS messages.
    790 
    791 
    792 .. code-block:: ini
    793 
    794       [MERCHANT]
    795       HELPER_SMS = sms_helper.sh
    796       HELPER_EMAIL = email_helper.sh
    797 
    798 These scripts will be called by the merchant backend with the
    799 first argument being the phone number or the e-mail address, and
    800 with the message with the TAN code to send to the user on standard
    801 input. The shell scripts must exit with a status code of 0 on
    802 success.  A trivial e-mail helper would look like this:
    803 
    804 .. code-block:: sh
    805 
    806       #!/bin/sh
    807       exec mail --subject="TAN code for the Taler merchant backend" "$1"
    808 
    809 Here, ``mail`` refers to the classic UNIX mail command.
    810 Example scripts can also be found in the `GNU Anastasis Git
    811 <https://git.taler.net/anastasis.git/tree/src/authorization>`_.
    812 
    813 
    814 Self-provisioning
    815 ^^^^^^^^^^^^^^^^^
    816 
    817 Self-provisioning allows anyone to create a merchant instance. This
    818 is useful if a merchant backend is offered as a public service. In this
    819 case, you should set:
    820 
    821 .. code-block:: ini
    822 
    823       [MERCHANT]
    824       ENABLE_SELF_PROVISIONING = YES
    825 
    826 
    827 To enable self-provisioned users to reset their passwords if they
    828 forgot them, the merchant backend requires two other authentication
    829 methods to be available and validated when the instance is
    830 self-provisioned.  This can be enabled using:
    831 
    832 .. code-block:: ini
    833 
    834       [MERCHANT]
    835       MANDATORY_TAN_CHANNELS = sms email
    836 
    837 With this setting, users that self-provision an instance must first
    838 demonstrate control over the e-mail address and phone number provided,
    839 and can thus later reset their password without needing support from
    840 the administrator.
    841 
    842 
    843 .. index:: instance
    844 .. _Instance-setup:
    845 
    846 
    847 Instance setup
    848 ==============
    849 
    850 We recommend the use of the single-page administration application (SPA) that
    851 is served by default at the base URL of the merchant backend.  You can use it
    852 to perform all steps described in this section (and more!), using a simple Web
    853 interface. Alternatively, you can also use the ``wget`` commands given below.
    854 
    855 Regardless of which approach you use, the first step for using the backend
    856 involves the creation of the ``admin`` instance. The ``admin`` instance can
    857 also create, configure or delete other instances, similar to the ``root``
    858 account on UNIX.  When no instance exists, then the backend is reachable
    859 without any access control (unless you configured some in the reverse proxy).
    860 
    861 .. note::
    862 
    863   If you created a non-admin instance first, you cannot create an ``admin``
    864   instance via the SPA anymore. In this case, you can only create an
    865   administrative account by using the command-line. By invoking
    866   ``taler-merchant-passwd --instance=admin $PASSWORD`` you can set both the
    867   password and create an ``admin`` instance if it does not yet exist.
    868   However, for non-admin instances, you can only set the password with this tool.
    869 
    870 The following documentation shows how to handle any instance. Thus, if you
    871 want to have multiple instances, you may need to perform the steps multiple
    872 times, once for each instance.
    873 
    874 .. note::
    875 
    876   A potential security concern is that normal API usage leaks instance existence.
    877   This means unauthorized users can distinguish between the case where the
    878   instance does not exist (HTTP 404) and the case where access is denied
    879   (HTTP 403).
    880   This is concern can be addressed using a properly configured
    881   :ref:`reverse proxy <reverse-proxy-configuration>`.
    882 
    883 
    884 Instance setup with the SPA
    885 ---------------------------
    886 
    887 In order to setup an instance, you need the merchant backend to already be
    888 running, and you must either have the credentials for the ``admin`` instance,
    889 or no instance must be configured at all yet.
    890 
    891 To start, point your browser to ``$PROTO://backend.$DOMAIN_NAME/``, replacing
    892 "$PROTO" with "https" or (rarely) "http" and "$DOMAIN_NAME" with your
    893 organizations DNS domain or subdomain.
    894 
    895 .. note::
    896 
    897    The label "backend" here is also just a suggestion, your administrator
    898    can in principle choose any name.
    899 
    900 You should be welcomed by the following merchant backoffice page:
    901 
    902 .. image:: screenshots/merchant_first_login.png
    903 
    904 After supplying the required fields, primarily the name of your organization
    905 and the desired access token, click ``confirm``.  You can change the instance
    906 settings later via the ``Settings`` entry in the menu on the left.
    907 
    908 
    909 Instance settings
    910 -----------------
    911 
    912 The settings dialog allows you to select an image to be used as a logo
    913 for your shop. Wallets may use that logo when showing contracts to
    914 highlight to customers which shop they are buying from.
    915 
    916 The settings dialog allows you to specify the address of your business
    917 and the jurisdiction the shop is under. Both will be embedded into the
    918 contracts and may be shown by the Taler wallet to customers that want
    919 to know these details.
    920 
    921 You must also configure whether you intend to pay transaction fees,
    922 or whether the customer is required to pay for any payment fees. If
    923 you do not cover the fees, the fees will be shown separately to the
    924 customer and added to the total of each order, which may discourage
    925 consumers from using the Taler payment method.  The specific
    926 magnitude of the fees cannot be configured here, as it depends on
    927 the amount of the order and is dynamically computed. Regardless of
    928 what you specify here, the front-end can override the acceptable
    929 fee amount for each order it creates.
    930 
    931 .. note::
    932 
    933   Details on the acceptable fee calcuation
    934   are described in the Taler design document 47.
    935 
    936 Finally, you need to specify several settings relating to default
    937 deadlines.
    938 
    939   (1) The "Default payment delay" specifies when an offer expires.  The
    940   customer basically has this amount of time to pay, or the backend will
    941   refuse the payment and require the customer to get a new quote.
    942 
    943   (2) The "Default refund delay" specifies how long the customer may receive
    944   refunds. The refund period is cummulative on top of the "Default payment
    945   delay". Thus, the refund period ends independently of when the customer
    946   actually paid for the order. The exchange will **not** wire the funds to the
    947   merchant before the refund deadline lapses, as after the funds have been
    948   wired refunds using Taler are no longer possible.
    949 
    950   (3) The "Default wire transfer delay" specifies how soon the exchange
    951   **must** wire the funds **after** the refund deadline.  The delay is again
    952   cummulative on top of the "Default payment delay" and the "Default refund
    953   delay".  However, the resulting time is still not the actual wire
    954   deadline, as first the "Default wire rounding interval" is also considered.
    955 
    956   (4) The "Default wire rounding interval" specifies to what period the
    957   wire deadline should be rounded up to. The ultimate wire deadline is
    958   computed by adding the default payment, rounding and wire delays to
    959   the current time and rounding the resulting timestamp to the
    960   "Default wire rounding interval". Typical values include
    961   end-of-day, end-of-week, end-of-month, end-of-quarter or end-of-year.
    962 
    963 .. note::
    964 
    965   The wire deadline is rounded using the local timezone of the Taler merchant
    966   backend server, so if you want end-of-day payments make sure to run your
    967   merchant backend in your own timezone.
    968 
    969 Specifying larger values for the wire transfer delay and the wire rounding
    970 interval allows the exchange to aggregate more payments into larger wire
    971 transfers. The exchange is required by the protocol to initiate the wire
    972 transfer **before** the wire transfer deadline.
    973 
    974 All of the computed deadlines (payment, refund and wire transfer)
    975 are just defaults and can be modified by frontends for any
    976 specific order.
    977 
    978 
    979 Instance setup without the Web interface
    980 ----------------------------------------
    981 
    982 Instances can be created by POSTing a request to ``/management/instances``
    983 without using the Web interface.  This could be useful if you want to create
    984 many instances programmatically.  To create an instance without the Web
    985 interface create a file ``instance.json`` with an
    986 `InstanceConfigurationMessage`:
    987 
    988 .. code-block:: json
    989 
    990    {
    991      "id" : "admin",
    992      "name": "Example Inc.",
    993      "address": { "country" : "zz" },
    994      "auth": { "method" : "external"} ,
    995      "jurisdiction": { "country" : "zz" },
    996      "use_stefan": true,
    997      "default_pay_delay": { "d_ms" : 1209600000 }
    998      "default_refund_delay": { "d_ms" : 1209600000 }
    999      "default_wire_transfer_delay": { "d_ms" : 1209600000 },
   1000    }
   1001 
   1002 The ``name`` field will be shown as the name of your shop. The ``address``
   1003 field is expected to contain your shop's physical address. The various
   1004 ``default_*`` values specify defaults for transaction fees your shop is
   1005 willing to cover, how long offers made to the customer are valid, and how long
   1006 the exchange has before it must wire the funds to your bank account. Those
   1007 defaults can be modified for individual orders.  For details, see the
   1008 :ref:`contract terms <contract-terms>` specification.
   1009 
   1010 You can then create the instance using:
   1011 
   1012 .. code-block:: console
   1013 
   1014    $ wget --post-file=instance.json http://localhost:9966/management/instances
   1015 
   1016 The base URL for the instance will then be ``http://localhost:9966/``.  You
   1017 can create additional instances, which will then be reachable under
   1018 ``http://localhost:9966/instances/$ID`` where ``$ID`` needs to be changed to
   1019 the identifier value of the respective instance.
   1020 
   1021 Endpoints to modify (reconfigure), permanently disable (while keeping the data)
   1022 or purge (deleting all associated data) instances exist as well and are documented
   1023 in the :ref:`Merchant Backend API documentation <merchant-api>`.
   1024 
   1025 .. _instance-account-setup:
   1026 
   1027 Instance bank account setup
   1028 ===========================
   1029 
   1030 Before you can use an instance productively, you need to configure one or more
   1031 bank accounts. These bank accounts will be provided to the Taler exchange
   1032 operator to tell it where to wire the income from your sales. Every bank
   1033 account has an associated *wire method* which determines how an exchange can
   1034 transfer the funds.  The most commonly supported wire method is *iban*, which
   1035 implies that bank accounts are identified by IBAN numbers and wire transfers
   1036 are to be executed between IBAN accounts.  For regional currency setups, the
   1037 wire method could also be *x-taler-bank*.
   1038 
   1039 .. note::
   1040 
   1041    When using a regional currency, you need to first create a bank account at
   1042    the regional bank. You may need to contact the respective administrator who
   1043    can set one up.  After being able to login to the new bank account, you can
   1044    see your bank account number by clicking on the ``Welcome, $USERNAME``
   1045    message in the profile page.  Next to the bank account number, you can find
   1046    a convenient button to copy the number to the clipboard.
   1047 
   1048 Not every exchange will support every *wire method*, and if you do not add a
   1049 bank account with a wire method that is supported by a particular exchange,
   1050 then you will not be able to receive payments via that exchange even if you
   1051 configured the merchant backend to trust that exchange.
   1052 
   1053 The simplest way to configure an account is to use the Web interface which has
   1054 specific forms for different wire methods.  First, select ``Bank account`` at
   1055 the left of the page.  The following page should be shown:
   1056 
   1057 .. image:: screenshots/no_default_account_yet.png
   1058 
   1059 Click on the blue "+" sign on the top right of the page to add a new
   1060 bank account. The following page should appear:
   1061 
   1062 .. image:: screenshots/enter_instance_details.png
   1063 
   1064 First, you should select the wire method, after which the dialog will show you
   1065 additional fields specific to the wire method. For example, if youchoose
   1066 ``iban`` as the account type, the following page should appear:
   1067 
   1068 .. image:: screenshots/instance_iban_config.png
   1069 
   1070 Specifying the revenue gateway with username and password is optional and
   1071 discussed in section :ref:`automatic-settlement-data-import` below.
   1072 
   1073 After providing the details and confirming, the shop is ready to generate orders
   1074 and accept payments.
   1075 
   1076 
   1077 
   1078 Detecting Settlement: Manually Adding Transfers
   1079 -----------------------------------------------
   1080 
   1081 The exchange may aggregate many small amounts into one larger wire transfer.
   1082 If you want to safely determine for which orders have been settled (final
   1083 payment from the exchange has been received), the backend must learn about the
   1084 wire transfers made into your bank account. Basically, as a secure system, we
   1085 do not simply trust a claim by the exchange that it would transfer the money,
   1086 but we allow each merchant to check settlements.
   1087 
   1088 An easy (but somewhat tedious) way to check settlements is to manually add
   1089 every wire transfer that a merchant bank account has received from the
   1090 exchange with the total amount and the wire transfer subject. Given this
   1091 information, the merchant backend will inquire with the exchange which
   1092 individual payments were aggregated, check that the total amount is correct,
   1093 and will then flag the respective contracts as wired.
   1094 
   1095 You can manually enter wire transfers under ``Transfers``. However, this is
   1096 tedious, and so if your banking setup supports it, we highly recommend
   1097 using the automatic settlement data import.
   1098 
   1099 .. _automatic-settlement-data-import:
   1100 
   1101 Automatic Settlement Data Import
   1102 --------------------------------
   1103 
   1104 To automatically import settlement data, you need to provide the merchant
   1105 backend with the address and access credentials of a
   1106 :ref:`taler-bank-merchant-http-api` for each bank account of an instance.  The
   1107 revenue API endpoint will allow the merchant backend to obtain a list of all
   1108 incoming wire transfers into your bank account and automatically import them
   1109 into the list of confirmed wire transfers.
   1110 
   1111 Note that setting up a revenue API endpoint will usually require you to first
   1112 ask your bank for EBICS access and to set up :ref:`libeufin-nexus` to provide
   1113 the revenue API endpoint. The :ref:`libeufin-bank` used by regional currency
   1114 setups also provides a revenue API endpoint at
   1115 ``$BANK_URL/accounts/$ACCOUNT_NAME/taler-revenue/``.  Thus, when using a
   1116 regional currency setup, simply use the ``$BANK_URL`` of your bank and specify
   1117 your bank login name and password in the :ref:`instance-account-setup` dialog.
   1118 
   1119 
   1120 Manually creating an order using the SPA
   1121 ========================================
   1122 
   1123 Arbitrary orders can also be created manually using the Web interface of
   1124 the GNU Taler merchant backend. For this, log into the single page app (SPA)
   1125 of the merchant backend using the authorization token of the respective
   1126 instance you want to use.
   1127 
   1128 Click on ``Orders`` at the top left corner of the merchant backoffice page; the
   1129 following page should appear
   1130 
   1131 .. image:: screenshots/create_orders.png
   1132 
   1133 You can then set up orders by providing all of the required fields of an
   1134 order, in particular an order summary and a price. You can also set various
   1135 optional fields or override instance default settings.
   1136 
   1137 After this the interface should show the following page with the related links
   1138 to check the status of the order and let wallet pay for it.
   1139 
   1140 .. image:: screenshots/payment_links.png
   1141 
   1142 The order status page also shows you the progress of the order, including when
   1143 a wallet has made the payment. You can also use the backend to approve refunds.
   1144 
   1145 In order to test the setup, it should be now possible to use the command line wallet
   1146 to withdraw Taler coins and spend them to pay for the order we just created.
   1147 
   1148 In practice, you will rarely if ever setup orders manually like this. Instead,
   1149 a `GNU Taler e-commerce front-end
   1150 <https://taler.net/en/docs.html#extensions>`_ or the
   1151 :ref:`taler-merchant-pos-app` will do this on-demand. Here, you will only need
   1152 to provide the respective front-ends with the URL of your instance
   1153 (e.g. ``https://backend.$DOMAIN/instances/$NAME``) and your access token.
   1154 
   1155 
   1156 Paying an order
   1157 ===============
   1158 
   1159 The payer simply scans the (dynamic) QR code to initiate the payment.  If a
   1160 website is interacting with a WebExtension wallet, it may also directly
   1161 trigger the GNU Taler wallet without requiring the user to explicitly scan the
   1162 QR code.  The payer should now review the contract terms and applicable fees.
   1163 Selecting "pay" will complete the transaction.  Typically, the wallet will
   1164 then redirect the user to the fulfillment page where they can track the order
   1165 or directly view the digital product that they purchased.
   1166 
   1167 
   1168 Setting up a template
   1169 =====================
   1170 
   1171 A template provides all or part of the information needed to setup an order
   1172 and allows GNU Taler wallets to create an order.  Usually, the creation of
   1173 orders is a privileged process that requires knowledge of the authorization
   1174 code for the respective instance. With templates, a customer's wallet can
   1175 directly create an order on-demand.  The information of a template can be
   1176 partial, in which case the customer is expected to provide the remaining
   1177 details, typically the summary and/or amount of the order.
   1178 
   1179 When setting up a template you need to specify all of the fixed inputs that
   1180 the customer cannot change.  You can then generate a template QR code where
   1181 you may additionally specify editable defaults for the order, such as a
   1182 default summary or a default amount which may still be changed by the wallet.
   1183 The resulting template QR code encodes the specific merchant backend, instance
   1184 and template ID as well as the (editable) default values.  The resulting
   1185 static QR code can then be printed and put on display.
   1186 
   1187 Customers can scan the QR code with their GNU Taler wallet, complete the
   1188 missing details or edit the defaults (if any), and pay the resulting order.
   1189 
   1190 To secure template-based payments, you may specify a TOTP secret as part of
   1191 the template. In this case, the merchant backend will send a set of TOTP
   1192 payment confirmation codes to the GNU Taler wallet upon receiving a payment
   1193 for an order created based on the template.  If the point-of-sale has a TOTP
   1194 generator with the same secret, they can compare their TOTP code with the
   1195 codes shown by the customer on their wallet. This provides additional
   1196 assurance that the customer actually made the payment instead of just showing
   1197 a fake confirmation screen.
   1198 
   1199 
   1200 Paying with static QR codes
   1201 ===========================
   1202 
   1203 The payer simply scans the (static) QR code to initiate the payment.  If the
   1204 template does not specify a fixed amount, the payer will be prompted to enter
   1205 the amount to be paid (and possibly given the opportunity to specify or alter
   1206 the summary).  Selecting "pay" will complete the transaction.  If payment
   1207 confirmations are configured by the merchant backend, the wallet will then
   1208 display a TOTP confirmation code that can be shown to the merchant as a proof
   1209 of payment.
   1210 
   1211 
   1212 
   1213 Setting up a webhook
   1214 ====================
   1215 
   1216 To receive notifications when a purchase has been made or a refund was given
   1217 to a wallet, you can set up webhooks in the GNU Taler merchant backend.
   1218 Webhooks allow you to trigger HTTP(S) requests based on certain events.  A
   1219 webhook is thus simply an HTTP request that the GNU Taler merchant backend
   1220 will make when a certain event (such as a payment) happens.
   1221 
   1222 There are various providers that can send an SMS to a phone number based on an
   1223 HTTP request.  Thus, by configuring such a provider in a webhook you can
   1224 receive an SMS notification whenever a customer makes a payment.
   1225 
   1226 Webhooks are configured per instance.  In the Webhook configuration,
   1227 you can specify which URL, which HTTP headers, which HTTP method and what HTTP
   1228 body to send to the Webhook.  Webhooks are automatically retried (with
   1229 increasing delays) when the target server returns a temporary error.
   1230 
   1231 `Mustach templates <https://mustache.github.io/mustache.5.html>`__ and limited
   1232 version of it are used when defining the contents of Webhooks.
   1233 Depending on the triggering event, the templates will be expanded with event-specific
   1234 data. Limited in this case means that only a specific string is being replaced
   1235 with the event-specific data, no support for parsing conditions or nested structures
   1236 is provided.
   1237 
   1238 
   1239 Order created events
   1240 --------------------
   1241 
   1242 For "order_created" events, the backend will provide the following
   1243 information to the Mustache templating engine:
   1244 
   1245 * webhook_type: "order_created".
   1246 * order_id: the identifier of the newly created order.
   1247 * contract: the full JSON contract for the order (see :ref:`contract_terms <contract-terms>` for the structure).
   1248 * instance_id: the merchant instance identifier that created the order.
   1249 
   1250 
   1251 Order pay events
   1252 ----------------
   1253 
   1254 For "pay" events, the backend will provide the following
   1255 information to the Mustache templating engine:
   1256 
   1257 * webhook_type: "pay".
   1258 * :ref:`contract_terms <contract-terms>`: the contract terms of the paid order.
   1259 * order_id: the ID of the order that received the refund.
   1260 
   1261 
   1262 Order refund events
   1263 -------------------
   1264 
   1265 For "refund" events which are triggered when a refund is
   1266 approved, the backend will provide the following information to the
   1267 Mustache templating engine:
   1268 
   1269 * webhook_type: "refund".
   1270 * timestamp: time of the refund (using a `Timestamp` with the time in seconds since the UNIX epoch).
   1271 * order_id: the ID of the order that received the refund.
   1272 * :ref:`contract_terms <contract-terms>`: the full JSON of the contract terms of the refunded order.
   1273 * refund_amount: the amount that was being refunded.
   1274 * reason: the reason entered by the merchant staff for granting the refund;
   1275   be careful, you probably want to inform your staff if a webhook may expose
   1276   this information to the consumer.
   1277 
   1278 
   1279 Order settled events
   1280 --------------------
   1281 
   1282 For "order_settled" events which are triggered when the
   1283 **taler-merchant-reconciliation** service is able to map
   1284 an incoming wire transfer from the exchange to a paid
   1285 order, the backend will provide the following information to the limited
   1286 Mustache templating engine:
   1287 
   1288 * webhook_type: "order_settled".
   1289 * order_id: The unique identifier of the order that has been fully settled (all payments completed and wired to the merchant).
   1290 * wtid: The wire transfer ID of the settlement.
   1291 
   1292 Category added events
   1293 ---------------------
   1294 
   1295 For "category_added" events, the backend will provide the following information to the limited
   1296 Mustache templating engine:
   1297 
   1298 * webhook_type: "category_added".
   1299 * category_serial: The unique identifier of the newly added category.
   1300 * category_name: The name of the newly added category.
   1301 * merchant_serial: The unique identifier of the merchant associated with the category.
   1302 
   1303 
   1304 Category updated events
   1305 -----------------------
   1306 
   1307 For "category_updated" events, the backend will provide the following information to the limited
   1308 Mustache templating engine:
   1309 
   1310 * webhook_type: "category_updated".
   1311 * category_serial: The unique identifier of the updated category.
   1312 * old_category_name: The name of the category before the update.
   1313 * category_name: The name of the category after the update.
   1314 * category_name_i18n: The internationalized name of the category after the update.
   1315 * old_category_name_i18n: The internationalized name of the category before the update.
   1316 
   1317 
   1318 Category deleted events
   1319 -----------------------
   1320 
   1321 For "category_deleted" events, the backend will provide the following information to the limited
   1322 Mustache templating engine:
   1323 
   1324 * webhook_type: "category_deleted".
   1325 * category_serial: The unique identifier of the deleted category.
   1326 * category_name: The name of the deleted category.
   1327 
   1328 
   1329 Inventory added events
   1330 ----------------------
   1331 
   1332 For "inventory_added" events, the backend will provide the following information to the limited
   1333 Mustache templating engine:
   1334 
   1335 * webhook_type: "inventory_added".
   1336 * product_serial: The unique identifier of the newly added product.
   1337 * product_id: The ID of the newly added product.
   1338 * description: The description of the newly added product.
   1339 * description_i18n: The internationalized description of the newly added product.
   1340 * unit: The unit of the newly added product.
   1341 * image: The image of the newly added product.
   1342 * taxes: The taxes of the newly added product.
   1343 * price: The price of the newly added product.
   1344 * total_stock: The total stock of the newly added product.
   1345 * total_sold: The total sold of the newly added product.
   1346 * total_lost: The total lost of the newly added product.
   1347 * address: The address of the newly added product.
   1348 * next_restock: The next restock of the newly added product.
   1349 * minimum_age: The minimum age for buying the newly added product.
   1350 
   1351 Inventory updated events
   1352 ------------------------
   1353 
   1354 For "inventory_updated" events, the backend will provide the following information to the limited
   1355 Mustache templating engine:
   1356 
   1357 * webhook_type: "inventory_updated".
   1358 * product_serial: The unique identifier of the updated product.
   1359 * product_id: The ID of the product.
   1360 * old_description: The description of the product before the update.
   1361 * description: The description of the product after the update.
   1362 * old_description_i18n: The internationalized description of the product before the update.
   1363 * description_i18n: The internationalized description of the product after the update.
   1364 * old_unit: The unit of the product before the update.
   1365 * unit: The unit of the product after the update.
   1366 * old_image: The image of the product before the update.
   1367 * image: The image of the product after the update.
   1368 * old_taxes: The taxes of the product before the update.
   1369 * taxes: The taxes of the product after the update.
   1370 * old_price: The price of the product before the update.
   1371 * price: The price of the product after the update.
   1372 * old_total_stock: The total stock of the product before the update.
   1373 * total_stock: The total stock of the product after the update.
   1374 * old_total_sold: The total sold of the product before the update.
   1375 * total_sold: The total sold of the product after the update.
   1376 * old_total_lost: The total lost of the product before the update.
   1377 * total_lost: The total lost of the product after the update.
   1378 * old_address: The address of the product before the update.
   1379 * address: The address of the product after the update.
   1380 * old_next_restock: The next restock of the product before the update.
   1381 * next_restock: The next restock of the product after the update.
   1382 * old_minimum_age: The minimum age for buying the product before the update.
   1383 * minimum_age: The minimum age for buying the product after the update.
   1384 
   1385 
   1386 Inventory deleted events
   1387 ------------------------
   1388 
   1389 For "inventory_deleted" events, the backend will provide the following information to the limited
   1390 Mustache templating engine:
   1391 
   1392 * webhook_type: "inventory_deleted".
   1393 * product_serial: The unique identifier of the deleted product.
   1394 * product_id: The ID of the deleted product.
   1395 * description: The description of the deleted product.
   1396 * description_i18n: The internationalized description of the deleted product.
   1397 * unit: The unit of the deleted product.
   1398 * image: The image of the deleted product.
   1399 * taxes: The taxes of the deleted product.
   1400 * price: The price of the deleted product.
   1401 * total_stock: The total stock of the deleted product.
   1402 * total_sold: The total sold of the deleted product.
   1403 * total_lost: The total lost of the deleted product.
   1404 * address: The address of the deleted product.
   1405 * next_restock: The next restock of the deleted product.
   1406 * minimum_age: The minimum age for buying the deleted product.
   1407 
   1408 
   1409 .. _Secure-setup:
   1410 
   1411 Secure setup
   1412 ============
   1413 
   1414 .. index:: security
   1415 .. index:: TLS
   1416 
   1417 The Taler backend is deliberately simple in terms of support for access
   1418 control or transport layer security (TLS).  Thus, production setups **must**
   1419 deploy the Taler backend behind an HTTP(S) server that acts as a *reverse
   1420 proxy*, performs TLS termination and authentication and then forwards requests
   1421 to the backend.
   1422 
   1423 
   1424 Using UNIX domain sockets
   1425 -------------------------
   1426 
   1427 To ensure that the merchant backend is not exposed directly to the network,
   1428 you *should* bind the backend to a UNIX domain socket:
   1429 
   1430 .. code-block:: ini
   1431 
   1432    [MERCHANT]
   1433    SERVE = unix
   1434    UNIXPATH = "/some/path/here.sock"
   1435 
   1436 Do not use a UNIX domain socket path in "/tmp": systemd (or other init
   1437 systems) may give Web servers a private "/tmp" thereby hiding UNIX domain
   1438 sockets created by other users/processes in "/tmp".
   1439 
   1440 If UNIX domain sockets are for some reason not possible, you *may* use a
   1441 host-based firewall to block access to the TCP port of the merchant backend,
   1442 but this is *not recommended*.  If you do need a TCP socket, you should
   1443 instead strongly consider using the "BIND_TO" option to at least bind it only
   1444 to "localhost".
   1445 
   1446 .. _reverse-proxy-configuration:
   1447 
   1448 Reverse proxy configuration
   1449 ---------------------------
   1450 
   1451 Nginx
   1452 ^^^^^
   1453 
   1454 For Nginx, a possible basic reverse proxy configuration would be:
   1455 
   1456 .. code-block:: nginx
   1457 
   1458       proxy_pass http://unix:/some/path/here.sock;
   1459       proxy_redirect off;
   1460       proxy_set_header Host $host;
   1461       proxy_set_header X-Forwarded-Host "example.com";
   1462       proxy_set_header X-Forwarded-Proto "https";
   1463 
   1464 Note that the above assumes your domain name is ``example.com`` and that you
   1465 have TLS configured.  Leave out the last line if your Nginx reverse proxy does
   1466 not have HTTPS enabled.  Make sure to restart the ``taler-merchant-httpd``
   1467 process after changing the ``SERVE`` configuration.
   1468 
   1469 Apache
   1470 ^^^^^^
   1471 
   1472 In Apache, make sure you have ``mod_proxy``, ``mod_proxy_http`` and
   1473 ``mod_headers`` enabled:
   1474 
   1475 .. code-block:: console
   1476 
   1477    $ a2enmod proxy
   1478    $ a2enmod proxy_http
   1479    $ a2enmod headers
   1480 
   1481 Then configure your Apache reverse proxy like this (you may change the
   1482 endpoint):
   1483 
   1484 .. code-block:: apacheconf
   1485 
   1486        <Location "/">
   1487        ProxyPass "unix:/some/path/here.sock|http://example.com/"
   1488        RequestHeader add "X-Forwarded-Proto" "https"
   1489        </Location>
   1490 
   1491 Note that the above again assumes your domain name is ``example.com`` and that
   1492 you have TLS configured.  Note that you must add the ``https`` header unless
   1493 your site is not available via TLS.
   1494 
   1495 .. _auto-reverse-proxy-configuration:
   1496 
   1497 Automated Reverse Proxy Configuration
   1498 -------------------------------------
   1499 
   1500 GNU Taler provides a helper script, ``taler-merchant-rproxy-setup``, that
   1501 automates the most common reverse-proxy configuration tasks for both Nginx
   1502 and Apache:
   1503 
   1504 -   Detects (or lets you choose) Nginx vs. Apache
   1505 -   Verifies and enables required modules and packages
   1506 -   Obtains (or skips) TLS certificates via Certbot (unless ``--httponly``)
   1507 -   Backs up and populates the stock configuration with your domain
   1508 -   Optionally forces HTTP → HTTPS redirection (``--httpsonly``)
   1509 -   Enables the site and reloads the web server
   1510 
   1511 Usage
   1512 ^^^^^
   1513 
   1514 .. code-block:: console
   1515 
   1516    taler-merchant-rproxy-setup \
   1517      --domain <example.com> [--nginx | --apache] [--httponly | --httpsonly]
   1518 
   1519 Options
   1520 ^^^^^^^
   1521 
   1522 ``--domain <name>``
   1523     (Required) The public domain name to configure.
   1524 
   1525 ``--nginx``
   1526     Force use of Nginx (overriding auto-detection).
   1527 
   1528 ``--apache``
   1529     Force use of Apache2 (overriding auto-detection).
   1530 
   1531 ``--httponly``
   1532     Only configure HTTP (no TLS). Skips Certbot entirely.
   1533 
   1534 ``--httpsonly``
   1535     Enable HTTPS and add an HTTP→HTTPS redirect.
   1536 
   1537 ``-h, --help``
   1538     Show this help message and exit.
   1539 
   1540 .. note::
   1541 
   1542    This script must be run as root (for example via ``sudo``) and requires
   1543    that either Nginx or Apache2 (and Certbot for non-HTTP-only modes) be
   1544    installed on the system.
   1545 
   1546 
   1547 Access control
   1548 --------------
   1549 
   1550 All endpoints with ``/private/`` in the URL must be restricted to authorized
   1551 users of the respective instance.  Specifically, the HTTP server must be
   1552 configured to only allow access to ``$BASE_URL/private/`` to the authorized
   1553 users of the ``admin`` instance, and to ``$BASE_URL/instances/$ID/private/`` to
   1554 the authorized users of the instance ``$ID``.
   1555 
   1556 By default, the GNU Taler merchant backend simply requires the respective
   1557 HTTP requests to include an "Authorization" header with a "Bearer" token
   1558 set to the respective shared secret which must begin with "secret-token:"
   1559 (following RFC 8959).
   1560 
   1561 Note that all of the other endpoints (without ``/private/``)
   1562 are expected to be fully exposed to the Internet, and wallets may have to
   1563 interact with those endpoints directly without client authentication.
   1564 
   1565 
   1566 Status code remapping
   1567 ---------------------
   1568 
   1569 Normal API usage leaks instance existence information.  Distinguishing between
   1570 404 (Not found) and 403 (Forbidden) is useful for diagnostics.
   1571 
   1572 For higher security (by leaking less information), you can add the following
   1573 fragment, which remaps all 404 response codes to 403.
   1574 
   1575 Nginx
   1576 ^^^^^
   1577 
   1578 .. code-block:: nginx
   1579 
   1580       error_page 404 =403 /empty.gif;
   1581 
   1582 Apache
   1583 ^^^^^^
   1584 
   1585 .. code-block:: apacheconf
   1586 
   1587        cond %{STATUS} =404
   1588        set-status 403
   1589 
   1590 
   1591 Customization
   1592 =============
   1593 
   1594 Legal conditions for using the service
   1595 --------------------------------------
   1596 
   1597 .. include:: frags/legal.rst
   1598 
   1599 .. _MerchantTemplateCustomization:
   1600 
   1601 Template Customization
   1602 ----------------------
   1603 
   1604 The installation process will install various HTML templates to be served to
   1605 trigger the wallet interaction. You may change those templates to your own
   1606 design. The templating language used is `C implementation of mustache
   1607 <https://gitlab.com/jobol/mustach>`__, and the templates are in the
   1608 ``share/taler-merchant/templates/`` directory.
   1609 
   1610 The file names must be of the form ``$NAME.$LANG.must`` where ``$NAME`` is the
   1611 name of the template and ``$LANG`` is the 2-letter language code of the
   1612 template. English templates must exist and will be used as a fallback.  If the
   1613 browser (user-agent) has provided language preferences in the HTTP header and
   1614 the respective language exists, the correct language will be automatically
   1615 served.
   1616 
   1617 The following subsections give details about each of the templates. The
   1618 subsection titles are the ``$NAME`` of the respective template.
   1619 
   1620 request_payment
   1621 ^^^^^^^^^^^^^^^
   1622 
   1623 Page shown to request the user to make a payment.
   1624 
   1625 This template is instantiated using the following information:
   1626 
   1627   * taler_pay_uri: String; the ``taler://pay/`` URI that must be given
   1628     to the wallet to initiate the payment
   1629 
   1630   * taler_pay_qrcode_svg: Image; an SVG image of the QR code with the
   1631     ``taler_pay_uri``.
   1632 
   1633   * order_summary: String; a text summarizing the order
   1634 
   1635   * order_status_url: URL of the merchant backend where the order status
   1636     can be found, useful for long-polling to check if the order has been paid
   1637 
   1638 
   1639 offer_refund
   1640 ^^^^^^^^^^^^
   1641 
   1642 Page shown to offer a customer a refund.
   1643 
   1644 This template is instantiated using the following information:
   1645 
   1646   * taler_refund_uri: String; the ``taler://pay/`` URI that must be given
   1647     to the wallet to initiate the payment
   1648 
   1649   * taler_refund_qrcode_svg: Image; an SVG image of the QR code with the
   1650     ``taler_pay_uri``.
   1651 
   1652   * refund_amount: Amount; how much did the merchant refund
   1653 
   1654   * refund_taken: Amount; how much did the customer already take back in refunds
   1655 
   1656   * order_summary: String; a text summarizing the order
   1657 
   1658 
   1659 
   1660 show_order_details
   1661 ^^^^^^^^^^^^^^^^^^
   1662 
   1663 Page shown to the user when they go back to the payment page but
   1664 no payment is required and no refund is present.
   1665 
   1666 This template is instantiated using the following information:
   1667 
   1668   * order_summary: String; a text summarizing the order
   1669 
   1670   * contract_terms: Object; the full contract terms (shoud probably
   1671     not be shown in full!)
   1672 
   1673   * refund_amount: Amount; how much did the merchant refund
   1674 
   1675   * refund_taken: Amount; how much did the customer already take back in refunds
   1676 
   1677 Static files
   1678 ------------
   1679 
   1680 The merchant backend also has the ability to serve small static files
   1681 under the ``/static/{FILENAME}`` endpoint.  This is used by the templating
   1682 logic to load a CSS file, but you can also put other resources such as
   1683 images or JavaScript.
   1684 
   1685 Internationalization
   1686 --------------------
   1687 
   1688 Both templates and static files can be internationalized.  This is done
   1689 by having the language of the resource be a part of the filename.
   1690 For templates the format is ``{BASENAME}.{LANGUAGE}.must``.  The
   1691 language is mandatory for templates, the default language is English (en).
   1692 
   1693 For static files, the format is ``{BASENAME}.{LANGUAGE}.{EXT}`` for
   1694 internationalized files, and ``{BASENAME}.{EXT}`` for resources that do not
   1695 support internationalization.  The HTTP client will always request
   1696 ``/static/{BASENAME}.{EXT}``. If ``{BASENAME}.{EXT}`` exists, that resource is
   1697 returned. Otherwise, an internationalized file based on the language
   1698 preferences indicated by the browser is returned.
   1699 
   1700 Limitations
   1701 -----------
   1702 
   1703 All of the static files must fit into memory and it must be possible for the
   1704 process to hold open file handles for all of these files.  You may want
   1705 to increase the ``ulimit`` of the ``taler-merchant-httpd`` process if you have
   1706 many static files. Note that Mustach templates do not increase the number of
   1707 open files.
   1708 
   1709 The backend determines the MIME type based on the file's extension. The list
   1710 of supported extensions is hard-coded and includes common text and image
   1711 formats.
   1712 
   1713 The current backend only provides a limited set of variables for the Mustach
   1714 template expansion, and does not make use of scopes and other Mustach
   1715 features.
   1716 
   1717 
   1718 
   1719 Upgrade procedure
   1720 =================
   1721 
   1722 This section describes the general upgrade procedure.  Please see the release
   1723 notes for your specific version to check if a particular release has special
   1724 upgrade requirements.
   1725 
   1726 Please note that upgrades are ONLY supported for released version of the
   1727 merchant. Attempting to upgrade from or to a version in Git is not supported
   1728 and may result in subtle data loss.
   1729 
   1730 To safely upgrade the merchant, you should first stop the existing
   1731 ``taler-merchant-httpd`` process, backup your merchant database (see
   1732 PostgreSQL manual), and then install the latest version of the code.
   1733 
   1734 If you REVOKED database permissions, ensure that the rights to CREATE,
   1735 DROP, and ALTER tables are GRANTed to ``$USER`` again.  Then, run:
   1736 
   1737 .. code-block:: console
   1738 
   1739    $ taler-merchant-dbinit
   1740 
   1741 to upgrade the database to the latest schema.  After that, you may again
   1742 REVOKE the database permissions. Finally, restart the merchant services
   1743 processes, either via your systemd or init system, or directly.
   1744 
   1745 
   1746 
   1747 
   1748 Advanced topics
   1749 ===============
   1750 
   1751 taler-merchant-config
   1752 ---------------------
   1753 
   1754 .. index:: taler-merchant-config
   1755 
   1756 .. include:: frags/using-taler-config.rst
   1757 
   1758 .. _MerchantDatabaseScheme:
   1759 
   1760 Database Scheme
   1761 ---------------
   1762 
   1763 The merchant database must be initialized using ``taler-merchant-dbinit``.
   1764 This tool creates the tables required by the Taler merchant to operate.
   1765 The tool also allows you to reset the Taler merchant database, which is
   1766 useful for test cases but should never be used in production. Finally,
   1767 ``taler-merchant-dbinit`` has a function to garbage collect a database,
   1768 allowing administrators to purge records that are no longer required.
   1769 
   1770 The database scheme used by the merchant looks as follows:
   1771 
   1772 .. image:: images/merchant-db.png
   1773 
   1774 .. _MerchantBenchmarking:
   1775 
   1776 Benchmarking
   1777 ------------
   1778 
   1779 The merchant codebase offers the ``taler-merchant-benchmark`` tool to populate
   1780 the database with fake payments.  The main goal of the benchmarking tool is to
   1781 serve as a starting point (!) for merchants that are interested in developing
   1782 stress tests to see how far their infrastructure can scale. As is, it
   1783 currently is not actually good at stressing the payment system.
   1784 
   1785 The ``taler-unified-setup.sh`` script can be used to launch all required
   1786 services and clients. However, the resulting deployment is simplistic
   1787 (everything on the local machine, one single-threaded process per service
   1788 type) and not optimized for performance at all. However, this can still be
   1789 useful to assess the performance impact of changes
   1790 to the code or configuration.
   1791 
   1792 
   1793 Various configuration files that can be used in the code snippets in this
   1794 section can be found in the ``src/merchant-tools/`` directory of the
   1795 merchant. These are generally intended as starting points.  Note that the
   1796 configuration files ending in ``.edited`` are created by
   1797 ``taler-unified-setup.sh`` and contain some options that are determined at
   1798 runtime by the setup logic provided by ``taler-unified-setup.sh``.
   1799 
   1800 See :ref:`Taler Exchange Manual <Benchmark-choose-bank>` for how to use ``taler-unified-setup.sh`` to setup the system and in particular on how to specify the bank to be used.
   1801 
   1802 
   1803 Running taler-merchant-benchmark
   1804 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   1805 
   1806 You can run the tool as follows:
   1807 
   1808 .. code-block:: console
   1809 
   1810     $ CONF=benchmark-rsa.conf
   1811     $ taler-unified-setup.sh -emwt -c "$CONF" -f -u exchange-account-1
   1812     $ time taler-merchant-benchmark ordinary -c "$CONF".edited -u exchange-account-1 -f -p 20
   1813 
   1814 The current tool has already a few options, but we expect that to deliver
   1815 *relevant* results it will need to be customized to better reflect the
   1816 workload of a particular merchant.  This customization would at this point
   1817 likely involve writing (C) code.  We welcome contributions to make it easier
   1818 to customize the benchmark and/or to cover more realistic workloads from the
   1819 start.
   1820 
   1821 The tool takes all of the values it needs from the command line, with
   1822 some of them being common to all subcommands:
   1823 
   1824 -  ``--exchange-account-section=SECTION`` Specifies which configuration
   1825    section specifies the bank account for the exchange that
   1826    should be used for the benchmark. For the example
   1827    configuration above, the SECTION value provided must be
   1828    ``exchange-account-exchange``.
   1829 -  ``--fakebank`` Specifies that the benchmark should expect to interact
   1830    with a fakebank (instead of libeufin).
   1831 
   1832 The tool comes with two operation modes: *ordinary*, and *corner*.
   1833 The first just executes normal payments, meaning that it uses the
   1834 ``admin`` instance and make sure that all payments get aggregated. The
   1835 second gives the chance to leave some payments unaggregated, and also to
   1836 use merchant instances other than ``admin`` (which is, actually, the
   1837 one used by default by the tool).
   1838 
   1839 .. note::
   1840 
   1841    The ability to drive the aggregation policy is useful for testing
   1842    the back-office facility.
   1843 
   1844 Any subcommand is also equipped with the canonical ``--help`` option, so
   1845 feel free to issue the following command in order to explore all the
   1846 possibilities. For example:
   1847 
   1848 .. code-block:: console
   1849 
   1850    $ taler-merchant-benchmark corner --help
   1851 
   1852 will show all the options offered by the *corner* mode. Among the most
   1853 interesting, there are:
   1854 
   1855 -  ``--two-coins=TC`` This option instructs the tool to perform *TC*
   1856    many payments that use two coins, because normally only one coin is
   1857    spent per payment.
   1858 
   1859 -  ``--unaggregated-number=UN`` This option instructs the tool to
   1860    perform *UN* (one coin) payments that will be left unaggregated.
   1861 
   1862 As for the ``ordinary`` subcommand, it is worth explaining the following
   1863 option:
   1864 
   1865 -  ``--payments-number=PN`` Instructs the tool to perform *PN* payments.
   1866 
   1867 
   1868 
   1869 Temporarily Abandoned Features
   1870 ==============================
   1871 
   1872 .. [1]
   1873    https://docs.docker.com/
   1874 
   1875 
   1876 Installing Taler using Docker
   1877 -----------------------------
   1878 
   1879 This section provides instructions for the merchant backend installation
   1880 using ‘Docker‘.
   1881 
   1882 For security reasons, we run Docker against a VirtualBox instance, so
   1883 the ``docker`` command should connect to a ``docker-machine`` instance
   1884 that uses the VirtualBox driver.
   1885 
   1886 Therefore, the needed tools are: “docker“, “docker-machine“, and
   1887 “docker-compose“. Please refer to Docker’s official  [1]_ documentation
   1888 in order to get those components installed, as that is not in this
   1889 manual’s scope.
   1890 
   1891 Before starting to build the merchant’s image, make sure a
   1892 “docker-machine“ instance is up and running.
   1893 
   1894 Because all of the Docker source file are kept in our “deployment“
   1895 repository, we start by checking out the ``git://git.taler.net/deployment``
   1896 codebase:
   1897 
   1898 .. code-block:: console
   1899 
   1900    $ git clone git://git.taler.net/deployment
   1901 
   1902 Now we actually build the merchant’s image. From the same directory as
   1903 above:
   1904 
   1905 .. code-block:: console
   1906 
   1907    $ cd deployment/docker/merchant/
   1908    $ docker-compose build
   1909 
   1910 If everything worked as expected, the merchant is ready to be launched.
   1911 From the same directory as the previous step:
   1912 
   1913 .. code-block:: console
   1914 
   1915    # Recall: the docker-machine should be up and running.
   1916    $ docker-compose up
   1917 
   1918 You should see some live logging from all the involved containers. At
   1919 this stage of development, you should also ignore some (harmless) error
   1920 message from postresql about already existing roles and databases.
   1921 
   1922 To test if everything worked as expected, it suffices to issue a simple
   1923 request to the merchant, for example:
   1924 
   1925 .. code-block:: console
   1926 
   1927    $ wget -O - http://$(docker-machine ip)/
   1928    # A greeting message should be returned by the merchant.