paystack-sdk 1.0.12 → 1.0.16

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.
@@ -1,36 +1,62 @@
1
- export class Charge {
2
- http;
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.Charge = void 0;
13
+ class Charge {
3
14
  constructor(http) {
4
15
  this.http = http;
5
16
  }
6
- async create(data) {
7
- const response = await this.http.post('/charge', JSON.stringify(data));
8
- return JSON.parse(response.data);
17
+ create(data) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ const response = yield this.http.post('/charge', JSON.stringify(data));
20
+ return JSON.parse(response.data);
21
+ });
9
22
  }
10
- async submitPIN(data) {
11
- const response = await this.http.post('/charge/submit_pin', JSON.stringify(data));
12
- return JSON.parse(response.data);
23
+ submitPIN(data) {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ const response = yield this.http.post('/charge/submit_pin', JSON.stringify(data));
26
+ return JSON.parse(response.data);
27
+ });
13
28
  }
14
- async submitOTP(data) {
15
- const response = await this.http.post('/charge/submit_otp', JSON.stringify(data));
16
- return JSON.parse(response.data);
29
+ submitOTP(data) {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ const response = yield this.http.post('/charge/submit_otp', JSON.stringify(data));
32
+ return JSON.parse(response.data);
33
+ });
17
34
  }
18
- async submitPhone(data) {
19
- const response = await this.http.post('/charge/submit_phone', JSON.stringify(data));
20
- return JSON.parse(response.data);
35
+ submitPhone(data) {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ const response = yield this.http.post('/charge/submit_phone', JSON.stringify(data));
38
+ return JSON.parse(response.data);
39
+ });
21
40
  }
22
- async submitBirthday(data) {
23
- const response = await this.http.post('/charge/submit_birthday', JSON.stringify(data));
24
- return JSON.parse(response.data);
41
+ submitBirthday(data) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ const response = yield this.http.post('/charge/submit_birthday', JSON.stringify(data));
44
+ return JSON.parse(response.data);
45
+ });
25
46
  }
