paystack-sdk 1.0.9 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2 -5
- package/dist/paystack.d.ts +6 -6
- package/dist/paystack.js +3 -5
- package/dist/plan/interface.d.ts +1 -1
- package/dist/plan/plan.d.ts +1 -7
- package/dist/plan/plan.js +2 -2
- package/dist/transaction/interface.d.ts +134 -5
- package/dist/transaction/transaction.d.ts +10 -8
- package/dist/transaction/transaction.js +33 -1
- package/package.json +2 -3
package/dist/index.js
CHANGED
package/dist/paystack.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Plan } from './plan
|
|
3
|
-
import {
|
|
1
|
+
import { Charge } from './charge';
|
|
2
|
+
import { Plan } from './plan';
|
|
3
|
+
import { Transaction } from './transaction';
|
|
4
4
|
/**
|
|
5
5
|
* Paystack SDK
|
|
6
6
|
* @author Asaju Enitan <@en1tan>
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export declare class Paystack {
|
|
9
9
|
readonly key: string;
|
|
10
10
|
private readonly http;
|
|
11
|
-
charge:
|
|
12
|
-
transaction:
|
|
11
|
+
charge: Charge;
|
|
12
|
+
transaction: Transaction;
|
|
13
13
|
plan: Plan;
|
|
14
14
|
constructor(key: string);
|
|
15
15
|
}
|
package/dist/paystack.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Axios } from 'axios';
|
|
2
2
|
import { Charge } from './charge';
|
|
3
|
-
import { Plan } from './plan
|
|
4
|
-
import { Transaction } from './transaction
|
|
3
|
+
import { Plan } from './plan';
|
|
4
|
+
import { Transaction } from './transaction';
|
|
5
5
|
/**
|
|
6
6
|
* Paystack SDK
|
|
7
7
|
* @author Asaju Enitan <@en1tan>
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export class Paystack {
|
|
10
10
|
key;
|
|
11
11
|
http;
|
|
12
12
|
charge;
|
|
@@ -18,9 +18,7 @@ export default class Paystack {
|
|
|
18
18
|
baseURL: 'https://api.paystack.co',
|
|
19
19
|
headers: {
|
|
20
20
|
Authorization: `Bearer ${this.key}`,
|
|
21
|
-
'Content-Type': 'application/json',
|
|
22
21
|
},
|
|
23
|
-
responseType: 'json',
|
|
24
22
|
});
|
|
25
23
|
this.charge = new Charge(this.http);
|
|
26
24
|
this.transaction = new Transaction(this.http);
|
package/dist/plan/interface.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export interface CreatePlan {
|
|
|
37
37
|
currency?: string;
|
|
38
38
|
/**
|
|
39
39
|
* Number of invoices to raise during subscription to this plan.
|
|
40
|
-
* Can be
|
|
40
|
+
* Can be overridden by specifying an `invoice_limit` while subscribing
|
|
41
41
|
*/
|
|
42
42
|
invoice_limit?: number;
|
|
43
43
|
}
|
package/dist/plan/plan.d.ts
CHANGED
|
@@ -5,19 +5,13 @@ interface BadRequest {
|
|
|
5
5
|
message: string;
|
|
6
6
|
data: null;
|
|
7
7
|
}
|
|
8
|
-
export interface IPlan {
|
|
9
|
-
create(data: CreatePlan): Promise<PlanResponse | BadRequest>;
|
|
10
|
-
list(queryParams?: ListPlanQueryParams): Promise<PlanResponse | BadRequest>;
|
|
11
|
-
fetch(id: string): Promise<PlanResponse | BadRequest>;
|
|
12
|
-
update(id: string, data: UpdatePlan): Promise<PlanResponse | BadRequest>;
|
|
13
|
-
}
|
|
14
8
|
/**
|
|
15
9
|
* ## Plans
|
|
16
10
|
* The Plans API allows you create and manage installment
|
|
17
11
|
* payment options on your integration
|
|
18
12
|
* @class Plan
|
|
19
13
|
*/
|
|
20
|
-
export declare class Plan
|
|
14
|
+
export declare class Plan {
|
|
21
15
|
private http;
|
|
22
16
|
constructor(http: Axios);
|
|
23
17
|
/**
|
package/dist/plan/plan.js
CHANGED
|
@@ -16,8 +16,8 @@ export class Plan {
|
|
|
16
16
|
* @returns {Promise<PlanResponse | BadRequest>}
|
|
17
17
|
*/
|
|
18
18
|
async create(data) {
|
|
19
|
-
const response = await this.http.post('/plan',
|
|
20
|
-
return
|
|
19
|
+
const response = await this.http.post('/plan', data);
|
|
20
|
+
return response.data;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* ### List Plans
|
|
@@ -16,7 +16,7 @@ export interface InitializeTransaction {
|
|
|
16
16
|
*/
|
|
17
17
|
currency?: string;
|
|
18
18
|
/**
|
|
19
|
-
* Unique transaction reference. Only
|
|
19
|
+
* Unique transaction reference. Only `-`,`.`,`=`
|
|
20
20
|
* and alphanumeric characters allowed
|
|
21
21
|
*/
|
|
22
22
|
reference?: string;
|
|
@@ -75,7 +75,7 @@ export interface InitializeTransaction {
|
|
|
75
75
|
export interface TransactionResponse {
|
|
76
76
|
status: boolean;
|
|
77
77
|
message: string;
|
|
78
|
-
data: TransactionInitializedOk | TransactionData | Transactions;
|
|
78
|
+
data: TransactionInitializedOk | TransactionData | Transactions | Timeline | ExportTransaction;
|
|
79
79
|
meta?: Meta;
|
|
80
80
|
}
|
|
81
81
|
interface TransactionInitializedOk {
|
|
@@ -118,6 +118,26 @@ interface TransactionData {
|
|
|
118
118
|
}
|
|
119
119
|
interface Transactions extends TransactionData {
|
|
120
120
|
}
|
|
121
|
+
interface Timeline {
|
|
122
|
+
time_spent: number;
|
|
123
|
+
attempts: number;
|
|
124
|
+
authentication: any;
|
|
125
|
+
errors: number;
|
|
126
|
+
success: boolean;
|
|
127
|
+
mobile: boolean;
|
|
128
|
+
input: [];
|
|
129
|
+
channel: string;
|
|
130
|
+
history: [
|
|
131
|
+
{
|
|
132
|
+
type: string;
|
|
133
|
+
message: string;
|
|
134
|
+
time: number;
|
|
135
|
+
}
|
|
136
|
+
];
|
|
137
|
+
}
|
|
138
|
+
interface ExportTransaction {
|
|
139
|
+
path: string;
|
|
140
|
+
}
|
|
121
141
|
export interface ListTransactionQueryParams {
|
|
122
142
|
/**
|
|
123
143
|
* Specify how many records you want to retrieve per page.
|
|
@@ -142,19 +162,19 @@ export interface ListTransactionQueryParams {
|
|
|
142
162
|
* A timestamp from which to start listing transaction
|
|
143
163
|
* e.g `2021-10-25T00.00.05.000z`, `2021-12-25`
|
|
144
164
|
*/
|
|
145
|
-
from
|
|
165
|
+
from?: Date;
|
|
146
166
|
/**
|
|
147
167
|
* A timestamp from which to stop listing transaction
|
|
148
168
|
* e.g `2021-10-25T00.00.05.000z`, `2021-12-25`
|
|
149
169
|
*/
|
|
150
|
-
to
|
|
170
|
+
to?: Date;
|
|
151
171
|
/**
|
|
152
172
|
* Filter transactions by amount.
|
|
153
173
|
* Specify the amount (in **kobo** if currency is `NGN`,
|
|
154
174
|
* **pesewas**, if currency is `GHS`,
|
|
155
175
|
* and **cents**, if currency is `ZAR`)
|
|
156
176
|
*/
|
|
157
|
-
amount
|
|
177
|
+
amount?: number;
|
|
158
178
|
}
|
|
159
179
|
export interface Meta {
|
|
160
180
|
total: number;
|
|
@@ -163,4 +183,113 @@ export interface Meta {
|
|
|
163
183
|
page: number;
|
|
164
184
|
pageCount: number;
|
|
165
185
|
}
|
|
186
|
+
export interface ChargeAuthorization {
|
|
187
|
+
/**
|
|
188
|
+
* Amount should be in kobo if currency is `NGN`, *pesewas*,
|
|
189
|
+
* if currency is `GHS`, and cents, if currency is `ZAR`
|
|
190
|
+
*/
|
|
191
|
+
amount: string;
|
|
192
|
+
/**
|
|
193
|
+
* Customer's email address
|
|
194
|
+
*/
|
|
195
|
+
email: string;
|
|
196
|
+
/**
|
|
197
|
+
* Valid authorization code to charge
|
|
198
|
+
*/
|
|
199
|
+
authorization_code: string;
|
|
200
|
+
/**
|
|
201
|
+
* Unique transaction reference. Only `-`, `.`,`=`
|
|
202
|
+
* and alphanumeric characters allowed
|
|
203
|
+
*/
|
|
204
|
+
reference?: string;
|
|
205
|
+
/**
|
|
206
|
+
* Currency in which amount shoud be charged.
|
|
207
|
+
* Allowed values are: NGN,GHS,ZAR or USD
|
|
208
|
+
*/
|
|
209
|
+
currency?: string;
|
|
210
|
+
/**
|
|
211
|
+
* Stringified JSON object. Add a custom_fields attribute which has
|
|
212
|
+
* an array of objects if you would like the fields to be added to your
|
|
213
|
+
* transaction when displayed on the dashboard.
|
|
214
|
+
* @example {
|
|
215
|
+
* "custom_fields": [{"display_name": "Cart ID","variable_name": "cart_id","value": "8393"}]}
|
|
216
|
+
*/
|
|
217
|
+
metadata?: Record<string, unknown>;
|
|
218
|
+
/**
|
|
219
|
+
* Send us 'card' or 'bank' or 'card','bank' as an array to specify what
|
|
220
|
+
* options to show the user paying
|
|
221
|
+
*/
|
|
222
|
+
channels?: string[];
|
|
223
|
+
/**
|
|
224
|
+
* The code for the subaccount that owns the payment.
|
|
225
|
+
* @exmple ACCT_8f4s1eq7ml6rlzj
|
|
226
|
+
*/
|
|
227
|
+
subaccount?: string;
|
|
228
|
+
/**
|
|
229
|
+
* A flat fee to charge the subaccount for this transaction (in kobo if currency is NGN,
|
|
230
|
+
* pesewas, if currency is GHS, and cents, if currency is ZAR). This overrides the split percentage
|
|
231
|
+
* set when the subaccount was created. Ideally, you will need to use this if you are splitting in
|
|
232
|
+
* flat rates (since subaccount creation only allows for
|
|
233
|
+
*/
|
|
234
|
+
transaction_charge?: number;
|
|
235
|
+
/**
|
|
236
|
+
* Who bears Paystack charges? `account` or `subaccount` (defaults to `account`).
|
|
237
|
+
*/
|
|
238
|
+
bearer?: string;
|
|
239
|
+
/**
|
|
240
|
+
* If you are making a scheduled charge call, it is a good idea to queue them so the processing
|
|
241
|
+
* system does not get overloaded causing transaction processing errors. Send queue:true
|
|
242
|
+
* to take advantage of our queued charging.
|
|
243
|
+
*/
|
|
244
|
+
queue?: boolean;
|
|
245
|
+
}
|
|
246
|
+
export interface CheckAuthorization {
|
|
247
|
+
/**
|
|
248
|
+
* Amount should be in kobo if currency is `NGN`,
|
|
249
|
+
* pesewas, if currency is `GHS`, and cents, if currency is `ZAR`
|
|
250
|
+
*/
|
|
251
|
+
amount: string;
|
|
252
|
+
/**
|
|
253
|
+
* Customer's email address
|
|
254
|
+
*/
|
|
255
|
+
email: string;
|
|
256
|
+
/**
|
|
257
|
+
* Valid authorization code to charge
|
|
258
|
+
*/
|
|
259
|
+
authorization_code: string;
|
|
260
|
+
/**
|
|
261
|
+
* Currency in which amount should be charged.
|
|
262
|
+
* Allowed values are: `NGN`, `GHS`, `ZAR` or `USD`
|
|
263
|
+
*/
|
|
264
|
+
currency?: string;
|
|
265
|
+
}
|
|
266
|
+
export interface PartialDebit {
|
|
267
|
+
/**
|
|
268
|
+
* Authorization Code
|
|
269
|
+
*/
|
|
270
|
+
authorization_code: string;
|
|
271
|
+
/**
|
|
272
|
+
* Specify the currency you want to debit.
|
|
273
|
+
* Allowed values are `NGN`, `GHS`, `ZAR` or `USD`.
|
|
274
|
+
*/
|
|
275
|
+
currency: string;
|
|
276
|
+
/**
|
|
277
|
+
* Amount should be in *kobo* if currency is NGN,
|
|
278
|
+
* pesewas, if *currency* is `GHS`, and *cents*, if currency is `ZAR`
|
|
279
|
+
*/
|
|
280
|
+
amount: string;
|
|
281
|
+
/**
|
|
282
|
+
* Customer's email address (attached to the authorization code)
|
|
283
|
+
*/
|
|
284
|
+
email: string;
|
|
285
|
+
/**
|
|
286
|
+
* Unique transaction reference.
|
|
287
|
+
* Only `-`, `.`, `=` and alphanumeric characters allowed.
|
|
288
|
+
*/
|
|
289
|
+
reference: string;
|
|
290
|
+
/**
|
|
291
|
+
* Minimum amount to charge
|
|
292
|
+
*/
|
|
293
|
+
at_least: string;
|
|
294
|
+
}
|
|
166
295
|
export {};
|
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
import { Axios } from 'axios';
|
|
2
|
-
import { InitializeTransaction, ListTransactionQueryParams, TransactionResponse } from './interface';
|
|
2
|
+
import { ChargeAuthorization, CheckAuthorization, InitializeTransaction, ListTransactionQueryParams, PartialDebit, TransactionResponse } from './interface';
|
|
3
3
|
interface BadRequest {
|
|
4
4
|
status: boolean;
|
|
5
5
|
message: string;
|
|
6
6
|
data: null;
|
|
7
7
|
}
|
|
8
|
-
export interface ITransaction {
|
|
9
|
-
initialize(data: InitializeTransaction): Promise<TransactionResponse | BadRequest>;
|
|
10
|
-
verify(reference: string): Promise<TransactionResponse | BadRequest>;
|
|
11
|
-
list(queryParams: ListTransactionQueryParams): Promise<TransactionResponse | BadRequest>;
|
|
12
|
-
}
|
|
13
8
|
/**
|
|
14
|
-
*
|
|
9
|
+
* # Tansactions
|
|
15
10
|
* The transaction API allows you create and manage
|
|
16
11
|
* payments on your integration
|
|
17
12
|
*/
|
|
18
|
-
export declare class Transaction
|
|
13
|
+
export declare class Transaction {
|
|
19
14
|
private http;
|
|
20
15
|
constructor(http: Axios);
|
|
21
16
|
/**
|
|
@@ -25,5 +20,12 @@ export declare class Transaction implements ITransaction {
|
|
|
25
20
|
initialize(data: InitializeTransaction): Promise<TransactionResponse | BadRequest>;
|
|
26
21
|
verify(reference: string): Promise<TransactionResponse | BadRequest>;
|
|
27
22
|
list(queryParams: ListTransactionQueryParams): Promise<TransactionResponse | BadRequest>;
|
|
23
|
+
fetch(id: string): Promise<TransactionResponse | BadRequest>;
|
|
24
|
+
chargeAuthorization(data: ChargeAuthorization): Promise<TransactionResponse | BadRequest>;
|
|
25
|
+
checkAuthorization(data: CheckAuthorization): Promise<TransactionResponse | BadRequest>;
|
|
26
|
+
viewTimeline(id: string): Promise<TransactionResponse | BadRequest>;
|
|
27
|
+
totals(queryParams: ListTransactionQueryParams): Promise<TransactionResponse | BadRequest>;
|
|
28
|
+
export(queryParams: ListTransactionQueryParams): Promise<TransactionResponse | BadRequest>;
|
|
29
|
+
partialDebit(data: PartialDebit): Promise<TransactionResponse | BadRequest>;
|
|
28
30
|
}
|
|
29
31
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* # Tansactions
|
|
3
3
|
* The transaction API allows you create and manage
|
|
4
4
|
* payments on your integration
|
|
5
5
|
*/
|
|
@@ -28,4 +28,36 @@ export class Transaction {
|
|
|
28
28
|
});
|
|
29
29
|
return JSON.parse(response.data);
|
|
30
30
|
}
|
|
31
|
+
async fetch(id) {
|
|
32
|
+
const response = await this.http.get(`/transaction/:${id}`);
|
|
33
|
+
return JSON.parse(response.data);
|
|
34
|
+
}
|
|
35
|
+
async chargeAuthorization(data) {
|
|
36
|
+
const response = await this.http.post('/transaction/charge_authorization', JSON.stringify(data));
|
|
37
|
+
return JSON.parse(response.data);
|
|
38
|
+
}
|
|
39
|
+
async checkAuthorization(data) {
|
|
40
|
+
const response = await this.http.post('/transaction/check_authorization', JSON.stringify(data));
|
|
41
|
+
return JSON.parse(response.data);
|
|
42
|
+
}
|
|
43
|
+
async viewTimeline(id) {
|
|
44
|
+
const response = await this.http.get(`/transaction/timeline/${id}`);
|
|
45
|
+
return JSON.parse(response.data);
|
|
46
|
+
}
|
|
47
|
+
async totals(queryParams) {
|
|
48
|
+
const response = await this.http.get('/transaction/totals', {
|
|
49
|
+
params: { ...queryParams },
|
|
50
|
+
});
|
|
51
|
+
return JSON.parse(response.data);
|
|
52
|
+
}
|
|
53
|
+
async export(queryParams) {
|
|
54
|
+
const response = await this.http.get('/transaction/export', {
|
|
55
|
+
params: { ...queryParams },
|
|
56
|
+
});
|
|
57
|
+
return JSON.parse(response.data);
|
|
58
|
+
}
|
|
59
|
+
async partialDebit(data) {
|
|
60
|
+
const response = await this.http.post('/transaction/partial_debit', JSON.stringify(data));
|
|
61
|
+
return JSON.parse(response.data);
|
|
62
|
+
}
|
|
31
63
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "paystack-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"description": "Paystack SDK written in Typescript",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"author": "Koderant",
|
|
@@ -40,6 +40,5 @@
|
|
|
40
40
|
"repository": {
|
|
41
41
|
"type": "git",
|
|
42
42
|
"url": "git+https://github.com/en1tan/paystack-node.git"
|
|
43
|
-
}
|
|
44
|
-
"type": "module"
|
|
43
|
+
}
|
|
45
44
|
}
|