paystack-sdk 1.0.15 → 1.0.19
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/README.md +8 -1
- package/dist/charge/charge.d.ts +8 -18
- package/dist/charge/charge.js +7 -14
- package/dist/charge/interface.d.ts +104 -76
- package/dist/customer/customer.d.ts +60 -0
- package/dist/customer/customer.js +96 -0
- package/dist/customer/index.d.ts +2 -0
- package/dist/customer/index.js +14 -0
- package/dist/customer/interface.d.ts +215 -0
- package/dist/customer/interface.js +13 -0
- package/dist/interface.d.ts +7 -0
- package/dist/interface.js +2 -0
- package/dist/paystack.d.ts +10 -2
- package/dist/paystack.js +12 -2
- package/dist/plan/interface.d.ts +26 -28
- package/dist/plan/plan.js +2 -2
- package/dist/product/index.d.ts +0 -0
- package/dist/product/index.js +1 -0
- package/dist/product/interface.d.ts +87 -0
- package/dist/product/interface.js +2 -0
- package/dist/product/product.d.ts +21 -0
- package/dist/product/product.js +46 -0
- package/dist/subscription/index.d.ts +1 -0
- package/dist/subscription/index.js +13 -0
- package/dist/subscription/interface.d.ts +118 -0
- package/dist/subscription/interface.js +2 -0
- package/dist/subscription/subscription.d.ts +18 -0
- package/dist/subscription/subscription.js +54 -0
- package/dist/transaction/interface.d.ts +75 -61
- package/dist/transaction/interface.js +0 -1
- package/dist/transaction/transaction.d.ts +12 -11
- package/dist/transaction/transaction.js +10 -13
- package/dist/transfer/interface.d.ts +105 -0
- package/dist/transfer/interface.js +2 -0
- package/dist/transfer/transfer.d.ts +26 -0
- package/dist/transfer/transfer.js +59 -0
- package/package.json +15 -12
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { Authorization } from '../charge';
|
|
2
|
+
import { ICustomer } from '../customer';
|
|
3
|
+
import { Meta } from '../interface';
|
|
4
|
+
import { IPlan } from '../plan';
|
|
5
|
+
export interface CreateSubscription {
|
|
6
|
+
/**
|
|
7
|
+
* Customer's email address or customer code
|
|
8
|
+
*/
|
|
9
|
+
customer: string;
|
|
10
|
+
/**
|
|
11
|
+
* Plan code
|
|
12
|
+
*/
|
|
13
|
+
plan: string;
|
|
14
|
+
/**
|
|
15
|
+
* If customer has multiple authorizations, you can set the desired
|
|
16
|
+
* authorization you wish to use for this subscription here.
|
|
17
|
+
* If this is not supplied, the customer's most recent authorization would be used
|
|
18
|
+
*/
|
|
19
|
+
authorization?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Set the date for the first debit. (ISO 8601 format)
|
|
22
|
+
* e.g `2022-01-01T00:00:00+01:00`
|
|
23
|
+
*/
|
|
24
|
+
start_date?: Date;
|
|
25
|
+
}
|
|
26
|
+
export interface Response {
|
|
27
|
+
status: boolean;
|
|
28
|
+
message: string;
|
|
29
|
+
}
|
|
30
|
+
export interface SubscriptionCreated extends Response {
|
|
31
|
+
data: {
|
|
32
|
+
customer: number;
|
|
33
|
+
plan: number;
|
|
34
|
+
integration: number;
|
|
35
|
+
domain: string;
|
|
36
|
+
start: number;
|
|
37
|
+
status: string;
|
|
38
|
+
quantity: number;
|
|
39
|
+
amount: number;
|
|
40
|
+
authorization: Authorization;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export interface ListSubscriptions extends Response {
|
|
44
|
+
data: Subscription[];
|
|
45
|
+
meta: Meta;
|
|
46
|
+
}
|
|
47
|
+
export interface FetchSubscription extends Response {
|
|
48
|
+
data: {
|
|
49
|
+
invoices: unknown[];
|
|
50
|
+
customer: ICustomer;
|
|
51
|
+
plan: IPlan;
|
|
52
|
+
integration: number;
|
|
53
|
+
authorization: Authorization;
|
|
54
|
+
domain: string;
|
|
55
|
+
start: number;
|
|
56
|
+
status: string;
|
|
57
|
+
quantity: number;
|
|
58
|
+
amount: number;
|
|
59
|
+
subscription_code: string;
|
|
60
|
+
email_token: string;
|
|
61
|
+
easy_cron_id: string;
|
|
62
|
+
cron_expression: string;
|
|
63
|
+
next_payment_date: Date;
|
|
64
|
+
open_invoice: string;
|
|
65
|
+
id: number;
|
|
66
|
+
createdAt: Date;
|
|
67
|
+
updatedAt: Date;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export interface GenerateSubscriptionLink extends Response {
|
|
71
|
+
data: {
|
|
72
|
+
link: string;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
export interface EnableOrDisableSubscription {
|
|
76
|
+
code: string;
|
|
77
|
+
token: string;
|
|
78
|
+
}
|
|
79
|
+
export interface Subscription {
|
|
80
|
+
customer: ICustomer;
|
|
81
|
+
plan: IPlan;
|
|
82
|
+
integration: number;
|
|
83
|
+
authorization: Authorization;
|
|
84
|
+
domain: string;
|
|
85
|
+
start: number;
|
|
86
|
+
status: string;
|
|
87
|
+
quantity: number;
|
|
88
|
+
amount: number;
|
|
89
|
+
subscription_code: string;
|
|
90
|
+
email_token: string;
|
|
91
|
+
easy_cron_id: string;
|
|
92
|
+
cron_expression: string;
|
|
93
|
+
next_payment_date: Date;
|
|
94
|
+
open_invoice: string;
|
|
95
|
+
id: number;
|
|
96
|
+
createdAt: Date;
|
|
97
|
+
updatedAt: Date;
|
|
98
|
+
}
|
|
99
|
+
export interface ListSubscriptionQueryParams {
|
|
100
|
+
/**
|
|
101
|
+
* Specify how many records you want to retrieve per page.
|
|
102
|
+
* If not specify we use a default value of 50.
|
|
103
|
+
*/
|
|
104
|
+
perPage?: number;
|
|
105
|
+
/**
|
|
106
|
+
* Specify exactly what page you want to retrieve.
|
|
107
|
+
* If not specify we use a default value of 1.
|
|
108
|
+
*/
|
|
109
|
+
page?: number;
|
|
110
|
+
/**
|
|
111
|
+
* Filter by Customer ID
|
|
112
|
+
*/
|
|
113
|
+
customer?: number;
|
|
114
|
+
/**
|
|
115
|
+
* Filter by Plan ID
|
|
116
|
+
*/
|
|
117
|
+
plan?: number;
|
|
118
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Axios } from 'axios';
|
|
2
|
+
import { CreateSubscription, EnableOrDisableSubscription, FetchSubscription, GenerateSubscriptionLink, ListSubscriptionQueryParams, ListSubscriptions, Response, SubscriptionCreated } from './interface';
|
|
3
|
+
interface BadRequest {
|
|
4
|
+
status: boolean;
|
|
5
|
+
message: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class Subscription {
|
|
8
|
+
http: Axios;
|
|
9
|
+
constructor(http: Axios);
|
|
10
|
+
create(data: CreateSubscription): Promise<SubscriptionCreated | BadRequest>;
|
|
11
|
+
list(queryParams?: ListSubscriptionQueryParams): Promise<ListSubscriptions | BadRequest>;
|
|
12
|
+
fetch(idOrCode: string): Promise<FetchSubscription | BadRequest>;
|
|
13
|
+
enable(data: EnableOrDisableSubscription): Promise<Response | BadRequest>;
|
|
14
|
+
disable(data: EnableOrDisableSubscription): Promise<Response | BadRequest>;
|
|
15
|
+
generateSubscriptionLink(code: string): Promise<GenerateSubscriptionLink | BadRequest>;
|
|
16
|
+
sendUpdateSubscriptionLink(code: string): Promise<Response | BadRequest>;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Subscription = void 0;
|
|
13
|
+
class Subscription {
|
|
14
|
+
constructor(http) {
|
|
15
|
+
this.http = http;
|
|
16
|
+
}
|
|
17
|
+
create(data) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const response = yield this.http.post('/subscription', JSON.stringify(data));
|
|
20
|
+
return response;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
list(queryParams) {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
return yield this.http.get('/subscription', { params: Object.assign({}, queryParams) });
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
fetch(idOrCode) {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
return yield this.http.get(`/subscription/${idOrCode}`);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
enable(data) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
return yield this.http.post('/subscription/enable', JSON.stringify(data));
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
disable(data) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
return yield this.http.post('/subscription/disable', JSON.stringify(data));
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
generateSubscriptionLink(code) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
return yield this.http.get(`/subscription/${code}/manage/link`);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
sendUpdateSubscriptionLink(code) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
return yield this.http.post(`/subscription/${code}/manage/email`);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.Subscription = Subscription;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Authorization, Customer } from '../charge';
|
|
2
|
+
import { Meta } from '../interface';
|
|
2
3
|
export interface InitializeTransaction {
|
|
3
4
|
/**
|
|
4
5
|
* Amount should be in **kobo** if currency
|
|
@@ -72,71 +73,83 @@ export interface InitializeTransaction {
|
|
|
72
73
|
*/
|
|
73
74
|
bearer?: string;
|
|
74
75
|
}
|
|
75
|
-
export interface
|
|
76
|
+
export interface Response {
|
|
76
77
|
status: boolean;
|
|
77
78
|
message: string;
|
|
78
|
-
data: TransactionInitializedOk | TransactionData | Transactions | Timeline | ExportTransaction;
|
|
79
|
-
meta?: Meta;
|
|
80
79
|
}
|
|
81
|
-
interface
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
export interface TransactionInitialized extends Response {
|
|
81
|
+
data: {
|
|
82
|
+
authorization_url: string;
|
|
83
|
+
access_code: string;
|
|
84
|
+
reference: string;
|
|
85
|
+
};
|
|
85
86
|
}
|
|
86
|
-
interface TransactionData {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
87
|
+
export interface TransactionData extends Response {
|
|
88
|
+
data: {
|
|
89
|
+
amount: number;
|
|
90
|
+
currency: string;
|
|
91
|
+
transaction_date: Date;
|
|
92
|
+
status: string;
|
|
93
|
+
reference: string;
|
|
94
|
+
domain: string;
|
|
95
|
+
metadata: number;
|
|
96
|
+
gateway_response: string;
|
|
97
|
+
message?: string;
|
|
98
|
+
channel: string;
|
|
99
|
+
ip_address: string;
|
|
100
|
+
log: [
|
|
101
|
+
{
|
|
102
|
+
time_spent: number;
|
|
103
|
+
attempt: number;
|
|
104
|
+
authentication: any;
|
|
105
|
+
errors: number;
|
|
106
|
+
success: boolean;
|
|
107
|
+
mobile: boolean;
|
|
108
|
+
input: [];
|
|
109
|
+
channel: string;
|
|
110
|
+
history: [
|
|
111
|
+
{
|
|
112
|
+
type: string;
|
|
113
|
+
message: string;
|
|
114
|
+
time: number;
|
|
115
|
+
}
|
|
116
|
+
];
|
|
117
|
+
}
|
|
118
|
+
];
|
|
119
|
+
fees: number;
|
|
120
|
+
authorization: Authorization;
|
|
121
|
+
customer: Customer;
|
|
122
|
+
pin: string;
|
|
123
|
+
required_amount: number;
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
export interface ListTransactions extends Response {
|
|
127
|
+
data: TransactionData[];
|
|
128
|
+
meta: Meta;
|
|
129
|
+
}
|
|
130
|
+
export interface Timeline extends Response {
|
|
131
|
+
data: {
|
|
99
132
|
time_spent: number;
|
|
100
|
-
|
|
133
|
+
attempts: number;
|
|
101
134
|
authentication: any;
|
|
102
135
|
errors: number;
|
|
103
136
|
success: boolean;
|
|
104
137
|
mobile: boolean;
|
|
105
138
|
input: [];
|
|
106
|
-
channel:
|
|
107
|
-
history:
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
139
|
+
channel: string;
|
|
140
|
+
history: [
|
|
141
|
+
{
|
|
142
|
+
type: string;
|
|
143
|
+
message: string;
|
|
144
|
+
time: number;
|
|
145
|
+
}
|
|
146
|
+
];
|
|
112
147
|
};
|
|
113
|
-
fees: any;
|
|
114
|
-
authorization: Authorization;
|
|
115
|
-
customer: Customer;
|
|
116
|
-
pin: string;
|
|
117
|
-
required_amount: number;
|
|
118
148
|
}
|
|
119
|
-
interface
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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;
|
|
149
|
+
export interface ExportTransaction extends Response {
|
|
150
|
+
data: {
|
|
151
|
+
path: string;
|
|
152
|
+
};
|
|
140
153
|
}
|
|
141
154
|
export interface ListTransactionQueryParams {
|
|
142
155
|
/**
|
|
@@ -176,13 +189,6 @@ export interface ListTransactionQueryParams {
|
|
|
176
189
|
*/
|
|
177
190
|
amount?: number;
|
|
178
191
|
}
|
|
179
|
-
export interface Meta {
|
|
180
|
-
total: number;
|
|
181
|
-
skipped: number;
|
|
182
|
-
perPage: number;
|
|
183
|
-
page: number;
|
|
184
|
-
pageCount: number;
|
|
185
|
-
}
|
|
186
192
|
export interface ChargeAuthorization {
|
|
187
193
|
/**
|
|
188
194
|
* Amount should be in kobo if currency is `NGN`, *pesewas*,
|
|
@@ -292,4 +298,12 @@ export interface PartialDebit {
|
|
|
292
298
|
*/
|
|
293
299
|
at_least: string;
|
|
294
300
|
}
|
|
295
|
-
export {
|
|
301
|
+
export interface PartialDebitResponse extends Response {
|
|
302
|
+
data: Record<string, any>;
|
|
303
|
+
}
|
|
304
|
+
export interface CheckAuthorizationResponse extends Response {
|
|
305
|
+
data: {
|
|
306
|
+
amount: string;
|
|
307
|
+
currency: string;
|
|
308
|
+
};
|
|
309
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Axios } from 'axios';
|
|
2
|
-
import {
|
|
2
|
+
import { CheckAuthorizationResponse, ExportTransaction, ListTransactions, PartialDebitResponse, Timeline, TransactionData } from '.';
|
|
3
|
+
import { ChargeAuthorization, CheckAuthorization, InitializeTransaction, ListTransactionQueryParams, PartialDebit, TransactionInitialized } from './interface';
|
|
3
4
|
interface BadRequest {
|
|
4
5
|
status: boolean;
|
|
5
6
|
message: string;
|
|
@@ -17,15 +18,15 @@ export declare class Transaction {
|
|
|
17
18
|
* Initialize a transaction
|
|
18
19
|
* @param {InitializeTransaction} data **Body Param**
|
|
19
20
|
*/
|
|
20
|
-
initialize(data: InitializeTransaction): Promise<
|
|
21
|
-
verify(reference: string): Promise<
|
|
22
|
-
list(queryParams
|
|
23
|
-
fetch(id: string): Promise<
|
|
24
|
-
chargeAuthorization(data: ChargeAuthorization): Promise<
|
|
25
|
-
checkAuthorization(data: CheckAuthorization): Promise<
|
|
26
|
-
viewTimeline(id: string): Promise<
|
|
27
|
-
|
|
28
|
-
export(queryParams: ListTransactionQueryParams): Promise<
|
|
29
|
-
partialDebit(data: PartialDebit): Promise<
|
|
21
|
+
initialize(data: InitializeTransaction): Promise<TransactionInitialized | BadRequest>;
|
|
22
|
+
verify(reference: string): Promise<TransactionData | BadRequest>;
|
|
23
|
+
list(queryParams?: ListTransactionQueryParams): Promise<ListTransactions | BadRequest>;
|
|
24
|
+
fetch(id: string): Promise<TransactionData | BadRequest>;
|
|
25
|
+
chargeAuthorization(data: ChargeAuthorization): Promise<TransactionData | BadRequest>;
|
|
26
|
+
checkAuthorization(data: CheckAuthorization): Promise<CheckAuthorizationResponse | BadRequest>;
|
|
27
|
+
viewTimeline(id: string): Promise<Timeline | BadRequest>;
|
|
28
|
+
total(queryParams: ListTransactionQueryParams): Promise<ListTransactions | BadRequest>;
|
|
29
|
+
export(queryParams: ListTransactionQueryParams): Promise<ExportTransaction | BadRequest>;
|
|
30
|
+
partialDebit(data: PartialDebit): Promise<PartialDebitResponse | BadRequest>;
|
|
30
31
|
}
|
|
31
32
|
export {};
|
|
@@ -26,7 +26,7 @@ class Transaction {
|
|
|
26
26
|
initialize(data) {
|
|
27
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
28
|
const response = yield this.http.post('/transaction/initialize', JSON.stringify(data));
|
|
29
|
-
return
|
|
29
|
+
return response;
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
verify(reference) {
|
|
@@ -34,7 +34,7 @@ class Transaction {
|
|
|
34
34
|
const response = yield this.http.get('/transaction/verify', {
|
|
35
35
|
params: { reference },
|
|
36
36
|
});
|
|
37
|
-
return
|
|
37
|
+
return response;
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
list(queryParams) {
|
|
@@ -42,47 +42,44 @@ class Transaction {
|
|
|
42
42
|
const response = yield this.http.get('/transaction', {
|
|
43
43
|
params: Object.assign({}, queryParams),
|
|
44
44
|
});
|
|
45
|
-
return
|
|
45
|
+
return response;
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
fetch(id) {
|
|
49
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
50
50
|
const response = yield this.http.get(`/transaction/:${id}`);
|
|
51
|
-
return
|
|
51
|
+
return response;
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
chargeAuthorization(data) {
|
|
55
55
|
return __awaiter(this, void 0, void 0, function* () {
|
|
56
56
|
const response = yield this.http.post('/transaction/charge_authorization', JSON.stringify(data));
|
|
57
|
-
return
|
|
57
|
+
return response;
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
60
|
checkAuthorization(data) {
|
|
61
61
|
return __awaiter(this, void 0, void 0, function* () {
|
|
62
62
|
const response = yield this.http.post('/transaction/check_authorization', JSON.stringify(data));
|
|
63
|
-
return
|
|
63
|
+
return response;
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
66
|
viewTimeline(id) {
|
|
67
67
|
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
|
|
69
|
-
return JSON.parse(response.data);
|
|
68
|
+
return yield this.http.get(`/transaction/timeline/${id}`);
|
|
70
69
|
});
|
|
71
70
|
}
|
|
72
|
-
|
|
71
|
+
total(queryParams) {
|
|
73
72
|
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
-
|
|
73
|
+
return yield this.http.get('/transaction/totals', {
|
|
75
74
|
params: Object.assign({}, queryParams),
|
|
76
75
|
});
|
|
77
|
-
return JSON.parse(response.data);
|
|
78
76
|
});
|
|
79
77
|
}
|
|
80
78
|
export(queryParams) {
|
|
81
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
-
|
|
80
|
+
return yield this.http.get('/transaction/export', {
|
|
83
81
|
params: Object.assign({}, queryParams),
|
|
84
82
|
});
|
|
85
|
-
return JSON.parse(response.data);
|
|
86
83
|
});
|
|
87
84
|
}
|
|
88
85
|
partialDebit(data) {
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
export interface InitiateTransfer {
|
|
2
|
+
/**
|
|
3
|
+
* Where should we transfer from? Only `balance` for now
|
|
4
|
+
*/
|
|
5
|
+
source: string;
|
|
6
|
+
/** Amount to transfer in *kobo* if currency is `NGN`
|
|
7
|
+
* and *pesewas* if currency is `GHS`.
|
|
8
|
+
*/
|
|
9
|
+
amount: number;
|
|
10
|
+
/**
|
|
11
|
+
* Code for transfer recipient
|
|
12
|
+
*/
|
|
13
|
+
recipient: string;
|
|
14
|
+
/**
|
|
15
|
+
* The reason for the transfer
|
|
16
|
+
*/
|
|
17
|
+
reason?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Specify the currency of the transfer. Defaults to NGN
|
|
20
|
+
*/
|
|
21
|
+
currency?: string;
|
|
22
|
+
/** If specified, the field should be a unique identifier (in lowercase)
|
|
23
|
+
* for the object. Only `-`,`_` and alphanumeric characters allowed.
|
|
24
|
+
*/
|
|
25
|
+
reference?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface Response {
|
|
28
|
+
status: boolean;
|
|
29
|
+
message: string;
|
|
30
|
+
}
|
|
31
|
+
export interface FinalizeTransfer extends Response {
|
|
32
|
+
data: Transfer;
|
|
33
|
+
}
|
|
34
|
+
export interface TransferInitiated extends Response {
|
|
35
|
+
data: Transfer;
|
|
36
|
+
}
|
|
37
|
+
export interface InitiateBulkTransfer {
|
|
38
|
+
/**
|
|
39
|
+
* Where should we transfer from? Only `balance` for now
|
|
40
|
+
*/
|
|
41
|
+
source: string;
|
|
42
|
+
/**
|
|
43
|
+
* A list of transfer object. Each object should contain `amount`, `recipient`, and `reference`
|
|
44
|
+
*/
|
|
45
|
+
transfers: {
|
|
46
|
+
amount: number;
|
|
47
|
+
recipient: string;
|
|
48
|
+
reference: string;
|
|
49
|
+
}[];
|
|
50
|
+
}
|
|
51
|
+
export interface BulkTransferInitiated extends Response {
|
|
52
|
+
data: Transfer[];
|
|
53
|
+
}
|
|
54
|
+
export interface ListTransfers extends Response {
|
|
55
|
+
data: Transfer[];
|
|
56
|
+
}
|
|
57
|
+
export interface FetchTransfer extends Response {
|
|
58
|
+
data: Transfer;
|
|
59
|
+
}
|
|
60
|
+
export interface VerifyTransfer extends Response {
|
|
61
|
+
data: Transfer;
|
|
62
|
+
}
|
|
63
|
+
export interface ListTransferQueryParams {
|
|
64
|
+
/**
|
|
65
|
+
* Specify how many records you want to retrieve per page.
|
|
66
|
+
* If not specify we use a default value of 50.
|
|
67
|
+
*/
|
|
68
|
+
perPage?: number;
|
|
69
|
+
/**
|
|
70
|
+
* Specify exactly what page you want to retrieve.
|
|
71
|
+
* If not specify we use a default value of 1.
|
|
72
|
+
*/
|
|
73
|
+
page?: number;
|
|
74
|
+
/**
|
|
75
|
+
* Specify an ID for the customer whose transactions
|
|
76
|
+
* you want to retrieve
|
|
77
|
+
*/
|
|
78
|
+
customer?: number;
|
|
79
|
+
/**
|
|
80
|
+
* A timestamp from which to start listing transaction
|
|
81
|
+
* e.g `2021-10-25T00.00.05.000z`, `2021-12-25`
|
|
82
|
+
*/
|
|
83
|
+
from?: Date;
|
|
84
|
+
/**
|
|
85
|
+
* A timestamp from which to stop listing transaction
|
|
86
|
+
* e.g `2021-10-25T00.00.05.000z`, `2021-12-25`
|
|
87
|
+
*/
|
|
88
|
+
to?: Date;
|
|
89
|
+
}
|
|
90
|
+
interface Transfer {
|
|
91
|
+
integration: number;
|
|
92
|
+
domain: string;
|
|
93
|
+
amount: number;
|
|
94
|
+
source: string;
|
|
95
|
+
source_details: string;
|
|
96
|
+
reason: string;
|
|
97
|
+
recipient: number | string | Record<string, unknown>;
|
|
98
|
+
status: string;
|
|
99
|
+
failures: unknown;
|
|
100
|
+
transfer_code: string;
|
|
101
|
+
id: number;
|
|
102
|
+
createdAt: Date;
|
|
103
|
+
updatedAt: Date;
|
|
104
|
+
}
|
|
105
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Axios } from 'axios';
|
|
2
|
+
import { BulkTransferInitiated, FetchTransfer, FinalizeTransfer, InitiateBulkTransfer, InitiateTransfer, ListTransferQueryParams, ListTransfers, TransferInitiated, VerifyTransfer } from './interface';
|
|
3
|
+
interface BadRequest {
|
|
4
|
+
status: boolean;
|
|
5
|
+
message: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class Transfer {
|
|
8
|
+
http: Axios;
|
|
9
|
+
constructor(http: Axios);
|
|
10
|
+
/**
|
|
11
|
+
* # Initiate Transfer
|
|
12
|
+
* Status of transfer object returned will be `pending` if OTP is disabled.
|
|
13
|
+
* In the event that an OTP is required, status will read `otp`.
|
|
14
|
+
*/
|
|
15
|
+
initiate(data: InitiateTransfer): Promise<TransferInitiated | BadRequest>;
|
|
16
|
+
/**
|
|
17
|
+
* # Finalize Transfer
|
|
18
|
+
* Finalize an initiated transfer
|
|
19
|
+
*/
|
|
20
|
+
finalize(transferCode: string, otp: string): Promise<FinalizeTransfer | BadRequest>;
|
|
21
|
+
bulk(data: InitiateBulkTransfer): Promise<BulkTransferInitiated | BadRequest>;
|
|
22
|
+
list(queryParams?: ListTransferQueryParams): Promise<ListTransfers | BadRequest>;
|
|
23
|
+
fetch(idOrCode: string): Promise<FetchTransfer | BadRequest>;
|
|
24
|
+
verify(reference: string): Promise<VerifyTransfer | BadRequest>;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Transfer = void 0;
|
|
13
|
+
class Transfer {
|
|
14
|
+
constructor(http) {
|
|
15
|
+
this.http = http;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* # Initiate Transfer
|
|
19
|
+
* Status of transfer object returned will be `pending` if OTP is disabled.
|
|
20
|
+
* In the event that an OTP is required, status will read `otp`.
|
|
21
|
+
*/
|
|
22
|
+
initiate(data) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
return yield this.http.post('/transfer', JSON.stringify(data));
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* # Finalize Transfer
|
|
29
|
+
* Finalize an initiated transfer
|
|
30
|
+
*/
|
|
31
|
+
finalize(transferCode, otp) {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
return yield this.http.post('/transfer/finalize_transfer', JSON.stringify({ transfer_code: transferCode, otp }));
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
bulk(data) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
return yield this.http.post('/transfer/bulk', JSON.stringify(data));
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
list(queryParams) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
return yield this.http.get('/transfer', {
|
|
44
|
+
params: Object.assign({}, queryParams),
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
fetch(idOrCode) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
return yield this.http.get(`/transfer/${idOrCode}`);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
verify(reference) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
return yield this.http.get(`transfer/verify/${reference}`);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.Transfer = Transfer;
|