-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathapi.ts
241 lines (235 loc) · 6.82 KB
/
api.ts
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
export enum ApiStatus {
Success = 'SUCCESS',
Error = 'ERROR',
}
export type ApiResponseSuccess<T> = {
status: 'SUCCESS'
code: string
data: T
}
export type ApiResponseError = {
status: 'ERROR'
code: string
message: string
visible: boolean
message_history: string
error_history: {
message: string
status: number
code: string
data: unknown
visible: boolean
}[]
}
export type ApiResponse<T> = ApiResponseSuccess<T> | ApiResponseError
export type GetSongResponse = {
isPlaying?: boolean
name: string
artist: string
album: string
albumImage: string
songUrl: string
}
export type CreatePayPalOrderResponse = {
id: string
// ... some other fields
}
/** Example response:
{
"id": "5N0258154D237152G",
"status": "COMPLETED",
"payment_source": {
"paypal": {
"email_address": "sb-l6zv14916488@personal.example.com",
"account_id": "78AXCBTHDUL24",
"account_status": "VERIFIED",
"name": {
"given_name": "John",
"surname": "Doe"
},
"address": {
"country_code": "IT"
}
}
},
"purchase_units": [
{
"reference_id": "default",
"shipping": {
"name": {
"full_name": "John Doe"
},
"address": {
"address_line_1": "Via Unit? d'Italia",
"admin_area_2": "Napoli",
"admin_area_1": "Napoli",
"postal_code": "80127",
"country_code": "IT"
}
},
"payments": {
"captures": [
{
"id": "6DB2270259909754G",
"status": "COMPLETED",
"amount": {
"currency_code": "USD",
"value": "100.00"
},
"final_capture": true,
"seller_protection": {
"status": "ELIGIBLE",
"dispute_categories": [
"ITEM_NOT_RECEIVED",
"UNAUTHORIZED_TRANSACTION"
]
},
"seller_receivable_breakdown": {
"gross_amount": {
"currency_code": "USD",
"value": "100.00"
},
"paypal_fee": {
"currency_code": "USD",
"value": "3.70"
},
"net_amount": {
"currency_code": "USD",
"value": "96.30"
}
},
"links": [
{
"href": "https://api.sandbox.paypal.com/v2/payments/captures/6DB2270259909754G",
"rel": "self",
"method": "GET"
},
{
"href": "https://api.sandbox.paypal.com/v2/payments/captures/6DB2270259909754G/refund",
"rel": "refund",
"method": "POST"
},
{
"href": "https://api.sandbox.paypal.com/v2/checkout/orders/5N0258154D237152G",
"rel": "up",
"method": "GET"
}
],
"create_time": "2023-07-25T06:42:35Z",
"update_time": "2023-07-25T06:42:35Z"
}
]
}
}
],
"payer": {
"name": {
"given_name": "John",
"surname": "Doe"
},
"email_address": "sb-l6zv14916488@personal.example.com",
"payer_id": "78AXCBTHDUL24",
"address": {
"country_code": "IT"
}
},
"links": [
{
"href": "https://api.sandbox.paypal.com/v2/checkout/orders/5N0258154D237152G",
"rel": "self",
"method": "GET"
}
]
}
*/
export type CapturePayPalOrderResponse = {
id: string
status: string
payment_source: {
paypal: {
email_address: string
account_id: string
account_status: string
name: {
given_name: string
surname: string
}
address: {
country_code: string
}
}
}
purchase_units: Array<{
reference_id: string
shipping: {
name: {
full_name: string
}
address: {
address_line_1: string
admin_area_2: string
admin_area_1: string
postal_code: string
country_code: string
}
}
payments: {
captures: Array<{
id: string
status: string
amount: {
currency_code: string
value: string
}
final_capture: boolean
seller_protection: {
status: string
dispute_categories: Array<string>
}
seller_receivable_breakdown: {
gross_amount: {
currency_code: string
value: string
}
paypal_fee: {
currency_code: string
value: string
}
net_amount: {
currency_code: string
value: string
}
}
links: Array<{
href: string
rel: string
method: string
}>
create_time: string
update_time: string
}>
}
}>
payer: {
name: {
given_name: string
surname: string
}
email_address: string
payer_id: string
address: {
country_code: string
}
}
links: Array<{
href: string
rel: string
method: string
}>
debug_id: string
details: Array<{
issue: string
description: string
debug_id: string
}>
}