This repository has been archived by the owner on Dec 9, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample.ts
98 lines (89 loc) · 2.32 KB
/
sample.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// tslint:disable:no-console
import * as fs from "fs";
import * as path from "path";
import { consumerKey, consumerSecret } from "./config";
import { ApiError } from "./core/response-classes";
import PesaLib from "./PesaLib";
const pesa = new PesaLib(
consumerKey,
consumerSecret,
"174379",
"bfb279f9aa9bdbcf158e97dd71a467cd2e0c893059b10f78e6b72ada1ed2c919"
);
function oAuth() {
pesa
.oAuth()
.then(value => console.log(value.accessToken))
.catch(error => console.log(JSON.stringify(error)));
}
function lnmoProcess() {
pesa
.lnmProcess(
"1",
"254721234567",
"https://mpesa-handler/callback_url",
"Test",
"test"
)
.then(value => console.log(value))
.catch(error => {
const err = new ApiError(error.message);
console.log(err.errorMessage);
});
}
function lnmoQuery() {
pesa
.lnmQuery("ws_CO_02032018014643109")
.then(value => console.log(value.ResultDesc))
.catch(error => {
console.log(error.message);
const err = new ApiError(error.message);
console.log(err.errorMessage);
});
}
function c2bRegister() {
pesa
.c2bRegister("http://266522a4.ngrok.io", "http://266522a4.ngrok.io")
.then(response => console.log(response))
.catch(error => console.log(error.message));
}
function c2bSimulate() {
pesa
.c2bSimulate(1, 254721234567, "Test billing", "CustomerBuyGoodsOnline")
.then(response => console.log(response))
.catch(error => console.log(error.message));
}
function security() {
const cred = pesa.security("460reset", "./src/sandbox-cert.cer");
console.log(cred);
}
function balance() {
const cred = pesa.security("460reset", "./src/sandbox-cert.cer");
pesa
.balance(
cred,
"apitest460",
"601460",
"4",
"Remarks",
"https://151d6ca3.ngrok.io/post",
"https://151d6ca3.ngrok.io/post"
)
.then(response => console.log(response))
.catch(error => console.log(error.message));
}
function trasactionStatus() {
pesa
.transactionStatus(
1,
"Some remarks",
"460reset",
pesa.security("460reset", "./src/sandbox-cert.cer"),
"https://39df448a.ngrok.io/post",
"https://39df448a.ngrok.io/post",
"LKXXXX1234",
"Occ"
)
.then(response => console.log(response))
.catch(error => console.log(error.message));
}