-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcard-service.yaml
More file actions
648 lines (648 loc) · 20.2 KB
/
card-service.yaml
File metadata and controls
648 lines (648 loc) · 20.2 KB
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
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
openapi: 3.0.3
info:
title: Digital Gift Card Issuing API
version: 1.0.0
description: |
API for issuing and managing digital gift cards.
servers:
- url: "https://api.chron.com"
security:
- bearerAuth: []
paths:
/v1/cards:
post:
summary: Create a Card
description: |
Creates a new digital gift card and loads the initial funds. A unique `clientReference` must be provided to prevent duplicate card creation. If the same clientReference is submitted, a 409 Conflict error is returned.
operationId: createCard
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/CreateCardRequest"
responses:
"200":
description: Card created successfully.
content:
application/json:
schema:
$ref: "#/components/schemas/Card"
"400":
description: Bad Request.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"401":
description: Unauthorized.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"409":
description: Duplicate clientReference. A card with the given clientReference already exists.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
get:
summary: Get a Paginated List of Cards
description: |
Retrieves a paginated list of digital gift cards with optional filtering on status, createdDate, expiryDate, activationDate, updatedDate, and metadata. The metadata filtering supports flat JSON objects (top-level keys only).
operationId: listCards
parameters:
- in: query
name: limit
schema:
type: integer
maximum: 100
description: Maximum number of cards per page.
required: true
- in: query
name: offset
schema:
type: integer
description: Starting index for pagination.
required: true
- in: query
name: status
schema:
type: string
enum:
- WAITING_ACTIVATION
- ACTIVE
- CANCELLED
- BLOCKED
- REISSUED
- EXPIRED
description: Filter cards by status.
- in: query
name: createdDate
schema:
type: string
format: date
description: Filter cards by creation date (YYYY-MM-DD).
- in: query
name: expiryDate
schema:
type: string
format: date
description: Filter cards by expiry date (YYYY-MM-DD).
- in: query
name: activationDate
schema:
type: string
format: date
description: Filter cards by activation date (YYYY-MM-DD).
- in: query
name: updatedDate
schema:
type: string
format: date
description: Filter cards by last updated date (YYYY-MM-DD).
- in: query
name: metadata
schema:
type: string
description: "Filter on metadata key-value pairs (flat JSON only), e.g., metadata.orderId=12345."
responses:
"200":
description: List of cards retrieved successfully.
content:
application/json:
schema:
type: object
properties:
total:
type: integer
description: Total number of cards matching the filter.
limit:
type: integer
offset:
type: integer
cards:
type: array
items:
$ref: "#/components/schemas/Card"
"400":
description: Invalid request parameters.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"401":
description: Unauthorized.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"/v1/cards/{cardId}":
get:
summary: Get an Existing Card
description: Retrieves the full details of a digital gift card by its unique identifier.
operationId: getCard
parameters:
- $ref: "#/components/parameters/CardIdParam"
responses:
"200":
description: Card retrieved successfully.
content:
application/json:
schema:
$ref: "#/components/schemas/Card"
"401":
description: Unauthorized.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"404":
description: Card not found.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"/v1/cards/{cardId}/activate":
post:
summary: Activate a Card
description: |
Activates a digital gift card that is currently in the WAITING_ACTIVATION state, transitioning it to ACTIVE.
operationId: activateCard
parameters:
- $ref: "#/components/parameters/CardIdParam"
responses:
"200":
description: Card activated successfully.
content:
application/json:
schema:
$ref: "#/components/schemas/Card"
"401":
description: Unauthorized.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"404":
description: Card not found.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"409":
description: Card is not in a state that allows activation.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"/v1/cards/{cardId}/cancel":
post:
summary: Cancel a Card
description: "Cancels a digital gift card, marking it as CANCELLED, unloading remaining funds, and recording cancellation details."
operationId: cancelCard
parameters:
- $ref: "#/components/parameters/CardIdParam"
responses:
"200":
description: Card cancelled successfully.
content:
application/json:
schema:
$ref: "#/components/schemas/Card"
"401":
description: Unauthorized.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"404":
description: Card not found.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"409":
description: Card is not in a state that permits cancellation.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"/v1/cards/{cardId}/block":
post:
summary: Block a Card
description: |
Blocks a digital gift card (setting status to BLOCKED). This operation is allowed only if the card is in ACTIVE or WAITING_ACTIVATION state.
operationId: blockCard
parameters:
- $ref: "#/components/parameters/CardIdParam"
requestBody:
required: false
content:
application/json:
schema:
$ref: "#/components/schemas/BlockCardRequest"
responses:
"200":
description: Card blocked successfully.
content:
application/json:
schema:
$ref: "#/components/schemas/Card"
"401":
description: Unauthorized.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"404":
description: Card not found.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"409":
description: Card is not in a state that permits blocking.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"/v1/cards/{cardId}/unblock":
post:
summary: Unblock a Card
description: |
Unblocks a digital gift card, transitioning it from BLOCKED to ACTIVE. This is only applicable if the card is currently BLOCKED.
operationId: unblockCard
parameters:
- $ref: "#/components/parameters/CardIdParam"
responses:
"200":
description: Card unblocked successfully.
content:
application/json:
schema:
$ref: "#/components/schemas/Card"
"401":
description: Unauthorized.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"404":
description: Card not found.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"409":
description: Card is not currently blocked.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"/v1/cards/{cardId}/provision/google":
post:
summary: Provision Card to Google
description: |
Provisions a card for Google Pay by passing required client device and wallet parameters.
operationId: provisionGoogle
parameters:
- $ref: "#/components/parameters/CardIdParam"
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/ProvisionToGoogleRequest"
responses:
"200":
description: Card provisioned to Google successfully.
content:
application/json:
schema:
$ref: "#/components/schemas/ProvisionToGoogleResponse"
"401":
description: Unauthorized.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"404":
description: Card not found.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"422":
description: Invalid request payload or card state for provisioning.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"/v1/cards/{cardId}/provision/apple":
post:
summary: Provision Card to Apple
description: |
Provisions a card for Apple Wallet by passing required client device and wallet parameters.
operationId: provisionApple
parameters:
- $ref: "#/components/parameters/CardIdParam"
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/ProvisionToAppleRequest"
responses:
"200":
description: Card provisioned to Apple successfully.
content:
application/json:
schema:
$ref: "#/components/schemas/ProvisionToAppleResponse"
"401":
description: Unauthorized.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"404":
description: Card not found.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"422":
description: Invalid request payload or card state for provisioning.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"/v1/cards/{cardId}/reissue":
post:
summary: Reissue or Replace a Card
description: |
Generates a new digital gift card to replace an existing one. Unloads funds from the original and adds them to the newly created card.
operationId: reissueCard
parameters:
- $ref: "#/components/parameters/CardIdParam"
requestBody:
required: false
content:
application/json:
schema:
$ref: "#/components/schemas/ReissueCardRequest"
responses:
"200":
description: Card reissued successfully.
content:
application/json:
schema:
$ref: "#/components/schemas/Card"
"401":
description: Unauthorized.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"404":
description: Card not found.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"409":
description: Card is not in a state that permits reissuance.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
components:
securitySchemes:
bearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
parameters:
CardIdParam:
name: cardId
in: path
required: true
description: Unique identifier for the card.
schema:
type: string
format: uuid
schemas:
Card:
type: object
properties:
cardId:
type: string
format: uuid
description: Unique identifier for the card.
clientReference:
type: string
description: Unique identifier provided by the client to prevent duplication.
status:
type: string
description: Current status of the card.
enum:
- WAITING_ACTIVATION
- ACTIVE
- CANCELLED
- BLOCKED
- REISSUED
- EXPIRED
initialBalance:
type: number
description: The starting balance on the card.
currentBalance:
type: number
description: The current available balance.
expiryDate:
type: string
format: date-time
description: The date and time when the card expires.
design:
type: string
description: The design or template selected for the card.
metadata:
type: object
additionalProperties: true
description: Updateable custom data associated with the card.
createdAt:
type: string
format: date-time
description: Timestamp when the card was created.
updatedAt:
type: string
format: date-time
description: Timestamp when the card was last updated.
activatedAt:
type: string
format: date-time
description: Timestamp when the card was activated (if applicable).
cancelledAt:
type: string
format: date-time
description: Timestamp when the card was cancelled (null if not cancelled).
cancellationAmount:
type: number
description: The amount that was unloaded from the card at cancellation (null if not cancelled).
cancellationAction:
type: string
description: Action that led to the card's cancellation.
enum:
- EXPIRY
- CANCELLATION
- REISSUE
transactions:
type: array
description: A list of transactions associated with the card.
items:
$ref: "#/components/schemas/Transaction"
required:
- cardId
- clientReference
- status
- initialBalance
- expiryDate
- design
- metadata
- createdAt
- updatedAt
Transaction:
type: object
properties:
transactionId:
type: string
description: Unique identifier for the transaction.
amount:
type: number
description: The amount for the transaction.
type:
type: string
description: Type of transaction.
enum:
- LOAD
- UNLOAD
- PURCHASE
createdAt:
type: string
format: date-time
description: Timestamp when the transaction was recorded.
required:
- transactionId
- amount
- type
- createdAt
CreateCardRequest:
type: object
properties:
clientReference:
type: string
description: A unique identifier provided by the client to prevent duplicate card creation.
initialBalance:
type: number
description: "The starting balance (e.g., up to AUD 500 or AUD 1000)."
expiryDate:
type: string
format: date-time
description: The expiry date/time for the card.
design:
type: string
description: The design or template chosen for the card.
metadata:
type: object
additionalProperties: true
description: Updateable custom data for the card.
required:
- clientReference
- initialBalance
- expiryDate
- design
- metadata
BlockCardRequest:
type: object
properties:
reason:
type: string
description: Optional reason for blocking the card.
ReissueCardRequest:
type: object
properties:
reason:
type: string
description: Optional reason for reissuing the card.
ProvisionToGoogleRequest:
type: object
properties:
clientDeviceID:
type: string
description: The identifier for the client device.
clientWalletProvider:
type: string
description: The wallet provider code.
clientWalletAccountID:
type: string
description: The wallet account identifier.
required:
- clientDeviceID
- clientWalletProvider
- clientWalletAccountID
ProvisionToGoogleResponse:
type: object
properties:
encryptedPaymentInstrument:
type: string
description: The encrypted payment instrument data returned by Google.
required:
- encryptedPaymentInstrument
ProvisionToAppleRequest:
type: object
properties:
clientDeviceID:
type: string
description: The identifier for the client device.
clientWalletProvider:
type: string
description: The wallet provider code.
clientWalletAccountID:
type: string
description: The wallet account identifier.
required:
- clientDeviceID
- clientWalletProvider
- clientWalletAccountID
ProvisionToAppleResponse:
type: object
properties:
primaryAccountNumberPrefix:
type: string
description: The prefix of the primary account number.
activationData:
type: string
description: The activation data provided by Apple.
authenticationData:
type: string
description: The authentication data provided by Apple.
required:
- primaryAccountNumberPrefix
- activationData
- authenticationData
ErrorResponse:
type: object
properties:
errorCode:
type: string
description: A machine-readable error code.
message:
type: string
description: A human-readable error message.
details:
type: object
additionalProperties: true
description: Additional details about the error.
required:
- errorCode
- message