tsapay-sdk 1.0.1 → 1.0.2
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 +3 -3
- package/dist/index.d.ts +4 -4
- package/dist/index.js +7 -7
- package/examples/create_payment.ts +2 -2
- package/package.json +11 -2
- package/src/index.ts +7 -7
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# TsaPay Node.js SDK
|
|
1
|
+
# TsaPay Node.js SDK
|
|
2
2
|
|
|
3
3
|

|
|
4
4
|

|
|
@@ -24,9 +24,9 @@ pnpm add tsapay-sdk
|
|
|
24
24
|
First, get your API Key from your TsaPay Merchant Dashboard.
|
|
25
25
|
|
|
26
26
|
```typescript
|
|
27
|
-
import {
|
|
27
|
+
import { TsaPayClient } from 'tsapay-sdk';
|
|
28
28
|
|
|
29
|
-
const tsapay = new
|
|
29
|
+
const tsapay = new TsaPayClient({
|
|
30
30
|
apiKey: 'sk_test_YOUR_API_KEY_HERE',
|
|
31
31
|
// baseUrl is optional, defaults to the production gateway
|
|
32
32
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface TsaPayConfig {
|
|
2
2
|
apiKey: string;
|
|
3
3
|
baseUrl?: string;
|
|
4
4
|
}
|
|
@@ -36,15 +36,15 @@ export interface ListPaymentsResponse {
|
|
|
36
36
|
payments: PaymentResponse["payment"][];
|
|
37
37
|
total: number;
|
|
38
38
|
}
|
|
39
|
-
export declare class
|
|
39
|
+
export declare class TsaPayError extends Error {
|
|
40
40
|
status: number;
|
|
41
41
|
data: any;
|
|
42
42
|
constructor(status: number, message: string, data?: any);
|
|
43
43
|
}
|
|
44
|
-
export declare class
|
|
44
|
+
export declare class TsaPayClient {
|
|
45
45
|
private apiKey;
|
|
46
46
|
private baseUrl;
|
|
47
|
-
constructor(config:
|
|
47
|
+
constructor(config: TsaPayConfig);
|
|
48
48
|
private request;
|
|
49
49
|
/**
|
|
50
50
|
* Create a new Mobile Money payment.
|
package/dist/index.js
CHANGED
|
@@ -3,20 +3,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.TsaPayClient = exports.TsaPayError = void 0;
|
|
7
7
|
const crypto_1 = __importDefault(require("crypto"));
|
|
8
|
-
class
|
|
8
|
+
class TsaPayError extends Error {
|
|
9
9
|
status;
|
|
10
10
|
data;
|
|
11
11
|
constructor(status, message, data) {
|
|
12
12
|
super(message);
|
|
13
|
-
this.name = "
|
|
13
|
+
this.name = "TsaPayError";
|
|
14
14
|
this.status = status;
|
|
15
15
|
this.data = data;
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
exports.
|
|
19
|
-
class
|
|
18
|
+
exports.TsaPayError = TsaPayError;
|
|
19
|
+
class TsaPayClient {
|
|
20
20
|
apiKey;
|
|
21
21
|
baseUrl;
|
|
22
22
|
constructor(config) {
|
|
@@ -41,7 +41,7 @@ class TinguilinClient {
|
|
|
41
41
|
catch (e) {
|
|
42
42
|
errorData = { message: response.statusText };
|
|
43
43
|
}
|
|
44
|
-
throw new
|
|
44
|
+
throw new TsaPayError(response.status, errorData.message || `API error ${response.status}`, errorData);
|
|
45
45
|
}
|
|
46
46
|
return response.json();
|
|
47
47
|
}
|
|
@@ -102,4 +102,4 @@ class TinguilinClient {
|
|
|
102
102
|
return expectedSignature === signatureHeader;
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
exports.
|
|
105
|
+
exports.TsaPayClient = TsaPayClient;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TsaPayClient } from "../src/index";
|
|
2
2
|
|
|
3
3
|
async function run() {
|
|
4
|
-
const client = new
|
|
4
|
+
const client = new TsaPayClient({
|
|
5
5
|
apiKey: "sk_test_1234567890", // Replace with your real test key
|
|
6
6
|
baseUrl: "http://localhost:8080/v1" // Use production URL when going live
|
|
7
7
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsapay-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "The official Node.js / TypeScript SDK for TsaPay Mobile Money Aggregator",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -8,7 +8,16 @@
|
|
|
8
8
|
"build": "tsc",
|
|
9
9
|
"prepublishOnly": "npm run build"
|
|
10
10
|
},
|
|
11
|
-
"keywords": [
|
|
11
|
+
"keywords": [
|
|
12
|
+
"tsapay",
|
|
13
|
+
"mobile-money",
|
|
14
|
+
"payments",
|
|
15
|
+
"mtn",
|
|
16
|
+
"orange-money",
|
|
17
|
+
"cemac",
|
|
18
|
+
"cameroon",
|
|
19
|
+
"fintech"
|
|
20
|
+
],
|
|
12
21
|
"author": "TsaPay",
|
|
13
22
|
"license": "MIT",
|
|
14
23
|
"type": "commonjs",
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import crypto from "crypto";
|
|
1
|
+
import crypto from "crypto";
|
|
2
2
|
|
|
3
|
-
export interface
|
|
3
|
+
export interface TsaPayConfig {
|
|
4
4
|
apiKey: string;
|
|
5
5
|
baseUrl?: string;
|
|
6
6
|
}
|
|
@@ -43,23 +43,23 @@ export interface ListPaymentsResponse {
|
|
|
43
43
|
total: number;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
export class
|
|
46
|
+
export class TsaPayError extends Error {
|
|
47
47
|
public status: number;
|
|
48
48
|
public data: any;
|
|
49
49
|
|
|
50
50
|
constructor(status: number, message: string, data?: any) {
|
|
51
51
|
super(message);
|
|
52
|
-
this.name = "
|
|
52
|
+
this.name = "TsaPayError";
|
|
53
53
|
this.status = status;
|
|
54
54
|
this.data = data;
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
export class
|
|
58
|
+
export class TsaPayClient {
|
|
59
59
|
private apiKey: string;
|
|
60
60
|
private baseUrl: string;
|
|
61
61
|
|
|
62
|
-
constructor(config:
|
|
62
|
+
constructor(config: TsaPayConfig) {
|
|
63
63
|
if (!config.apiKey) {
|
|
64
64
|
throw new Error("TsaPay API key is required");
|
|
65
65
|
}
|
|
@@ -84,7 +84,7 @@ export class TinguilinClient {
|
|
|
84
84
|
} catch (e) {
|
|
85
85
|
errorData = { message: response.statusText };
|
|
86
86
|
}
|
|
87
|
-
throw new
|
|
87
|
+
throw new TsaPayError(
|
|
88
88
|
response.status,
|
|
89
89
|
errorData.message || `API error ${response.status}`,
|
|
90
90
|
errorData
|