This repository has been archived by the owner on May 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
payment.yaml
463 lines (442 loc) · 11.8 KB
/
payment.yaml
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
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
openapi: 3.0.0
info:
version: 1.0.0
title: Payment Ecosystem
description: Internal API that provides payment and wallet creation services
servers:
- url: 'https://api.kinmarketplace.internal/v1/'
paths:
/payments/{payment_id}:
parameters:
- $ref: '#/components/parameters/RequestId'
- in: path
name: payment_id
schema:
type: string
required: true
description: application payment id
get:
tags:
- Payments
description: get payment info
summary: get payment info
operationId: getPayment
responses:
'200':
description: Successfully returned payment info
content:
application/json:
schema:
$ref: '#/components/schemas/Payment'
'404':
description: Payment not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
default:
description: Generic Error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/payments:
parameters:
- $ref: '#/components/parameters/RequestId'
post:
tags:
- Payments
description: create a payment
summary: create a payment
operationId: createPayment
requestBody:
description: payment description
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/PaymentRequest'
responses:
'202':
description: Successfully created a payment and now is processing
default:
description: Generic Error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/wallets:
parameters:
- $ref: '#/components/parameters/RequestId'
post:
tags:
- Wallets
description: create wallet
summary: create wallet
operationId: createWallet
requestBody:
description: wallet_address and app_id
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/WalletRequest'
responses:
'202':
description: Successfully created wallet
default:
description: Generic Error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/wallets/{wallet_address}:
parameters:
- $ref: '#/components/parameters/RequestId'
- $ref: '#/components/parameters/WalletAddressParam'
get:
tags:
- Wallets
description: get wallet information
summary: get wallet information
operationId: getWalletInfo
responses:
'200':
description: Successfully returned wallet info
content:
application/json:
schema:
$ref: '#/components/schemas/Wallet'
default:
description: Generic Error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/wallets/{wallet_address}/payments:
parameters:
- $ref: '#/components/parameters/RequestId'
- $ref: '#/components/parameters/WalletAddressParam'
get:
tags:
- Wallets
description: get wallet payments
summary: get wallet payments
operationId: getWalletPayments
responses:
'200':
description: Successfully returned wallet payments
content:
application/json:
schema:
type: object
properties:
payments:
type: array
items:
$ref: '#/components/schemas/Payment'
default:
description: Generic Error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/services/{service_id}:
parameters:
- in: path
name: service_id
schema:
type: string
required: true
description: an identifer to group addresses watched and callback
put:
tags:
- Watchers
description: create a service with some addresses to always watch
summary: create a service with some addresses to always watch
operationId: createService
requestBody:
description: watcher addresses and callback
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Service'
responses:
'200':
description: Successfully created service
content:
application/json:
schema:
$ref: '#/components/schemas/Service'
default:
description: Generic Error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
delete:
tags:
- Watchers
description: delete service
summary: delete service
operationId: deleteService
responses:
'200':
description: Successfully deleted
content:
application/json:
schema:
$ref: '#/components/schemas/Service'
default:
description: Generic Error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/config:
get:
tags:
- Configuration
responses:
'200':
description: Server Configuration
content:
application/json:
schema:
$ref: '#/components/schemas/Config'
'/services/{service_id}/watchers/{address}/payments/{payment_id}':
parameters:
- in: path
name: service_id
schema:
type: string
required: true
description: service id
- in: path
name: address
schema:
type: string
required: true
description: address to watch
- in: path
name: payment_id
schema:
type: string
required: true
description: payment to watch
put:
tags:
- Watchers
description: start watching a payment
summary: starts watching a specific payment on a specific address. Will stop watching after a timeout
operationId: addWatcher
responses:
'200':
description: Successfully created service
content:
application/json:
schema:
$ref: '#/components/schemas/Service'
default:
description: Generic Error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
delete:
tags:
- Watchers
description: delete watcher
summary: delete watcher
operationId: deleteWatcher
responses:
'200':
description: Successfully deleted
default:
description: Generic Error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
components:
parameters:
RequestId:
in: header
name: X-REQUEST-ID
required: true
schema:
type: string
description: >-
A unique id for the request. A retransmitted request will have the same
id
WalletAddressParam:
in: path
name: wallet_address
schema:
type: string
required: true
description: public address of wallet
schemas:
WalletBase:
type: object
required:
- wallet_address
- id
properties:
wallet_address:
type: string
id:
type: string
description: some identifier of the wallet to be transmitted back via callback
WalletRequest:
allOf:
- $ref: '#/components/schemas/WalletBase'
- type: object
required:
- app_id
- callback
properties:
app_id:
type: string
description: for book keeping
callback:
type: string
format: url
description: a url to post back the payment once complete
Wallet:
allOf:
- $ref: '#/components/schemas/WalletBase'
- type: object
required:
- kin_balance
properties:
kin_balance:
type: number
native_balance:
type: number
WalletCreationFailed:
type: object
properties:
id:
type: string
reason:
type: string
PaymentBase:
type: object
required:
- id
- amount
- app_id
- recipient_address
properties:
id:
type: string
description: |
a unique identifier for this value transfer.
The payment service should use this identifer to prevent duplicate payments.
amount:
type: integer
description: amount in KIN
app_id:
type: string
recipient_address:
type: string
PaymentRequest:
allOf:
- $ref: '#/components/schemas/PaymentBase'
- type: object
required:
- callback
properties:
callback:
type: string
format: url
description: a url to post back the payment once complete
Payment:
allOf:
- $ref: '#/components/schemas/PaymentBase'
- type: object
required:
- transaction_id
- sender_address
- timestamp
properties:
transaction_id:
type: string
description: identifier of the transaction on the blockchain
sender_address:
type: string
description: identifier of the sender on the blockchain
timestamp:
type: string
PaymentFailed:
description: a failed payment transmitted to a callback
type: object
properties:
id:
type: string
reason:
type: string
Service:
type: object
required:
- wallet_addresses
- callback
- service_id
properties:
wallet_addresses:
type: array
items:
type: string
callback:
type: string
description: a webhook to call when a payment is complete
service_id:
type: string
description: the identifier of a service - usually there will only be a single server that wants to get updates on specific addresses. This can be used to shard callbacks onto multiple nodes for example.
Error:
type: object
required:
- error
- code
properties:
error:
type: string
example: "Invalid Transaction"
message:
type: string
example: "no such transaction"
code:
type: integer
example: 4041
Config:
type: object
properties:
horizon_url:
type: string
network_passphrase:
type: string
asset_issuer:
type: string
asset_code:
type: string
example: KIN
CallbackPayload:
type: object
properties:
object:
type: string
enum: [payment, wallet]
action:
type: string
enum:
- send
- receive
- create # for wallet
state:
type: string
enum: [success, fail]
value:
type: object
enum: [Payment, Wallet, PaymentFailed, WalletCreationFailed]