paystack-sdk 1.0.16 → 1.0.20

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,5 +1,6 @@
1
1
  import { Axios } from 'axios';
2
- import { ChargeAuthorization, CheckAuthorization, InitializeTransaction, ListTransactionQueryParams, PartialDebit, TransactionResponse } from './interface';
2
+ import { CheckAuthorizationResponse, ExportTransaction, ListTransactions, PartialDebitResponse, Timeline, TransactionData } from '.';
3
+ import { ChargeAuthorization, CheckAuthorization, InitializeTransaction, ListTransactionQueryParams, PartialDebit, TransactionInitialized } from './interface';
3
4
  interface BadRequest {
4
5
  status: boolean;
5
6
  message: string;
@@ -17,15 +18,15 @@ export declare class Transaction {
17
18
  * Initialize a transaction
18
19
  * @param {InitializeTransaction} data **Body Param**
19
20
  */
20
- initialize(data: InitializeTransaction): Promise<TransactionResponse | BadRequest>;
21
- verify(reference: string): Promise<TransactionResponse | BadRequest>;
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>;
21
+ initialize(data: InitializeTransaction): Promise<TransactionInitialized | BadRequest>;
22
+ verify(reference: string): Promise<TransactionData | BadRequest>;
23
+ list(queryParams?: ListTransactionQueryParams): Promise<ListTransactions | BadRequest>;
24
+ fetch(id: string): Promise<TransactionData | BadRequest>;
25
+ chargeAuthorization(data: ChargeAuthorization): Promise<TransactionData | BadRequest>;
26
+ checkAuthorization(data: CheckAuthorization): Promise<CheckAuthorizationResponse | BadRequest>;
27
+ viewTimeline(id: string): Promise<Timeline | BadRequest>;
28
+ total(queryParams: ListTransactionQueryParams): Promise<ListTransactions | BadRequest>;
29
+ export(queryParams: ListTransactionQueryParams): Promise<ExportTransaction | BadRequest>;
30
+ partialDebit(data: PartialDebit): Promise<PartialDebitResponse | BadRequest>;
30
31
  }
31
32
  export {};
@@ -26,7 +26,7 @@ class Transaction {
26
26
  initialize(data) {
27
27
  return __awaiter(this, void 0, void 0, function* () {
28
28
  const response = yield this.http.post('/transaction/initialize', JSON.stringify(data));
29
- return JSON.parse(response.data);
29
+ return response;
30
30
  });
31
31
  }
32
32
  verify(reference) {
@@ -34,7 +34,7 @@ class Transaction {
34
34
  const response = yield this.http.get('/transaction/verify', {
35
35
  params: { reference },
36
36
  });
37
- return JSON.parse(response.data);
37
+ return response;
38
38
  });
39
39
  }
40
40
  list(queryParams) {
@@ -42,47 +42,44 @@ class Transaction {
42
42
  const response = yield this.http.get('/transaction', {
43
43
  params: Object.assign({}, queryParams),
44
44
  });
45
- return JSON.parse(response.data);
45
+ return response;
46
46
  });
47
47
  }
48
48
  fetch(id) {
49
49
  return __awaiter(this, void 0, void 0, function* () {
50
50
  const response = yield this.http.get(`/transaction/:${id}`);
51
- return JSON.parse(response.data);
51
+ return response;
52
52
  });
53
53
  }
54
54
  chargeAuthorization(data) {
55
55
  return __awaiter(this, void 0, void 0, function* () {
56
56
  const response = yield this.http.post('/transaction/charge_authorization', JSON.stringify(data));
57
- return JSON.parse(response.data);
57
+ return response;
58
58
  });
59
59
  }
60
60
  checkAuthorization(data) {
61
61
  return __awaiter(this, void 0, void 0, function* () {
62
62
  const response = yield this.http.post('/transaction/check_authorization', JSON.stringify(data));
63
- return JSON.parse(response.data);
63
+ return response;
64
64
  });
65
65
  }
66
66
  viewTimeline(id) {
67
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);
68
+ return yield this.http.get(`/transaction/timeline/${id}`);
70
69
  });
71
70
  }
