@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.
Files changed (93) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +187 -0
  3. package/lib/cjs/auth.d.ts +17 -0
  4. package/lib/cjs/auth.d.ts.map +1 -0
  5. package/lib/cjs/auth.js +86 -0
  6. package/lib/cjs/auth.js.map +1 -0
  7. package/lib/cjs/cli.d.ts +3 -0
  8. package/lib/cjs/cli.d.ts.map +1 -0
  9. package/lib/cjs/cli.js +66 -0
  10. package/lib/cjs/cli.js.map +1 -0
  11. package/lib/cjs/client.d.ts +7 -0
  12. package/lib/cjs/client.d.ts.map +1 -0
  13. package/lib/cjs/client.js +67 -0
  14. package/lib/cjs/client.js.map +1 -0
  15. package/lib/cjs/collections.d.ts +176 -0
  16. package/lib/cjs/collections.d.ts.map +1 -0
  17. package/lib/cjs/collections.js +219 -0
  18. package/lib/cjs/collections.js.map +1 -0
  19. package/lib/cjs/common.d.ts +299 -0
  20. package/lib/cjs/common.d.ts.map +1 -0
  21. package/lib/cjs/common.js +41 -0
  22. package/lib/cjs/common.js.map +1 -0
  23. package/lib/cjs/disbursements.d.ts +190 -0
  24. package/lib/cjs/disbursements.d.ts.map +1 -0
  25. package/lib/cjs/disbursements.js +268 -0
  26. package/lib/cjs/disbursements.js.map +1 -0
  27. package/lib/cjs/errors.d.ts +67 -0
  28. package/lib/cjs/errors.d.ts.map +1 -0
  29. package/lib/cjs/errors.js +207 -0
  30. package/lib/cjs/errors.js.map +1 -0
  31. package/lib/cjs/index.d.ts +24 -0
  32. package/lib/cjs/index.d.ts.map +1 -0
  33. package/lib/cjs/index.js +87 -0
  34. package/lib/cjs/index.js.map +1 -0
  35. package/lib/cjs/package.json +1 -0
  36. package/lib/cjs/remittance.d.ts +59 -0
  37. package/lib/cjs/remittance.d.ts.map +1 -0
  38. package/lib/cjs/remittance.js +145 -0
  39. package/lib/cjs/remittance.js.map +1 -0
  40. package/lib/cjs/users.d.ts +22 -0
  41. package/lib/cjs/users.d.ts.map +1 -0
  42. package/lib/cjs/users.js +42 -0
  43. package/lib/cjs/users.js.map +1 -0
  44. package/lib/cjs/validate.d.ts +14 -0
  45. package/lib/cjs/validate.d.ts.map +1 -0
  46. package/lib/cjs/validate.js +111 -0
  47. package/lib/cjs/validate.js.map +1 -0
  48. package/lib/esm/auth.d.ts +17 -0
  49. package/lib/esm/auth.d.ts.map +1 -0
  50. package/lib/esm/auth.js +78 -0
  51. package/lib/esm/auth.js.map +1 -0
  52. package/lib/esm/cli.d.ts +3 -0
  53. package/lib/esm/cli.d.ts.map +1 -0
  54. package/lib/esm/cli.js +31 -0
  55. package/lib/esm/cli.js.map +1 -0
  56. package/lib/esm/client.d.ts +7 -0
  57. package/lib/esm/client.d.ts.map +1 -0
  58. package/lib/esm/client.js +29 -0
  59. package/lib/esm/client.js.map +1 -0
  60. package/lib/esm/collections.d.ts +176 -0
  61. package/lib/esm/collections.d.ts.map +1 -0
  62. package/lib/esm/collections.js +216 -0
  63. package/lib/esm/collections.js.map +1 -0
  64. package/lib/esm/common.d.ts +299 -0
  65. package/lib/esm/common.d.ts.map +1 -0
  66. package/lib/esm/common.js +38 -0
  67. package/lib/esm/common.js.map +1 -0
  68. package/lib/esm/disbursements.d.ts +190 -0
  69. package/lib/esm/disbursements.d.ts.map +1 -0
  70. package/lib/esm/disbursements.js +265 -0
  71. package/lib/esm/disbursements.js.map +1 -0
  72. package/lib/esm/errors.d.ts +67 -0
  73. package/lib/esm/errors.d.ts.map +1 -0
  74. package/lib/esm/errors.js +182 -0
  75. package/lib/esm/errors.js.map +1 -0
  76. package/lib/esm/index.d.ts +24 -0
  77. package/lib/esm/index.d.ts.map +1 -0
  78. package/lib/esm/index.js +63 -0
  79. package/lib/esm/index.js.map +1 -0
  80. package/lib/esm/package.json +1 -0
  81. package/lib/esm/remittance.d.ts +59 -0
  82. package/lib/esm/remittance.d.ts.map +1 -0
  83. package/lib/esm/remittance.js +142 -0
  84. package/lib/esm/remittance.js.map +1 -0
  85. package/lib/esm/users.d.ts +22 -0
  86. package/lib/esm/users.d.ts.map +1 -0
  87. package/lib/esm/users.js +39 -0
  88. package/lib/esm/users.js.map +1 -0
  89. package/lib/esm/validate.d.ts +14 -0
  90. package/lib/esm/validate.d.ts.map +1 -0
  91. package/lib/esm/validate.js +100 -0
  92. package/lib/esm/validate.js.map +1 -0
  93. package/package.json +68 -0