26
- async submitAddress(data) {
27
- const response = await this.http.post('/charge/submit_address', JSON.stringify(data));
28
- return JSON.parse(response.data);
47
+ submitAddress(data) {
48
+ return __awaiter(this, void 0, void 0, function* () {
49
+ const response = yield this.http.post('/charge/submit_address', JSON.stringify(data));
50
+ return JSON.parse(response.data);
51
+ });
29
52
  }
30
- async checkPending(reference) {
31
- const response = await this.http.get('/charge/submit_address', {
32
- params: { reference },
53
+ checkPending(reference) {
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ const response = yield this.http.get('/charge/submit_address', {
56
+ params: { reference },
57
+ });
58
+ return JSON.parse(response.data);
33
59
  });
34
- return JSON.parse(response.data);
35
60
  }
36
61
  }
62
+ exports.Charge = Charge;
@@ -1,2 +1,14 @@
1
- export * from './charge';
2
- export * from './interface';
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./charge"), exports);
14
+ __exportStar(require("./interface"), exports);
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,60 @@
1
+ import { Axios } from 'axios';
2
+ import { Meta } from '../transaction';
3
+ import { CreateCustomer, CustomerCreated, CustomerData, ListCustomerQueryParams, ListCustomers, Response, SetRiskAction, UpdateCustomer, ValidateCustomer } from './interface';
4
+ interface BadRequest {
5
+ status: boolean;
6
+ message: string;
7
+ data: null;
8
+ }
9
+ /**
10
+ * # Customers
11
+ * The Customers API allows you create and manage
12
+ * customers on your integration
13
+ */
14
+ export declare class Customer {
15
+ private http;
16
+ constructor(http: Axios);
17
+ /**
18
+ * ## Create Customer
19
+ * Create a customer on your integration
20
+ * @param {CreateCustomer} data
21
+ */
22
+ create(data: CreateCustomer): Promise<CustomerCreated | BadRequest>;
23
+ /**
24
+ * ## List Customers
25
+ * List customers available on your integration
26
+ * @param {ListCustomerQueryParams} queryParams
27
+ */
28
+ list(queryParams?: ListCustomerQueryParams): Promise<(Response & ListCustomers[] & Meta) | BadRequest>;
29
+ /**
30
+ * ## Fetch Customer
31
+ * Get details of a customer on your integration
32
+ * @param {String} email_or_code
33
+ */
34
+ fetch(emailCode: string): Promise<CustomerData | BadRequest>;
35
+ /**
36
+ * ## Update CUstomer
37
+ * Update a customer's details on your integration
38
+ */
39
+ update(code: string, data: UpdateCustomer): Promise<CustomerData | BadRequest>;
40
+ /**
41
+ * ## Validate Customer
42
+ * Validate a customer's identity
43
+ * @param {String} customer_code
44
+ * @param {ValidateCustomer} data
45
+ */
46
+ validate(customerCode: string, data: ValidateCustomer): Promise<Response | BadRequest>;
47
+ /**
48
+ * ## Whitelist/Blacklist Customer
49
+ * Whitelist or black a customer on your integration
50
+ * @param {SetRiskAction} data
51
+ */
52
+ setRiskAction(data: SetRiskAction): Promise<CustomerData | BadRequest>;
53
+ /**
54
+ * ## Deactivate Authorization
55
+ * Deactivate an authorization when the card needs to be forgotten
56
+ * @param {String} authorizaion_code
57
+ */
58
+ deactivateAutorization(authorizationCode: string): Promise<Response>;
59
+ }
60
+ export {};
@@ -0,0 +1,102 @@
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.Customer = void 0;
13
+ /**
14
+ * # Customers
15
+ * The Customers API allows you create and manage
16
+ * customers on your integration
17
+ */
18
+ class Customer {
19
+ constructor(http) {
20
+ this.http = http;
21
+ }
22
+ /**
23
+ * ## Create Customer
24
+ * Create a customer on your integration
25
+ * @param {CreateCustomer} data
26
+ */
27
+ create(data) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ const response = yield this.http.post('/customer', JSON.stringify(data));
30
+ return JSON.parse(response.data);
31
+ });
32
+ }
33
+ /**
34
+ * ## List Customers
35
+ * List customers available on your integration
36
+ * @param {ListCustomerQueryParams} queryParams
37
+ */
38
+ list(queryParams) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ const response = yield this.http.get('/customer', {
41
+ params: Object.assign({}, queryParams),
42
+ });
43
+ return JSON.parse(response.data);
44
+ });
45
+ }
46
+ /**
47
+ * ## Fetch Customer
48
+ * Get details of a customer on your integration
49
+ * @param {String} email_or_code
50
+ */
51
+ fetch(emailCode) {
52
+ return __awaiter(this, void 0, void 0, function* () {
53
+ const response = yield this.http.get(`/customer/${emailCode}`);
54
+ return JSON.parse(response.data);
55
+ });
56
+ }
57
+ /**
58
+ * ## Update CUstomer
59
+ * Update a customer's details on your integration
60
+ */
61
+ update(code, data) {
62
+ return __awaiter(this, void 0, void 0, function* () {
63
+ const response = yield this.http.put(`/customer/${code}`, JSON.stringify(data));
64
+ return JSON.parse(response.data);
65
+ });
66
+ }
67
+ /**
68
+ * ## Validate Customer
69
+ * Validate a customer's identity
70
+ * @param {String} customer_code
71
+ * @param {ValidateCustomer} data
72
+ */
73
+ validate(customerCode, data) {
74
+ return __awaiter(this, void 0, void 0, function* () {
75
+ const response = yield this.http.post(`/customer/${customerCode}/identification`, JSON.stringify(data));
76
+ return JSON.parse(response.data);
77
+ });
78
+ }
79
+ /**
80
+ * ## Whitelist/Blacklist Customer
81
+ * Whitelist or black a customer on your integration
82
+ * @param {SetRiskAction} data
83
+ */
84
+ setRiskAction(data) {
85
+ return __awaiter(this, void 0, void 0, function* () {
86
+ const response = yield this.http.post('/customer/set_risk_action', JSON.stringify(data));
87
+ return JSON.parse(response.data);
88
+ });
89
+ }
90
+ /**
91
+ * ## Deactivate Authorization
92
+ * Deactivate an authorization when the card needs to be forgotten
93
+ * @param {String} authorizaion_code
94
+ */
95
+ deactivateAutorization(authorizationCode) {
96
+ return __awaiter(this, void 0, void 0, function* () {
97
+ const response = yield this.http.post('/customer/deactivate_authorization', JSON.stringify({ authorizaion_code: authorizationCode }));
98
+ return JSON.parse(response.data);
99
+ });
100
+ }
101
+ }
102
+ exports.Customer = Customer;
@@ -0,0 +1,177 @@
1
+ import { Authorization } from '../charge';
2
+ import { Subscription, TransactionData } from '../transaction';
3
+ export interface CreateCustomer {
4
+ email: string;
5
+ first_name: string;
6
+ last_name: string;
7
+ phone: string;
8
+ metadata: Record<string, any>;
9
+ }
10
+ export interface Response {
11
+ status: boolean;
12
+ message: string;
13
+ }
14
+ export interface CustomerCreated extends Response {
15
+ email: string;
16
+ integration: number;
17
+ domain: string;
18
+ customer_code: string;
19
+ id: number;
20
+ identified: boolean;
21
+ identifications: null;
22
+ createdAt: Date;
23
+ updatedAt: Date;
24
+ }
25
+ export interface CustomerData extends Response {
26
+ integration: number;
27
+ first_name: string;
28
+ last_name: string;
29
+ email: string;
30
+ phone: string | null;
31
+ dedicated_account: DedicatedAccount | null;
32
+ identified: boolean;
33
+ identifications: CustomerIdentification[] | null;
34
+ metadata: Record<string, any> | null;
35
+ domain: string;
36
+ customer_code: string;
37
+ id: string;
38
+ transactions: TransactionData[];
39
+ subscriptions: Subscription[];
40
+ authorizations: Authorization[];
41
+ createdAt: Date;
42
+ updatedAt: Date;
43
+ }
44
+ export interface ListCustomers {
45
+ integration: number;
46
+ first_name: string;
47
+ last_name: string;
48
+ email: string;
49
+ phone: string | null;
50
+ metadata: Record<string, any> | null;
51
+ domain: string;
52
+ customer_code: string;
53
+ id: number;
54
+ createdAt: Date;
55
+ updatedAt: Date;
56
+ }
57
+ export interface ListCustomerQueryParams {
58
+ /**
59
+ * Specify how many records you want to retrieve per page.
60
+ * If not specify we use a default value of 50.
61
+ */
62
+ perPage?: number;
63
+ /**
64
+ * Specify exactly what page you want to retrieve.
65
+ * If not specify we use a default value of 1.
66
+ */
67
+ page?: number;
68
+ /**
69
+ * Specify an ID for the customer whose transactions
70
+ * you want to retrieve
71
+ */
72
+ customer?: number;
73
+ /**
74
+ * Filter transactions by status ('failed', 'success', 'abandoned')
75
+ */
76
+ status?: string;
77
+ /**
78
+ * A timestamp from which to start listing transaction
79
+ * e.g `2021-10-25T00.00.05.000z`, `2021-12-25`
80
+ */
81
+ from?: Date;
82
+ /**
83
+ * A timestamp from which to stop listing transaction
84
+ * e.g `2021-10-25T00.00.05.000z`, `2021-12-25`
85
+ */
86
+ to?: Date;
87
+ }
88
+ export interface SplitConfig {
89
+ id: number;
90
+ name: string;
91
+ type: string;
92
+ currency: string;
93
+ integration: number;
94
+ domain: string;
95
+ split_code: string;
96
+ active: boolean;
97
+ bearer_type: string;
98
+ bearer_subaccount: string | null;
99
+ createdAt: Date;
100
+ updatedAt: Date;
101
+ is_dynamic: boolean;
102
+ subaccounts: SubAccount[];
103
+ total_subaccounts: number;
104
+ }
105
+ export interface SubAccount {
106
+ subaccount: {
107
+ id: number;
108
+ sunaccount_code: string;
109
+ business_name: string;
110
+ description: string;
111
+ primary_contact_name: string | null;
112
+ primary_contact_email: string | null;
113
+ primary_contact_phone: string | null;
114
+ metadata: Record<string, any>;
115
+ settlement_bank: string;
116
+ currency: string;
117
+ account_number: string;
118
+ };
119
+ share: number;
120
+ }
121
+ export interface CustomerIdentification {
122
+ country: string;
123
+ type: string;
124
+ value: string;
125
+ }
126
+ export interface DedicatedAccount {
127
+ bank: {
128
+ name: string;
129
+ id: number;
130
+ slug: string;
131
+ };
132
+ id: number;
133
+ account_name: string;
134
+ account_number: string;
135
+ created_at: Date;
136
+ updated_at: Date;
137
+ currency: string;
138
+ split_config: SplitConfig;
139
+ active: boolean;
140
+ assigned: boolean;
141
+ assignment: {
142
+ assignee_id: number;
143
+ assignee_type: string;
144
+ account_type: string;
145
+ integration: number;
146
+ };
147
+ }
148
+ export interface UpdateCustomer {
149
+ first_name: string;
150
+ last_name: string;
151
+ phone: string;
152
+ metadata: Record<string, any>;
153
+ }
154
+ export interface SetRiskAction {
155
+ customer: string;
156
+ risk_action: RiskAction;
157
+ }
158
+ export interface ValidateCustomer {
159
+ first_name: string;
160
+ last_name: string;
161
+ type: ValidationType;
162
+ value: string;
163
+ country: string;
164
+ bvn: string;
165
+ bank_code: string;
166
+ account_number: string;
167
+ }
168
+ declare enum RiskAction {
169
+ default = 0,
170
+ allow = 1,
171
+ deny = 2
172
+ }
173
+ declare enum ValidationType {
174
+ bvn = 0,
175
+ bank_account = 1
176
+ }
177
+ export {};
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var RiskAction;
4
+ (function (RiskAction) {
5
+ RiskAction[RiskAction["default"] = 0] = "default";
6
+ RiskAction[RiskAction["allow"] = 1] = "allow";
7
+ RiskAction[RiskAction["deny"] = 2] = "deny";
8
+ })(RiskAction || (RiskAction = {}));
9
+ var ValidationType;
10
+ (function (ValidationType) {
11
+ ValidationType[ValidationType["bvn"] = 0] = "bvn";
12
+ ValidationType[ValidationType["bank_account"] = 1] = "bank_account";
13
+ })(ValidationType || (ValidationType = {}));
package/dist/index.d.ts CHANGED
@@ -1 +1 @@
1
- export * from './paystack';
1
+ export { Paystack } from './paystack';
package/dist/index.js CHANGED
@@ -1 +1,5 @@
1
- export * from './paystack';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Paystack = void 0;
4
+ var paystack_1 = require("./paystack");
5
+ Object.defineProperty(exports, "Paystack", { enumerable: true, get: function () { return paystack_1.Paystack; } });
@@ -1,15 +1,15 @@
1
- import { ICharge } from './charge';
2
- import { Plan } from './plan/plan';
3
- import { ITransaction } from './transaction/transaction';
1
+ import { Charge } from './charge';
2
+ import { Plan } from './plan';
3
+ import { Transaction } from './transaction';
4
4
  /**
5
5
  * Paystack SDK
6
6
  * @author Asaju Enitan <@en1tan>
7
7
  */
