@maxkabechani/mtn-momo-sdk 0.1.0
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/LICENSE +21 -0
- package/README.md +187 -0
- package/lib/cjs/auth.d.ts +17 -0
- package/lib/cjs/auth.d.ts.map +1 -0
- package/lib/cjs/auth.js +86 -0
- package/lib/cjs/auth.js.map +1 -0
- package/lib/cjs/cli.d.ts +3 -0
- package/lib/cjs/cli.d.ts.map +1 -0
- package/lib/cjs/cli.js +66 -0
- package/lib/cjs/cli.js.map +1 -0
- package/lib/cjs/client.d.ts +7 -0
- package/lib/cjs/client.d.ts.map +1 -0
- package/lib/cjs/client.js +67 -0
- package/lib/cjs/client.js.map +1 -0
- package/lib/cjs/collections.d.ts +176 -0
- package/lib/cjs/collections.d.ts.map +1 -0
- package/lib/cjs/collections.js +219 -0
- package/lib/cjs/collections.js.map +1 -0
- package/lib/cjs/common.d.ts +299 -0
- package/lib/cjs/common.d.ts.map +1 -0
- package/lib/cjs/common.js +41 -0
- package/lib/cjs/common.js.map +1 -0
- package/lib/cjs/disbursements.d.ts +190 -0
- package/lib/cjs/disbursements.d.ts.map +1 -0
- package/lib/cjs/disbursements.js +268 -0
- package/lib/cjs/disbursements.js.map +1 -0
- package/lib/cjs/errors.d.ts +67 -0
- package/lib/cjs/errors.d.ts.map +1 -0
- package/lib/cjs/errors.js +207 -0
- package/lib/cjs/errors.js.map +1 -0
- package/lib/cjs/index.d.ts +24 -0
- package/lib/cjs/index.d.ts.map +1 -0
- package/lib/cjs/index.js +87 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/package.json +1 -0
- package/lib/cjs/remittance.d.ts +59 -0
- package/lib/cjs/remittance.d.ts.map +1 -0
- package/lib/cjs/remittance.js +145 -0
- package/lib/cjs/remittance.js.map +1 -0
- package/lib/cjs/users.d.ts +22 -0
- package/lib/cjs/users.d.ts.map +1 -0
- package/lib/cjs/users.js +42 -0
- package/lib/cjs/users.js.map +1 -0
- package/lib/cjs/validate.d.ts +14 -0
- package/lib/cjs/validate.d.ts.map +1 -0
- package/lib/cjs/validate.js +111 -0
- package/lib/cjs/validate.js.map +1 -0
- package/lib/esm/auth.d.ts +17 -0
- package/lib/esm/auth.d.ts.map +1 -0
- package/lib/esm/auth.js +78 -0
- package/lib/esm/auth.js.map +1 -0
- package/lib/esm/cli.d.ts +3 -0
- package/lib/esm/cli.d.ts.map +1 -0
- package/lib/esm/cli.js +31 -0
- package/lib/esm/cli.js.map +1 -0
- package/lib/esm/client.d.ts +7 -0
- package/lib/esm/client.d.ts.map +1 -0
- package/lib/esm/client.js +29 -0
- package/lib/esm/client.js.map +1 -0
- package/lib/esm/collections.d.ts +176 -0
- package/lib/esm/collections.d.ts.map +1 -0
- package/lib/esm/collections.js +216 -0
- package/lib/esm/collections.js.map +1 -0
- package/lib/esm/common.d.ts +299 -0
- package/lib/esm/common.d.ts.map +1 -0
- package/lib/esm/common.js +38 -0
- package/lib/esm/common.js.map +1 -0
- package/lib/esm/disbursements.d.ts +190 -0
- package/lib/esm/disbursements.d.ts.map +1 -0
- package/lib/esm/disbursements.js +265 -0
- package/lib/esm/disbursements.js.map +1 -0
- package/lib/esm/errors.d.ts +67 -0
- package/lib/esm/errors.d.ts.map +1 -0
- package/lib/esm/errors.js +182 -0
- package/lib/esm/errors.js.map +1 -0
- package/lib/esm/index.d.ts +24 -0
- package/lib/esm/index.d.ts.map +1 -0
- package/lib/esm/index.js +63 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/package.json +1 -0
- package/lib/esm/remittance.d.ts +59 -0
- package/lib/esm/remittance.d.ts.map +1 -0
- package/lib/esm/remittance.js +142 -0
- package/lib/esm/remittance.js.map +1 -0
- package/lib/esm/users.d.ts +22 -0
- package/lib/esm/users.d.ts.map +1 -0
- package/lib/esm/users.js +39 -0
- package/lib/esm/users.js.map +1 -0
- package/lib/esm/validate.d.ts +14 -0
- package/lib/esm/validate.d.ts.map +1 -0
- package/lib/esm/validate.js +100 -0
- package/lib/esm/validate.js.map +1 -0
- package/package.json +68 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import type { AxiosInstance } from "axios";
|
|
2
|
+
import type { Config } from "./common";
|
|
3
|
+
import { type Balance, type BasicUserInfo, type BcAuthorizeRequest, type BcAuthorizeResponse, type Deposit, type DepositRequest, FailureReason, PartyIdType, type Refund, type RefundRequest, TransactionStatus } from "./common";
|
|
4
|
+
export interface TransferRequest {
|
|
5
|
+
/**
|
|
6
|
+
* Unique Transfer Reference (UUID v4), will be automatically generated if not explicitly supplied
|
|
7
|
+
*/
|
|
8
|
+
referenceId?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Amount that will be debited from the payer account.
|
|
11
|
+
*/
|
|
12
|
+
amount: string;
|
|
13
|
+
/**
|
|
14
|
+
* ISO4217 Currency
|
|
15
|
+
*/
|
|
16
|
+
currency: string;
|
|
17
|
+
/**
|
|
18
|
+
* External id is used as a reference to the transaction.
|
|
19
|
+
* External id is used for reconciliation.
|
|
20
|
+
* The external id will be included in transaction history report.
|
|
21
|
+
* External id is not required to be unique.
|
|
22
|
+
*/
|
|
23
|
+
externalId?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Party identifies a account holder in the wallet platform.
|
|
26
|
+
* Party consists of two parameters, type and partyId.
|
|
27
|
+
* Each type have its own validation of the partyId
|
|
28
|
+
* MSISDN - Mobile Number validated according to ITU-T E.164. Validated with IsMSISDN
|
|
29
|
+
* EMAIL - Validated to be a valid e-mail format. Validated with IsEmail
|
|
30
|
+
* PARTY_CODE - UUID of the party. Validated with IsUuid
|
|
31
|
+
*/
|
|
32
|
+
payee: {
|
|
33
|
+
partyIdType: PartyIdType;
|
|
34
|
+
partyId: string;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Message that will be written in the payer transaction history message field.
|
|
38
|
+
*/
|
|
39
|
+
payerMessage?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Message that will be written in the payee transaction history note field.
|
|
42
|
+
*/
|
|
43
|
+
payeeNote?: string;
|
|
44
|
+
/**
|
|
45
|
+
* URL to the server where the callback should be sent.
|
|
46
|
+
*/
|
|
47
|
+
callbackUrl?: string;
|
|
48
|
+
}
|
|
49
|
+
export interface Transfer {
|
|
50
|
+
/**
|
|
51
|
+
* Amount that will be debited from the payer account.
|
|
52
|
+
*/
|
|
53
|
+
amount: string;
|
|
54
|
+
/**
|
|
55
|
+
* ISO4217 Currency
|
|
56
|
+
*/
|
|
57
|
+
currency: string;
|
|
58
|
+
/**
|
|
59
|
+
* Financial transactionIdd from mobile money manager.
|
|
60
|
+
* Used to connect to the specific financial transaction made in the account
|
|
61
|
+
*/
|
|
62
|
+
financialTransactionId: string;
|
|
63
|
+
/**
|
|
64
|
+
* External id is used as a reference to the transaction.
|
|
65
|
+
* External id is used for reconciliation.
|
|
66
|
+
* The external id will be included in transaction history report.
|
|
67
|
+
* External id is not required to be unique.
|
|
68
|
+
*/
|
|
69
|
+
externalId: string;
|
|
70
|
+
/**
|
|
71
|
+
* Party identifies a account holder in the wallet platform.
|
|
72
|
+
* Party consists of two parameters, type and partyId.
|
|
73
|
+
* Each type have its own validation of the partyId
|
|
74
|
+
* MSISDN - Mobile Number validated according to ITU-T E.164. Validated with IsMSISDN
|
|
75
|
+
* EMAIL - Validated to be a valid e-mail format. Validated with IsEmail
|
|
76
|
+
* PARTY_CODE - UUID of the party. Validated with IsUuid
|
|
77
|
+
*/
|
|
78
|
+
payee: {
|
|
79
|
+
partyIdType: "MSISDN";
|
|
80
|
+
partyId: string;
|
|
81
|
+
};
|
|
82
|
+
status: TransactionStatus;
|
|
83
|
+
reason?: FailureReason;
|
|
84
|
+
}
|
|
85
|
+
export default class Disbursements {
|
|
86
|
+
private client;
|
|
87
|
+
private config;
|
|
88
|
+
constructor(client: AxiosInstance, config: Config);
|
|
89
|
+
/**
|
|
90
|
+
* Transfer operation is used to transfer an amount from the owner’s
|
|
91
|
+
* account to a payee account.
|
|
92
|
+
* Status of the transaction can be validated by using the
|
|
93
|
+
*
|
|
94
|
+
* @param paymentRequest
|
|
95
|
+
*/
|
|
96
|
+
transfer({ callbackUrl, referenceId, ...payoutRequest }: TransferRequest): Promise<string>;
|
|
97
|
+
/**
|
|
98
|
+
* This method is used to retrieve the transaction. You can invoke this method
|
|
99
|
+
* to at intervals until your transaction fails or succeeds.
|
|
100
|
+
*
|
|
101
|
+
* If the transaction has failed, it will throw an appropriate error. The error will be a subclass
|
|
102
|
+
* of `MtnMoMoError`. Check [`src/error.ts`](https://github.com/maxkabechani/mtn-momo-sdk/blob/master/src/errors.ts)
|
|
103
|
+
* for the various errors that can be thrown
|
|
104
|
+
*
|
|
105
|
+
* @param referenceId the value returned from `transfer`
|
|
106
|
+
*/
|
|
107
|
+
getTransaction(referenceId: string): Promise<Transfer>;
|
|
108
|
+
/**
|
|
109
|
+
* Get the balance of the account.
|
|
110
|
+
*/
|
|
111
|
+
getBalance(): Promise<Balance>;
|
|
112
|
+
/**
|
|
113
|
+
* This method is used to check if an account holder is registered and active in the system.
|
|
114
|
+
*
|
|
115
|
+
* @param id Specifies the type of the party ID. Allowed values [msisdn, email, party_code].
|
|
116
|
+
* accountHolderId should explicitly be in small letters.
|
|
117
|
+
*
|
|
118
|
+
* @param type The party number. Validated according to the party ID type (case Sensitive).
|
|
119
|
+
* msisdn - Mobile Number validated according to ITU-T E.164. Validated with IsMSISDN
|
|
120
|
+
* email - Validated to be a valid e-mail format. Validated with IsEmail
|
|
121
|
+
* party_code - UUID of the party. Validated with IsUuid
|
|
122
|
+
*/
|
|
123
|
+
isPayerActive(id: string, type?: PartyIdType): Promise<boolean>;
|
|
124
|
+
/**
|
|
125
|
+
* Deposit money into a payee account (V1).
|
|
126
|
+
*
|
|
127
|
+
* @param depositRequest The deposit request details
|
|
128
|
+
* @returns A promise that resolves to the deposit reference ID
|
|
129
|
+
*/
|
|
130
|
+
deposit(depositRequest: DepositRequest): Promise<string>;
|
|
131
|
+
/**
|
|
132
|
+
* Deposit money into a payee account (V2).
|
|
133
|
+
*
|
|
134
|
+
* @param depositRequest The deposit request details
|
|
135
|
+
* @returns A promise that resolves to the deposit reference ID
|
|
136
|
+
*/
|
|
137
|
+
depositV2(depositRequest: DepositRequest): Promise<string>;
|
|
138
|
+
/**
|
|
139
|
+
* Get the details and status of a deposit transaction.
|
|
140
|
+
*
|
|
141
|
+
* @param referenceId The deposit reference ID from deposit
|
|
142
|
+
* @returns A promise that resolves to the deposit details
|
|
143
|
+
*/
|
|
144
|
+
getDeposit(referenceId: string): Promise<Deposit>;
|
|
145
|
+
/**
|
|
146
|
+
* Refund money from a previous transfer or deposit (V1).
|
|
147
|
+
*
|
|
148
|
+
* @param refundRequest The refund request details
|
|
149
|
+
* @returns A promise that resolves to the refund reference ID
|
|
150
|
+
*/
|
|
151
|
+
refund(refundRequest: RefundRequest): Promise<string>;
|
|
152
|
+
/**
|
|
153
|
+
* Refund money from a previous transfer or deposit (V2).
|
|
154
|
+
*
|
|
155
|
+
* @param refundRequest The refund request details
|
|
156
|
+
* @returns A promise that resolves to the refund reference ID
|
|
157
|
+
*/
|
|
158
|
+
refundV2(refundRequest: RefundRequest): Promise<string>;
|
|
159
|
+
/**
|
|
160
|
+
* Get the details and status of a refund transaction.
|
|
161
|
+
*
|
|
162
|
+
* @param referenceId The refund reference ID from refund
|
|
163
|
+
* @returns A promise that resolves to the refund details
|
|
164
|
+
*/
|
|
165
|
+
getRefund(referenceId: string): Promise<Refund>;
|
|
166
|
+
/**
|
|
167
|
+
* Get basic user information for an account holder.
|
|
168
|
+
*
|
|
169
|
+
* @param partyIdType The type of party ID (MSISDN, EMAIL, or PARTY_CODE)
|
|
170
|
+
* @param partyId The party identifier
|
|
171
|
+
* @returns A promise that resolves to the basic user information
|
|
172
|
+
*/
|
|
173
|
+
getBasicUserInfo(partyIdType: PartyIdType, partyId: string): Promise<BasicUserInfo>;
|
|
174
|
+
/**
|
|
175
|
+
* Get the balance of the account in a specific currency.
|
|
176
|
+
*
|
|
177
|
+
* @param currency The ISO4217 currency code
|
|
178
|
+
* @returns A promise that resolves to the account balance in the specified currency
|
|
179
|
+
*/
|
|
180
|
+
getBalanceInCurrency(currency: string): Promise<Balance>;
|
|
181
|
+
/**
|
|
182
|
+
* Request Biometric Consent (BC) authorization.
|
|
183
|
+
* This initiates the BC authorization flow for enhanced security.
|
|
184
|
+
*
|
|
185
|
+
* @param request The BC authorization request
|
|
186
|
+
* @returns A promise that resolves to the BC authorization response with auth_req_id
|
|
187
|
+
*/
|
|
188
|
+
bcAuthorize(request: BcAuthorizeRequest): Promise<BcAuthorizeResponse>;
|
|
189
|
+
}
|
|
190
|
+
//# sourceMappingURL=disbursements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disbursements.d.ts","sourceRoot":"","sources":["../../src/disbursements.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAM3C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,aAAa,EACb,WAAW,EACX,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;;;;OAOG;IACH,KAAK,EAAE;QACL,WAAW,EAAE,WAAW,CAAC;QACzB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IAEF;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAA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E,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAYxD;;;;;OAKG;IACI,MAAM,CAAC,aAAa,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;IAwB5D;;;;;OAKG;IACI,QAAQ,CAAC,aAAa,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;IAwB9D;;;;;OAKG;IACI,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAYtD;;;;;;OAMG;IACI,gBAAgB,CACrB,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,aAAa,CAAC;IAQzB;;;;;OAKG;IACI,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAM/D;;;;;;OAMG;IACI,WAAW,CAChB,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,mBAAmB,CAAC;CAoBhC"}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { v4 as uuid } from "uuid";
|
|
2
|
+
import { getTransactionError } from "./errors";
|
|
3
|
+
import { validateTransfer, validateDepositRequest, validateRefundRequest } from "./validate";
|
|
4
|
+
import { createBasicAuthToken } from "./auth";
|
|
5
|
+
import { FailureReason, PartyIdType, TransactionStatus, } from "./common";
|
|
6
|
+
export default class Disbursements {
|
|
7
|
+
constructor(client, config) {
|
|
8
|
+
this.client = client;
|
|
9
|
+
this.config = config;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Transfer operation is used to transfer an amount from the owner’s
|
|
13
|
+
* account to a payee account.
|
|
14
|
+
* Status of the transaction can be validated by using the
|
|
15
|
+
*
|
|
16
|
+
* @param paymentRequest
|
|
17
|
+
*/
|
|
18
|
+
transfer({ callbackUrl, referenceId = uuid(), ...payoutRequest }) {
|
|
19
|
+
return validateTransfer({ referenceId, ...payoutRequest }).then(() => {
|
|
20
|
+
return this.client
|
|
21
|
+
.post("/disbursement/v1_0/transfer", payoutRequest, {
|
|
22
|
+
headers: {
|
|
23
|
+
"X-Reference-Id": referenceId,
|
|
24
|
+
...(callbackUrl ? { "X-Callback-Url": callbackUrl } : {}),
|
|
25
|
+
},
|
|
26
|
+
})
|
|
27
|
+
.then(() => referenceId);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* This method is used to retrieve the transaction. You can invoke this method
|
|
32
|
+
* to at intervals until your transaction fails or succeeds.
|
|
33
|
+
*
|
|
34
|
+
* If the transaction has failed, it will throw an appropriate error. The error will be a subclass
|
|
35
|
+
* of `MtnMoMoError`. Check [`src/error.ts`](https://github.com/maxkabechani/mtn-momo-sdk/blob/master/src/errors.ts)
|
|
36
|
+
* for the various errors that can be thrown
|
|
37
|
+
*
|
|
38
|
+
* @param referenceId the value returned from `transfer`
|
|
39
|
+
*/
|
|
40
|
+
getTransaction(referenceId) {
|
|
41
|
+
return this.client
|
|
42
|
+
.get(`/disbursement/v1_0/transfer/${referenceId}`)
|
|
43
|
+
.then((response) => response.data)
|
|
44
|
+
.then((transaction) => {
|
|
45
|
+
if (transaction.status === TransactionStatus.FAILED) {
|
|
46
|
+
return Promise.reject(getTransactionError(transaction));
|
|
47
|
+
}
|
|
48
|
+
return Promise.resolve(transaction);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get the balance of the account.
|
|
53
|
+
*/
|
|
54
|
+
getBalance() {
|
|
55
|
+
return this.client
|
|
56
|
+
.get("/disbursement/v1_0/account/balance")
|
|
57
|
+
.then((response) => response.data);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* This method is used to check if an account holder is registered and active in the system.
|
|
61
|
+
*
|
|
62
|
+
* @param id Specifies the type of the party ID. Allowed values [msisdn, email, party_code].
|
|
63
|
+
* accountHolderId should explicitly be in small letters.
|
|
64
|
+
*
|
|
65
|
+
* @param type The party number. Validated according to the party ID type (case Sensitive).
|
|
66
|
+
* msisdn - Mobile Number validated according to ITU-T E.164. Validated with IsMSISDN
|
|
67
|
+
* email - Validated to be a valid e-mail format. Validated with IsEmail
|
|
68
|
+
* party_code - UUID of the party. Validated with IsUuid
|
|
69
|
+
*/
|
|
70
|
+
isPayerActive(id, type = PartyIdType.MSISDN) {
|
|
71
|
+
return this.client
|
|
72
|
+
.get(`/disbursement/v1_0/accountholder/${type}/${id}/active`)
|
|
73
|
+
.then((response) => response.data)
|
|
74
|
+
.then((data) => (data.result !== undefined ? data.result : false));
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Deposit money into a payee account (V1).
|
|
78
|
+
*
|
|
79
|
+
* @param depositRequest The deposit request details
|
|
80
|
+
* @returns A promise that resolves to the deposit reference ID
|
|
81
|
+
*/
|
|
82
|
+
deposit(depositRequest) {
|
|
83
|
+
const referenceId = uuid();
|
|
84
|
+
return validateDepositRequest(depositRequest).then(() => {
|
|
85
|
+
return this.client
|
|
86
|
+
.post("/disbursement/v1_0/deposit", {
|
|
87
|
+
amount: depositRequest.amount,
|
|
88
|
+
currency: depositRequest.currency,
|
|
89
|
+
externalId: depositRequest.externalId,
|
|
90
|
+
payee: depositRequest.payee,
|
|
91
|
+
payerMessage: depositRequest.payerMessage,
|
|
92
|
+
payeeNote: depositRequest.payeeNote,
|
|
93
|
+
}, {
|
|
94
|
+
headers: {
|
|
95
|
+
"X-Reference-Id": referenceId,
|
|
96
|
+
...(depositRequest.callbackUrl
|
|
97
|
+
? { "X-Callback-Url": depositRequest.callbackUrl }
|
|
98
|
+
: {}),
|
|
99
|
+
},
|
|
100
|
+
})
|
|
101
|
+
.then(() => referenceId);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Deposit money into a payee account (V2).
|
|
106
|
+
*
|
|
107
|
+
* @param depositRequest The deposit request details
|
|
108
|
+
* @returns A promise that resolves to the deposit reference ID
|
|
109
|
+
*/
|
|
110
|
+
depositV2(depositRequest) {
|
|
111
|
+
const referenceId = uuid();
|
|
112
|
+
return validateDepositRequest(depositRequest).then(() => {
|
|
113
|
+
return this.client
|
|
114
|
+
.post("/disbursement/v2_0/deposit", {
|
|
115
|
+
amount: depositRequest.amount,
|
|
116
|
+
currency: depositRequest.currency,
|
|
117
|
+
externalId: depositRequest.externalId,
|
|
118
|
+
payee: depositRequest.payee,
|
|
119
|
+
payerMessage: depositRequest.payerMessage,
|
|
120
|
+
payeeNote: depositRequest.payeeNote,
|
|
121
|
+
}, {
|
|
122
|
+
headers: {
|
|
123
|
+
"X-Reference-Id": referenceId,
|
|
124
|
+
...(depositRequest.callbackUrl
|
|
125
|
+
? { "X-Callback-Url": depositRequest.callbackUrl }
|
|
126
|
+
: {}),
|
|
127
|
+
},
|
|
128
|
+
})
|
|
129
|
+
.then(() => referenceId);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Get the details and status of a deposit transaction.
|
|
134
|
+
*
|
|
135
|
+
* @param referenceId The deposit reference ID from deposit
|
|
136
|
+
* @returns A promise that resolves to the deposit details
|
|
137
|
+
*/
|
|
138
|
+
getDeposit(referenceId) {
|
|
139
|
+
return this.client
|
|
140
|
+
.get(`/disbursement/v1_0/deposit/${referenceId}`)
|
|
141
|
+
.then((response) => response.data)
|
|
142
|
+
.then((deposit) => {
|
|
143
|
+
if (deposit.status === TransactionStatus.FAILED) {
|
|
144
|
+
return Promise.reject(getTransactionError(deposit));
|
|
145
|
+
}
|
|
146
|
+
return Promise.resolve(deposit);
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Refund money from a previous transfer or deposit (V1).
|
|
151
|
+
*
|
|
152
|
+
* @param refundRequest The refund request details
|
|
153
|
+
* @returns A promise that resolves to the refund reference ID
|
|
154
|
+
*/
|
|
155
|
+
refund(refundRequest) {
|
|
156
|
+
const referenceId = uuid();
|
|
157
|
+
return validateRefundRequest(refundRequest).then(() => {
|
|
158
|
+
return this.client
|
|
159
|
+
.post("/disbursement/v1_0/refund", {
|
|
160
|
+
amount: refundRequest.amount,
|
|
161
|
+
currency: refundRequest.currency,
|
|
162
|
+
externalId: refundRequest.externalId,
|
|
163
|
+
payerMessage: refundRequest.payerMessage,
|
|
164
|
+
payeeNote: refundRequest.payeeNote,
|
|
165
|
+
referenceIdToRefund: refundRequest.referenceIdToRefund,
|
|
166
|
+
}, {
|
|
167
|
+
headers: {
|
|
168
|
+
"X-Reference-Id": referenceId,
|
|
169
|
+
},
|
|
170
|
+
})
|
|
171
|
+
.then(() => referenceId);
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Refund money from a previous transfer or deposit (V2).
|
|
176
|
+
*
|
|
177
|
+
* @param refundRequest The refund request details
|
|
178
|
+
* @returns A promise that resolves to the refund reference ID
|
|
179
|
+
*/
|
|
180
|
+
refundV2(refundRequest) {
|
|
181
|
+
const referenceId = uuid();
|
|
182
|
+
return validateRefundRequest(refundRequest).then(() => {
|
|
183
|
+
return this.client
|
|
184
|
+
.post("/disbursement/v2_0/refund", {
|
|
185
|
+
amount: refundRequest.amount,
|
|
186
|
+
currency: refundRequest.currency,
|
|
187
|
+
externalId: refundRequest.externalId,
|
|
188
|
+
payerMessage: refundRequest.payerMessage,
|
|
189
|
+
payeeNote: refundRequest.payeeNote,
|
|
190
|
+
referenceIdToRefund: refundRequest.referenceIdToRefund,
|
|
191
|
+
}, {
|
|
192
|
+
headers: {
|
|
193
|
+
"X-Reference-Id": referenceId,
|
|
194
|
+
},
|
|
195
|
+
})
|
|
196
|
+
.then(() => referenceId);
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Get the details and status of a refund transaction.
|
|
201
|
+
*
|
|
202
|
+
* @param referenceId The refund reference ID from refund
|
|
203
|
+
* @returns A promise that resolves to the refund details
|
|
204
|
+
*/
|
|
205
|
+
getRefund(referenceId) {
|
|
206
|
+
return this.client
|
|
207
|
+
.get(`/disbursement/v1_0/refund/${referenceId}`)
|
|
208
|
+
.then((response) => response.data)
|
|
209
|
+
.then((refund) => {
|
|
210
|
+
if (refund.status === TransactionStatus.FAILED) {
|
|
211
|
+
return Promise.reject(getTransactionError(refund));
|
|
212
|
+
}
|
|
213
|
+
return Promise.resolve(refund);
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Get basic user information for an account holder.
|
|
218
|
+
*
|
|
219
|
+
* @param partyIdType The type of party ID (MSISDN, EMAIL, or PARTY_CODE)
|
|
220
|
+
* @param partyId The party identifier
|
|
221
|
+
* @returns A promise that resolves to the basic user information
|
|
222
|
+
*/
|
|
223
|
+
getBasicUserInfo(partyIdType, partyId) {
|
|
224
|
+
return this.client
|
|
225
|
+
.get(`/disbursement/v1_0/accountholder/${partyIdType}/${partyId}/basicuserinfo`)
|
|
226
|
+
.then((response) => response.data);
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Get the balance of the account in a specific currency.
|
|
230
|
+
*
|
|
231
|
+
* @param currency The ISO4217 currency code
|
|
232
|
+
* @returns A promise that resolves to the account balance in the specified currency
|
|
233
|
+
*/
|
|
234
|
+
getBalanceInCurrency(currency) {
|
|
235
|
+
return this.client
|
|
236
|
+
.get(`/disbursement/v1_0/account/balance/${currency}`)
|
|
237
|
+
.then((response) => response.data);
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Request Biometric Consent (BC) authorization.
|
|
241
|
+
* This initiates the BC authorization flow for enhanced security.
|
|
242
|
+
*
|
|
243
|
+
* @param request The BC authorization request
|
|
244
|
+
* @returns A promise that resolves to the BC authorization response with auth_req_id
|
|
245
|
+
*/
|
|
246
|
+
bcAuthorize(request) {
|
|
247
|
+
const params = new URLSearchParams();
|
|
248
|
+
params.append("login_hint", request.login_hint);
|
|
249
|
+
params.append("scope", request.scope);
|
|
250
|
+
params.append("access_type", request.access_type);
|
|
251
|
+
if (request.consent_valid_in) {
|
|
252
|
+
params.append("consent_valid_in", String(request.consent_valid_in));
|
|
253
|
+
}
|
|
254
|
+
const basicAuthToken = createBasicAuthToken(this.config);
|
|
255
|
+
return this.client
|
|
256
|
+
.post("/disbursement/v1_0/bc-authorize", params, {
|
|
257
|
+
headers: {
|
|
258
|
+
Authorization: `Basic ${basicAuthToken}`,
|
|
259
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
260
|
+
},
|
|
261
|
+
})
|
|
262
|
+
.then((response) => response.data);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
//# sourceMappingURL=disbursements.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disbursements.js","sourceRoot":"","sources":["../../src/disbursements.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAC7F,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAG9C,OAAO,EAOL,aAAa,EACb,WAAW,EAGX,iBAAiB,GAClB,MAAM,UAAU,CAAC;AA6FlB,MAAM,CAAC,OAAO,OAAO,aAAa;IAIhC,YAAY,MAAqB,EAAE,MAAc;QAC/C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;;;;OAMG;IACI,QAAQ,CAAC,EACd,WAAW,EACX,WAAW,GAAG,IAAI,EAAE,EACpB,GAAG,aAAa,EACA;QAChB,OAAO,gBAAgB,CAAC,EAAE,WAAW,EAAE,GAAG,aAAa,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;YACnE,OAAO,IAAI,CAAC,MAAM;iBACf,IAAI,CAAO,6BAA6B,EAAE,aAAa,EAAE;gBACxD,OAAO,EAAE;oBACP,gBAAgB,EAAE,WA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AC;CACF"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { AxiosError } from "axios";
|
|
2
|
+
import type { Payment } from "./collections";
|
|
3
|
+
import type { Deposit, Refund, Withdrawal } from "./common";
|
|
4
|
+
import { FailureReason } from "./common";
|
|
5
|
+
import type { Transfer } from "./disbursements";
|
|
6
|
+
export declare class MtnMoMoError extends Error {
|
|
7
|
+
transaction?: Payment | Transfer;
|
|
8
|
+
constructor(message?: string);
|
|
9
|
+
}
|
|
10
|
+
export declare class ApprovalRejectedError extends MtnMoMoError {
|
|
11
|
+
name: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class ExpiredError extends MtnMoMoError {
|
|
14
|
+
name: string;
|
|
15
|
+
}
|
|
16
|
+
export declare class InternalProcessingError extends MtnMoMoError {
|
|
17
|
+
name: string;
|
|
18
|
+
}
|
|
19
|
+
export declare class InvalidCallbackUrlHostError extends MtnMoMoError {
|
|
20
|
+
name: string;
|
|
21
|
+
}
|
|
22
|
+
export declare class InvalidCurrencyError extends MtnMoMoError {
|
|
23
|
+
name: string;
|
|
24
|
+
}
|
|
25
|
+
export declare class NotAllowedTargetEnvironmentError extends MtnMoMoError {
|
|
26
|
+
name: string;
|
|
27
|
+
}
|
|
28
|
+
export declare class NotAllowedError extends MtnMoMoError {
|
|
29
|
+
name: string;
|
|
30
|
+
}
|
|
31
|
+
export declare class NotEnoughFundsError extends MtnMoMoError {
|
|
32
|
+
name: string;
|
|
33
|
+
}
|
|
34
|
+
export declare class PayeeNotFoundError extends MtnMoMoError {
|
|
35
|
+
name: string;
|
|
36
|
+
}
|
|
37
|
+
export declare class PayeeNotAllowedToReceiveError extends MtnMoMoError {
|
|
38
|
+
name: string;
|
|
39
|
+
}
|
|
40
|
+
export declare class PayerLimitReachedError extends MtnMoMoError {
|
|
41
|
+
name: string;
|
|
42
|
+
}
|
|
43
|
+
export declare class PayerNotFoundError extends MtnMoMoError {
|
|
44
|
+
name: string;
|
|
45
|
+
}
|
|
46
|
+
export declare class PaymentNotApprovedError extends MtnMoMoError {
|
|
47
|
+
name: string;
|
|
48
|
+
}
|
|
49
|
+
export declare class ResourceAlreadyExistError extends MtnMoMoError {
|
|
50
|
+
name: string;
|
|
51
|
+
}
|
|
52
|
+
export declare class ResourceNotFoundError extends MtnMoMoError {
|
|
53
|
+
name: string;
|
|
54
|
+
}
|
|
55
|
+
export declare class ServiceUnavailableError extends MtnMoMoError {
|
|
56
|
+
name: string;
|
|
57
|
+
}
|
|
58
|
+
export declare class TransactionCancelledError extends MtnMoMoError {
|
|
59
|
+
name: string;
|
|
60
|
+
}
|
|
61
|
+
export declare class UnspecifiedError extends MtnMoMoError {
|
|
62
|
+
name: string;
|
|
63
|
+
}
|
|
64
|
+
export declare function handleError(error: AxiosError): Error;
|
|
65
|
+
export declare function getError(code?: FailureReason, message?: string): ApprovalRejectedError | ExpiredError | InternalProcessingError | InvalidCallbackUrlHostError | InvalidCurrencyError | NotAllowedTargetEnvironmentError | NotAllowedError | NotEnoughFundsError | PayeeNotFoundError | PayeeNotAllowedToReceiveError | PayerLimitReachedError | PayerNotFoundError | PaymentNotApprovedError | ResourceAlreadyExistError | ResourceNotFoundError | ServiceUnavailableError | TransactionCancelledError | UnspecifiedError;
|
|
66
|
+
export declare function getTransactionError(transaction: Payment | Transfer | Withdrawal | Deposit | Refund): MtnMoMoError;
|
|
67
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EAAE,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