summaryrefslogtreecommitdiff
path: root/api/api-bank.rst
blob: 8bfffa03dabf38b81648c10922d2f21046f45dfd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
..
  This file is part of GNU TALER.
  Copyright (C) 2014, 2015, 2016 INRIA
  TALER is free software; you can redistribute it and/or modify it under the
  terms of the GNU General Public License as published by the Free Software
  Foundation; either version 2.1, or (at your option) any later version.
  TALER is distributed in the hope that it will be useful, but WITHOUT ANY
  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
  You should have received a copy of the GNU Lesser General Public License along with
  TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>

  @author Marcello Stanisci

=========
Bank API
=========

The following APIs are served from banks, in order to allow exchanges to
deposit funds to money recipients.  A typical scenario for calling this
APIs is after a merchant has deposited coins to the exchange, and the exchange
needs to give real money to the merchant.

------------------
Administrative API
------------------

This API allows one user to send money to another user, withing the same "test"
bank.  The user calling it has to authenticate by including his credentials in the
request.

.. _bank-deposit:
.. http:post:: /admin/add/incoming

**Request:** The body of this request must have the format of a `BankDepositRequest`_.

**Response:**

:status 200 OK: The request has been correctly handled, so the funds have been transferred to the recipient's account

:status 400 Bad Request: The bank replies a `BankIncomingError`_ object

**Details:**

.. _BankDepositRequest:
.. code-block:: tsref

  interface BankDepositRequest {

    // Authentication method used
    auth: BankAuth;

    // JSON 'amount' object. The amount the caller wants to transfer
    // to the recipient's count
    amount: Amount;

    // Exchange base URL, used to perform tracking requests against the
    // wire transfer ID.  Note that in the actual bank wire transfer,
    // the schema may have to be encoded differently, i.e.
    // "https://exchange.com/" may become "https exchange.com" due to
    // character set restrictions.  It is the responsibility of the
    // wire transfer adapter to properly encode/decode the URL.
    // Payment service providers must ensure that their URL is short
    // enough to fit together with the wire transfer identifier into
    // the wire transfer subject of their respective banking system.
    exchange_url: string;

    // The id of this wire transfer, a `TALER_WireTransferIdentifierRawP`.
    // Should be encoded together with a checksum in actual wire transfers.
    // (See `TALER_WireTransferIdentifierP`_ for an encoding with CRC8.).
    wtid: base32;

    // The sender's account identificator
    debit_account: number;

    // The recipient's account identificator
    credit_account: number;

  }


.. _BankAuth:
.. code-block:: tsref

  interface BankAuth {

    // authentication type.  Accepted values are:
    // "basic", "digest", "token".
    type: string; 
    
    // Optional object containing data consistent with the
    // used authentication type.
    data: Object;

  }



.. _BankIncomingError:
.. code-block:: tsref

  interface BankIncomingError {

    // Human readable explanation of the failure.
    reason: string;

  }

--------
User API
--------

This API returns a list of his transactions, optionally limiting
the number of results.

.. http:post:: /history

  **Request** JSON of type `HistoryRequest`_.


  **Response** JSON array of type `BankTransaction`_.


.. _HistoryRequest:
.. code-block:: tsref

  interface HistoryRequest {
    
    // Authentication credentials to get right of
    // issuing this call.
    auth: BasicAuth;

    // Optional parameter that lets the caller specify
    // only incoming, outgoing, or both types of records.  If not given,
    // then the API will return both types; if set to `credit` (`debit`),
    // only incoming (outgoing) records are returned.
    direction: string;

    }

.. _BankTransaction:
.. code-block:: tsref

  interface BankTransaction {
  
    // identification number of the record
    row_id: number;

    // Date of the transaction
    date: Timestamp;

    // Amount transferred
    amount: Amount;

    // "-" if the transfer was outgoing, "+" if it was
    // incoming.  This field is only present if the
    // argument `direction` was NOT given.
    sign: string;

    // Bank account number of the other party involved in the
    // transaction.
    counterpart: number; 
  
  }

..
  The counterpart currently only points to the same bank as
  the client using the bank.  A reasonable improvement is to
  specify a bank URI too, so that Taler can run across multiple
  banks.

.. _HistoryRequest:
.. code-block:: tsref

  interface HistoryRequest {
  
    // Authentication method used
    auth: BankAuth;

    // Only records with row id LESSER than `start' will
    // be returned.  NOTE, smaller row ids denote older db
    // records.  If this value equals zero, then the youngest
    // `delta' rows are returned.
    start: number;

    // Optional value denoting how many rows we want receive.
    // If not given, then it defaults to 10.
    delta: number;
  }