72
- totals(queryParams) {
71
+ total(queryParams) {
73
72
  return __awaiter(this, void 0, void 0, function* () {
74
- const response = yield this.http.get('/transaction/totals', {
73
+ return yield this.http.get('/transaction/totals', {
75
74
  params: Object.assign({}, queryParams),
76
75
  });
77
- return JSON.parse(response.data);
78
76
  });
79
77
  }
80
78
  export(queryParams) {
81
79
  return __awaiter(this, void 0, void 0, function* () {
82
- const response = yield this.http.get('/transaction/export', {
80
+ return yield this.http.get('/transaction/export', {
83
81
  params: Object.assign({}, queryParams),
84
82
  });
85
- return JSON.parse(response.data);
86
83
  });
87
84
  }
88
85
  partialDebit(data) {
@@ -0,0 +1,105 @@
1
+ export interface InitiateTransfer {
2
+ /**
3
+ * Where should we transfer from? Only `balance` for now
4
+ */
5
+ source: string;
6
+ /** Amount to transfer in *kobo* if currency is `NGN`
7
+ * and *pesewas* if currency is `GHS`.
8
+ */
9
+ amount: number;
10
+ /**
11
+ * Code for transfer recipient
12
+ */
13
+ recipient: string;
14
+ /**
15
+ * The reason for the transfer
16
+ */
17
+ reason?: string;
18
+ /**
19
+ * Specify the currency of the transfer. Defaults to NGN
20
+ */
21
+ currency?: string;
22
+ /** If specified, the field should be a unique identifier (in lowercase)
23
+ * for the object. Only `-`,`_` and alphanumeric characters allowed.
24
+ */
25
+ reference?: string;
26
+ }
27
+ export interface Response {
28
+ status: boolean;
29
+ message: string;
30
+ }
31
+ export interface FinalizeTransfer extends Response {
32
+ data: Transfer;
33
+ }
34
+ export interface TransferInitiated extends Response {
35
+ data: Transfer;
36
+ }
37
+ export interface InitiateBulkTransfer {
38
+ /**
39
+ * Where should we transfer from? Only `balance` for now
40
+ */
41
+ source: string;
42
+ /**
43
+ * A list of transfer object. Each object should contain `amount`, `recipient`, and `reference`
44
+ */
45
+ transfers: {
46
+ amount: number;
47
+ recipient: string;
48
+ reference: string;
49
+ }[];
50
+ }
51
+ export interface BulkTransferInitiated extends Response {
52
+ data: Transfer[];
53
+ }
54
+ export interface ListTransfers extends Response {
55
+ data: Transfer[];
56
+ }
57
+ export interface FetchTransfer extends Response {
58
+ data: Transfer;
59
+ }
60
+ export interface VerifyTransfer extends Response {
61
+ data: Transfer;
62
+ }
63
+ export interface ListTransferQueryParams {
64
+ /**
65
+ * Specify how many records you want to retrieve per page.
66
+ * If not specify we use a default value of 50.
67
+ */
68
+ perPage?: number;
69
+ /**
70
+ * Specify exactly what page you want to retrieve.
71
+ * If not specify we use a default value of 1.
72
+ */
73
+ page?: number;
74
+ /**
75
+ * Specify an ID for the customer whose transactions
76
+ * you want to retrieve
77
+ */
78
+ customer?: number;
79
+ /**
80
+ * A timestamp from which to start listing transaction
81
+ * e.g `2021-10-25T00.00.05.000z`, `2021-12-25`
82
+ */
83
+ from?: Date;
84
+ /**
85
+ * A timestamp from which to stop listing transaction
86
+ * e.g `2021-10-25T00.00.05.000z`, `2021-12-25`
87
+ */
88
+ to?: Date;
89
+ }
90
+ interface Transfer {
91
+ integration: number;
92
+ domain: string;
93
+ amount: number;
94
+ source: string;
95
+ source_details: string;
96
+ reason: string;
97
+ recipient: number | string | Record<string, unknown>;
98
+ status: string;
99
+ failures: unknown;
100
+ transfer_code: string;
101
+ id: number;
102
+ createdAt: Date;
103
+ updatedAt: Date;
104
+ }
105
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,26 @@
1
+ import { Axios } from 'axios';
2
+ import { BulkTransferInitiated, FetchTransfer, FinalizeTransfer, InitiateBulkTransfer, InitiateTransfer, ListTransferQueryParams, ListTransfers, TransferInitiated, VerifyTransfer } from './interface';
3
+ interface BadRequest {
4
+ status: boolean;
5
+ message: string;
6
+ }
7
+ export declare class Transfer {
8
+ http: Axios;
9
+ constructor(http: Axios);
10
+ /**
11
+ * # Initiate Transfer
12
+ * Status of transfer object returned will be `pending` if OTP is disabled.
13
+ * In the event that an OTP is required, status will read `otp`.
14
+ */
15
+ initiate(data: InitiateTransfer): Promise<TransferInitiated | BadRequest>;
16
+ /**
17
+ * # Finalize Transfer
18
+ * Finalize an initiated transfer
19
+ */
20
+ finalize(transferCode: string, otp: string): Promise<FinalizeTransfer | BadRequest>;
21
+ bulk(data: InitiateBulkTransfer): Promise<BulkTransferInitiated | BadRequest>;
22
+ list(queryParams?: ListTransferQueryParams): Promise<ListTransfers | BadRequest>;
23
+ fetch(idOrCode: string): Promise<FetchTransfer | BadRequest>;
24
+ verify(reference: string): Promise<VerifyTransfer | BadRequest>;
25
+ }
26
+ export {};
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Transfer = void 0;
13
+ class Transfer {
14
+ constructor(http) {
15
+ this.http = http;
16
+ }
17
+ /**
18
+ * # Initiate Transfer
19
+ * Status of transfer object returned will be `pending` if OTP is disabled.
20
+ * In the event that an OTP is required, status will read `otp`.
21
+ */
22
+ initiate(data) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ return yield this.http.post('/transfer', JSON.stringify(data));
25
+ });
26
+ }
27
+ /**
28
+ * # Finalize Transfer
29
+ * Finalize an initiated transfer
30
+ */
31
+ finalize(transferCode, otp) {
32
+ return __awaiter(this, void 0, void 0, function* () {
33
+ return yield this.http.post('/transfer/finalize_transfer', JSON.stringify({ transfer_code: transferCode, otp }));
34
+ });
35
+ }
36
+ bulk(data) {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ return yield this.http.post('/transfer/bulk', JSON.stringify(data));
39
+ });
40
+ }
41
+ list(queryParams) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ return yield this.http.get('/transfer', {
44
+ params: Object.assign({}, queryParams),
45
+ });
46
+ });
47
+ }
48
+ fetch(idOrCode) {
49
+ return __awaiter(this, void 0, void 0, function* () {
50
+ return yield this.http.get(`/transfer/${idOrCode}`);
51
+ });
52
+ }
53
+ verify(reference) {
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ return yield this.http.get(`transfer/verify/${reference}`);
56
+ });
57
+ }
58
+ }
59
+ exports.Transfer = Transfer;
package/package.json CHANGED
@@ -1,16 +1,15 @@
1
1
  {
2
2
  "name": "paystack-sdk",
3
- "version": "1.0.16",
3
+ "version": "1.0.20",
4
4
  "description": "Paystack SDK written in Typescript",
5
5
  "main": "dist/index.js",
6
- "author": "Koderant",
6
+ "author": "Tech Priest",
7
7
  "license": "MIT",
8
8
  "private": false,
9
9
  "scripts": {
10
10
  "build": "tsc",
11
11
  "format": "prettier --write \"src/**/*.ts\"",
12
12
  "lint": "tslint -p tsconfig.json",
13
- "test": "jest --config jestconfig.json",
14
13
  "prepare": "npm run build",
15
14
  "prepublishOnly": "npm run lint",
16
15
  "preversion": "npm run lint",
@@ -18,14 +17,16 @@
18
17
  "postversion": "git push && git push --tags"
19
18
  },
20
19
  "devDependencies": {
21
- "@types/jest": "^27.0.3",
22
- "@types/node": "^16.11.11",
23
- "jest": "^27.4.3",
24
- "prettier": "^2.5.1",
25
- "ts-jest": "^27.0.7",
26
- "tslint": "^6.1.3",
27
- "tslint-config-prettier": "^1.18.0",
28
- "typescript": "^4.5.2"
20
+ "@types/node": "16.11.11",
21
+ "@typescript-eslint/eslint-plugin": "^5.10.0",
22
+ "@typescript-eslint/parser": "^5.10.0",
23
+ "eslint": "8.6.0",
24
+ "prettier": "2.5.1",
25
+ "ts-node": "10.4.0",
26
+ "tslint": "6.1.3",
27
+ "tslint-config-prettier": "1.18.0",
28
+ "typescript": "4.5.2",
29
+ "typescript-eslint": "0.0.1-alpha.0"
29
30
  },
30
31
  "dependencies": {
31
32
  "axios": "^0.24.0"
@@ -35,7 +36,9 @@
35
36
  ],
36
37
  "keywords": [
37
38
  "Paystack",
38
- "Typescript"
39
+ "Typescript",
40
+ "payment",
41
+ "node"
39
42
  ],
40
43
  "repository": {
41
44
  "type": "git",