paystack-sdk 2.2.0 → 2.3.1

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 CHANGED
@@ -26,25 +26,45 @@ For Javscript
26
26
 
27
27
  ```javascript
28
28
  const Paystack = require('paystack-sdk').Paystack;
29
- const paystack = new Paystack("secret_key");
29
+ const paystack = new Paystack('secret_key');
30
30
  ```
31
31
 
32
- All methods use promise meaning you can either use the `async...await` or `then...catch` or `try...catch`
32
+ OR
33
33
 
34
- ### Available Functions
34
+ ```javascript
35
+ const { Paystack } = require('paystack-sdk').Paystack;
36
+ const paystack = new Paystack('secret_key');
37
+ ```
35
38
 
36
- - Charge
37
- - Customer
38
- - Plan
39
- - Product
40
- - Subscription
41
- - Transaction
42
- - Transfer
43
- - dedicated (For dedicated accounts)
39
+ All methods use promise meaning you can either use the `async...await` or `then...catch` or `try...catch`
44
40
 
41
+ ### Modules
42
+
43
+ - [x] Charge
44
+ - [x] Customers
45
+ - [x] Plans
46
+ - [x] Products
47
+ - [x] Subscriptions
48
+ - [x] Transactions
49
+ - [x] Transfers
50
+ - [x] Dedicated Virtual Accounts
51
+ - [x] Apple Pay
52
+ - [x] Subaccounts
53
+ - [x] Transaction Splits
54
+ - [x] Settlements
55
+ - [x] Invoices
56
+ - [ ] Transaction Recipients
57
+ - [ ] Transfers Control
58
+ - [ ] Bulk Charges
59
+ - [ ] Control Panel
60
+ - [ ] Disputes
61
+ - [ ] Refunds
62
+ - [ ] Verification
63
+ - [ ] Miscellaneous
45
64
 
46
65
  ## CONTRIBUTING
66
+
47
67
  If you notice a missing function, or maybe a bug. Please feel free to submit
48
68
  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:
69
+ You will need to fork the repo and create a PR against it with your changes.
70
+ Thank you :smile:
@@ -1,4 +1,4 @@
1
- import { Response } from '../transaction';
1
+ import { Response } from '../interface';
2
2
  export declare type ChargeCreatedResponse = ChargeCreated | ChargeCreatedWithOTP | ChargeCreatedWithPending | ChargeCreatedWithAddress | ChargeCreatedWithBankAuth | ChargeCreatedWithPin | ChargeCreatedWithPhone | ChargeCreatedWithBirthday | ChargeCreatedWithUSSD | ChargeCreatedWithMobileMoney | ChargeFailed;
3
3
  export interface CreateCharge {
4
4
  email: string;
@@ -1,11 +1,7 @@
1
1
  import { Axios } from 'axios';
2
- import { ListCustomersResponse } from '.';
3
- import { CreateCustomer, CustomerCreated, CustomerData, ListCustomerQueryParams, SetRiskAction, UpdateCustomer, ValidateCustomer } from './interface';
4
- interface BadRequest {
5
- status: boolean;
6
- message: string;
7
- data: null;
8
- }
2
+ import { BadRequest } from '../interface';
3
+ import { ListCustomersResponse } from './interface';
4
+ import { CreateCustomer, CustomerCreated, FetchCustomerResponse, ListCustomerQueryParams, SetRiskAction, UpdateCustomer, ValidateCustomer } from './interface';
9
5
  /**
10
6
  * # Customers
11
7
  * The Customers API allows you create and manage
@@ -23,7 +19,6 @@ export declare class Customer {
23
19
  /**
24
20
  * ## List Customers
25
21
  * List customers available on your integration
26
- * @param {ListCustomerQueryParams} queryParams
27
22
  */
28
23
  list(queryParams?: ListCustomerQueryParams): Promise<ListCustomersResponse | BadRequest>;
29
24
  /**
@@ -31,30 +26,25 @@ export declare class Customer {
31
26
  * Get details of a customer on your integration
32
27
  * @param {String} email_or_code
33
28
  */
34
- fetch(emailCode: string): Promise<CustomerData | BadRequest>;
29
+ fetch(emailCode: string): Promise<FetchCustomerResponse | BadRequest>;
35
30
  /**
36
31
  * ## Update CUstomer
37
32
  * Update a customer's details on your integration
38
33
  */
39
- update(code: string, data: UpdateCustomer): Promise<CustomerData | BadRequest>;
34
+ update(code: string, data: UpdateCustomer): Promise<FetchCustomerResponse | BadRequest>;
40
35
  /**
41
36
  * ## Validate Customer
42
37
  * Validate a customer's identity
43
- * @param {String} customer_code
44
- * @param {ValidateCustomer} data
45
38
  */
46
39
  validate(customerCode: string, data: ValidateCustomer): Promise<Response | BadRequest>;
47
40
  /**
48
41
  * ## Whitelist/Blacklist Customer
49
42
  * Whitelist or black a customer on your integration
50
- * @param {SetRiskAction} data
51
43
  */
52
- setRiskAction(data: SetRiskAction): Promise<CustomerData | BadRequest>;
44
+ setRiskAction(data: SetRiskAction): Promise<FetchCustomerResponse | BadRequest>;
53
45
  /**
54
46
  * ## Deactivate Authorization
55
47
  * Deactivate an authorization when the card needs to be forgotten
56
- * @param {String} authorizaion_code
57
48
  */
58
49
  deactivateAutorization(authorizationCode: string): Promise<Response>;
59
50
  }