@@ -0,0 +1,182 @@
1
+ import { FailureReason } from "./common";
2
+ export class MtnMoMoError extends Error {
3
+ constructor(message) {
4
+ super(message);
5
+ Object.setPrototypeOf(this, new.target.prototype);
6
+ }
7
+ }
8
+ export class ApprovalRejectedError extends MtnMoMoError {
9
+ constructor() {
10
+ super(...arguments);
11
+ this.name = "ApprovalRejectedError";
12
+ }
13
+ }
14
+ export class ExpiredError extends MtnMoMoError {
15
+ constructor() {
16
+ super(...arguments);
17
+ this.name = "ExpiredError";
18
+ }
19
+ }
20
+ export class InternalProcessingError extends MtnMoMoError {
21
+ constructor() {
22
+ super(...arguments);
23
+ this.name = "InternalProcessingError";
24
+ }
25
+ }
26
+ export class InvalidCallbackUrlHostError extends MtnMoMoError {
27
+ constructor() {
28
+ super(...arguments);
29
+ this.name = "InvalidCallbackUrlHostError";
30
+ }
31
+ }
32
+ export class InvalidCurrencyError extends MtnMoMoError {
33
+ constructor() {
34
+ super(...arguments);
35
+ this.name = "InvalidCurrencyError";
36
+ }
37
+ }
38
+ export class NotAllowedTargetEnvironmentError extends MtnMoMoError {
39
+ constructor() {
40
+ super(...arguments);
41
+ this.name = "NotAllowedTargetEnvironmentError";
42
+ }
43
+ }
44
+ export class NotAllowedError extends MtnMoMoError {
45
+ constructor() {
46
+ super(...arguments);
47
+ this.name = "NotAllowedError";
48
+ }
49
+ }
50
+ export class NotEnoughFundsError extends MtnMoMoError {
51
+ constructor() {
52
+ super(...arguments);
53
+ this.name = "NotEnoughFundsError";
54
+ }
55
+ }
56
+ export class PayeeNotFoundError extends MtnMoMoError {
57
+ constructor() {
58
+ super(...arguments);
59
+ this.name = "PayeeNotFoundError";
60
+ }
61
+ }
62
+ export class PayeeNotAllowedToReceiveError extends MtnMoMoError {
63
+ constructor() {
64
+ super(...arguments);
65
+ this.name = "PayeeNotAllowedToReceiveError";
66
+ }
67
+ }
68
+ export class PayerLimitReachedError extends MtnMoMoError {
69
+ constructor() {
70
+ super(...arguments);
71
+ this.name = "PayerLimitReachedError";
72
+ }
73
+ }
74
+ export class PayerNotFoundError extends MtnMoMoError {
75
+ constructor() {
76
+ super(...arguments);
77
+ this.name = "PayerNotFoundError";
78
+ }
79
+ }
80
+ export class PaymentNotApprovedError extends MtnMoMoError {
81
+ constructor() {
82
+ super(...arguments);
83
+ this.name = "PaymentNotApprovedError";
84
+ }
85
+ }
86
+ export class ResourceAlreadyExistError extends MtnMoMoError {
87
+ constructor() {
88
+ super(...arguments);
89
+ this.name = "ResourceAlreadyExistError";
90
+ }
91
+ }
92
+ export class ResourceNotFoundError extends MtnMoMoError {
93
+ constructor() {
94
+ super(...arguments);
95
+ this.name = "ResourceNotFoundError";
96
+ }
97
+ }
98
+ export class ServiceUnavailableError extends MtnMoMoError {
99
+ constructor() {
100
+ super(...arguments);
101
+ this.name = "ServiceUnavailableError";
102
+ }
103
+ }
104
+ export class TransactionCancelledError extends MtnMoMoError {
105
+ constructor() {
106
+ super(...arguments);
107
+ this.name = "TransactionCancelledError";
108
+ }
109
+ }
110
+ export class UnspecifiedError extends MtnMoMoError {
111
+ constructor() {
112
+ super(...arguments);
113
+ this.name = "UnspecifiedError";
114
+ }
115
+ }
116
+ export function handleError(error) {
117
+ if (!error.response) {
118
+ return error;
119
+ }
120
+ const { code, message } = (error.response.data || {});
121
+ return getError(code, message);
122
+ }
123
+ export function getError(code, message) {
124
+ if (code === FailureReason.APPROVAL_REJECTED) {
125
+ return new ApprovalRejectedError(message);
126
+ }
127
+ if (code === FailureReason.EXPIRED) {
128
+ return new ExpiredError(message);
129
+ }
130
+ if (code === FailureReason.INTERNAL_PROCESSING_ERROR) {
131
+ return new InternalProcessingError(message);
132
+ }
133
+ if (code === FailureReason.INVALID_CALLBACK_URL_HOST) {
134
+ return new InvalidCallbackUrlHostError(message);
135
+ }
136
+ if (code === FailureReason.INVALID_CURRENCY) {
137
+ return new InvalidCurrencyError(message);
138
+ }
139
+ if (code === FailureReason.NOT_ALLOWED) {
140
+ return new NotAllowedError(message);
141
+ }
142
+ if (code === FailureReason.NOT_ALLOWED_TARGET_ENVIRONMENT) {
143
+ return new NotAllowedTargetEnvironmentError(message);
144
+ }
145
+ if (code === FailureReason.NOT_ENOUGH_FUNDS) {
146
+ return new NotEnoughFundsError(message);
147
+ }
148
+ if (code === FailureReason.PAYEE_NOT_FOUND) {
149
+ return new PayeeNotFoundError(message);
150
+ }
151
+ if (code === FailureReason.PAYEE_NOT_ALLOWED_TO_RECEIVE) {
152
+ return new PayeeNotAllowedToReceiveError(message);
153
+ }
154
+ if (code === FailureReason.PAYER_LIMIT_REACHED) {
155
+ return new PayerLimitReachedError(message);
156
+ }
157
+ if (code === FailureReason.PAYER_NOT_FOUND) {
158
+ return new PayerNotFoundError(message);
159
+ }
160
+ if (code === FailureReason.PAYMENT_NOT_APPROVED) {
161
+ return new PaymentNotApprovedError(message);
162
+ }
163
+ if (code === FailureReason.RESOURCE_ALREADY_EXIST) {
164
+ return new ResourceAlreadyExistError(message);
165
+ }
166
+ if (code === FailureReason.RESOURCE_NOT_FOUND) {
167
+ return new ResourceNotFoundError(message);
168
+ }
169
+ if (code === FailureReason.SERVICE_UNAVAILABLE) {
170
+ return new ServiceUnavailableError(message);
171
+ }
172
+ if (code === FailureReason.TRANSACTION_CANCELED) {
173
+ return new TransactionCancelledError(message);
174
+ }
175
+ return new UnspecifiedError(message);
176
+ }
177
+ export function getTransactionError(transaction) {
178
+ const error = getError(transaction.reason);
179
+ error.transaction = transaction;
180
+ return error;
181
+ }
182
+ //# sourceMappingURL=errors.js.map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C,OAAO,CAAC,CAAC;IAC7C,CAAC;IAED,IAAI,IAAI,KAAK,aAAa,CAAC,eAAe,EAAE,CAAC;QAC3C,OAAO,IAAI,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAED,IAAI,IAAI,KAAK,aAAa,CAAC,oBAAoB,EAAE,CAAC;QAChD,OAAO,IAAI,uBAAuB,CAAC,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED,IAAI,IAAI,KAAK,aAAa,CAAC,sBAAsB,EAAE,CAAC;QAClD,OAAO,IAAI,yBAAyB,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC;IAED,IAAI,IAAI,KAAK,aAAa,CAAC,kBAAkB,EAAE,CAAC;QAC9C,OAAO,IAAI,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAC5C,CAAC;IAED,IAAI,IAAI,KAAK,aAAa,CAAC,mBAAmB,EAAE,CAAC;QAC/C,OAAO,IAAI,uBAAuB,CAAC,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED,IAAI,IAAI,KAAK,aAAa,CAAC,oBAAoB,EAAE,CAAC;QAChD,OAAO,IAAI,yBAAyB,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC;IAED,OAAO,IAAI,gBAAgB,CAAC,OAAO,CAAC,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,WAA+D;IAE/D,MAAM,KAAK,GAAiB,QAAQ,CAAC,WAAW,CAAC,MAAuB,CAAC,CAAC;IAC1E,KAAK,CAAC,WAAW,GAAG,WAAiC,CAAC;IAEtD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,24 @@
1
+ export type { Payment, PaymentRequest } from "./collections";
2
+ export type { Transfer, TransferRequest } from "./disbursements";
3
+ export type { Withdrawal, WithdrawalRequest, Deposit, DepositRequest, Refund, RefundRequest, CashTransfer, CashTransferRequest, } from "./common";
4
+ export * from "./errors";
5
+ export { PartyIdType as PayerType, TransactionStatus as Status, Environment, } from "./common";
6
+ export type { ApiUserInfo, Party as Payer, Balance, FailureReason, GlobalConfig, ProductConfig, BasicUserInfo, BcAuthorizeRequest, BcAuthorizeResponse, OAuth2TokenResponse, ConsentKycResponse, DeliveryNotification, } from "./common";
7
+ import Collections from "./collections";
8
+ import Disbursements from "./disbursements";
9
+ import Remittance from "./remittance";
10
+ import Users from "./users";
11
+ import type { GlobalConfig, ProductConfig, SubscriptionConfig } from "./common";
12
+ export interface MomoClient {
13
+ Collections(productConfig: ProductConfig): Collections;
14
+ Disbursements(productConfig: ProductConfig): Disbursements;
15
+ Remittance(productConfig: ProductConfig): Remittance;
16
+ Users(subscription: SubscriptionConfig): Users;
17
+ }
18
+ /**
19
+ * Initialise the library
20
+ *
21
+ * @param globalConfig Global configuration required to use any product
22
+ */
23
+ export declare function create(globalConfig: GlobalConfig): MomoClient;
24
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC7D,YAAY,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACjE,YAAY,EACV,UAAU,EACV,iBAAiB,EACjB,OAAO,EACP,cAAc,EACd,MAAM,EACN,aAAa,EACb,YAAY,EACZ,mBAAmB,GACpB,MAAM,UAAU,CAAC;AAClB,cAAc,UAAU,CAAC;AACzB,OAAO,EACL,WAAW,IAAI,SAAS,EACxB,iBAAiB,IAAI,MAAM,EAC3B,WAAW,GACZ,MAAM,UAAU,CAAC;AAClB,YAAY,EACV,WAAW,EACX,KAAK,IAAI,KAAK,EACd,OAAO,EACP,aAAa,EACb,YAAY,EACZ,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,UAAU,CAAC;AAIlB,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,MAAM,SAAS,CAAC;AAgB5B,OAAO,KAAK,EAEV,YAAY,EACZ,aAAa,EACb,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,UAAU;IACzB,WAAW,CAAC,aAAa,EAAE,aAAa,GAAG,WAAW,CAAC;IACvD,aAAa,CAAC,aAAa,EAAE,aAAa,GAAG,aAAa,CAAC;IAC3D,UAAU,CAAC,aAAa,EAAE,aAAa,GAAG,UAAU,CAAC;IACrD,KAAK,CAAC,YAAY,EAAE,kBAAkB,GAAG,KAAK,CAAC;CAChD;AAOD;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,YAAY,EAAE,YAAY,GAAG,UAAU,CAgE7D"}
@@ -0,0 +1,63 @@
1
+ export * from "./errors";
2
+ export { PartyIdType as PayerType, TransactionStatus as Status, Environment, } from "./common";
3
+ import Collections from "./collections";
4
+ import Disbursements from "./disbursements";
5
+ import Remittance from "./remittance";
6
+ import Users from "./users";
7
+ import { authorizeCollections, authorizeDisbursements, authorizeRemittance, createTokenRefresher, } from "./auth";
8
+ import { createAuthClient, createClient } from "./client";
9
+ import { validateGlobalConfig, validateProductConfig, validateSubscriptionConfig, } from "./validate";
10
+ import { Environment } from "./common";
11
+ const defaultGlobalConfig = {
12
+ baseUrl: "https://sandbox.momodeveloper.mtn.com",
13
+ environment: Environment.SANDBOX,
14
+ };
15
+ /**
16
+ * Initialise the library
17
+ *
18
+ * @param globalConfig Global configuration required to use any product
19
+ */
20
+ export function create(globalConfig) {
21
+ validateGlobalConfig(globalConfig);
22
+ return {
23
+ Collections(productConfig) {
24
+ validateProductConfig(productConfig);
25
+ const config = {
26
+ ...defaultGlobalConfig,
27
+ ...globalConfig,
28
+ ...productConfig,
29
+ };
30
+ const client = createAuthClient(createTokenRefresher(authorizeCollections, config), createClient(config));
31
+ return new Collections(client, config);
32
+ },
33
+ Disbursements(productConfig) {
34
+ const config = {
35
+ ...defaultGlobalConfig,
36
+ ...globalConfig,
37
+ ...productConfig,
38
+ };
39
+ const client = createAuthClient(createTokenRefresher(authorizeDisbursements, config), createClient(config));
40
+ return new Disbursements(client, config);
41
+ },
42
+ Remittance(productConfig) {
43
+ const config = {
44
+ ...defaultGlobalConfig,
45
+ ...globalConfig,
46
+ ...productConfig,
47
+ };
48
+ const client = createAuthClient(createTokenRefresher(authorizeRemittance, config), createClient(config));
49
+ return new Remittance(client, config);
50
+ },
51
+ Users(subscriptionConfig) {
52
+ validateSubscriptionConfig(subscriptionConfig);
53
+ const config = {
54
+ ...defaultGlobalConfig,
55
+ ...globalConfig,
56
+ ...subscriptionConfig,
57
+ };
58
+ const client = createClient(config);
59
+ return new Users(client);
60
+ },
61
+ };
62
+ }
63
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAYA,cAAc,UAAU,CAAC;AACzB,OAAO,EACL,WAAW,IAAI,SAAS,EACxB,iBAAiB,IAAI,MAAM,EAC3B,WAAW,GACZ,MAAM,UAAU,CAAC;AAkBlB,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,MAAM,SAAS,CAAC;AAE5B,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,0BAA0B,GAC3B,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAevC,MAAM,mBAAmB,GAAiB;IACxC,OAA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M,MAAM,GAAsC;gBAChD,GAAG,mBAAmB;gBACtB,GAAG,YAAY;gBACf,GAAG,kBAAkB;aACtB,CAAC;YAEF,MAAM,MAAM,GAAkB,YAAY,CAAC,MAAM,CAAC,CAAC;YAEnD,OAAO,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;QAC3B,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,59 @@
1
+ import type { AxiosInstance } from "axios";
2
+ import type { Balance, BasicUserInfo, BcAuthorizeRequest, BcAuthorizeResponse, CashTransfer, CashTransferRequest, ConsentKycResponse } from "./common";
3
+ import { PartyIdType } from "./common";
4
+ import type { Config } from "./common";
5
+ /**
6
+ * Remittance product for cross-border money transfers with optional OAuth2 consent flows
7
+ */
8
+ export default class Remittance {
9
+ private readonly client;
10
+ private readonly config;
11
+ constructor(client: AxiosInstance, config: Config);
12
+ /**
13
+ * Send money across borders to a beneficiary
14
+ * @param request - The cash transfer request details (amount, currency, beneficiary, etc.)
15
+ * @returns A promise that resolves to the financial transaction ID (referenceId)
16
+ */
17
+ transfer(request: CashTransferRequest): Promise<string>;
18
+ /**
19
+ * Get the details and status of a specific transfer
20
+ * @param referenceId - The unique identifier of the transfer transaction
21
+ * @returns A promise that resolves to the transfer details and status
22
+ */
23
+ getTransaction(referenceId: string): Promise<CashTransfer>;
24
+ /**
25
+ * Get the current account balance
26
+ * @returns A promise that resolves to the account balance with currency information
27
+ */
28
+ getBalance(): Promise<Balance>;
29
+ /**
30
+ * Check if a beneficiary is active and can receive transfers
31
+ * @param partyId - The ID of the beneficiary (in the format specified by partyIdType)
32
+ * @param partyIdType - The type of ID (MSISDN, EMAIL, or PARTY_CODE)
33
+ * @returns A promise that resolves to true if the beneficiary is active, false otherwise
34
+ */
35
+ isPayerActive(partyId: string, partyIdType?: PartyIdType): Promise<boolean>;
36
+ /**
37
+ * Get basic user information for an account holder.
38
+ * Remittance only supports MSISDN for this endpoint in some versions.
39
+ *
40
+ * @param partyId The party identifier (MSISDN)
41
+ * @returns A promise that resolves to the basic user information
42
+ */
43
+ getBasicUserInfo(partyId: string): Promise<BasicUserInfo>;
44
+ /**
45
+ * Get the balance of the account in a specific currency.
46
+ *
47
+ * @param currency The ISO4217 currency code
48
+ * @returns A promise that resolves to the account balance in the specified currency
49
+ */
50
+ getBalanceInCurrency(currency: string): Promise<Balance>;
51
+ /**
52
+ * Retrieve user information with KYC consent (OAuth2-gated endpoint)
53
+ * Requires prior OAuth2 user consent/login flow to obtain authorization
54
+ * @returns A promise that resolves to the user's information and KYC consent details
55
+ */
56
+ getUserInfoWithConsent(): Promise<ConsentKycResponse>;
57
+ bcAuthorize(request: BcAuthorizeRequest): Promise<BcAuthorizeResponse>;
58
+ }
59
+ //# sourceMappingURL=remittance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remittance.d.ts","sourceRoot":"","sources":["../../src/remittance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,KAAK,EACV,OAAO,EACP,aAAa,EACb,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAGnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAqB,WAAW,EAAE,MAAM,UAAU,CAAC;AAG1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAIvC;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,UAAU;IAC7B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;IACvC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;gBAEpB,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM;IAKjD;;;;OAIG;IACG,QAAQ,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;IAkC7D;;;;OAIG;IACG,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAchE;;;OAGG;IACG,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;IAYpC;;;;;OAKG;IACG,aAAa,CACjB,OAAO,EAAE,MAAM,EACf,WAAW,GAAE,WAAgC,GAC5C,OAAO,CAAC,OAAO,CAAC;IAenB;;;;;;OAMG;IACI,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAQhE;;;;;OAKG;IACI,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAM/D;;;;OAIG;IACG,sBAAsB,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAWpD,WAAW,CAChB,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,mBAAmB,CAAC;CAoBhC"}
@@ -0,0 +1,142 @@
1
+ import { TransactionStatus, PartyIdType } from "./common";
2
+ import { MtnMoMoError } from "./errors";
3
+ import { createBasicAuthToken } from "./auth";
4
+ import { v4 as uuid } from "uuid";
5
+ /**
6
+ * Remittance product for cross-border money transfers with optional OAuth2 consent flows
7
+ */
8
+ export default class Remittance {
9
+ constructor(client, config) {
10
+ this.client = client;
11
+ this.config = config;
12
+ }
13
+ /**
14
+ * Send money across borders to a beneficiary
15
+ * @param request - The cash transfer request details (amount, currency, beneficiary, etc.)
16
+ * @returns A promise that resolves to the financial transaction ID (referenceId)
17
+ */
18
+ async transfer(request) {
19
+ const referenceId = uuid();
20
+ const response = await this.client.post(`/remittance/v1_0/transfer`, {
21
+ amount: request.amount,
22
+ currency: request.currency,
23
+ externalId: request.externalId,
24
+ payee: request.payee,
25
+ originatingCountry: request.originatingCountry,
26
+ originalAmount: request.originalAmount,
27
+ originalCurrency: request.originalCurrency,
28
+ payerMessage: request.payerMessage,
29
+ payeeNote: request.payeeNote,
30
+ }, {
31
+ headers: {
32
+ "X-Reference-Id": referenceId,
33
+ "Content-Type": "application/json",
34
+ ...(request.callbackUrl
35
+ ? { "X-Callback-Url": request.callbackUrl }
36
+ : {}),
37
+ },
38
+ });
39
+ // In MoMo API, a 202 Accepted means the request was received successfully.
40
+ // The reference ID is what we supplied in the header.
41
+ if (response.status === 202) {
42
+ return referenceId;
43
+ }
44
+ throw new MtnMoMoError("Failed to retrieve transfer reference ID");
45
+ }
46
+ /**
47
+ * Get the details and status of a specific transfer
48
+ * @param referenceId - The unique identifier of the transfer transaction
49
+ * @returns A promise that resolves to the transfer details and status
50
+ */
51
+ async getTransaction(referenceId) {
52
+ const response = await this.client.get(`/remittance/v1_0/transfer/${referenceId}`);
53
+ if (response.status !== 200) {
54
+ throw new MtnMoMoError(`Failed to retrieve transfer: ${response.data?.message || "Unknown error"}`);
55
+ }
56
+ return response.data;
57
+ }
58
+ /**
59
+ * Get the current account balance
60
+ * @returns A promise that resolves to the account balance with currency information
61
+ */
62
+ async getBalance() {
63
+ const response = await this.client.get(`/remittance/v1_0/account/balance`);
64
+ if (response.status !== 200) {
65
+ throw new MtnMoMoError(`Failed to retrieve balance: ${response.data?.message || "Unknown error"}`);
66
+ }
67
+ return response.data;
68
+ }
69
+ /**
70
+ * Check if a beneficiary is active and can receive transfers
71
+ * @param partyId - The ID of the beneficiary (in the format specified by partyIdType)
72
+ * @param partyIdType - The type of ID (MSISDN, EMAIL, or PARTY_CODE)
73
+ * @returns A promise that resolves to true if the beneficiary is active, false otherwise
74
+ */
75
+ async isPayerActive(partyId, partyIdType = PartyIdType.MSISDN) {
76
+ const type = String(partyIdType);
77
+ try {
78
+ const response = await this.client.get(`/remittance/v1_0/accountholder/${partyIdType}/${partyId}/active`);
79
+ return response.status === 200;
80
+ }
81
+ catch (error) {
82
+ if (error.response?.status === 404) {
83
+ return false;
84
+ }
85
+ throw error;
86
+ }
87
+ }
88
+ /**
89
+ * Get basic user information for an account holder.
90
+ * Remittance only supports MSISDN for this endpoint in some versions.
91
+ *
92
+ * @param partyId The party identifier (MSISDN)
93
+ * @returns A promise that resolves to the basic user information
94
+ */
95
+ getBasicUserInfo(partyId) {
96
+ return this.client
97
+ .get(`/remittance/v1_0/accountholder/MSISDN/${partyId}/basicuserinfo`)
98
+ .then((response) => response.data);
99
+ }
100
+ /**
101
+ * Get the balance of the account in a specific currency.
102
+ *
103
+ * @param currency The ISO4217 currency code
104
+ * @returns A promise that resolves to the account balance in the specified currency
105
+ */
106
+ getBalanceInCurrency(currency) {
107
+ return this.client
108
+ .get(`/remittance/v1_0/account/balance/${currency}`)
109
+ .then((response) => response.data);
110
+ }
111
+ /**
112
+ * Retrieve user information with KYC consent (OAuth2-gated endpoint)
113
+ * Requires prior OAuth2 user consent/login flow to obtain authorization
114
+ * @returns A promise that resolves to the user's information and KYC consent details
115
+ */
116
+ async getUserInfoWithConsent() {
117
+ const response = await this.client.get(`/remittance/oauth2/v1_0/userinfo`);
118
+ if (response.status !== 200) {
119
+ throw new MtnMoMoError(`Failed to retrieve user info: ${response.data?.message || "Unknown error"}`);
120
+ }
121
+ return response.data;
122
+ }
123
+ bcAuthorize(request) {
124
+ const params = new URLSearchParams();
125
+ params.append("login_hint", request.login_hint);
126
+ params.append("scope", request.scope);
127
+ params.append("access_type", request.access_type);
128
+ if (request.consent_valid_in) {
129
+ params.append("consent_valid_in", String(request.consent_valid_in));
130
+ }
131
+ const basicAuthToken = createBasicAuthToken(this.config);
132
+ return this.client
133
+ .post("/remittance/v1_0/bc-authorize", params, {
134
+ headers: {
135
+ Authorization: `Basic ${basicAuthToken}`,
136
+ "Content-Type": "application/x-www-form-urlencoded",
137
+ },
138
+ })
139
+ .then((response) => response.data);
140
+ }
141
+ }
142
+ //# sourceMappingURL=remittance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remittance.js","sourceRoot":"","sources":["../../src/remittance.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ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I,CAAC,MAAM;aACf,IAAI,CAAsB,+BAA+B,EAAE,MAAM,EAAE;YAClE,OAAO,EAAE;gBACP,aAAa,EAAE,SAAS,cAAc,EAAE;gBACxC,cAAc,EAAE,mCAAmC;aACpD;SACF,CAAC;aACD,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;CACF"}
@@ -0,0 +1,22 @@
1
+ import type { AxiosInstance } from "axios";
2
+ import type { ApiUserInfo, Credentials } from "./common";
3
+ export default class Users {
4
+ private client;
5
+ constructor(client: AxiosInstance);
6
+ /**
7
+ * Used to create an API user in the sandbox target environment
8
+ * @param host The provider callback host
9
+ */
10
+ create(host: string): Promise<string>;
11
+ /**
12
+ * Used to create an API key for an API user in the sandbox target environment.
13
+ * @param userId
14
+ */
15
+ login(userId: string): Promise<Credentials>;
16
+ /**
17
+ * Used to retrieve an API user by reference id in the sandbox target environment.
18
+ * @param referenceId API user reference id (X-Reference-Id used at creation)
19
+ */
20
+ getApiUser(referenceId: string): Promise<ApiUserInfo>;
21
+ }
22
+ //# sourceMappingURL=users.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../src/users.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAG3C,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEzD,MAAM,CAAC,OAAO,OAAO,KAAK;IACxB,OAAO,CAAC,MAAM,CAAgB;gBAElB,MAAM,EAAE,aAAa;IAIjC;;;OAGG;IACI,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAe5C;;;OAGG;IACI,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAMlD;;;OAGG;IACI,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;CAK7D"}
@@ -0,0 +1,39 @@
1
+ import { v4 as uuid } from "uuid";
2
+ export default class Users {
3
+ constructor(client) {
4
+ this.client = client;
5
+ }
6
+ /**
7
+ * Used to create an API user in the sandbox target environment
8
+ * @param host The provider callback host
9
+ */
10
+ create(host) {
11
+ const userId = uuid();
12
+ return this.client
13
+ .post("/v1_0/apiuser", { providerCallbackHost: host }, {
14
+ headers: {
15
+ "X-Reference-Id": userId,
16
+ },
17
+ })
18
+ .then(() => userId);
19
+ }
20
+ /**
21
+ * Used to create an API key for an API user in the sandbox target environment.
22
+ * @param userId
23
+ */
24
+ login(userId) {
25
+ return this.client
26
+ .post(`/v1_0/apiuser/${userId}/apikey`)
27
+ .then((response) => response.data);
28
+ }
29
+ /**
30
+ * Used to retrieve an API user by reference id in the sandbox target environment.
31
+ * @param referenceId API user reference id (X-Reference-Id used at creation)
32
+ */
33
+ getApiUser(referenceId) {
34
+ return this.client
35
+ .get(`/v1_0/apiuser/${referenceId}`)
36
+ .then((response) => response.data);
37
+ }
38
+ }
39
+ //# sourceMappingURL=users.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"users.js","sourceRoot":"","sources":["../../src/users.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAIlC,MAAM,CAAC,OAAO,OAAO,KAAK;IAGxB,YAAY,MAAqB;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,IAAY;QACxB,MAAM,MAAM,GAAW,IAAI,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC,MAAM;aACf,IAAI,CACH,eAAe,EACf,EAAE,oBAAoB,EAAE,IAAI,EAAE,EAC9B;YACE,OAAO,EAAE;gBACP,gBAAgB,EAAE,MAAM;aACzB;SACF,CACF;aACA,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC;IACxB,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,MAAc;QACzB,OAAO,IAAI,CAAC,MAAM;aACf,IAAI,CAAc,iBAAiB,MAAM,SAAS,CAAC;aACnD,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IAED;;;OAGG;IACI,UAAU,CAAC,WAAmB;QACnC,OAAO,IAAI,CAAC,MAAM;aACf,GAAG,CAAc,iBAAiB,WAAW,EAAE,CAAC;aAChD,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;CACF"}
@@ -0,0 +1,14 @@
1
+ import type { PaymentRequest } from "./collections";
2
+ import type { WithdrawalRequest, DepositRequest, RefundRequest } from "./common";
3
+ import type { GlobalConfig, ProductConfig, SubscriptionConfig, UserConfig } from "./common";
4
+ import type { TransferRequest } from "./disbursements";
5
+ export declare function validateRequestToPay(paymentRequest: PaymentRequest): Promise<void>;
6
+ export declare function validateWithdrawalRequest(request: WithdrawalRequest): Promise<void>;
7
+ export declare function validateDepositRequest(request: DepositRequest): Promise<void>;
8
+ export declare function validateRefundRequest(request: RefundRequest): Promise<void>;
9
+ export declare function validateTransfer(payoutRequest: TransferRequest): Promise<void>;
10
+ export declare function validateGlobalConfig(config: GlobalConfig): void;
11
+ export declare function validateProductConfig(config: ProductConfig): void;
12
+ export declare function validateSubscriptionConfig(config: SubscriptionConfig): void;
13
+ export declare function validateUserConfig({ userId, userSecret }: UserConfig): void;
14
+ //# sourceMappingURL=validate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/validate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEjF,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,UAAU,EACX,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,wBAAgB,oBAAoB,CAClC,cAAc,EAAE,cAAc,GAC7B,OAAO,CAAC,IAAI,CAAC,CAef;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAWnF;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAW7E;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAU3E;AAED,wBAAgB,gBAAgB,CAC9B,aAAa,EAAE,eAAe,GAC7B,OAAO,CAAC,IAAI,CAAC,CAsBf;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAY/D;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAGjE;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAI3E;AAED,wBAAgB,kBAAkB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,UAAU,GAAG,IAAI,CAQ3E"}