forked from tekpriest/paystack-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterface.ts
More file actions
327 lines (313 loc) · 8.07 KB
/
interface.ts
File metadata and controls
327 lines (313 loc) · 8.07 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
import { Authorization } from '../charge/interface';
import { Customer } from '../customer/interface';
import { Meta } from '../interface';
export interface InitializeTransaction {
/**
* Amount should be in **kobo** if currency
* is `NGN`, **pesewas**, if the currency is `GHS` and
* **cents**, if currency is `ZAR`
*/
amount: string;
/**
* Customer's email address
*/
email: string;
/**
* The transaction currency (NGN, GHS, ZAR or USD).
* Defaults to your integration currency.
*/
currency?: string;
/**
* Unique transaction reference. Only `-`,`.`,`=`
* and alphanumeric characters allowed
*/
reference?: string;
/**
* Fully qualified url, e.g. https://example.com/.
* Use this to override the callback url provided on
* the dashboard for this transaction
*/
callback_url?: string;
/**
* If transaction is to create a subscription to a predefined plan,
* provide plan code here. This would invalidate the value provided
* in `amount`
*/
plan?: string;
/**
* Number of times to charge customer during subscription to plan
*/
invoice_limit?: string;
/**
* Stringified JSON object of custom data.
* Kindly check the [Metadata](https://paystack.com/docs/payments/metadata)
* page for more information.
*/
metadata?: Record<string, unknown>;
/**
* An array of payment channels to control what channels
* you want to make available to the user to make a payment
* with.
* @example ['card','bank','ussd','qr','mobile_money','bank_transfer']
*/
channels?: string[];
/**
* The split code of the transaction split.
* e.g `SPL_98WF13Eb3w`
*/
split_code?: string;
/**
* The code for the subaccount that owns the payment e.g `ACCT_8f4s1eq7m16rlzj`
*/
subaccount?: string;
/**
* A flat fee to charge the subaccount for this transaction ().
* This overrides the split percentage set when the subaccount
* was created. Ideally, you will need to use this if you are
* splitting in flat rates (since subaccount creation only allows
* for percentage split). e.g. `7000` for a 70 naira fiat fee.
*/
transaction_charge?: number;
/**
* Who bears Paystack charges?
* `account` or `subaccount` (defaults to `account`)
*/
bearer?: string;
}
export interface Response {
status: boolean;
message: string;
}
export interface TransactionInitialized extends Response {
data: {
authorization_url: string;
access_code: string;
reference: string;
};
}
export interface Transaction {
id:number;
amount: number;
currency: string;
paid_at: Date;
created_at:Date;
status: string;
reference: string;
domain: string;
metadata: Record<string, unknown>;
gateway_response: string;
message?: string;
channel: string;
ip_address: string;
log: [
{
time_spent: number;
attempt: number;
authentication?: unknown;
errors: number;
success: boolean;
mobile: boolean;
input: [];
channel: string;
history: [
{
type: string;
message: string;
time: number;
},
];
},
];
fees: number;
authorization: Authorization;
customer: Customer;
pin: string;
requested_amount: number;
}
export interface GetTransactionResponse extends Response {
data: Transaction;
}
export interface ListTransactions extends Response {
data: Transaction[];
meta: Meta;
}
export interface Timeline extends Response {
data: {
time_spent: number;
attempts: number;
authentication?: unknown;
errors: number;
success: boolean;
mobile: boolean;
input: [];
channel: string;
history: [
{
type: string;
message: string;
time: number;
},
];
};
}
export interface ExportTransaction extends Response {
data: {
path: string;
};
}
export interface ListTransactionQueryParams {
/**
* Specify how many records you want to retrieve per page.
* If not specify we use a default value of 50.
*/
perPage?: number;
/**
* Specify exactly what page you want to retrieve.
* If not specify we use a default value of 1.
*/
page?: number;
/**
* Specify an ID for the customer whose transactions
* you want to retrieve
*/
customer?: number;
/**
* Filter transactions by status ('failed', 'success', 'abandoned')
*/
status?: string;
/**
* A timestamp from which to start listing transaction
* e.g `2021-10-25T00.00.05.000z`, `2021-12-25`
*/
from?: Date;
/**
* A timestamp from which to stop listing transaction
* e.g `2021-10-25T00.00.05.000z`, `2021-12-25`
*/
to?: Date;
/**
* Filter transactions by amount.
* Specify the amount (in **kobo** if currency is `NGN`,
* **pesewas**, if currency is `GHS`,
* and **cents**, if currency is `ZAR`)
*/
amount?: number;
}
export interface ChargeAuthorization {
/**
* Amount should be in kobo if currency is `NGN`, *pesewas*,
* if currency is `GHS`, and cents, if currency is `ZAR`
*/
amount: string;
/**
* Customer's email address
*/
email: string;
/**
* Valid authorization code to charge
*/
authorization_code: string;
/**
* Unique transaction reference. Only `-`, `.`,`=`
* and alphanumeric characters allowed
*/
reference?: string;
/**
* Currency in which amount shoud be charged.
* Allowed values are: NGN,GHS,ZAR or USD
*/
currency?: string;
/**
* Stringified JSON object. Add a custom_fields attribute which has
* an array of objects if you would like the fields to be added to your
* transaction when displayed on the dashboard.
* @example {
* "custom_fields": [{"display_name": "Cart ID","variable_name": "cart_id","value": "8393"}]}
*/
metadata?: Record<string, unknown>;
/**
* Send us 'card' or 'bank' or 'card','bank' as an array to specify what
* options to show the user paying
*/
channels?: string[];
/**
* The code for the subaccount that owns the payment.
* @exmple ACCT_8f4s1eq7ml6rlzj
*/
subaccount?: string;
/**
* A flat fee to charge the subaccount for this transaction (in kobo if currency is NGN,
* pesewas, if currency is GHS, and cents, if currency is ZAR). This overrides the split percentage
* set when the subaccount was created. Ideally, you will need to use this if you are splitting in
* flat rates (since subaccount creation only allows for
*/
transaction_charge?: number;
/**
* Who bears Paystack charges? `account` or `subaccount` (defaults to `account`).
*/
bearer?: string;
/**
* If you are making a scheduled charge call, it is a good idea to queue them so the processing
* system does not get overloaded causing transaction processing errors. Send queue:true
* to take advantage of our queued charging.
*/
queue?: boolean;
}
export interface CheckAuthorization {
/**
* Amount should be in kobo if currency is `NGN`,
* pesewas, if currency is `GHS`, and cents, if currency is `ZAR`
*/
amount: string;
/**
* Customer's email address
*/
email: string;
/**
* Valid authorization code to charge
*/
authorization_code: string;
/**
* Currency in which amount should be charged.
* Allowed values are: `NGN`, `GHS`, `ZAR` or `USD`
*/
currency?: string;
}
export interface PartialDebit {
/**
* Authorization Code
*/
authorization_code: string;
/**
* Specify the currency you want to debit.
* Allowed values are `NGN`, `GHS`, `ZAR` or `USD`.
*/
currency: string;
/**
* Amount should be in *kobo* if currency is NGN,
* pesewas, if *currency* is `GHS`, and *cents*, if currency is `ZAR`
*/
amount: string;
/**
* Customer's email address (attached to the authorization code)
*/
email: string;
/**
* Unique transaction reference.
* Only `-`, `.`, `=` and alphanumeric characters allowed.
*/
reference: string;
/**
* Minimum amount to charge
*/
at_least: string;
}
export interface PartialDebitResponse extends Response {
data: Record<string, unknown>;
}
export interface CheckAuthorizationResponse extends Response {
data: {
amount: string;
currency: string;
};
}