60
- export {};
@@ -32,7 +32,6 @@ class Customer {
32
32
  /**
33
33
  * ## List Customers
34
34
  * List customers available on your integration
35
- * @param {ListCustomerQueryParams} queryParams
36
35
  */
37
36
  list(queryParams) {
38
37
  return __awaiter(this, void 0, void 0, function* () {
@@ -63,8 +62,6 @@ class Customer {
63
62
  /**
64
63
  * ## Validate Customer
65
64
  * Validate a customer's identity
66
- * @param {String} customer_code
67
- * @param {ValidateCustomer} data
68
65
  */
69
66
  validate(customerCode, data) {
70
67
  return __awaiter(this, void 0, void 0, function* () {
@@ -74,7 +71,6 @@ class Customer {
74
71
  /**
75
72
  * ## Whitelist/Blacklist Customer
76
73
  * Whitelist or black a customer on your integration
77
- * @param {SetRiskAction} data
78
74
  */
79
75
  setRiskAction(data) {
80
76
  return __awaiter(this, void 0, void 0, function* () {
@@ -84,12 +80,10 @@ class Customer {
84
80
  /**
85
81
  * ## Deactivate Authorization
86
82
  * Deactivate an authorization when the card needs to be forgotten
87
- * @param {String} authorizaion_code
88
83
  */
89
84
  deactivateAutorization(authorizationCode) {
90
85
  return __awaiter(this, void 0, void 0, function* () {
91
- const response = yield this.http.post('/customer/deactivate_authorization', JSON.stringify({ authorizaion_code: authorizationCode }));
92
- return response;
86
+ return yield this.http.post('/customer/deactivate_authorization', JSON.stringify({ authorizaion_code: authorizationCode }));
93
87
  });
94
88
  }
95
89
  }
@@ -1,7 +1,8 @@
1
1
  import { Authorization } from '../charge';
2
2
  import { Meta } from '../interface';
3
+ import { SubAccount } from '../subaccounts/subaccount';
3
4
  import { Subscription } from '../subscription/interface';
4
- import { Transaction } from '../transaction';
5
+ import { Transaction } from '../transaction/interface';
5
6
  export interface CreateCustomer {
6
7
  email: string;
7
8
  first_name: string;
@@ -13,64 +14,35 @@ export interface Response {
13
14
  status: boolean;
14
15
  message: string;
15
16
  }
17
+ export interface Customer {
18
+ id: number;
19
+ transactions: Transaction[];
20
+ subscriptions: Subscription[];
21
+ authorizations: Authorization[];
22
+ first_name: string;
23
+ last_name: string;
24
+ email: string;
25
+ phone?: string;
26
+ metadata?: Record<string, unknown>;
27
+ domain: string;
28
+ customer_code: string;
29
+ risk_action: string;
30
+ international_format_phone?: string;
31
+ integration: number;
32
+ createdAt: Date;
33
+ updatedAt: Date;
34
+ identified: boolean;
35
+ identifications: CustomerIdentification[];
36
+ dedicated_account: DedicatedAccount[];
37
+ }
16
38
  export interface CustomerCreated extends Response {
17
- data: {
18
- transactions: Transaction[];
19
- subscriptions: Subscription[];
20
- authorizations: Authorization[];
21
- first_name: string;
22
- last_name: string;
23
- email: string;
24
- phone: string | null;
25
- metadata?: Record<string, unknown>;
26
- domain: string;
27
- customer_code: string;
28
- risk_action: string;
29
- id: number;
30
- integration: number;
31
- createdAt: Date;
32
- updatedAt: Date;
33
- identified: boolean;
34
- identifications: null;
35
- };
39
+ data: Customer;
36
40
  }
37
- export interface CustomerData extends Response {
38
- data: {
39
- integration: number;
40
- first_name: string;
41
- last_name: string;
42
- email: string;
43
- phone: string | null;
44
- dedicated_account: DedicatedAccount | null;
45
- identified: boolean;
46
- identifications: CustomerIdentification[] | null;
47
- metadata: Record<string, any> | null;
48
- domain: string;
49
- customer_code: string;
50
- id: string;
51
- transactions: Transaction[];
52
- subscriptions: Subscription[];
53
- authorizations: Authorization[];
54
- createdAt: Date;
55
- updatedAt: Date;
56
- };
41
+ export interface FetchCustomerResponse extends Response {
42
+ data: Customer;
57
43
  }
58
44
  export interface ListCustomersResponse extends Response {
59
- data: [
60
- {
61
- integration: number;
62
- first_name: string;
63
- last_name: string;
64
- email: string;
65
- phone: string | null;
66
- metadata: Record<string, any> | null;
67
- domain: string;
68
- customer_code: string;
69
- id: number;
70
- createdAt: Date;
71
- updatedAt: Date;
72
- }
73
- ];
45
+ data: Customer[];
74
46
  meta: Meta;
75
47
  }
76
48
  export interface ListCustomerQueryParams {
@@ -118,23 +90,11 @@ export interface SplitConfig {
118
90
  createdAt: Date;
119
91
  updatedAt: Date;
120
92
  is_dynamic: boolean;
121
- subaccounts: SubAccount[];
93
+ subaccounts: CustomerSubAccount[];
122
94
  total_subaccounts: number;
123
95
  }
124
- export interface SubAccount {
125
- subaccount: {
126
- id: number;
127
- sunaccount_code: string;
128
- business_name: string;
129
- description: string;
130
- primary_contact_name: string | null;
131
- primary_contact_email: string | null;
132
- primary_contact_phone: string | null;
133
- metadata: Record<string, any>;
134
- settlement_bank: string;
135
- currency: string;
136
- account_number: string;
137
- };
96
+ export interface CustomerSubAccount {
97
+ subaccount: SubAccount;
138
98
  share: number;
139
99
  }
140
100
  export interface CustomerIdentification {
@@ -168,7 +128,7 @@ export interface UpdateCustomer {
168
128
  first_name: string;
169
129
  last_name: string;
170
130
  phone: string;
171
- metadata: Record<string, any>;
131
+ metadata: Record<string, unknown>;
172
132
  }
173
133
  export interface SetRiskAction {
174
134
  customer: string;
@@ -1,16 +1,17 @@
1
1
  import { Authorization, Customer } from '../charge';
2
2
  import { Meta } from '../interface';
3
3
  import { Subscription } from '../subscription';
4
- import { Response, Transaction } from '../transaction';
4
+ import { Response } from '../interface';
5
+ import { Transaction } from '../transaction/interface';
5
6
  export interface DedicatedAccountData {
6
7
  id: number;
7
8
  account_name: string;
8
9
  account_number: string;
9
10
  assigned: boolean;
10
11
  currency: string;
11
- metadata: Record<string, any> | null;
12
+ metadata?: Record<string, unknown>;
12
13
  active: boolean;
13
- split_config: Record<string, any> | null;
14
+ split_config?: Record<string, unknown>;
14
15
  bank: Bank;
15
16
  slug: string;
16
17
  created_at: string;
@@ -56,7 +57,7 @@ export interface FetchDedicatedVirtualAccountResponse extends Response {
56
57
  last_name: string;
57
58
  email: string;
58
59
  phone: string;
59
- metadata: Record<string, any> | null;
60
+ metadata?: Record<string, unknown>;
60
61
  domain: string;
61
62
  customer_code: string;
62
63
  risk_action: string;
@@ -67,7 +68,7 @@ export interface FetchDedicatedVirtualAccountResponse extends Response {
67
68
  created_at: Date;
68
69
  updated_at: Date;
69
70
  total_transactions: number;
70
- total_transaction_value: any[];
71
+ total_transaction_value: unknown[];
71
72
  dedicated_account: {
72
73
  id: number;
73
74
  account_name: string;
@@ -94,7 +95,7 @@ export interface DeactivateDedicatedAccountResponse {
94
95
  account_number: string;
95
96
  assigned: boolean;
96
97
  currency: string;
97
- metadata: Record<string, any> | null;
98
+ metadata?: Record<string, unknown>;
98
99
  active: boolean;
99
100
  id: number;
100
101
  created_at: Date;
@@ -109,13 +110,13 @@ export interface SplitDedicatedAccountTransactionResponse extends Response {
109
110
  account_number: string;
110
111
  assigned: boolean;
111
112
  currency: string;
112
- metadata: Record<string, any> | null;
113
+ metadata?: Record<string, unknown>;
113
114
  active: boolean;
114
115
  bank: Bank;
115
116
  assignment: Assignment;
116
117
  created_at: Date;
117
118
  updated_at: Date;
118
- split_config: Record<string, any> | null;
119
+ split_config?: Record<string, unknown>;
119
120
  customer: Customer;
120
121
  };
121
122
  }
@@ -126,7 +127,7 @@ export interface RemoveSplitDedicatedAccountResponse extends Response {
126
127
  account_number: string;
127
128
  assigned: boolean;
128
129
  currency: string;
129
- split_config: Record<string, any> | null;
130
+ split_config?: Record<string, unknown>;
130
131
  active: boolean;
131
132
  createdAt: Date;
132
133
  updatedAt: Date;
@@ -14,3 +14,23 @@ export interface Response {
14
14
  status: boolean;
15
15
  message: string;
16
16
  }
17
+ export interface QueryParams {
18
+ /**
19
+ * Specify how many records you want to retrieve per page.
20
+ * If not specify we use a default value of 50.
21
+ */
22
+ perPage?: number;
23
+ /**
24
+ * Specify exactly what page you want to retrieve.
25
+ * If not specify we use a default value of 1.
26
+ */
27
+ page?: number;
28
+ /**
29
+ * A timestamp from which to start listing subaccounts e.g. 2016-09-24T00:00:05.000Z, 2016-09-21
30
+ */
31
+ from?: Date;
32
+ /**
33
+ * A timestamp at which to stop listing subaccounts e.g. 2016-09-24T00:00:05.000Z, 2016-09-21
34
+ */
35
+ to?: Date;
36
+ }
@@ -0,0 +1,137 @@
1
+ import { Customer } from '../charge';
2
+ import { Meta, QueryParams, Response } from '../interface';
3
+ import { Transaction } from '../transaction/interface';
4
+ export interface CreateInvoice {
5
+ /** Customer id or code */
6
+ customer: string;
7
+ /**
8
+ * Payment request amount.
9
+ * It should be used when line items and tax values aren't specified.
10
+ */
11
+ amount: number;
12
+ /** ISO 8601 representation of request due date */
13
+ date_time?: Date;
14
+ /** A short description of the payment request */
15
+ description?: string;
16
+ /**
17
+ * Array of line items int the format
18
+ * [{"name":"item 1", "amount":2000, "quantity": 1}]
19
+ */
20
+ line_items?: Record<string, unknown>[];
21
+ /**
22
+ * Array of taxes to be charged in the format
23
+ * [{"name":"VAT", "amount":2000}]
24
+ */
25
+ tax?: Record<string, unknown>[];
26
+ /**
27
+ * Specify the currency of the invoice.
28
+ * Allowed values are `NGN`, `GHS`, `ZAR` and `USD`. Defaults to NGN
29
+ */
30
+ currency?: string;
31
+ /**
32
+ * Indicates whether Paystack sends an email notification to customer.
33
+ * Defaults to true
34
+ */
35
+ send_notification?: boolean;
36
+ /**
37
+ * Indicate if request should be saved as draft.
38
+ * Defaults to false and overrides send_notification
39
+ */
40
+ draft?: boolean;
41
+ /**
42
+ * Set to true to create a draft invoice
43
+ * (adds an auto incrementing invoice number if none is provided)
44
+ * even if there are no line_items or tax passed
45
+ */
46
+ has_invoice?: boolean;
47
+ /**
48
+ * Numeric value of invoice.
49
+ * Invoice will start from 1 and auto increment from there.
50
+ * This field is to help override whatever value Paystack decides.
51
+ * Auto increment for subsequent invoices continue from this point.
52
+ */
53
+ invoice_number?: number;
54
+ /** The split code of the transaction split. e.g. SPL_98WF13Eb3w */
55
+ split_code?: string;
56
+ }
57
+ export interface InvoiceQueryParams extends QueryParams {
58
+ /** Filter by customer ID */
59
+ customer?: string;
60
+ /** Filter by invoice status */
61
+ status?: string;
62
+ /**
63
+ * Filter by currency.
64
+ * Allowed values are NGN, GHS, ZAR and USD.
65
+ */
66
+ currency?: string;
67
+ /** Show archived invoices */
68
+ include_archive?: string;
69
+ }
70
+ export declare type UpdateInvoice = CreateInvoice;
71
+ interface InvoiceLineItem {
72
+ name: string;
73
+ amount: number;
74
+ quantity: number;
75
+ }
76
+ interface InvoiceTax {
77
+ name: string;
78
+ amount: number;
79
+ }
80
+ interface IInvoiceTotal {
81
+ currency: string;
82
+ amount: number;
83
+ }
84
+ export interface Invoice {
85
+ id: number;
86
+ domain: string;
87
+ amount: number;
88
+ discount?: unknown;
89
+ currency: string;
90
+ due_date: Date;
91
+ has_invoice: boolean;
92
+ invoice_number: number;
93
+ description: string;
94
+ line_items: InvoiceLineItem[];
95
+ tax: InvoiceTax[];
96
+ request_code: string;
97
+ status: string;
98
+ paid: boolean;
99
+ paid_at?: Date;
100
+ metadata?: Record<string, unknown>;
101
+ notifications: unknown[];
102
+ offline_reference: string;
103
+ pdf_url?: string;
104
+ transactions: Transaction[];
105
+ archived?: boolean;
106
+ source?: string;
107
+ payment_method?: unknown;
108
+ note?: string;
109
+ amount_paid?: unknown;
110
+ integration: number;
111
+ customer?: number | Customer;
112
+ createdAt: Date;
113
+ updatedAt: Date;
114
+ pending_amount?: number;
115
+ }
116
+ export interface InvoiceTotal {
117
+ pending: IInvoiceTotal[];
118
+ successful: IInvoiceTotal[];
119
+ total: IInvoiceTotal[];
120
+ }
121
+ export interface InvoiceCreatedResponse extends Response {
122
+ data: Invoice;
123
+ }
124
+ export interface ListInvoicesResponse extends Response {
125
+ data: Invoice[];
126
+ meta: Meta;
127
+ }
128
+ export interface ViewInvoiceResponse extends Response {
129
+ data: Invoice;
130
+ }
131
+ export interface VerifyInvoiceResponse extends Response {
132
+ data: Invoice;
133
+ }
134
+ export interface InvoiceTotalResponse extends Response {
135
+ data: InvoiceTotal;
136
+ }
137
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,16 @@
1
+ import { Axios } from 'axios';
2
+ import { BadRequest, Response } from '../interface';
3
+ import { CreateInvoice, InvoiceCreatedResponse, InvoiceQueryParams, InvoiceTotalResponse, ListInvoicesResponse, UpdateInvoice, ViewInvoiceResponse } from './interface';
4
+ export declare class Invoice {
5
+ private http;
6
+ constructor(http: Axios);
7
+ create(data: CreateInvoice): Promise<InvoiceCreatedResponse | BadRequest>;
8
+ list(queryParams?: InvoiceQueryParams): Promise<ListInvoicesResponse | BadRequest>;
9
+ view(id: string): Promise<ViewInvoiceResponse | BadRequest>;
10
+ verify(code: string): Promise<ViewInvoiceResponse | BadRequest>;
11
+ sendNotification(code: string): Promise<Response | BadRequest>;
12
+ total(): Promise<InvoiceTotalResponse | BadRequest>;
13
+ finalize(code: string): Promise<ViewInvoiceResponse | BadRequest>;
14
+ update(id: string, data: UpdateInvoice): Promise<ViewInvoiceResponse | BadRequest>;
15
+ archive(code: string): Promise<Response | BadRequest>;
16
+ }
@@ -0,0 +1,65 @@
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.Invoice = void 0;
13
+ class Invoice {
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('/paymentrequest', JSON.stringify(data));
20
+ });
21
+ }
22
+ list(queryParams) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ return yield this.http.get('/paymentrequest', {
25
+ params: Object.assign({}, queryParams),
26
+ });
27
+ });
28
+ }
29
+ view(id) {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ return yield this.http.get(`'/paymentrequest/${id}`);
32
+ });
33
+ }
34
+ verify(code) {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ return yield this.http.get(`/paymentrequest/verify/${code}`);
37
+ });
38
+ }
39
+ sendNotification(code) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ return yield this.http.post(`/paymentrequest/notify/${code}`);
42
+ });
43
+ }
44
+ total() {
45
+ return __awaiter(this, void 0, void 0, function* () {
46
+ return yield this.http.get('/paymentrequest/totals');
47
+ });
48
+ }
49
+ finalize(code) {
50
+ return __awaiter(this, void 0, void 0, function* () {
51
+ return yield this.http.post(`/paymentrequest/finalize/${code}`);
52
+ });
53
+ }
54
+ update(id, data) {
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ return yield this.http.put(`/paymentrequest/${id}`, JSON.stringify(data));
57
+ });
58
+ }
59
+ archive(code) {
60
+ return __awaiter(this, void 0, void 0, function* () {
61
+ return yield this.http.post(`/paymentrequest/archive/${code}`);
62
+ });
63
+ }
64
+ }
65
+ exports.Invoice = Invoice;
@@ -0,0 +1,101 @@
1
+ import { Meta, Response } from '../interface';
2
+ import { ProductCreated } from '../product/interface';
3
+ export interface CreatePage {
4
+ /**
5
+ * Name of page
6
+ */
7
+ name: string;
8
+ /**
9
+ * A description for this page
10
+ */
11
+ description?: string;
12
+ /**
13
+ * Amount should be in kobo if currency is `NGN`, pesewas,
14
+ * if currency is `GHS`, and cents, if currency is `ZAR`
15
+ */
16
+ amount?: number;
17
+ /**
18
+ * URL slug you would like to be associated with this page.
19
+ * Page will be accessible at https://paystack.com/pay/[slug]
20
+ */
21
+ slug?: string;
22
+ /**
23
+ * Extra data to configure the payment page including subaccount,
24
+ * logo image, transaction charge
25
+ */
26
+ metadata?: Record<string, unknown>;
27
+ /**
28
+ * If you would like Paystack to redirect someplace upon successful payment,
29
+ * specify the URL here.
30
+ */
31
+ redirect_url?: string;
32
+ /**
33
+ * If you would like to accept custom fields, specify them here.
34
+ */
35
+ custom_fields?: Record<string, unknown>[];
36
+ }
37
+ export interface UpdatePage {
38
+ /**
39
+ * Name of page
40
+ */
41
+ name: string;
42
+ /**
43
+ * A description for this page
44
+ */
45
+ description: string;
46
+ /**
47
+ * Amount should be in kobo if currency is `NGN`, pesewas,
48
+ * if currency is `GHS`, and cents, if currency is `ZAR`
49
+ */
50
+ amount?: number;
51
+ /**
52
+ * Set to false to deactivate page url
53
+ */
54
+ active?: boolean;
55
+ }
56
+ export interface PaymentPageProduct {
57
+ product_id: number;
58
+ name: string;
59
+ description: string;
60
+ product_code: string;
61
+ page: number;
62
+ price: number;
63
+ currency: string;
64
+ quantity: number;
65
+ type: string;
66
+ features?: unknown;
67
+ is_shippable: number;
68
+ domain: string;
69
+ integration: number;
70
+ active: number;
71
+ in_stock: number;
72
+ }
73
+ export interface PaymentPage {
74
+ id: number;
75
+ name: string;
76
+ description?: string;
77
+ integration: number;
78
+ domain: string;
79
+ slug: string;
80
+ currency: string;
81
+ type: string;
82
+ redirect_url?: string;
83
+ success_message?: string;
84
+ collect_phone: boolean;
85
+ active: boolean;
86
+ published: boolean;
87
+ migrate: boolean;
88
+ notification_email?: string;
89
+ metadata?: Record<string, unknown>;
90
+ split_code?: string;
91
+ createdAt: Date;
92
+ updatedAt: Date;
93
+ products?: ProductCreated[];
94
+ }
95
+ export interface PaymentPageCreatedFetchedUpdatedResponse extends Response {
96
+ data: PaymentPage;
97
+ }
98
+ export interface ListPaymentPagesResponse extends Response {
99
+ data: PaymentPage[];
100
+ meta?: Meta;
101
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,13 @@
1
+ import { Axios } from 'axios';
2
+ import { BadRequest, QueryParams } from '../interface';
3
+ import { CreatePage, ListPaymentPagesResponse, PaymentPageCreatedFetchedUpdatedResponse, UpdatePage } from './interface';
4
+ export declare class PaymentPage {
5
+ private http;
6
+ constructor(http: Axios);
7
+ create(data: CreatePage): Promise<PaymentPageCreatedFetchedUpdatedResponse | BadRequest>;
8
+ list(queryParams?: QueryParams): Promise<ListPaymentPagesResponse | BadRequest>;
9
+ fetch(id: string): Promise<PaymentPageCreatedFetchedUpdatedResponse | BadRequest>;
10
+ update(id: string, data: UpdatePage): Promise<PaymentPageCreatedFetchedUpdatedResponse | BadRequest>;
11
+ slugAvailable(slug: string): Promise<PaymentPageCreatedFetchedUpdatedResponse | BadRequest>;
12
+ addProduct(id: number, products: number[]): Promise<PaymentPageCreatedFetchedUpdatedResponse | BadRequest>;
13
+ }
@@ -0,0 +1,48 @@
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.PaymentPage = void 0;
13
+ class PaymentPage {
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('/page', JSON.stringify(data));
20
+ });
21
+ }
22
+ list(queryParams) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ return yield this.http.get('/page', { params: Object.assign({}, queryParams) });
25
+ });
26
+ }
27
+ fetch(id) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ return yield this.http.get(`/page/${id}`);
30
+ });
31
+ }
32
+ update(id, data) {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ return yield this.http.put(`/page/${id}`, JSON.stringify(data));
35
+ });
36
+ }
37
+ slugAvailable(slug) {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ return yield this.http.get(`/page/check_slug_availability/${slug}`);
40
+ });
41
+ }
42
+ addProduct(id, products) {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ return yield this.http.post(`/page/${id}/product`, JSON.stringify({ products }));
45
+ });
46
+ }
47
+ }
48
+ exports.PaymentPage = PaymentPage;
@@ -1,20 +1,23 @@
1
1
  import { ApplePay } from './apple/apple';
