-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapiary.apib
378 lines (291 loc) · 13.8 KB
/
apiary.apib
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
FORMAT: 1A
HOST: https://tokenizer-api.herokuapp.com/
# Mbill Transfer Tokenization Service
# Authorization
We use BASIC HTTP authorization. You should provide access token as HTTP Basic username:
> curl -uAPI_TOKEN https://example.com/
# Transfer Flow
1. Include `https://transfers.mbill.co/tokenizer.js` into your page source and [configure it]() to replace your card container.
2. Your card container will be replaced by a secured iframe that is served from our domain.
3. User inputs card data in iframe and you receive `postMessage` with card token if card data is valid or validation errors.
4. Create transfer using card token.
5. Authenticate transfer via 3-D Secure page or via Lookup code. (To authorize on this steps you must to add transfer token to authorization header)
6. Fetch transfer status.
# TODOs
- card2phone and code2card transfers
- transfer status webhooks
# Group Tokens
## Tokens [/tokens]
### Create Card Token [POST]
Exchange card data with **one-time** token that can be used to create transfers.
Data will be stored in RAM and will be encrypted by AES cbc-128 encryption with HMAC signature.
This token with all relative data is temporary and will be automatically removed in pre-defined time period. Usually **15 minutes**.
+ Request (application/json)
+ Attributes(Card)
+ Response 201 (application/json)
+ Attributes (Response_OK)
+ meta (Response__Meta)
+ code: 201
+ data (CardToken_Full)
# Group Transfer
### Create [POST /transfers]
Initiate a peer-to-peer transfer from `sender` peer credentials to `recipient`'s.
Sender can be:
- `card` - Deprecated. Full card data, including: number, cvv, expiration date.
- `card-token` - Recommended. Token issues in [Create Token](#reference/tokens) endpoint.
Recipient can be:
- `card-token` - Recommended. Token issues in [Create Token](#reference/tokens) endpoint.
- `card-number`
- `external-id` - whenever you want to send payment that can be claimed later. Currently supports only transfers with a system-generated recipient tokens.
Transfer will be created in one of following statuses:
Status | Description
-------|-------
`authentication` | You need to [authorize transfer](#) with data from `auth` field.
`completed` | Transfer is completed, money is sent to recipients issuing bank.
`processing` | Transfer is processing and should be completed or declined within few seconds.
`declined` | Transfer was declined. Reason could be found in `decline` object.
`waiting_for_claim` | Transfer processing will be continued when recipient will claim it's rights on transaction.
+ Request (application/json)
+ Headers
Authorization: Basic REdSc01wWERDajoK
+ Attributes(Transfer)
+ Response 201 (application/json)
+ Attributes (Response_OK)
+ meta (Response__Meta)
+ code: 201
+ data (Transfer_FullWithAuth)
### Get [GET /transfers/{id}]
Read transfer data via it's `id`. Transfer access token must be sent via HTTP Basic Auth in **password** field.
+ Parameters
+ id: 1 (string) - Transfer ID
+ Request (application/json)
+ Headers
Authorization: Basic base64(TRANSFER_TOKEN:)
+ Response 200 (application/json)
+ Attributes (Response_OK)
+ meta (Response__Meta)
+ data (Transfer_FullWithAuth)
### Authentication [POST /transfers/{id}/auth]
#### For 3-D Secure Cards
For 3-D Secure cards you don't need to call this method.
Instead, client broser should create a `application/x-www-form-urlencoded` HTTP POST request to page specified in `auth.acs_url` response field.
This request should contain following fields:
Request Field | Transfer Field
---|---|---
`PaReq` | `auth.pa_req` |
`TermUrl` | `auth.terminal_url`
`MD` | `auth.md`
If you want browser to be redirected to a custom page after 3-D Secure page, you can add urlencoded redirect url as URI parameter `arrival` in `TermUrl`, example:
> https://p2y.com.ua/pay2you-ext/Confirm3D/input3d?arrival=https%3A%2F%2Fexample.com%2F%23!%2Fsend%2Fsuccess
#### For Non 3-D Secure Card
OTP code will be sent to a user device. *Usually code is sent via issuing bank in SMS to a phone that is listed in bank, NOT a `recipient.phone` number*.
This code must be used to auhorize transfer via this method. All unathorized transfer will be declined in about 15 minutes.
+ Parameters
+ id: 1 (string) - Transfer ID
+ Request (application/json)
+ Headers
Authorization: Basic base64(TRANSFER_TOKEN:)
+ Attributes(object)
+ code: 3382837 (string) - OTP code that was sent to peer's device.
+ Response 201 (application/json)
+ Attributes (Response_OK)
+ meta (Response__Meta)
+ data (Transfer_Full)
+ status: completed
# Group Claims
### Create [POST /claims]
For transfers in `waiting_for_claim` status (when recipient credential has `external-credential` type) our back-end is waiting for recipient to claim hes right to receive this transfer.
+ Request (application/json)
+ Attributes(Claim)
+ Response 201 (application/json)
+ Attributes (Response_OK)
+ meta (Response__Meta)
+ code: 201 (number)
+ data (Claim_FullWithAuth)
### Get [GET /claims/{id}]
+ Parameters
+ id: 1 (string) - Claim ID
+ Request (application/json)
+ Headers
Authorization: Basic base64(CLAIM_TOKEN:)
+ Response 200 (application/json)
+ Attributes (Response_OK)
+ meta (Response__Meta)
+ data (Claim_FullWithAuth)
### Authentication [POST /claims/{id}/auth]
+ Parameters
+ id: 1 (string) - Claim ID
+ Request (application/json)
+ Headers
Authorization: Basic base64(CLAIM_TOKEN:)
+ Attributes(object)
+ code: 3382837 (string) - OTP code that was sent to peer's device.
+ Response 201 (application/json)
+ Attributes (Response_OK)
+ meta (Response__Meta)
+ data (Claim_FullWithTransfer)
+ status: completed
# Data Structures
## Responses
### `Response_Collection`
+ meta (Response__Meta, fixed-type)
+ data (array[], fixed-type)
+ paging (Response__Pagination, fixed-type)
### `Response_OK`
+ meta (Response__Meta, fixed-type)
+ data (object, fixed-type)
### `Response_Error`
+ meta (Response__Meta, fixed-type)
+ code: 400 (number)
+ error (Response__Error, fixed-type)
### `Response__Meta`
+ code: 200 (number) - HTTP response code.
+ url: http://example.com/resource (string) - URL to requested resource.
+ type (enum) - Type of data that is located in `data` attribute.
+ object (string) - `data` attribute is a JSON object.
+ list (string) - `data` attribute is a list.
+ code: 200 (number) - HTTP response code.
+ `idempotency_key`: `idemp-ssjssdjoa8308u0us0` (string, optional) - [Idempotency key](http://docs.apimanifest.apiary.io/#introduction/optional-features/idempotent-requests). Send it trough `X-Idempotency-Key` header.
+ `request_id`: `req-adasdoijasdojsda` (string) - [Request ID](http://docs.apimanifest.apiary.io/#introduction/interacting-with-api/request-id). Send it with `X-Request-ID` header.
### `Response__Error`
+ type: type_atom (string) - Atom that represents error type.
+ message: Error description (string) - Human-readable error message. This is for developers, not end-users.
### `Response__Error_DuplicateEntity`
+ type: `object_already_exists` (string) - Atom that represents error type.
+ message: This API already exists (string) - Human-readable error message. This is for developers, not end-users.
### `Response__Error_ValidationFailed`
+ type: validation_failed (string) - type of an error.
+ message: Validation failed. You can find validators description at our API Manifest: http://docs.apimanifest.apiary.io/#introduction/interacting-with-api/errors. (string)
+ invalid (array)
+ `entry_type`: `json_data_proprty` (string) - Type of error.
+ entry: $.cvv (string) - JSON Path to an invalid property.
+ rules (array)
+ rule: required (string) - String constant that represents validation rule type. List of all types can be found in [API Manifest](http://docs.apimanifest.apiary.io/#introduction/interacting-with-api/errors).
+ params (array) - Validation Parameters.
### `Response__Pagination`
+ limit: 20 (number) - A limit on the number of objects to be returned, between 1 and 100. Default: 50.
+ cursors (object)
+ `starting_after`: 56c31536a60ad644060041af (string) - A cursor for use in pagination. An object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list.
+ `ending_before`: 56c31536a60ad644060041aa (string) - A cursor for use in pagination. An object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list.
+ size: 1000 (number) - Total number of objects in collection.
+ has_more: false (boolean) - Is this collection have more data to load in the same style as last request loaded it.
## Cards
### `Card`
+ type: card (string)
+ number: 5591587543706253 (string) - Card number.
+ expiration_month: 01 (string) - Card expiration month with leading zero.
+ expiration_year: 2020 (string) - Card expiration year in YYYY format.
+ cvv: 160 (string) - CVV/CVC code.
### `CardNumber`
+ type: `card-number` (string)
+ number: 5591587543706253 (string) - Card number.
### `CardToken`
+ type: `card-token` (string) - Type. Simplifies futher requests that require it.
+ token: `card-token-6253-8a6985e8247a194c58872d85d5ffad05742679fe` (string) - Token that can be used to create transfer with this card. Followed by last 4 digits from card number.
### `CardToken_Full`
+ Include CardToken
+ `token_expires_at`: `2016-10-29T17:35:28.274477Z` (string) - ISO datetime that signals when token will be expired.
### `ExternalCredential`
+ type: `external-credential` (string)
+ id: my_id (string) - Any ID that is relevant to an external system that will complete this transfer.
+ metadata (object) - Metadata object that can be used by your system to store additional recipients credential details.
## Peers
### Peer
+ phone: +380631112233 (string, optional) - Peer phone number.
+ email: smith@example.com (string, optional) - Peer's email.
### `Peer_Sender`
+ Include Peer
+ One Of
+ credential (Card)
+ credential (CardToken)
### `Peer_Recipient`
+ Include Peer
+ One Of
+ credential (CardNumber)
+ credential (CardToken)
+ credential (ExternalCredential)
## Transfers
### Transfer
+ amount: 1000 (number) - Transfer amount.
+ fee: 10 (number) - Transfer fee.
+ description: some content (string, optional) - Transfer description
+ metadata (object, optional) - Metadata for transfer. Can store any keys and values that match [specification](http://docs.apimanifest.apiary.io/#introduction/optional-features/metadata).
+ sender (Peer_Sender)
+ recipient (Peer_Recipient)
### `Transfer_Full`
+ id: 1 (string) - Transfer ID that can be used to fetch it later.
+ external_id: 29384 (string) - ID generated by our transfer processing partner.
+ status: authentication (enum) - Transfer status.
+ authentication
+ waiting_for_claim
+ processing
+ completed
+ declined
+ Include Transfer
+ sender (Peer)
+ One Of
+ credential (Card)
+ credential (CardToken_Full)
+ recipient (Peer)
+ One Of
+ credential (CardNumber)
+ credential (CardToken_Full)
+ credential (ExternalCredential)
+ token: `transfer-token-70eb3c2b-9ef0-41b9-989b-0d4bf1d10831` (string) - Access token that can be used to fetch transfer later.
+ `token_expires_at`: `2016-10-18T13:50:40.54502Z` (string) - ISO datetime that signals when token will be expired.
+ updated_at: `2016-10-18T13:50:39.677992` (string) - ISO datetime when there was last change in transfer.
+ created_at: `2016-10-18T13:50:39.677992` - ISO datetime when transfer was created.
### `Transfer_FullWithAuth`
+ Include Transfer_Full
+ One Of
+ auth (Transfer__Auth_3DS)
+ auth (Transfer__Auth_Lookup)
### `Transfer__Auth_3DS`
+ type: `3d-secure` (string) - Type of authentication.
+ acs_url
+ md
+ pa_req
+ terminal_url
### `Transfer__Auth_Lookup`
+ type: `lookup-code` (string) - Type of authentication.
+ md
## Claims
### Claim
+ id: 1239381 (string) - Claim ID, currently auto-generated and sent to recipient's phone number.
+ One Of
+ credential (CardNumber)
+ credential (CardToken_Full)
### `Claim_Full`
+ Include Claim
+ status (enum) - Claim status
+ authentication
+ processing
+ completed
+ declined
+ token: `claim-token-70eb3c2b-9ef0-41b9-989b-0d4bf1d10831` (string) - Access token that can be used to fetch claim later.
+ `token_expires_at`: `2016-10-18T13:50:40.54502Z` (string) - ISO datetime that signals when token will be expired.
+ updated_at: `2016-10-18T13:50:39.677992` (string) - ISO datetime when there was last change in claim.
+ created_at: `2016-10-18T13:50:39.677992` - ISO datetime when claim was created.
### `Claim_FullWithAuth`
+ Include Claim_Full
+ auth (Claim__Auth_Lookup)
### `Claim_FullWithTransfer`
+ Include Claim_Full
+ transfer (object)
+ id: 1 (string) - Transfer ID that can be used to fetch it later.
+ status: processing (enum) - Transfer status.
+ processing
+ completed
+ declined
+ Include Transfer
+ sender (Peer)
+ One Of
+ credential (Card)
+ credential (CardToken_Full)
+ recipient (Peer)
+ One Of
+ credential (ExternalCredential)
+ updated_at: `2016-10-18T13:50:39.677992` (string) - ISO datetime when there was last change in transfer.
+ created_at: `2016-10-18T13:50:39.677992` - ISO datetime when transfer was created.
### `Claim__Auth_Lookup`
+ type: `otp-code` (string) - Type of authentication.