-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpayments-api.yaml
More file actions
334 lines (321 loc) · 9.18 KB
/
Copy pathpayments-api.yaml
File metadata and controls
334 lines (321 loc) · 9.18 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
openapi: "3.1.0"
info:
title: Payments API
version: "1.0.0"
description: Payments service for processing and querying payment records.
servers:
- url: https://api.grapity.dev
description: Production server
security:
- oauth2: [payments:read, payments:write]
components:
securitySchemes:
oauth2:
type: oauth2
flows:
clientCredentials:
tokenUrl: https://auth.grapity.dev/oauth/token
scopes:
payments:read: Read payment data
payments:write: Create or update payments
schemas:
Payment:
title: Payment
description: A recorded payment transaction.
type: object
required: [id, amount, currency, status, createdAt]
properties:
id:
type: string
description: Unique payment identifier.
examples: [pay_01J2K3M4N5P6Q7R8S9T0]
amount:
type: number
format: decimal
description: Payment amount in the smallest currency unit.
examples: [1999.99]
currency:
type: string
format: currency
description: ISO 4217 currency code.
enum: [USD, EUR, GBP]
examples: [USD]
status:
type: string
enum: [pending, completed, failed, refunded]
description: Lifecycle status of the payment.
examples: [completed]
createdAt:
type: string
format: date-time
description: Timestamp when the payment was created.
examples: ["2026-01-15T10:30:00Z"]
PaymentInput:
title: Payment Input
description: Fields required to create a new payment.
type: object
required: [amount, currency]
properties:
amount:
type: number
format: decimal
examples: [1999.99]
currency:
type: string
enum: [USD, EUR, GBP]
examples: [USD]
status:
type: string
enum: [pending, completed, failed, refunded]
examples: [pending]
metadata:
type: object
description: Optional key-value metadata.
properties:
orderId:
type: string
customerId:
type: string
Error:
title: Error
type: object
required: [error, message, statusCode]
properties:
error:
type: string
examples: [invalid_request]
message:
type: string
examples: ["Amount must be greater than zero"]
statusCode:
type: integer
examples: [400]
paths:
/v1/payments:
get:
operationId: listPayments
summary: List payments
description: Returns a paginated list of payments for the authenticated account.
parameters:
- name: limit
in: query
description: Maximum number of payments to return.
schema:
type: integer
default: 20
examples: [20]
- name: status
in: query
description: Filter by payment status.
schema:
type: string
enum: [pending, completed, failed, refunded]
examples: [completed]
responses:
"200":
description: A list of payments
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/Payment"
examples:
default:
summary: Paginated payment list
value:
- id: pay_01J2K3M4N5P6Q7R8S9T0
amount: 1999.99
currency: USD
status: completed
createdAt: "2026-01-15T10:30:00Z"
post:
operationId: createPayment
summary: Create a payment
description: Creates a new payment record.
security:
- oauth2: [payments:write]
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/PaymentInput"
examples:
default:
summary: Create a payment
value:
amount: 1999.99
currency: USD
status: pending
metadata:
orderId: ord_123
customerId: cus_456
responses:
"201":
description: Payment created
content:
application/json:
schema:
$ref: "#/components/schemas/Payment"
examples:
default:
summary: Created payment
value:
id: pay_01J2K3M4N5P6Q7R8S9T0
amount: 1999.99
currency: USD
status: pending
createdAt: "2026-01-15T10:30:00Z"
"400":
description: Invalid request
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
examples:
default:
summary: Validation error
value:
error: invalid_request
message: Amount must be greater than zero
statusCode: 400
/v1/payments/{id}:
get:
operationId: getPayment
summary: Get a payment by ID
description: Retrieves a single payment by its identifier.
parameters:
- name: id
in: path
required: true
description: Unique payment identifier.
schema:
type: string
examples: [pay_01J2K3M4N5P6Q7R8S9T0]
responses:
"200":
description: Payment details
content:
application/json:
schema:
$ref: "#/components/schemas/Payment"
examples:
default:
summary: Payment details
value:
id: pay_01J2K3M4N5P6Q7R8S9T0
amount: 1999.99
currency: USD
status: completed
createdAt: "2026-01-15T10:30:00Z"
"404":
description: Payment not found
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
examples:
default:
summary: Not found
value:
error: not_found
message: Payment not found
statusCode: 404
put:
operationId: updatePayment
summary: Update a payment
description: Updates an existing payment.
security:
- oauth2: [payments:write]
parameters:
- name: id
in: path
required: true
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/PaymentInput"
examples:
default:
summary: Update a payment
value:
amount: 2499.99
currency: USD
status: completed
responses:
"200":
description: Payment updated
content:
application/json:
schema:
$ref: "#/components/schemas/Payment"
delete:
operationId: deletePayment
summary: Delete a payment
description: Deletes a payment by ID. Requires write scope.
security:
- oauth2: [payments:write]
parameters:
- name: id
in: path
required: true
schema:
type: string
responses:
"204":
description: Payment deleted
/v1/payments/{id}/refund:
post:
operationId: refundPayment
summary: Refund a payment
description: Refunds a completed payment.
security:
- oauth2: [payments:write]
parameters:
- name: id
in: path
required: true
schema:
type: string
requestBody:
required: false
content:
application/json:
schema:
type: object
properties:
reason:
type: string
examples: ["Customer request"]
responses:
"200":
description: Payment refunded
content:
application/json:
schema:
$ref: "#/components/schemas/Payment"
/v1/payments/legacy/{id}:
get:
operationId: getLegacyPayment
summary: Get a legacy payment (deprecated)
description: Legacy endpoint. Use `GET /payments/{id}` instead.
deprecated: true
x-sunset: "2026-12-31"
parameters:
- name: id
in: path
required: true
schema:
type: string
responses:
"200":
description: Legacy payment details
content:
application/json:
schema:
$ref: "#/components/schemas/Payment"