8
- export default class Paystack {
8
+ export declare class Paystack {
9
9
  readonly key: string;
10
10
  private readonly http;
11
- charge: ICharge;
12
- transaction: ITransaction;
11
+ charge: Charge;
12
+ transaction: Transaction;
13
13
  plan: Plan;
14
14
  constructor(key: string);
15
15
  }
package/dist/paystack.js CHANGED
@@ -1,29 +1,26 @@
1
- import { Axios } from 'axios';
2
- import { Charge } from './charge';
3
- import { Plan } from './plan/plan';
4
- import { Transaction } from './transaction/transaction';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Paystack = void 0;
4
+ const axios_1 = require("axios");
5
+ const charge_1 = require("./charge");
6
+ const plan_1 = require("./plan");
7
+ const transaction_1 = require("./transaction");
5
8
  /**
6
9
  * Paystack SDK
7
10
  * @author Asaju Enitan <@en1tan>
8
11
  */
9
- export default class Paystack {
10
- key;
11
- http;
12
- charge;
13
- transaction;
14
- plan;
12
+ class Paystack {
15
13
  constructor(key) {
16
14
  this.key = key;
17
- this.http = new Axios({
15
+ this.http = new axios_1.Axios({
18
16
  baseURL: 'https://api.paystack.co',
19
17
  headers: {
20
18
  Authorization: `Bearer ${this.key}`,
21
- 'Content-Type': 'application/json',
22
19
  },
23
- responseType: 'json',
24
20
  });
25
- this.charge = new Charge(this.http);
26
- this.transaction = new Transaction(this.http);
27
- this.plan = new Plan(this.http);
21
+ this.charge = new charge_1.Charge(this.http);
22
+ this.transaction = new transaction_1.Transaction(this.http);
23
+ this.plan = new plan_1.Plan(this.http);
28
24
  }
29
25
  }
26
+ exports.Paystack = Paystack;
@@ -1,2 +1,14 @@
1
- export * from './interface';
2
- export * from './plan';
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./interface"), exports);
14
+ __exportStar(require("./plan"), exports);
@@ -1,2 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
1
3
  [];
2
- export {};
@@ -5,19 +5,13 @@ interface BadRequest {
5
5
  message: string;
6
6
  data: null;
7
7
  }
8
- export interface IPlan {
9
- create(data: CreatePlan): Promise<PlanResponse | BadRequest>;
10
- list(queryParams?: ListPlanQueryParams): Promise<PlanResponse | BadRequest>;
11
- fetch(id: string): Promise<PlanResponse | BadRequest>;
12
- update(id: string, data: UpdatePlan): Promise<PlanResponse | BadRequest>;
13
- }
14
8
  /**
15
9
  * ## Plans
16
10
  * The Plans API allows you create and manage installment
17
11
  * payment options on your integration
18
12
  * @class Plan
19
13
  */
20
- export declare class Plan implements IPlan {
14
+ export declare class Plan {
21
15
  private http;
22
16
  constructor(http: Axios);
23
17
  /**
package/dist/plan/plan.js CHANGED
@@ -1,11 +1,22 @@
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.Plan = void 0;
1
13
  /**
2
14
  * ## Plans
3
15
  * The Plans API allows you create and manage installment
4
16
  * payment options on your integration
5
17
  * @class Plan
6
18
  */
7
- export class Plan {
8
- http;
19
+ class Plan {
9
20
  constructor(http) {
10
21
  this.http = http;
11
22
  }
@@ -15,9 +26,11 @@ export class Plan {
15
26
  * @param {CreatePlan} data Body Param
16
27
  * @returns {Promise<PlanResponse | BadRequest>}
17
28
  */
18
- async create(data) {
19
- const response = await this.http.post('/plan', JSON.stringify(data));
20
- return JSON.parse(response.data);
29
+ create(data) {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ const response = yield this.http.post('/plan', JSON.stringify(data));
32
+ return JSON.parse(response.data);
33
+ });
21
34
  }
22
35
  /**
23
36
  * ### List Plans
@@ -25,11 +38,13 @@ export class Plan {
25
38
  * @param queryParams Query Parameters
26
39
  * @returns {Promise<PlanResponse | BadRequest>}
27
40
  */
28
- async list(queryParams) {
29
- const response = await this.http.get('/plan', {
30
- params: { ...queryParams },
41
+ list(queryParams) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ const response = yield this.http.get('/plan', {
44
+ params: Object.assign({}, queryParams),
45
+ });
46
+ return JSON.parse(response.data);
31
47
  });
32
- return JSON.parse(response.data);
33
48
  }
34
49
  /**
35
50
  * ### Fetch Plan
@@ -37,9 +52,11 @@ export class Plan {
37
52
  * @param id The plan `ID` or `code` you want to fetch
38
53
  * @returns {Promise<PlanResponse | BadRequest>}
39
54
  */
40
- async fetch(id) {
41
- const response = await this.http.get(`/plan/${id}`);
42
- return JSON.parse(response.data);
55
+ fetch(id) {
56
+ return __awaiter(this, void 0, void 0, function* () {
57
+ const response = yield this.http.get(`/plan/${id}`);
58
+ return JSON.parse(response.data);
59
+ });
43
60
  }
44
61
  /**
45
62
  * ### Update Plan
@@ -48,8 +65,11 @@ export class Plan {
48
65
  * @param {UpdatePlan} data Update Plan Data
49
66
  * @returns {Promise<PlanResponse | BadRequest>}
50
67
  */
51
- async update(id, data) {
52
- const response = await this.http.put(`/plan/${id}`, JSON.stringify(data));
53
- return JSON.parse(response.data);
68
+ update(id, data) {
69
+ return __awaiter(this, void 0, void 0, function* () {
70
+ const response = yield this.http.put(`/plan/${id}`, JSON.stringify(data));
71
+ return JSON.parse(response.data);
72
+ });
54
73
  }
55
74
  }
75
+ exports.Plan = Plan;
@@ -1,2 +1,14 @@
1
- export * from './interface';
2
- export * from './transaction';
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./interface"), exports);
14
+ __exportStar(require("./transaction"), exports);
@@ -16,7 +16,7 @@ export interface InitializeTransaction {
16
16
  */
17
17
  currency?: string;
18
18
  /**
19
- * Unique transaction reference. Only `-`,`.`,`_`
19
+ * Unique transaction reference. Only `-`,`.`,`=`
20
20
  * and alphanumeric characters allowed
21
21
  */
22
22
  reference?: string;
@@ -75,7 +75,7 @@ export interface InitializeTransaction {
75
75
  export interface TransactionResponse {
76
76
  status: boolean;
77
77
  message: string;
78
- data: TransactionInitializedOk | TransactionData | Transactions;
78
+ data: TransactionInitializedOk | TransactionData | Transactions | Timeline | ExportTransaction;
79
79
  meta?: Meta;
80
80
  }
81
81
  interface TransactionInitializedOk {
@@ -83,7 +83,7 @@ interface TransactionInitializedOk {
83
83
  access_code: string;
84
84
  reference: string;
85
85
  }
86
- interface TransactionData {
86
+ export interface TransactionData {
87
87
  amount: number;
88
88
  currency: string;
89
89
  transaction_date: Date;
@@ -92,7 +92,7 @@ interface TransactionData {
92
92
  domain: string;
93
93
  metadata: number;
94
94
  gateway_response: string;
95
- message?: null;
95
+ message?: any;
96
96
  channel: string;
97
97
  ip_address: string;
98
98
  log: {
@@ -118,6 +118,26 @@ interface TransactionData {
118
118
  }
119
119
  interface Transactions extends TransactionData {
120
120
  }
121
+ interface Timeline {
122
+ time_spent: number;
123
+ attempts: number;
124
+ authentication: any;
125
+ errors: number;
126
+ success: boolean;
127
+ mobile: boolean;
128
+ input: [];
129
+ channel: string;
130
+ history: [
131
+ {
132
+ type: string;
133
+ message: string;
134
+ time: number;
135
+ }
136
+ ];
137
+ }
138
+ interface ExportTransaction {
139
+ path: string;
140
+ }
121
141
  export interface ListTransactionQueryParams {
122
142
  /**
123
143
  * Specify how many records you want to retrieve per page.
@@ -142,19 +162,19 @@ export interface ListTransactionQueryParams {
142
162
  * A timestamp from which to start listing transaction
143
163
  * e.g `2021-10-25T00.00.05.000z`, `2021-12-25`
144
164
  */
145
- from: Date;
165
+ from?: Date;
146
166
  /**
147
167
  * A timestamp from which to stop listing transaction
148
168
  * e.g `2021-10-25T00.00.05.000z`, `2021-12-25`
149
169
  */
150
- to: Date;
170
+ to?: Date;
151
171
  /**
152
172
  * Filter transactions by amount.
153
173
  * Specify the amount (in **kobo** if currency is `NGN`,
154
174
  * **pesewas**, if currency is `GHS`,
155
175
  * and **cents**, if currency is `ZAR`)
156
176
  */
157
- amount: number;
177
+ amount?: number;
158
178
  }
159
179
  export interface Meta {
160
180
  total: number;
@@ -163,4 +183,115 @@ export interface Meta {
163
183
  page: number;
164
184
  pageCount: number;
165
185
  }
186
+ export interface ChargeAuthorization {
187
+ /**
188
+ * Amount should be in kobo if currency is `NGN`, *pesewas*,
189
+ * if currency is `GHS`, and cents, if currency is `ZAR`
190
+ */
191
+ amount: string;
192
+ /**
193
+ * Customer's email address
194
+ */
195
+ email: string;
196
+ /**
197
+ * Valid authorization code to charge
198
+ */
199
+ authorization_code: string;
200
+ /**
201
+ * Unique transaction reference. Only `-`, `.`,`=`
202
+ * and alphanumeric characters allowed
203
+ */
204
+ reference?: string;
205
+ /**
206
+ * Currency in which amount shoud be charged.
207
+ * Allowed values are: NGN,GHS,ZAR or USD
208
+ */
209
+ currency?: string;
210
+ /**
211
+ * Stringified JSON object. Add a custom_fields attribute which has
212
+ * an array of objects if you would like the fields to be added to your
213
+ * transaction when displayed on the dashboard.
214
+ * @example {
215
+ * "custom_fields": [{"display_name": "Cart ID","variable_name": "cart_id","value": "8393"}]}
216
+ */
217
+ metadata?: Record<string, unknown>;
218
+ /**
219
+ * Send us 'card' or 'bank' or 'card','bank' as an array to specify what
220
+ * options to show the user paying
221
+ */
222
+ channels?: string[];
223
+ /**
224
+ * The code for the subaccount that owns the payment.
225
+ * @exmple ACCT_8f4s1eq7ml6rlzj
226
+ */
227
+ subaccount?: string;
228
+ /**
229
+ * A flat fee to charge the subaccount for this transaction (in kobo if currency is NGN,
230
+ * pesewas, if currency is GHS, and cents, if currency is ZAR). This overrides the split percentage
231
+ * set when the subaccount was created. Ideally, you will need to use this if you are splitting in
232
+ * flat rates (since subaccount creation only allows for
233
+ */
234
+ transaction_charge?: number;
235
+ /**
236
+ * Who bears Paystack charges? `account` or `subaccount` (defaults to `account`).
237
+ */
238
+ bearer?: string;
239
+ /**
240
+ * If you are making a scheduled charge call, it is a good idea to queue them so the processing
241
+ * system does not get overloaded causing transaction processing errors. Send queue:true
242
+ * to take advantage of our queued charging.
243
+ */
244
+ queue?: boolean;
245
+ }
246
+ export interface CheckAuthorization {
247
+ /**
248
+ * Amount should be in kobo if currency is `NGN`,
249
+ * pesewas, if currency is `GHS`, and cents, if currency is `ZAR`
250
+ */
251
+ amount: string;
252
+ /**
253
+ * Customer's email address
254
+ */
255
+ email: string;
256
+ /**
257
+ * Valid authorization code to charge
258
+ */
259
+ authorization_code: string;
260
+ /**
261
+ * Currency in which amount should be charged.
262
+ * Allowed values are: `NGN`, `GHS`, `ZAR` or `USD`
263
+ */
264
+ currency?: string;
265
+ }
266
+ export interface PartialDebit {
267
+ /**
268
+ * Authorization Code
269
+ */
270
+ authorization_code: string;
271
+ /**
272
+ * Specify the currency you want to debit.
273
+ * Allowed values are `NGN`, `GHS`, `ZAR` or `USD`.
274
+ */
275
+ currency: string;
276
+ /**
277
+ * Amount should be in *kobo* if currency is NGN,
278
+ * pesewas, if *currency* is `GHS`, and *cents*, if currency is `ZAR`
279
+ */
280
+ amount: string;
281
+ /**
282
+ * Customer's email address (attached to the authorization code)
283
+ */
284
+ email: string;
285
+ /**
286
+ * Unique transaction reference.
287
+ * Only `-`, `.`, `=` and alphanumeric characters allowed.
288
+ */
289
+ reference: string;
290
+ /**
291
+ * Minimum amount to charge
292
+ */
293
+ at_least: string;
294
+ }
295
+ export interface Subscription {
296
+ }
166
297
  export {};
@@ -1,2 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
1
3
  [];
2
- export {};
@@ -1,21 +1,16 @@
1
1
  import { Axios } from 'axios';
2
- import { InitializeTransaction, ListTransactionQueryParams, TransactionResponse } from './interface';
2
+ import { ChargeAuthorization, CheckAuthorization, InitializeTransaction, ListTransactionQueryParams, PartialDebit, TransactionResponse } from './interface';
3
3
  interface BadRequest {
4
4
  status: boolean;
5
5
  message: string;
6
6
  data: null;
7
7
  }
8
- export interface ITransaction {
9
- initialize(data: InitializeTransaction): Promise<TransactionResponse | BadRequest>;
10
- verify(reference: string): Promise<TransactionResponse | BadRequest>;
11
- list(queryParams: ListTransactionQueryParams): Promise<TransactionResponse | BadRequest>;
12
- }
13
8
  /**
14
- * ## Tansactions
9
+ * # Tansactions
15
10
  * The transaction API allows you create and manage
16
11
  * payments on your integration
17
12
  */
18
- export declare class Transaction implements ITransaction {
13
+ export declare class Transaction {
19
14
  private http;
20
15
  constructor(http: Axios);
21
16
  /**
@@ -25,5 +20,12 @@ export declare class Transaction implements ITransaction {
25
20
  initialize(data: InitializeTransaction): Promise<TransactionResponse | BadRequest>;
26
21
  verify(reference: string): Promise<TransactionResponse | BadRequest>;
27
22
  list(queryParams: ListTransactionQueryParams): Promise<TransactionResponse | BadRequest>;
23
+ fetch(id: string): Promise<TransactionResponse | BadRequest>;
24
+ chargeAuthorization(data: ChargeAuthorization): Promise<TransactionResponse | BadRequest>;
25
+ checkAuthorization(data: CheckAuthorization): Promise<TransactionResponse | BadRequest>;
26
+ viewTimeline(id: string): Promise<TransactionResponse | BadRequest>;
27
+ totals(queryParams: ListTransactionQueryParams): Promise<TransactionResponse | BadRequest>;
28
+ export(queryParams: ListTransactionQueryParams): Promise<TransactionResponse | BadRequest>;
29
+ partialDebit(data: PartialDebit): Promise<TransactionResponse | BadRequest>;
28
30
  }
29
31
  export {};
@@ -1,10 +1,21 @@
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.Transaction = void 0;
1
13
  /**
2
- * ## Tansactions
14
+ * # Tansactions
3
15
  * The transaction API allows you create and manage
4
16
  * payments on your integration
5
17
  */
6
- export class Transaction {
7
- http;
18
+ class Transaction {
8
19
  constructor(http) {
9
20
  this.http = http;
10
21
  }
@@ -12,20 +23,73 @@ export class Transaction {
12
23
  * Initialize a transaction
13
24
  * @param {InitializeTransaction} data **Body Param**
14
25
  */
15
- async initialize(data) {
16
- const response = await this.http.post('/transaction/initialize', JSON.stringify(data));
17
- return JSON.parse(response.data);
26
+ initialize(data) {
27
+ return __awaiter(this, void 0, void 0, function* () {
28
+ const response = yield this.http.post('/transaction/initialize', JSON.stringify(data));
29
+ return JSON.parse(response.data);
30
+ });
31
+ }
32
+ verify(reference) {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ const response = yield this.http.get('/transaction/verify', {
35
+ params: { reference },
36
+ });
37
+ return JSON.parse(response.data);
38
+ });
39
+ }
40
+ list(queryParams) {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ const response = yield this.http.get('/transaction', {
43
+ params: Object.assign({}, queryParams),
44
+ });
45
+ return JSON.parse(response.data);
46
+ });
47
+ }
48
+ fetch(id) {
49
+ return __awaiter(this, void 0, void 0, function* () {
50
+ const response = yield this.http.get(`/transaction/:${id}`);
51
+ return JSON.parse(response.data);
52
+ });
53
+ }
54
+ chargeAuthorization(data) {
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ const response = yield this.http.post('/transaction/charge_authorization', JSON.stringify(data));
57
+ return JSON.parse(response.data);
58
+ });
59
+ }
60
+ checkAuthorization(data) {
61
+ return __awaiter(this, void 0, void 0, function* () {
62
+ const response = yield this.http.post('/transaction/check_authorization', JSON.stringify(data));
63
+ return JSON.parse(response.data);
64
+ });
65
+ }
66
+ viewTimeline(id) {
67
+ return __awaiter(this, void 0, void 0, function* () {
68
+ const response = yield this.http.get(`/transaction/timeline/${id}`);
69
+ return JSON.parse(response.data);
70
+ });
71
+ }
72
+ totals(queryParams) {
73
+ return __awaiter(this, void 0, void 0, function* () {
74
+ const response = yield this.http.get('/transaction/totals', {
75
+ params: Object.assign({}, queryParams),
76
+ });
77
+ return JSON.parse(response.data);
78
+ });
18
79
  }
19
- async verify(reference) {
20
- const response = await this.http.get('/transaction/verify', {
21
- params: { reference },
80
+ export(queryParams) {
81
+ return __awaiter(this, void 0, void 0, function* () {
82
+ const response = yield this.http.get('/transaction/export', {
83
+ params: Object.assign({}, queryParams),
84
+ });
85
+ return JSON.parse(response.data);
22
86
  });
23
- return JSON.parse(response.data);
24
87
  }
25
- async list(queryParams) {
26
- const response = await this.http.get('/transaction', {
27
- params: { ...queryParams },
88
+ partialDebit(data) {
89
+ return __awaiter(this, void 0, void 0, function* () {
90
+ const response = yield this.http.post('/transaction/partial_debit', JSON.stringify(data));
91
+ return JSON.parse(response.data);
28
92
  });
29
- return JSON.parse(response.data);
30
93
  }
31
94
  }
95
+ exports.Transaction = Transaction;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paystack-sdk",
3
- "version": "1.0.12",
3
+ "version": "1.0.16",
4
4
  "description": "Paystack SDK written in Typescript",
5
5
  "main": "dist/index.js",
6
6
  "author": "Koderant",