paystack-sdk 2.1.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.
@@ -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
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -5,3 +5,12 @@ export interface Meta {
5
5
  page: number;
6
6
  pageCount: number;
7
7
  }
8
+ export interface BadRequest {
9
+ status: boolean;
10
+ message: string;
11
+ data: null;
12
+ }
13
+ export interface Response {
14
+ status: boolean;
15
+ message: string;
16
+ }
@@ -1,9 +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';
6
7
  import { TransactionSplit } from './split/split';
8
+ import { SubAccount } from './subaccounts/subaccount';
7
9
  import { Subscription } from './subscription/subscription';
8
10
  import { Transaction } from './transaction';
9
11
  import { Transfer } from './transfer/transfer';
@@ -23,5 +25,7 @@ export declare class Paystack {
23
25
  transaction: Transaction;
24
26
  transfer: Transfer;
25
27
  split: TransactionSplit;
28
+ applePay: ApplePay;
29
+ subAccount: SubAccount;
26
30
  constructor(key: string);
27
31
  }
package/dist/paystack.js CHANGED
@@ -2,12 +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");
10
11
  const split_1 = require("./split/split");
12
+ const subaccount_1 = require("./subaccounts/subaccount");
11
13
  const subscription_1 = require("./subscription/subscription");
12
14
  const transaction_1 = require("./transaction");
13
15
  const transfer_1 = require("./transfer/transfer");
@@ -26,18 +28,17 @@ class Paystack {
26
28
  },
27
29
  });
28
30
  this.http.interceptors.response.use((response) => (response.data = JSON.parse(response.data)));
29
- // this.http.interceptors.request.use(
30
- // (body) => (body.data = JSON.stringify(body.data)),
31
- // );
32
31
  this.charge = new charge_1.Charge(this.http);
33
32
  this.customer = new customer_1.Customer(this.http);
33
+ this.dedicated = new dedicated_1.DedicatedAccount(this.http);
34
34
  this.plan = new plan_1.Plan(this.http);
35
35
  this.product = new product_1.Product(this.http);
36
+ this.split = new split_1.TransactionSplit(this.http);
36
37
  this.subscription = new subscription_1.Subscription(this.http);
37
38
  this.transaction = new transaction_1.Transaction(this.http);
38
39
  this.transfer = new transfer_1.Transfer(this.http);
39
- this.dedicated = new dedicated_1.DedicatedAccount(this.http);
40
- this.split = new split_1.TransactionSplit(this.http);
40
+ this.applePay = new apple_1.ApplePay(this.http);
41
+ this.subAccount = new subaccount_1.SubAccount(this.http);
41
42
  }
42
43
  }
43
44
  exports.Paystack = Paystack;
@@ -1,11 +1,6 @@
1
1
  import { Meta } from '../interface';
2
2
  export declare type SplitCurrrencyType = 'GHS' | 'NGN' | 'ZAR' | 'USD';
3
3
  export declare type SplitType = 'percentage' | 'flat';
4
- export interface BadRequest {
5
- status: boolean;
6
- message: string;
7
- data: null;
8
- }
9
4
  interface SubAccount {
10
5
  id: number;
11
6
  subaccount_code: string;
@@ -1,5 +1,6 @@
1
1
  import { Axios } from 'axios';
2
- import { BadRequest, CreateSplit, ListSplitQueryParams, ListSplitsResponse, Response, SplitCreatedResponse, SplitSubAccount, TransactionSplitResponse, UpdateTransactionSplit, UpdateTransactionSplitResponse } from './interface';
2
+ import { BadRequest } from '../interface';
3
+ import { CreateSplit, ListSplitQueryParams, ListSplitsResponse, Response, SplitCreatedResponse, SplitSubAccount, TransactionSplitResponse, UpdateTransactionSplit, UpdateTransactionSplitResponse } from './interface';
3
4
  /**
4
5
  * The Transaction Splits API enables merchants
5
6
  * split the settlement for a transaction across
@@ -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,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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;
@@ -24,10 +24,6 @@ export interface InitiateTransfer {
24
24
  */
25
25
  reference?: string;
26
26
  }
27
- export interface Response {
28
- status: boolean;
29
- message: string;
30
- }
31
27
  export interface FinalizeTransfer extends Response {
32
28
  data: Transfer;
33
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paystack-sdk",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "Paystack SDK written in Typescript",
5
5
  "main": "dist/index.js",
6
6
  "author": "Tech Priest",