@singularity-payments/fastify 0.1.0-alpha.6 → 1.0.0-alpha.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/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +11 -42
- package/dist/index.mjs +11 -42
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import * as node_http from 'node:http';
|
|
|
2
2
|
import * as fastify from 'fastify';
|
|
3
3
|
import { FastifyRequest, FastifyReply, FastifyInstance } from 'fastify';
|
|
4
4
|
import { MpesaClient, MpesaConfig, MpesaClientOptions } from '@singularity-payments/core';
|
|
5
|
-
export { C2BCallback, C2BRegisterRequest, C2BRegisterResponse,
|
|
5
|
+
export { AccountBalanceCallback, AccountBalanceRequest, AccountBalanceResponse, B2BCallback, B2BRequest, B2BResponse, B2CCallback, B2CRequest, B2CResponse, C2BCallback, C2BRegisterRequest, C2BRegisterResponse, CallbackHandlerOptions, DynamicQRRequest, DynamicQRResponse, GeneralTransactionStatusRequest, GeneralTransactionStatusResponse, MpesaClient, MpesaClientOptions, MpesaConfig, ParsedC2BCallback, ParsedCallbackData, ReversalCallback, ReversalRequest, ReversalResponse, STKCallback, STKPushRequest, STKPushResponse, TransactionStatusCallback, TransactionStatusRequest, TransactionStatusResponse } from '@singularity-payments/core';
|
|
6
6
|
|
|
7
7
|
interface MpesaRouteHandler {
|
|
8
8
|
(req: FastifyRequest, reply: FastifyReply): Promise<void>;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as node_http from 'node:http';
|
|
|
2
2
|
import * as fastify from 'fastify';
|
|
3
3
|
import { FastifyRequest, FastifyReply, FastifyInstance } from 'fastify';
|
|
4
4
|
import { MpesaClient, MpesaConfig, MpesaClientOptions } from '@singularity-payments/core';
|
|
5
|
-
export { C2BCallback, C2BRegisterRequest, C2BRegisterResponse,
|
|
5
|
+
export { AccountBalanceCallback, AccountBalanceRequest, AccountBalanceResponse, B2BCallback, B2BRequest, B2BResponse, B2CCallback, B2CRequest, B2CResponse, C2BCallback, C2BRegisterRequest, C2BRegisterResponse, CallbackHandlerOptions, DynamicQRRequest, DynamicQRResponse, GeneralTransactionStatusRequest, GeneralTransactionStatusResponse, MpesaClient, MpesaClientOptions, MpesaConfig, ParsedC2BCallback, ParsedCallbackData, ReversalCallback, ReversalRequest, ReversalResponse, STKCallback, STKPushRequest, STKPushResponse, TransactionStatusCallback, TransactionStatusRequest, TransactionStatusResponse } from '@singularity-payments/core';
|
|
6
6
|
|
|
7
7
|
interface MpesaRouteHandler {
|
|
8
8
|
(req: FastifyRequest, reply: FastifyReply): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -76,12 +76,8 @@ function createMpesaHandlers(client) {
|
|
|
76
76
|
b2cResult: async (req, reply) => {
|
|
77
77
|
try {
|
|
78
78
|
const body = req.body;
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
reply.status(200).send({
|
|
82
|
-
ResultCode: 0,
|
|
83
|
-
ResultDesc: "Accepted"
|
|
84
|
-
});
|
|
79
|
+
const response = await client.handleB2CCallback(body);
|
|
80
|
+
reply.status(200).send(response);
|
|
85
81
|
} catch (error) {
|
|
86
82
|
console.error("B2C Result error:", error);
|
|
87
83
|
reply.status(200).send({
|
|
@@ -109,12 +105,8 @@ function createMpesaHandlers(client) {
|
|
|
109
105
|
b2bResult: async (req, reply) => {
|
|
110
106
|
try {
|
|
111
107
|
const body = req.body;
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
reply.status(200).send({
|
|
115
|
-
ResultCode: 0,
|
|
116
|
-
ResultDesc: "Accepted"
|
|
117
|
-
});
|
|
108
|
+
const response = await client.handleB2BCallback(body);
|
|
109
|
+
reply.status(200).send(response);
|
|
118
110
|
} catch (error) {
|
|
119
111
|
console.error("B2B Result error:", error);
|
|
120
112
|
reply.status(200).send({
|
|
@@ -142,12 +134,8 @@ function createMpesaHandlers(client) {
|
|
|
142
134
|
balanceResult: async (req, reply) => {
|
|
143
135
|
try {
|
|
144
136
|
const body = req.body;
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
reply.status(200).send({
|
|
148
|
-
ResultCode: 0,
|
|
149
|
-
ResultDesc: "Accepted"
|
|
150
|
-
});
|
|
137
|
+
const response = await client.handleAccountBalanceCallback(body);
|
|
138
|
+
reply.status(200).send(response);
|
|
151
139
|
} catch (error) {
|
|
152
140
|
console.error("Balance Result error:", error);
|
|
153
141
|
reply.status(200).send({
|
|
@@ -175,12 +163,8 @@ function createMpesaHandlers(client) {
|
|
|
175
163
|
reversalResult: async (req, reply) => {
|
|
176
164
|
try {
|
|
177
165
|
const body = req.body;
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
reply.status(200).send({
|
|
181
|
-
ResultCode: 0,
|
|
182
|
-
ResultDesc: "Accepted"
|
|
183
|
-
});
|
|
166
|
+
const response = await client.handleReversalCallback(body);
|
|
167
|
+
reply.status(200).send(response);
|
|
184
168
|
} catch (error) {
|
|
185
169
|
console.error("Reversal Result error:", error);
|
|
186
170
|
reply.status(200).send({
|
|
@@ -208,12 +192,8 @@ function createMpesaHandlers(client) {
|
|
|
208
192
|
statusResult: async (req, reply) => {
|
|
209
193
|
try {
|
|
210
194
|
const body = req.body;
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
reply.status(200).send({
|
|
214
|
-
ResultCode: 0,
|
|
215
|
-
ResultDesc: "Accepted"
|
|
216
|
-
});
|
|
195
|
+
const response = await client.handleTransactionStatusCallback(body);
|
|
196
|
+
reply.status(200).send(response);
|
|
217
197
|
} catch (error) {
|
|
218
198
|
console.error("Status Result error:", error);
|
|
219
199
|
reply.status(200).send({
|
|
@@ -323,15 +303,6 @@ function createMpesaHandlers(client) {
|
|
|
323
303
|
resultUrl,
|
|
324
304
|
timeoutUrl
|
|
325
305
|
} = req.body;
|
|
326
|
-
console.log("B2B Request Parameters:", {
|
|
327
|
-
amount,
|
|
328
|
-
partyB,
|
|
329
|
-
commandID,
|
|
330
|
-
senderIdentifierType,
|
|
331
|
-
receiverIdentifierType,
|
|
332
|
-
accountReference,
|
|
333
|
-
remarks
|
|
334
|
-
});
|
|
335
306
|
if (!amount || !partyB || !commandID || !accountReference) {
|
|
336
307
|
reply.status(400).send({
|
|
337
308
|
error: "Amount, partyB, commandID, and account reference are required"
|
|
@@ -349,7 +320,6 @@ function createMpesaHandlers(client) {
|
|
|
349
320
|
resultUrl,
|
|
350
321
|
timeoutUrl
|
|
351
322
|
});
|
|
352
|
-
console.log("B2B Response:", response);
|
|
353
323
|
reply.send(response);
|
|
354
324
|
} catch (error) {
|
|
355
325
|
console.error("B2B error:", error);
|
|
@@ -428,8 +398,7 @@ function createMpesaHandlers(client) {
|
|
|
428
398
|
} = req.body;
|
|
429
399
|
if (!merchantName || !refNo || !amount || !transactionType || !creditPartyIdentifier) {
|
|
430
400
|
reply.status(400).send({
|
|
431
|
-
error: "Merchant name, reference number, amount, transaction type, and credit party identifier are required"
|
|
432
|
-
received: req.body
|
|
401
|
+
error: "Merchant name, reference number, amount, transaction type, and credit party identifier are required"
|
|
433
402
|
});
|
|
434
403
|
return;
|
|
435
404
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -50,12 +50,8 @@ function createMpesaHandlers(client) {
|
|
|
50
50
|
b2cResult: async (req, reply) => {
|
|
51
51
|
try {
|
|
52
52
|
const body = req.body;
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
reply.status(200).send({
|
|
56
|
-
ResultCode: 0,
|
|
57
|
-
ResultDesc: "Accepted"
|
|
58
|
-
});
|
|
53
|
+
const response = await client.handleB2CCallback(body);
|
|
54
|
+
reply.status(200).send(response);
|
|
59
55
|
} catch (error) {
|
|
60
56
|
console.error("B2C Result error:", error);
|
|
61
57
|
reply.status(200).send({
|
|
@@ -83,12 +79,8 @@ function createMpesaHandlers(client) {
|
|
|
83
79
|
b2bResult: async (req, reply) => {
|
|
84
80
|
try {
|
|
85
81
|
const body = req.body;
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
reply.status(200).send({
|
|
89
|
-
ResultCode: 0,
|
|
90
|
-
ResultDesc: "Accepted"
|
|
91
|
-
});
|
|
82
|
+
const response = await client.handleB2BCallback(body);
|
|
83
|
+
reply.status(200).send(response);
|
|
92
84
|
} catch (error) {
|
|
93
85
|
console.error("B2B Result error:", error);
|
|
94
86
|
reply.status(200).send({
|
|
@@ -116,12 +108,8 @@ function createMpesaHandlers(client) {
|
|
|
116
108
|
balanceResult: async (req, reply) => {
|
|
117
109
|
try {
|
|
118
110
|
const body = req.body;
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
reply.status(200).send({
|
|
122
|
-
ResultCode: 0,
|
|
123
|
-
ResultDesc: "Accepted"
|
|
124
|
-
});
|
|
111
|
+
const response = await client.handleAccountBalanceCallback(body);
|
|
112
|
+
reply.status(200).send(response);
|
|
125
113
|
} catch (error) {
|
|
126
114
|
console.error("Balance Result error:", error);
|
|
127
115
|
reply.status(200).send({
|
|
@@ -149,12 +137,8 @@ function createMpesaHandlers(client) {
|
|
|
149
137
|
reversalResult: async (req, reply) => {
|
|
150
138
|
try {
|
|
151
139
|
const body = req.body;
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
reply.status(200).send({
|
|
155
|
-
ResultCode: 0,
|
|
156
|
-
ResultDesc: "Accepted"
|
|
157
|
-
});
|
|
140
|
+
const response = await client.handleReversalCallback(body);
|
|
141
|
+
reply.status(200).send(response);
|
|
158
142
|
} catch (error) {
|
|
159
143
|
console.error("Reversal Result error:", error);
|
|
160
144
|
reply.status(200).send({
|
|
@@ -182,12 +166,8 @@ function createMpesaHandlers(client) {
|
|
|
182
166
|
statusResult: async (req, reply) => {
|
|
183
167
|
try {
|
|
184
168
|
const body = req.body;
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
reply.status(200).send({
|
|
188
|
-
ResultCode: 0,
|
|
189
|
-
ResultDesc: "Accepted"
|
|
190
|
-
});
|
|
169
|
+
const response = await client.handleTransactionStatusCallback(body);
|
|
170
|
+
reply.status(200).send(response);
|
|
191
171
|
} catch (error) {
|
|
192
172
|
console.error("Status Result error:", error);
|
|
193
173
|
reply.status(200).send({
|
|
@@ -297,15 +277,6 @@ function createMpesaHandlers(client) {
|
|
|
297
277
|
resultUrl,
|
|
298
278
|
timeoutUrl
|
|
299
279
|
} = req.body;
|
|
300
|
-
console.log("B2B Request Parameters:", {
|
|
301
|
-
amount,
|
|
302
|
-
partyB,
|
|
303
|
-
commandID,
|
|
304
|
-
senderIdentifierType,
|
|
305
|
-
receiverIdentifierType,
|
|
306
|
-
accountReference,
|
|
307
|
-
remarks
|
|
308
|
-
});
|
|
309
280
|
if (!amount || !partyB || !commandID || !accountReference) {
|
|
310
281
|
reply.status(400).send({
|
|
311
282
|
error: "Amount, partyB, commandID, and account reference are required"
|
|
@@ -323,7 +294,6 @@ function createMpesaHandlers(client) {
|
|
|
323
294
|
resultUrl,
|
|
324
295
|
timeoutUrl
|
|
325
296
|
});
|
|
326
|
-
console.log("B2B Response:", response);
|
|
327
297
|
reply.send(response);
|
|
328
298
|
} catch (error) {
|
|
329
299
|
console.error("B2B error:", error);
|
|
@@ -402,8 +372,7 @@ function createMpesaHandlers(client) {
|
|
|
402
372
|
} = req.body;
|
|
403
373
|
if (!merchantName || !refNo || !amount || !transactionType || !creditPartyIdentifier) {
|
|
404
374
|
reply.status(400).send({
|
|
405
|
-
error: "Merchant name, reference number, amount, transaction type, and credit party identifier are required"
|
|
406
|
-
received: req.body
|
|
375
|
+
error: "Merchant name, reference number, amount, transaction type, and credit party identifier are required"
|
|
407
376
|
});
|
|
408
377
|
return;
|
|
409
378
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@singularity-payments/fastify",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.0-alpha.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"fastify": ">=4.0.0"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@singularity-payments/core": "
|
|
34
|
+
"@singularity-payments/core": "1.0.0-alpha.1"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/node": "^25.0.3",
|