litegate-sdk 1.0.0 → 1.0.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/dist/client.d.ts +4 -2
- package/dist/client.js +7 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/services/LiteGateService.d.ts +25 -0
- package/dist/services/LiteGateService.js +96 -0
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export declare class LiteGateClient {
|
|
2
2
|
private baseUrl;
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
PublicKey: string;
|
|
4
|
+
PrivateKey: string;
|
|
5
|
+
constructor(PublicKey: string, PrivateKey: string);
|
|
6
|
+
initiateTelebirrPayment(title: string, amount: string, buyer_phone_number: string): Promise<any>;
|
|
5
7
|
telebirrCallback({ notify_url, appid, notify_time, merch_code, merch_order_id, payment_order_id, total_amount, trans_currency, trade_status, trans_end_time, callback_info, sign, sign_type, transId, }: {
|
|
6
8
|
notify_url: string;
|
|
7
9
|
appid: string;
|
package/dist/client.js
CHANGED
|
@@ -3,17 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.LiteGateClient = void 0;
|
|
4
4
|
const signature_1 = require("./crypto/signature");
|
|
5
5
|
class LiteGateClient {
|
|
6
|
-
constructor(
|
|
7
|
-
this.baseUrl =
|
|
6
|
+
constructor(PublicKey, PrivateKey) {
|
|
7
|
+
this.baseUrl = "https://api.litegate.et";
|
|
8
|
+
this.PublicKey = PublicKey;
|
|
9
|
+
this.PrivateKey = PrivateKey;
|
|
8
10
|
}
|
|
9
|
-
async initiateTelebirrPayment(title, amount, buyer_phone_number
|
|
11
|
+
async initiateTelebirrPayment(title, amount, buyer_phone_number) {
|
|
10
12
|
const body = { title, amount, buyer_phone_number };
|
|
11
|
-
const signature = await (0, signature_1.signRequest)(body,
|
|
13
|
+
const signature = await (0, signature_1.signRequest)(body, this.PrivateKey);
|
|
12
14
|
const response = await fetch(`${this.baseUrl}/v1/telebirr/initiate/`, {
|
|
13
15
|
method: "POST",
|
|
14
16
|
headers: {
|
|
15
17
|
"Content-Type": "application/json",
|
|
16
|
-
Authorization: `PublicKey ${
|
|
18
|
+
Authorization: `PublicKey ${this.PublicKey}`,
|
|
17
19
|
"X-SIGNATURE": signature,
|
|
18
20
|
},
|
|
19
21
|
body: JSON.stringify(body),
|
package/dist/index.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ export type { OpenAPIConfig } from "./core/OpenAPI";
|
|
|
5
5
|
export type { ErrorResponse } from "./models/ErrorResponse";
|
|
6
6
|
export type { SuccessResponse } from "./models/SuccessResponse";
|
|
7
7
|
export type { TelebirrPaymentRequest } from "./models/TelebirrPaymentRequest";
|
|
8
|
-
export {
|
|
8
|
+
export { LiteGateClient } from "./services/LiteGateService";
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.LiteGateClient = exports.OpenAPI = exports.CancelError = exports.CancelablePromise = exports.ApiError = void 0;
|
|
4
4
|
var ApiError_1 = require("./core/ApiError");
|
|
5
5
|
Object.defineProperty(exports, "ApiError", { enumerable: true, get: function () { return ApiError_1.ApiError; } });
|
|
6
6
|
var CancelablePromise_1 = require("./core/CancelablePromise");
|
|
@@ -8,5 +8,5 @@ Object.defineProperty(exports, "CancelablePromise", { enumerable: true, get: fun
|
|
|
8
8
|
Object.defineProperty(exports, "CancelError", { enumerable: true, get: function () { return CancelablePromise_1.CancelError; } });
|
|
9
9
|
var OpenAPI_1 = require("./core/OpenAPI");
|
|
10
10
|
Object.defineProperty(exports, "OpenAPI", { enumerable: true, get: function () { return OpenAPI_1.OpenAPI; } });
|
|
11
|
-
var
|
|
12
|
-
Object.defineProperty(exports, "
|
|
11
|
+
var LiteGateService_1 = require("./services/LiteGateService");
|
|
12
|
+
Object.defineProperty(exports, "LiteGateClient", { enumerable: true, get: function () { return LiteGateService_1.LiteGateClient; } });
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare class LiteGateClient {
|
|
2
|
+
private baseUrl;
|
|
3
|
+
PublicKey: string;
|
|
4
|
+
PrivateKey: string;
|
|
5
|
+
constructor(PublicKey: string, PrivateKey: string);
|
|
6
|
+
initiateTelebirrPayment(title: string, amount: string, buyer_phone_number: string): Promise<any>;
|
|
7
|
+
telebirrCallback({ notify_url, appid, notify_time, merch_code, merch_order_id, payment_order_id, total_amount, trans_currency, trade_status, trans_end_time, callback_info, sign, sign_type, transId, }: {
|
|
8
|
+
notify_url: string;
|
|
9
|
+
appid: string;
|
|
10
|
+
notify_time: string;
|
|
11
|
+
merch_code: string;
|
|
12
|
+
merch_order_id: string;
|
|
13
|
+
payment_order_id: string;
|
|
14
|
+
total_amount: string;
|
|
15
|
+
trans_currency: string;
|
|
16
|
+
trade_status: string;
|
|
17
|
+
trans_end_time: string;
|
|
18
|
+
callback_info: string;
|
|
19
|
+
sign: string;
|
|
20
|
+
sign_type: string;
|
|
21
|
+
transId: string;
|
|
22
|
+
}): Promise<any>;
|
|
23
|
+
initiateCbebirrPayment(title: string, amount: string, buyer_phone_number: string): Promise<any>;
|
|
24
|
+
cbebirrCallback(EncVal: string, publicKey: string, privateKey: string): Promise<any>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LiteGateClient = void 0;
|
|
4
|
+
const signature_1 = require("../crypto/signature");
|
|
5
|
+
class LiteGateClient {
|
|
6
|
+
constructor(PublicKey, PrivateKey) {
|
|
7
|
+
this.baseUrl = "https://api.litegate.et";
|
|
8
|
+
this.PublicKey = PublicKey;
|
|
9
|
+
this.PrivateKey = PrivateKey;
|
|
10
|
+
}
|
|
11
|
+
async initiateTelebirrPayment(title, amount, buyer_phone_number) {
|
|
12
|
+
const body = { title, amount, buyer_phone_number };
|
|
13
|
+
const signature = await (0, signature_1.signRequest)(body, this.PrivateKey);
|
|
14
|
+
const response = await fetch(`${this.baseUrl}/v1/telebirr/initiate/`, {
|
|
15
|
+
method: "POST",
|
|
16
|
+
headers: {
|
|
17
|
+
"Content-Type": "application/json",
|
|
18
|
+
Authorization: `PublicKey ${this.PublicKey}`,
|
|
19
|
+
"X-SIGNATURE": signature,
|
|
20
|
+
},
|
|
21
|
+
body: JSON.stringify(body),
|
|
22
|
+
});
|
|
23
|
+
if (!response.ok) {
|
|
24
|
+
const err = await response.json();
|
|
25
|
+
throw new Error(JSON.stringify(err));
|
|
26
|
+
}
|
|
27
|
+
return response.json();
|
|
28
|
+
}
|
|
29
|
+
async telebirrCallback({ notify_url, appid, notify_time, merch_code, merch_order_id, payment_order_id, total_amount, trans_currency, trade_status, trans_end_time, callback_info, sign, sign_type, transId, }) {
|
|
30
|
+
const body = {
|
|
31
|
+
notify_url,
|
|
32
|
+
appid,
|
|
33
|
+
notify_time,
|
|
34
|
+
merch_code,
|
|
35
|
+
merch_order_id,
|
|
36
|
+
payment_order_id,
|
|
37
|
+
total_amount,
|
|
38
|
+
trans_currency,
|
|
39
|
+
trade_status,
|
|
40
|
+
trans_end_time,
|
|
41
|
+
callback_info,
|
|
42
|
+
sign,
|
|
43
|
+
sign_type,
|
|
44
|
+
transId,
|
|
45
|
+
};
|
|
46
|
+
const response = await fetch(`${this.baseUrl}/v1/telebirr/notify/`, {
|
|
47
|
+
method: "POST",
|
|
48
|
+
headers: {
|
|
49
|
+
"Content-Type": "application/json",
|
|
50
|
+
},
|
|
51
|
+
body: JSON.stringify(body),
|
|
52
|
+
});
|
|
53
|
+
if (!response.ok) {
|
|
54
|
+
const err = await response.json();
|
|
55
|
+
throw new Error(JSON.stringify(err));
|
|
56
|
+
}
|
|
57
|
+
return response.json();
|
|
58
|
+
}
|
|
59
|
+
async initiateCbebirrPayment(title, amount, buyer_phone_number) {
|
|
60
|
+
const body = { title, amount, buyer_phone_number };
|
|
61
|
+
const signature = await (0, signature_1.signRequest)(body, this.PrivateKey);
|
|
62
|
+
const response = await fetch(`${this.baseUrl}/v1/cbebirr/initiate/`, {
|
|
63
|
+
method: "POST",
|
|
64
|
+
headers: {
|
|
65
|
+
"Content-Type": "application/json",
|
|
66
|
+
Authorization: `PublicKey ${this.PublicKey}`,
|
|
67
|
+
"X-SIGNATURE": signature,
|
|
68
|
+
},
|
|
69
|
+
body: JSON.stringify(body),
|
|
70
|
+
});
|
|
71
|
+
if (!response.ok) {
|
|
72
|
+
const err = await response.json();
|
|
73
|
+
throw new Error(JSON.stringify(err));
|
|
74
|
+
}
|
|
75
|
+
return response.json();
|
|
76
|
+
}
|
|
77
|
+
async cbebirrCallback(EncVal, publicKey, privateKey) {
|
|
78
|
+
const body = { EncVal };
|
|
79
|
+
const signature = await (0, signature_1.signRequest)(body, privateKey);
|
|
80
|
+
const response = await fetch(`${this.baseUrl}/v1/cbebirr/notify/`, {
|
|
81
|
+
method: "POST",
|
|
82
|
+
headers: {
|
|
83
|
+
"Content-Type": "application/json",
|
|
84
|
+
Authorization: `PublicKey ${publicKey}`,
|
|
85
|
+
"X-SIGNATURE": signature,
|
|
86
|
+
},
|
|
87
|
+
body: JSON.stringify(body),
|
|
88
|
+
});
|
|
89
|
+
if (!response.ok) {
|
|
90
|
+
const err = await response.json();
|
|
91
|
+
throw new Error(JSON.stringify(err));
|
|
92
|
+
}
|
|
93
|
+
return response.json();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.LiteGateClient = LiteGateClient;
|