2
2
  import { Charge } from './charge';
3
- import { Customer } from './customer';
3
+ import { Customer } from './customer/customer';
4
4
  import { DedicatedAccount } from './dedicated/dedicated';
5
+ import { Invoice } from './invoice/invoice';
6
+ import { PaymentPage } from './payment/payment';
5
7
  import { Plan } from './plan';
6
8
  import { Product } from './product/product';
9
+ import { Settlement } from './settlement/settlement';
7
10
  import { TransactionSplit } from './split/split';
8
11
  import { SubAccount } from './subaccounts/subaccount';
9
12
  import { Subscription } from './subscription/subscription';
10
- import { Transaction } from './transaction';
13
+ import { Transaction } from './transaction/transaction';
11
14
  import { Transfer } from './transfer/transfer';
12
15
  /**
13
16
  * Paystack SDK
14
17
  * @author Asaju Enitan <@tPriest>
15
18
  */
16
19
  export declare class Paystack {
17
- readonly key: string;
20
+ private readonly key;
18
21
  private readonly http;
19
22
  charge: Charge;
20
23
  customer: Customer;
@@ -27,5 +30,8 @@ export declare class Paystack {
27
30
  split: TransactionSplit;
28
31
  applePay: ApplePay;
29
32
  subAccount: SubAccount;
33
+ page: PaymentPage;
34
+ invoice: Invoice;
35
+ settlement: Settlement;
30
36
  constructor(key: string);
31
37
  }
package/dist/paystack.js CHANGED
@@ -4,14 +4,17 @@ exports.Paystack = void 0;
4
4
  const axios_1 = require("axios");
5
5
  const apple_1 = require("./apple/apple");
6
6
  const charge_1 = require("./charge");
7
- const customer_1 = require("./customer");
7
+ const customer_1 = require("./customer/customer");
8
8
  const dedicated_1 = require("./dedicated/dedicated");
9
+ const invoice_1 = require("./invoice/invoice");
10
+ const payment_1 = require("./payment/payment");
9
11
  const plan_1 = require("./plan");
10
12
  const product_1 = require("./product/product");
13
+ const settlement_1 = require("./settlement/settlement");
11
14
  const split_1 = require("./split/split");
12
15
  const subaccount_1 = require("./subaccounts/subaccount");
13
16
  const subscription_1 = require("./subscription/subscription");
14
- const transaction_1 = require("./transaction");
17
+ const transaction_1 = require("./transaction/transaction");
15
18
  const transfer_1 = require("./transfer/transfer");
16
19
  /**
17
20
  * Paystack SDK
@@ -39,6 +42,9 @@ class Paystack {
39
42
  this.transfer = new transfer_1.Transfer(this.http);
40
43
  this.applePay = new apple_1.ApplePay(this.http);
41
44
  this.subAccount = new subaccount_1.SubAccount(this.http);
45
+ this.page = new payment_1.PaymentPage(this.http);
46
+ this.invoice = new invoice_1.Invoice(this.http);
47
+ this.settlement = new settlement_1.Settlement(this.http);
42
48
  }
43
49
  }
44
50
  exports.Paystack = Paystack;
@@ -0,0 +1,40 @@
1
+ import { CustomerSubAccount } from '../customer/interface';
2
+ import { Meta, QueryParams } from '../interface';
3
+ export interface SettlementQueryParams extends QueryParams {
4
+ subaccount?: string;
5
+ }
6
+ export interface Settlement {
7
+ integration: number;
8
+ settled_by?: string;
9
+ settlement_date: Date;
10
+ domain: string;
11
+ total_amount: number;
12
+ status: string;
13
+ id: number;
14
+ createdAt: Date;
15
+ updatedAt?: Date;
16
+ subaccount: CustomerSubAccount;
17
+ }
18
+ export interface ListSettlementsResponse extends Response {
19
+ data: Settlement[];
20
+ meta: Meta;
21
+ }
22
+ export interface SettlementTransaction {
23
+ id: number;
24
+ reference: string;
25
+ amount: number;
26
+ created_at: Date;
27
+ paidAt: Date;
28
+ currency: string;
29
+ channel: string;
30
+ domain: string;
31
+ message?: string;
32
+ gateway_response: string;
33
+ fees: number;
34
+ }
35
+ export interface ListSettlementTransactionsResponse extends Response {
36
+ data: SettlementTransaction[];
37
+ meta: Meta & {
38
+ total_volume: number;
39
+ };
40
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,9 @@
1
+ import { Axios } from 'axios';
2
+ import { BadRequest, QueryParams } from '../interface';
3
+ import { ListSettlementsResponse, ListSettlementTransactionsResponse, SettlementQueryParams } from './interface';
4
+ export declare class Settlement {
5
+ private http;
6
+ constructor(http: Axios);
7
+ list(queryParams?: SettlementQueryParams): Promise<ListSettlementsResponse | BadRequest>;
8
+ transactions(id: string, queryParams: QueryParams): Promise<ListSettlementTransactionsResponse | BadRequest>;
9
+ }
@@ -0,0 +1,30 @@
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.Settlement = void 0;
13
+ class Settlement {
14
+ constructor(http) {
15
+ this.http = http;
16
+ }
17
+ list(queryParams) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ return yield this.http.get('/settlement', { params: Object.assign({}, queryParams) });
20
+ });
21
+ }
22
+ transactions(id, queryParams) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ return yield this.http.get(`/settlement/$[id]/transactions`, {
25
+ params: Object.assign({}, queryParams),
26
+ });
27
+ });
28
+ }
29
+ }
30
+ exports.Settlement = Settlement;
@@ -53,28 +53,8 @@ export interface CreateUpdateSubAccount {
53
53
  */
54
54
  metadata?: string;
55
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
56
  interface SubAccount {
77
- integration: number;
57
+ id: number;
78
58
  domain: string;
79
59
  subaccount_code: string;
80
60
  business_name: string;
@@ -82,7 +62,7 @@ interface SubAccount {
82
62
  primary_contact_name?: string;
83
63
  primary_contact_email?: string;
84
64
  primary_contact_phone?: string;
85
- metadata?: Record<string, unknown>;
65
+ metadata: Record<string, unknown>;
86
66
  percentage_charge: number;
87
67
  is_verified: boolean;
88
68
  settlement_bank: string;
@@ -90,9 +70,10 @@ interface SubAccount {
90
70
  settlement_schedule: string;
91
71
  active: boolean;
92
72
  migrate: boolean;
93
- id: number;
73
+ integration: number;
94
74
  createdAt: Date;
95
75
  updatedAt: Date;
76
+ currency: string;
96
77
  }
97
78
  export interface SubAccountCreatedUpdateResponse extends Response {
98
79
  data: SubAccount;
@@ -1,11 +1,11 @@
1
1
  import { Axios } from 'axios';
2
- import { BadRequest } from '../interface';
3
- import { CreateUpdateSubAccount, FetchSubAccountResponse, ListSubAccountsResponse, SubAccountCreatedUpdateResponse, SubAccountQueryParams } from './interface';
2
+ import { BadRequest, QueryParams } from '../interface';
3
+ import { CreateUpdateSubAccount, FetchSubAccountResponse, ListSubAccountsResponse, SubAccountCreatedUpdateResponse } from './interface';
4
4
  export declare class SubAccount {
5
5
  private http;
6
6
  constructor(http: Axios);
7
7
  create(data: CreateUpdateSubAccount): Promise<SubAccountCreatedUpdateResponse | BadRequest>;
8
- list(queryParams?: SubAccountQueryParams): Promise<ListSubAccountsResponse>;
8
+ list(queryParams?: QueryParams): Promise<ListSubAccountsResponse>;
9
9
  fetch(id: string): Promise<FetchSubAccountResponse | BadRequest>;
10
10
  update(id: string, data: CreateUpdateSubAccount): Promise<SubAccountCreatedUpdateResponse | BadRequest>;
11
11
  }
@@ -1,5 +1,5 @@
1
1
  import { Authorization } from '../charge';
2
- import { ICustomer } from '../customer';
2
+ import { Customer } from '../customer/interface';
3
3
  import { Meta } from '../interface';
4
4
  import { IPlan } from '../plan';
5
5
  export interface CreateSubscription {
@@ -47,7 +47,7 @@ export interface ListSubscriptions extends Response {
47
47
  export interface FetchSubscription extends Response {
48
48
  data: {
49
49
  invoices: unknown[];
50
- customer: ICustomer;
50
+ customer: Customer;
51
51
  plan: IPlan;
52
52
  integration: number;
53
53
  authorization: Authorization;
@@ -77,7 +77,7 @@ export interface EnableOrDisableSubscription {
77
77
  token: string;
78
78
  }
79
79
  export interface Subscription {
80
- customer: ICustomer;
80
+ customer: Customer;
81
81
  plan: IPlan;
82
82
  integration: number;
83
83
  authorization: Authorization;
@@ -84,7 +84,7 @@ export interface TransactionInitialized extends Response {
84
84
  reference: string;
85
85
  };
86
86
  }
87
- interface Transaction {
87
+ export interface Transaction {
88
88
  amount: number;
89
89
  currency: string;
90
90
  transaction_date: Date;
@@ -308,4 +308,3 @@ export interface CheckAuthorizationResponse extends Response {
308
308
  currency: string;
309
309
  };
310
310
  }
311
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paystack-sdk",
3
- "version": "2.2.0",
3
+ "version": "2.3.1",
4
4
  "description": "Paystack SDK written in Typescript",
5
5
  "main": "dist/index.js",
6
6
  "author": "Tech Priest",