paystack-sdk 1.2.0 → 2.2.0
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 +9 -2
- package/dist/apple/apple.d.ts +10 -0
- package/dist/apple/apple.js +35 -0
- package/dist/apple/interface.d.ts +11 -0
- package/dist/apple/interface.js +2 -0
- package/dist/customer/interface.d.ts +6 -6
- package/dist/dedicated/interface.d.ts +2 -2
- package/dist/interface.d.ts +9 -0
- package/dist/paystack.d.ts +6 -0
- package/dist/paystack.js +7 -1
- package/dist/split/index.d.ts +0 -0
- package/dist/split/index.js +1 -0
- package/dist/split/interface.d.ts +125 -0
- package/dist/split/interface.js +2 -0
- package/dist/split/split.d.ts +37 -0
- package/dist/split/split.js +95 -0
- package/dist/subaccounts/interface.d.ts +106 -0
- package/dist/subaccounts/interface.js +2 -0
- package/dist/subaccounts/subaccount.d.ts +11 -0
- package/dist/subaccounts/subaccount.js +38 -0
- package/dist/transaction/interface.d.ts +41 -39
- package/dist/transaction/transaction.d.ts +4 -4
- package/dist/transfer/interface.d.ts +0 -4
- package/package.json +4 -4
- package/CHANGELOG.md +0 -29
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ For NPM
|
|
|
16
16
|
|
|
17
17
|
For Typescript
|
|
18
18
|
|
|
19
|
-
```
|
|
19
|
+
```typescript
|
|
20
20
|
import {Paystack} from 'paystack-sdk';
|
|
21
21
|
|
|
22
22
|
const paystack = new Paystack("secret_key);
|
|
@@ -24,7 +24,7 @@ const paystack = new Paystack("secret_key);
|
|
|
24
24
|
|
|
25
25
|
For Javscript
|
|
26
26
|
|
|
27
|
-
```
|
|
27
|
+
```javascript
|
|
28
28
|
const Paystack = require('paystack-sdk').Paystack;
|
|
29
29
|
const paystack = new Paystack("secret_key");
|
|
30
30
|
```
|
|
@@ -41,3 +41,10 @@ All methods use promise meaning you can either use the `async...await` or `then.
|
|
|
41
41
|
- Transaction
|
|
42
42
|
- Transfer
|
|
43
43
|
- dedicated (For dedicated accounts)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
## CONTRIBUTING
|
|
47
|
+
If you notice a missing function, or maybe a bug. Please feel free to submit
|
|
48
|
+
a PR. I will take a look at it.
|
|
49
|
+
You will need to fork the repo and create a PR against it with your changes.
|
|
50
|
+
Thank you :heart:
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Axios } from 'axios';
|
|
2
|
+
import { BadRequest } from '../interface';
|
|
3
|
+
import { DomainRegisterResponse, ListDomainsResponse, UnregisterDomainRegisterResponse } from './interface';
|
|
4
|
+
export declare class ApplePay {
|
|
5
|
+
private http;
|
|
6
|
+
constructor(http: Axios);
|
|
7
|
+
registerDomain(domainName: string): Promise<DomainRegisterResponse | BadRequest>;
|
|
8
|
+
listDomains(): Promise<ListDomainsResponse | BadRequest>;
|
|
9
|
+
unregisterDomain(domainName: string): Promise<UnregisterDomainRegisterResponse | BadRequest>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
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.ApplePay = void 0;
|
|
13
|
+
class ApplePay {
|
|
14
|
+
constructor(http) {
|
|
15
|
+
this.http = http;
|
|
16
|
+
}
|
|
17
|
+
registerDomain(domainName) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
return yield this.http.post('/apple-pay/domain', JSON.stringify({ domainName }));
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
listDomains() {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
return yield this.http.get('/apple-pay');
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
unregisterDomain(domainName) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
return yield this.http.delete('/apple-pay', {
|
|
30
|
+
params: { domainName },
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.ApplePay = ApplePay;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface Response {
|
|
2
|
+
status: boolean;
|
|
3
|
+
message: string;
|
|
4
|
+
}
|
|
5
|
+
export declare type DomainRegisterResponse = Response;
|
|
6
|
+
export declare type UnregisterDomainRegisterResponse = Response;
|
|
7
|
+
export interface ListDomainsResponse extends Response {
|
|
8
|
+
data: {
|
|
9
|
+
domainNames: string[];
|
|
10
|
+
};
|
|
11
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Authorization } from '../charge';
|
|
2
2
|
import { Meta } from '../interface';
|
|
3
3
|
import { Subscription } from '../subscription/interface';
|
|
4
|
-
import {
|
|
4
|
+
import { Transaction } from '../transaction';
|
|
5
5
|
export interface CreateCustomer {
|
|
6
6
|
email: string;
|
|
7
7
|
first_name: string;
|
|
8
8
|
last_name: string;
|
|
9
9
|
phone?: string;
|
|
10
|
-
metadata?: Record<string,
|
|
10
|
+
metadata?: Record<string, unknown>;
|
|
11
11
|
}
|
|
12
12
|
export interface Response {
|
|
13
13
|
status: boolean;
|
|
@@ -15,14 +15,14 @@ export interface Response {
|
|
|
15
15
|
}
|
|
16
16
|
export interface CustomerCreated extends Response {
|
|
17
17
|
data: {
|
|
18
|
-
transactions:
|
|
18
|
+
transactions: Transaction[];
|
|
19
19
|
subscriptions: Subscription[];
|
|
20
20
|
authorizations: Authorization[];
|
|
21
21
|
first_name: string;
|
|
22
22
|
last_name: string;
|
|
23
23
|
email: string;
|
|
24
24
|
phone: string | null;
|
|
25
|
-
metadata
|
|
25
|
+
metadata?: Record<string, unknown>;
|
|
26
26
|
domain: string;
|
|
27
27
|
customer_code: string;
|
|
28
28
|
risk_action: string;
|
|
@@ -48,7 +48,7 @@ export interface CustomerData extends Response {
|
|
|
48
48
|
domain: string;
|
|
49
49
|
customer_code: string;
|
|
50
50
|
id: string;
|
|
51
|
-
transactions:
|
|
51
|
+
transactions: Transaction[];
|
|
52
52
|
subscriptions: Subscription[];
|
|
53
53
|
authorizations: Authorization[];
|
|
54
54
|
createdAt: Date;
|
|
@@ -206,7 +206,7 @@ export interface ICustomer {
|
|
|
206
206
|
domain: string;
|
|
207
207
|
customer_code: string;
|
|
208
208
|
id: string;
|
|
209
|
-
transactions:
|
|
209
|
+
transactions: Transaction[];
|
|
210
210
|
subscriptions: Subscription[];
|
|
211
211
|
authorizations: Authorization[];
|
|
212
212
|
createdAt: Date;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Authorization, Customer } from '../charge';
|
|
2
2
|
import { Meta } from '../interface';
|
|
3
3
|
import { Subscription } from '../subscription';
|
|
4
|
-
import { Response,
|
|
4
|
+
import { Response, Transaction } from '../transaction';
|
|
5
5
|
export interface DedicatedAccountData {
|
|
6
6
|
id: number;
|
|
7
7
|
account_name: string;
|
|
@@ -49,7 +49,7 @@ export interface DedicatedAccountCreatedResponse extends Response {
|
|
|
49
49
|
}
|
|
50
50
|
export interface FetchDedicatedVirtualAccountResponse extends Response {
|
|
51
51
|
data: {
|
|
52
|
-
transactions:
|
|
52
|
+
transactions: Transaction[];
|
|
53
53
|
subscriptions: Subscription[];
|
|
54
54
|
authorizations: Authorization[];
|
|
55
55
|
first_name: string;
|
package/dist/interface.d.ts
CHANGED
package/dist/paystack.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { ApplePay } from './apple/apple';
|
|
1
2
|
import { Charge } from './charge';
|
|
2
3
|
import { Customer } from './customer';
|
|
3
4
|
import { DedicatedAccount } from './dedicated/dedicated';
|
|
4
5
|
import { Plan } from './plan';
|
|
5
6
|
import { Product } from './product/product';
|
|
7
|
+
import { TransactionSplit } from './split/split';
|
|
8
|
+
import { SubAccount } from './subaccounts/subaccount';
|
|
6
9
|
import { Subscription } from './subscription/subscription';
|
|
7
10
|
import { Transaction } from './transaction';
|
|
8
11
|
import { Transfer } from './transfer/transfer';
|
|
@@ -21,5 +24,8 @@ export declare class Paystack {
|
|
|
21
24
|
subscription: Subscription;
|
|
22
25
|
transaction: Transaction;
|
|
23
26
|
transfer: Transfer;
|
|
27
|
+
split: TransactionSplit;
|
|
28
|
+
applePay: ApplePay;
|
|
29
|
+
subAccount: SubAccount;
|
|
24
30
|
constructor(key: string);
|
|
25
31
|
}
|
package/dist/paystack.js
CHANGED
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Paystack = void 0;
|
|
4
4
|
const axios_1 = require("axios");
|
|
5
|
+
const apple_1 = require("./apple/apple");
|
|
5
6
|
const charge_1 = require("./charge");
|
|
6
7
|
const customer_1 = require("./customer");
|
|
7
8
|
const dedicated_1 = require("./dedicated/dedicated");
|
|
8
9
|
const plan_1 = require("./plan");
|
|
9
10
|
const product_1 = require("./product/product");
|
|
11
|
+
const split_1 = require("./split/split");
|
|
12
|
+
const subaccount_1 = require("./subaccounts/subaccount");
|
|
10
13
|
const subscription_1 = require("./subscription/subscription");
|
|
11
14
|
const transaction_1 = require("./transaction");
|
|
12
15
|
const transfer_1 = require("./transfer/transfer");
|
|
@@ -27,12 +30,15 @@ class Paystack {
|
|
|
27
30
|
this.http.interceptors.response.use((response) => (response.data = JSON.parse(response.data)));
|
|
28
31
|
this.charge = new charge_1.Charge(this.http);
|
|
29
32
|
this.customer = new customer_1.Customer(this.http);
|
|
33
|
+
this.dedicated = new dedicated_1.DedicatedAccount(this.http);
|
|
30
34
|
this.plan = new plan_1.Plan(this.http);
|
|
31
35
|
this.product = new product_1.Product(this.http);
|
|
36
|
+
this.split = new split_1.TransactionSplit(this.http);
|
|
32
37
|
this.subscription = new subscription_1.Subscription(this.http);
|
|
33
38
|
this.transaction = new transaction_1.Transaction(this.http);
|
|
34
39
|
this.transfer = new transfer_1.Transfer(this.http);
|
|
35
|
-
this.
|
|
40
|
+
this.applePay = new apple_1.ApplePay(this.http);
|
|
41
|
+
this.subAccount = new subaccount_1.SubAccount(this.http);
|
|
36
42
|
}
|
|
37
43
|
}
|
|
38
44
|
exports.Paystack = Paystack;
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { Meta } from '../interface';
|
|
2
|
+
export declare type SplitCurrrencyType = 'GHS' | 'NGN' | 'ZAR' | 'USD';
|
|
3
|
+
export declare type SplitType = 'percentage' | 'flat';
|
|
4
|
+
interface SubAccount {
|
|
5
|
+
id: number;
|
|
6
|
+
subaccount_code: string;
|
|
7
|
+
business_name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
primary_contact_name?: string;
|
|
10
|
+
primary_contact_email?: string;
|
|
11
|
+
primary_contact_phone?: string;
|
|
12
|
+
metadata?: Record<string, unknown>;
|
|
13
|
+
percentage_charge?: number;
|
|
14
|
+
settlement_bank?: string;
|
|
15
|
+
account_number?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface SplitSubAccount {
|
|
18
|
+
/**
|
|
19
|
+
* This is the sub account code
|
|
20
|
+
*/
|
|
21
|
+
subaccount: string;
|
|
22
|
+
share: number;
|
|
23
|
+
}
|
|
24
|
+
export interface CreateSplit {
|
|
25
|
+
/**
|
|
26
|
+
* Name of the transaction split
|
|
27
|
+
*/
|
|
28
|
+
name: string;
|
|
29
|
+
/**
|
|
30
|
+
* The type of transaction split you want to create.
|
|
31
|
+
* You can use one of the following: percentage | flat
|
|
32
|
+
*/
|
|
33
|
+
type: SplitType;
|
|
34
|
+
/**
|
|
35
|
+
* Any of NGN, GHS, ZAR, or USD
|
|
36
|
+
*/
|
|
37
|
+
currency: SplitCurrrencyType;
|
|
38
|
+
/**
|
|
39
|
+
* A list of object containing subaccount code
|
|
40
|
+
* and number of shares: [{subaccount: ‘ACT_xxxxxxxxxx’, share: xxx},{...}]
|
|
41
|
+
*/
|
|
42
|
+
subaccounts: SplitSubAccount[];
|
|
43
|
+
/**
|
|
44
|
+
* Any of subaccount | account | all-proportional | all
|
|
45
|
+
*/
|
|
46
|
+
bearer_type: string;
|
|
47
|
+
/**
|
|
48
|
+
* Subaccount code
|
|
49
|
+
*/
|
|
50
|
+
bearer_subaccount: string;
|
|
51
|
+
}
|
|
52
|
+
export interface ListSplitQueryParams {
|
|
53
|
+
/**
|
|
54
|
+
* The name of the split
|
|
55
|
+
*/
|
|
56
|
+
name?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Any of true or false
|
|
59
|
+
*/
|
|
60
|
+
active?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Sort by name, defaults to createdAt dat
|
|
63
|
+
*/
|
|
64
|
+
sort_by?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Number of splits per page. If not specify we use a default value of 50.
|
|
67
|
+
*/
|
|
68
|
+
perPage?: number;
|
|
69
|
+
/**
|
|
70
|
+
* Page number to view. If not specify we use a default value of 1.
|
|
71
|
+
* @default 1
|
|
72
|
+
*/
|
|
73
|
+
page?: number;
|
|
74
|
+
/**
|
|
75
|
+
* A timestamp from which to start listing splits e.g. 2019-09-24T00:00:05.000Z, 2019-09-21
|
|
76
|
+
*/
|
|
77
|
+
from?: Date;
|
|
78
|
+
/**
|
|
79
|
+
* A timestamp at which to stop listing splits e.g. 2019-09-24T00:00:05.000Z, 2019-09-21
|
|
80
|
+
*/
|
|
81
|
+
to?: Date;
|
|
82
|
+
}
|
|
83
|
+
interface TransactionSplit {
|
|
84
|
+
id: number;
|
|
85
|
+
name: string;
|
|
86
|
+
type: string;
|
|
87
|
+
currency: SplitCurrrencyType;
|
|
88
|
+
integration: number;
|
|
89
|
+
domain: string;
|
|
90
|
+
split_code: string;
|
|
91
|
+
active: boolean;
|
|
92
|
+
bearer_type: string;
|
|
93
|
+
bearer_subaccount: number;
|
|
94
|
+
createdAt: Date;
|
|
95
|
+
updatedAt: Date;
|
|
96
|
+
subaccounts: {
|
|
97
|
+
subaccount: SubAccount;
|
|
98
|
+
share: number;
|
|
99
|
+
}[];
|
|
100
|
+
total_subaccounts?: number;
|
|
101
|
+
}
|
|
102
|
+
export interface UpdateTransactionSplit {
|
|
103
|
+
name: string;
|
|
104
|
+
active: boolean;
|
|
105
|
+
bearer_type?: string;
|
|
106
|
+
bearer_subaccount?: string;
|
|
107
|
+
}
|
|
108
|
+
export interface Response {
|
|
109
|
+
status: boolean;
|
|
110
|
+
message: string;
|
|
111
|
+
}
|
|
112
|
+
export interface SplitCreatedResponse extends Response {
|
|
113
|
+
data: TransactionSplit;
|
|
114
|
+
}
|
|
115
|
+
export interface ListSplitsResponse extends Response {
|
|
116
|
+
data: TransactionSplit[];
|
|
117
|
+
meta: Meta;
|
|
118
|
+
}
|
|
119
|
+
export interface TransactionSplitResponse extends Response {
|
|
120
|
+
data: TransactionSplit;
|
|
121
|
+
}
|
|
122
|
+
export interface UpdateTransactionSplitResponse extends Response {
|
|
123
|
+
data: TransactionSplit;
|
|
124
|
+
}
|
|
125
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Axios } from 'axios';
|
|
2
|
+
import { BadRequest } from '../interface';
|
|
3
|
+
import { CreateSplit, ListSplitQueryParams, ListSplitsResponse, Response, SplitCreatedResponse, SplitSubAccount, TransactionSplitResponse, UpdateTransactionSplit, UpdateTransactionSplitResponse } from './interface';
|
|
4
|
+
/**
|
|
5
|
+
* The Transaction Splits API enables merchants
|
|
6
|
+
* split the settlement for a transaction across
|
|
7
|
+
* their payout account, and one or more Subaccounts.
|
|
8
|
+
*/
|
|
9
|
+
export declare class TransactionSplit {
|
|
10
|
+
private http;
|
|
11
|
+
constructor(http: Axios);
|
|
12
|
+
/**
|
|
13
|
+
* Create a split payment on your integration
|
|
14
|
+
*/
|
|
15
|
+
create(data: CreateSplit): Promise<SplitCreatedResponse | BadRequest>;
|
|
16
|
+
/**
|
|
17
|
+
* List/search for the transaction splits available on your integration.
|
|
18
|
+
*/
|
|
19
|
+
list(queryParams?: ListSplitQueryParams): Promise<ListSplitsResponse | BadRequest>;
|
|
20
|
+
/**
|
|
21
|
+
* Get details of a split on your integration.
|
|
22
|
+
*/
|
|
23
|
+
fetch(splitId: string): Promise<TransactionSplitResponse | BadRequest>;
|
|
24
|
+
/**
|
|
25
|
+
* Update a transaction split details on your integration
|
|
26
|
+
*/
|
|
27
|
+
update(splitId: string, data: UpdateTransactionSplit): Promise<UpdateTransactionSplitResponse | BadRequest>;
|
|
28
|
+
/**
|
|
29
|
+
* Add a Subaccount to a Transaction Split,
|
|
30
|
+
* or update the share of an existing Subaccount in a Transaction Split
|
|
31
|
+
*/
|
|
32
|
+
add(splitId: string, data: SplitSubAccount): Promise<TransactionSplitResponse | BadRequest>;
|
|
33
|
+
/**
|
|
34
|
+
* Remove a subaccount from a transaction split
|
|
35
|
+
*/
|
|
36
|
+
remove(splitId: string, subaccount: string): Promise<Response | BadRequest>;
|
|
37
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
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.TransactionSplit = void 0;
|
|
13
|
+
/**
|
|
14
|
+
* The Transaction Splits API enables merchants
|
|
15
|
+
* split the settlement for a transaction across
|
|
16
|
+
* their payout account, and one or more Subaccounts.
|
|
17
|
+
*/
|
|
18
|
+
class TransactionSplit {
|
|
19
|
+
constructor(http) {
|
|
20
|
+
this.http = http;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Create a split payment on your integration
|
|
24
|
+
*/
|
|
25
|
+
create(data) {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
return yield this.http.request({
|
|
28
|
+
url: '/split',
|
|
29
|
+
data: JSON.stringify(data),
|
|
30
|
+
method: 'post',
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* List/search for the transaction splits available on your integration.
|
|
36
|
+
*/
|
|
37
|
+
list(queryParams) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
return yield this.http.request({
|
|
40
|
+
url: '/split',
|
|
41
|
+
params: Object.assign({}, queryParams),
|
|
42
|
+
method: 'get',
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Get details of a split on your integration.
|
|
48
|
+
*/
|
|
49
|
+
fetch(splitId) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
return yield this.http.request({
|
|
52
|
+
url: `/split/${splitId}`,
|
|
53
|
+
method: 'get',
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Update a transaction split details on your integration
|
|
59
|
+
*/
|
|
60
|
+
update(splitId, data) {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
return yield this.http.request({
|
|
63
|
+
url: `/split/${splitId}`,
|
|
64
|
+
data: JSON.stringify(data),
|
|
65
|
+
method: 'put',
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Add a Subaccount to a Transaction Split,
|
|
71
|
+
* or update the share of an existing Subaccount in a Transaction Split
|
|
72
|
+
*/
|
|
73
|
+
add(splitId, data) {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
return yield this.http.request({
|
|
76
|
+
url: `/split/${splitId}/subaccount/add`,
|
|
77
|
+
data: JSON.stringify(data),
|
|
78
|
+
method: 'post',
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Remove a subaccount from a transaction split
|
|
84
|
+
*/
|
|
85
|
+
remove(splitId, subaccount) {
|
|
86
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
87
|
+
return yield this.http.request({
|
|
88
|
+
url: `/split/${splitId}/subaccount/remove`,
|
|
89
|
+
data: JSON.stringify({ subaccount }),
|
|
90
|
+
method: 'post',
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.TransactionSplit = TransactionSplit;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { Response } from '../interface';
|
|
2
|
+
export interface CreateUpdateSubAccount {
|
|
3
|
+
/**
|
|
4
|
+
* Name of business for subaccount
|
|
5
|
+
*/
|
|
6
|
+
business_name: string;
|
|
7
|
+
/**
|
|
8
|
+
* Bank Code for the bank.
|
|
9
|
+
* You can get the list of Bank Codes by calling the List Banks endpoint.
|
|
10
|
+
*/
|
|
11
|
+
settlement_bank: string;
|
|
12
|
+
/**
|
|
13
|
+
* Bank Account Number
|
|
14
|
+
*/
|
|
15
|
+
account_number: string;
|
|
16
|
+
/**
|
|
17
|
+
* The default percentage charged when
|
|
18
|
+
* receiving on behalf of this subaccount
|
|
19
|
+
*/
|
|
20
|
+
percentage_charge: number;
|
|
21
|
+
/**
|
|
22
|
+
* A description for this subaccount
|
|
23
|
+
*/
|
|
24
|
+
description: string;
|
|
25
|
+
/**
|
|
26
|
+
* A name for the contact person for this subaccoun
|
|
27
|
+
*/
|
|
28
|
+
primary_contact_name?: string;
|
|
29
|
+
/**
|
|
30
|
+
* A contact email for the subaccount
|
|
31
|
+
*/
|
|
32
|
+
primary_contact_email?: string;
|
|
33
|
+
/**
|
|
34
|
+
* A phone number to call for this subaccount
|
|
35
|
+
*/
|
|
36
|
+
primary_contact_phone?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Stringified JSON object.
|
|
39
|
+
* Add a custom_fields attribute which has an
|
|
40
|
+
* array of objects if you would like the
|
|
41
|
+
* fields to be added to your transaction
|
|
42
|
+
* when displayed on the dashboard.
|
|
43
|
+
* Sample:
|
|
44
|
+
* {
|
|
45
|
+
* "custom_fields": [
|
|
46
|
+
* {
|
|
47
|
+
* "display_name":"Cart ID",
|
|
48
|
+
* "variable_name": "cart_id",
|
|
49
|
+
* "value": "8393"
|
|
50
|
+
* }
|
|
51
|
+
* ]
|
|
52
|
+
* }
|
|
53
|
+
*/
|
|
54
|
+
metadata?: string;
|
|
55
|
+
}
|
|
56
|
+
export interface SubAccountQueryParams {
|
|
57
|
+
/**
|
|
58
|
+
* Specify how many records you want to retrieve per page.
|
|
59
|
+
* If not specify we use a default value of 50.
|
|
60
|
+
*/
|
|
61
|
+
perPage?: number;
|
|
62
|
+
/**
|
|
63
|
+
* Specify exactly what page you want to retrieve.
|
|
64
|
+
* If not specify we use a default value of 1.
|
|
65
|
+
*/
|
|
66
|
+
page?: number;
|
|
67
|
+
/**
|
|
68
|
+
* A timestamp from which to start listing subaccounts e.g. 2016-09-24T00:00:05.000Z, 2016-09-21
|
|
69
|
+
*/
|
|
70
|
+
from?: Date;
|
|
71
|
+
/**
|
|
72
|
+
* A timestamp at which to stop listing subaccounts e.g. 2016-09-24T00:00:05.000Z, 2016-09-21
|
|
73
|
+
*/
|
|
74
|
+
to?: Date;
|
|
75
|
+
}
|
|
76
|
+
interface SubAccount {
|
|
77
|
+
integration: number;
|
|
78
|
+
domain: string;
|
|
79
|
+
subaccount_code: string;
|
|
80
|
+
business_name: string;
|
|
81
|
+
description?: string;
|
|
82
|
+
primary_contact_name?: string;
|
|
83
|
+
primary_contact_email?: string;
|
|
84
|
+
primary_contact_phone?: string;
|
|
85
|
+
metadata?: Record<string, unknown>;
|
|
86
|
+
percentage_charge: number;
|
|
87
|
+
is_verified: boolean;
|
|
88
|
+
settlement_bank: string;
|
|
89
|
+
account_number: string;
|
|
90
|
+
settlement_schedule: string;
|
|
91
|
+
active: boolean;
|
|
92
|
+
migrate: boolean;
|
|
93
|
+
id: number;
|
|
94
|
+
createdAt: Date;
|
|
95
|
+
updatedAt: Date;
|
|
96
|
+
}
|
|
97
|
+
export interface SubAccountCreatedUpdateResponse extends Response {
|
|
98
|
+
data: SubAccount;
|
|
99
|
+
}
|
|
100
|
+
export interface ListSubAccountsResponse extends Response {
|
|
101
|
+
data: SubAccount[];
|
|
102
|
+
}
|
|
103
|
+
export interface FetchSubAccountResponse extends Response {
|
|
104
|
+
data: SubAccount;
|
|
105
|
+
}
|
|
106
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Axios } from 'axios';
|
|
2
|
+
import { BadRequest } from '../interface';
|
|
3
|
+
import { CreateUpdateSubAccount, FetchSubAccountResponse, ListSubAccountsResponse, SubAccountCreatedUpdateResponse, SubAccountQueryParams } from './interface';
|
|
4
|
+
export declare class SubAccount {
|
|
5
|
+
private http;
|
|
6
|
+
constructor(http: Axios);
|
|
7
|
+
create(data: CreateUpdateSubAccount): Promise<SubAccountCreatedUpdateResponse | BadRequest>;
|
|
8
|
+
list(queryParams?: SubAccountQueryParams): Promise<ListSubAccountsResponse>;
|
|
9
|
+
fetch(id: string): Promise<FetchSubAccountResponse | BadRequest>;
|
|
10
|
+
update(id: string, data: CreateUpdateSubAccount): Promise<SubAccountCreatedUpdateResponse | BadRequest>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
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.SubAccount = void 0;
|
|
13
|
+
class SubAccount {
|
|
14
|
+
constructor(http) {
|
|
15
|
+
this.http = http;
|
|
16
|
+
}
|
|
17
|
+
create(data) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
return yield this.http.post('/subaccount', JSON.stringify(data));
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
list(queryParams) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
return yield this.http.get('/subaccount', { params: Object.assign({}, queryParams) });
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
fetch(id) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
return yield this.http.get(`/subaccount/${id}`);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
update(id, data) {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
return yield this.http.put(`/subaccount/${id}`, JSON.stringify(data));
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.SubAccount = SubAccount;
|
|
@@ -84,47 +84,48 @@ export interface TransactionInitialized extends Response {
|
|
|
84
84
|
reference: string;
|
|
85
85
|
};
|
|
86
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
|
-
|
|
87
|
+
interface Transaction {
|
|
88
|
+
amount: number;
|
|
89
|
+
currency: string;
|
|
90
|
+
transaction_date: Date;
|
|
91
|
+
status: string;
|
|
92
|
+
reference: string;
|
|
93
|
+
domain: string;
|
|
94
|
+
metadata: number;
|
|
95
|
+
gateway_response: string;
|
|
96
|
+
message?: string;
|
|
97
|
+
channel: string;
|
|
98
|
+
ip_address: string;
|
|
99
|
+
log: [
|
|
100
|
+
{
|
|
101
|
+
time_spent: number;
|
|
102
|
+
attempt: number;
|
|
103
|
+
authentication: any;
|
|
104
|
+
errors: number;
|
|
105
|
+
success: boolean;
|
|
106
|
+
mobile: boolean;
|
|
107
|
+
input: [];
|
|
108
|
+
channel: string;
|
|
109
|
+
history: [
|
|
110
|
+
{
|
|
111
|
+
type: string;
|
|
112
|
+
message: string;
|
|
113
|
+
time: number;
|
|
114
|
+
}
|
|
115
|
+
];
|
|
116
|
+
}
|
|
117
|
+
];
|
|
118
|
+
fees: number;
|
|
119
|
+
authorization: Authorization;
|
|
120
|
+
customer: Customer;
|
|
121
|
+
pin: string;
|
|
122
|
+
required_amount: number;
|
|
123
|
+
}
|
|
124
|
+
export interface GetTransactionResponse extends Response {
|
|
125
|
+
data: Transaction;
|
|
125
126
|
}
|
|
126
127
|
export interface ListTransactions extends Response {
|
|
127
|
-
data:
|
|
128
|
+
data: Transaction[];
|
|
128
129
|
meta: Meta;
|
|
129
130
|
}
|
|
130
131
|
export interface Timeline extends Response {
|
|
@@ -307,3 +308,4 @@ export interface CheckAuthorizationResponse extends Response {
|
|
|
307
308
|
currency: string;
|
|
308
309
|
};
|
|
309
310
|
}
|
|
311
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Axios } from 'axios';
|
|
2
|
-
import { CheckAuthorizationResponse, ExportTransaction, ListTransactions, PartialDebitResponse, Timeline,
|
|
2
|
+
import { CheckAuthorizationResponse, ExportTransaction, ListTransactions, PartialDebitResponse, Timeline, GetTransactionResponse } from './interface';
|
|
3
3
|
import { ChargeAuthorization, CheckAuthorization, InitializeTransaction, ListTransactionQueryParams, PartialDebit, TransactionInitialized } from './interface';
|
|
4
4
|
interface BadRequest {
|
|
5
5
|
status: boolean;
|
|
@@ -19,10 +19,10 @@ export declare class Transaction {
|
|
|
19
19
|
* @param {InitializeTransaction} data **Body Param**
|
|
20
20
|
*/
|
|
21
21
|
initialize(data: InitializeTransaction): Promise<TransactionInitialized | BadRequest>;
|
|
22
|
-
verify(reference: string): Promise<
|
|
22
|
+
verify(reference: string): Promise<GetTransactionResponse | BadRequest>;
|
|
23
23
|
list(queryParams?: ListTransactionQueryParams): Promise<ListTransactions | BadRequest>;
|
|
24
|
-
fetch(id: string): Promise<
|
|
25
|
-
chargeAuthorization(data: ChargeAuthorization): Promise<
|
|
24
|
+
fetch(id: string): Promise<GetTransactionResponse | BadRequest>;
|
|
25
|
+
chargeAuthorization(data: ChargeAuthorization): Promise<GetTransactionResponse | BadRequest>;
|
|
26
26
|
checkAuthorization(data: CheckAuthorization): Promise<CheckAuthorizationResponse | BadRequest>;
|
|
27
27
|
viewTimeline(id: string): Promise<Timeline | BadRequest>;
|
|
28
28
|
total(queryParams: ListTransactionQueryParams): Promise<ListTransactions | BadRequest>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "paystack-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Paystack SDK written in Typescript",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"author": "Tech Priest",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@types/node": "16.11.11",
|
|
21
|
-
"@typescript-eslint/eslint-plugin": "
|
|
22
|
-
"@typescript-eslint/parser": "
|
|
21
|
+
"@typescript-eslint/eslint-plugin": "5.36.2",
|
|
22
|
+
"@typescript-eslint/parser": "5.36.2",
|
|
23
23
|
"eslint": "8.6.0",
|
|
24
24
|
"prettier": "2.5.1",
|
|
25
25
|
"ts-node": "10.4.0",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"typescript-eslint": "0.0.1-alpha.0"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"axios": "
|
|
32
|
+
"axios": "0.24.0"
|
|
33
33
|
},
|
|
34
34
|
"files": [
|
|
35
35
|
"dist/**/*"
|
package/CHANGELOG.md
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
#### 1.0.4 (2021-12-06)
|
|
2
|
-
|
|
3
|
-
##### Other Changes
|
|
4
|
-
|
|
5
|
-
* **plan:** added methods for plan ([d68ff371](https://github.com/en1tan/paystack-node/commit/d68ff371a90b363ea087bbd5d7cfbece14ca216b))
|
|
6
|
-
|
|
7
|
-
#### 1.0.3 (2021-12-06)
|
|
8
|
-
|
|
9
|
-
##### Other Changes
|
|
10
|
-
|
|
11
|
-
* **transactions:** added initialize transaction, verify transaction, list transactions ([73c85a83](https://github.com/en1tan/paystack-node/commit/73c85a83b1ae52b4be63e3d77b8c8ff64588b8e2))
|
|
12
|
-
* **charge:** compeleted the endpoints, what remains is custom validtion and comments ([cc3165ce](https://github.com/en1tan/paystack-node/commit/cc3165ce772ac574cdfbcda082ff22f67e9c8945))
|
|
13
|
-
|
|
14
|
-
#### 1.0.3 (2021-12-06)
|
|
15
|
-
|
|
16
|
-
##### Other Changes
|
|
17
|
-
|
|
18
|
-
* **charge:** compeleted the endpoints, what remains is custom validtion and comments ([cc3165ce](https://github.com/en1tan/paystack-node/commit/cc3165ce772ac574cdfbcda082ff22f67e9c8945))
|
|
19
|
-
|
|
20
|
-
- ✍🏻 UPDATE(charge): compeleted the endpoints, what remains is custom validtion and comments
|
|
21
|
-
- 1.0.3
|
|
22
|
-
- ✍🏻 UPDATE(charge): compeleted the endpoints, what remains is custom validtion and comments
|
|
23
|
-
- 1.0.2
|
|
24
|
-
- 🐞 FIX(main entry file):
|
|
25
|
-
- 1.0.1
|
|
26
|
-
- ✍🏻 UPDATE(travis): for automated builds
|
|
27
|
-
- 🐞 FIX(main entry file):
|
|
28
|
-
- 📦 NEW(set up sdk):
|
|
29
|
-
- Initial commit
|