-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.d.ts
More file actions
298 lines (244 loc) · 8.24 KB
/
index.d.ts
File metadata and controls
298 lines (244 loc) · 8.24 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
// Type definitions for Paylike
import * as Promise from 'bluebird'
declare class Paylike {
constructor(appKey: string)
transactions: Paylike.Transactions
merchants: Paylike.Merchants
cards: Paylike.Cards
apps: Paylike.Apps
service: Paylike.Service
}
declare namespace Paylike {
export interface PaylikeError extends Error {
message: string
}
export interface PaylikeErrorConstructor extends Error {
new (message: string): PaylikeError
(message: string): PaylikeError
prototype: PaylikeError
}
export const Error: PaylikeErrorConstructor
export interface AuthorizationError extends PaylikeError {
message: string
}
export interface AuthorizationErrorConstructor extends PaylikeError {
new (message: string): AuthorizationError
(message: string): AuthorizationError
prototype: AuthorizationError
}
export const AuthorizationError: AuthorizationErrorConstructor
export interface PermissionsError extends PaylikeError {
message: string
}
export interface PermissionsErrorConstructor extends PaylikeError {
new (message: string): PermissionsError
(message: string): PermissionsError
prototype: PermissionsError
}
export const PermissionsError: PermissionsErrorConstructor
export interface NotFoundError extends PaylikeError {
message: string
}
export interface NotFoundErrorConstructor extends PaylikeError {
new (message: string): NotFoundError
(message: string): NotFoundError
prototype: NotFoundError
}
export const NotFoundError: NotFoundErrorConstructor
export interface ConflictError extends PaylikeError {
message: string
}
export interface ConflictErrorConstructor extends PaylikeError {
new (message: string): ConflictError
(message: string): ConflictError
prototype: ConflictError
}
export const ConflictError: ConflictErrorConstructor
export interface ValidationError extends PaylikeError {
message: string
}
export interface ValidationErrorConstructor extends PaylikeError {
new (message: string): ValidationError
(message: string): ValidationError
prototype: ValidationError
}
export const ValidationError: ValidationErrorConstructor
interface Cursor<T> {
after: (id: string) => Cursor<T>
before: (id: string) => Cursor<T>
limit: (limit: number) => Cursor<T>
stream: (highWaterMark: number) => any
toArray: () => Promise<Array<T>>
}
interface Apps {
create: (opts: any, cb?: (err) => void) => Promise<void>
findOne: (cb?: (err) => void) => Promise<App>
}
interface App {
id: string
name: string
key: string
}
interface Merchants {
create: (opts: any) => Promise<string>
update: (merchantId: string, opts: any) => Promise<void>
findOne: (merchantId: string) => Promise<Merchant>
apps: Merchants.Apps
users: Merchants.Users
lines: Merchants.Lines
transactions: Merchants.Transactions
}
interface Merchant {
name: string // optional
currency: string // required, three letter ISO
test: boolean // optional, defaults to false
email: string // required, contact email
website: string // required, website with implementation
descriptor: string // required, text on client bank statements
company: Merchant.Company
bank: Merchant.Bank // optional
}
namespace Merchant {
interface Company {
country: string // required, ISO 3166 code (e.g. DK)
number: string // optional, registration number ("CVR" in Denmark)
}
interface Bank {
iban: string // optional, (format: XX00000000, XX is country code, length varies)
}
}
namespace Merchants {
interface Users {
add: (merchantId: string, opts: any, cb?: (err: any, value?: any) => void) => Promise<void>
revoke: (merchantId: string, userId: string, cb?: (err: any, value?: any) => void) => Promise<void>
find: (merchantId: string) => Cursor<Merchants.User>
}
interface User {
id: string
created: Date
email: string
}
interface Apps {
add: (merchantId: string, opts: any, cb?: (err: any, value?: any) => void) => Promise<void>
revoke: (merchantId: string, appId: string, cb?: (err: any, value?: any) => void) => Promise<void>
find: (merchantId: string) => Cursor<App>
}
interface Lines {
find: (merchantId: string) => Cursor<Merchants.Line>
}
interface Line {
id: string
created: Date
merchantId: string
transactionId: string
amount: Amount
balance: number
capture: boolean
fee: number
}
interface Amount {
amount: number
currency: string
}
interface Transactions {
create: (merchantId: string, opts: CreateTransactionOptions, cb?: (err: any, value?: string) => void) => Promise<string>
find: (merchantId: string) => Cursor<Transaction>
}
}
interface CreateTransactionOptions {
transactionId?: string
cardId?: string
amount: number
currency: string
descriptor?: any
custom?: any
}
interface VoidTransactionOptions {
amount: number
}
interface RefundTransactionOptions {
amount: number
descriptor: string
}
interface Transactions {
capture: (transactionId: string, opts: CaptureTransactionOptions, cb?: (err: any, value?: any) => void) => Promise<void>
refund: (transactionId: string, opts: RefundTransactionOptions, cb?: (err: any, value?: any) => void) => Promise<void>
void: (transactionId: string, opts: VoidTransactionOptions, cb?: (err: any, value?: any) => void) => Promise<void>
findOne: (transactionId: string) => Promise<Transaction>
}
interface CaptureTransactionOptions {
amount: number
currency: string
descriptor?: string
}
interface Transaction {
id: string
merchantId: string // ID of the owning merchant account
test: boolean // whether on a test merchant account
created: Date // Date of transaction
currency: string // currency ISO code
amount: number // amount in minor units
descriptor: string // text on bank statement
pendingAmount: number // amount available for capture or void
capturedAmount: number // amount captured (available for refund)
refundedAmount: number // amount refunded (no further action possible)
voidedAmount: number // amount voided (no further action possible)
disputedAmount: number // amount involed in disputes such as chargebacks
card: {
bin: string // first 6 numbers in PAN (card number)
last4: string
expiry: Date
scheme: string // "visa" or "mastercard"
}
custom: any
tds: string
recurring: boolean // whether the transaction was made from the server
successful: boolean
error: false|any // contains a processing error if unsuccessful
trail: Array<TrailItem>
}
interface TrailItem {
// only one of the following will be present
capture?: boolean
refund?: boolean
void?: boolean
dispute?: {
id: string
// only one of the following will be present
won?: boolean
lost?: boolean
}
created: Date
amount: number // amount in minor units and transaction currency
/*
Amount in the merchant account's currency in minor units that
the merchant account balance was affected with which in
practice means the actual profit from the transaction after
fees and/or currency conversion.
*/
balance: number
fee: any // detailed description of fees applied
descriptor: string // text on bank statement
lineId: string // ID of the related accounting line
}
interface Cards {
create: (merchantId: string, opts: any) => Promise<string>
findOne: (cardId: string) => Promise<Card>
}
interface Card {
id: string
merchantId: string
created: Date
bin: string // first 6 numbers in PAN (card number)
last4: string
expiry: Date
scheme: Card.Scheme // "visa" or "mastercard"
}
namespace Card {
type Scheme = 'visa' | 'mastercard'
}
interface Service {
request: (verb: string, path: string, query: any, cb?: (err: any, value?: any) => void) => Promise<any>
}
}
export = Paylike