@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,207 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnspecifiedError = exports.TransactionCancelledError = exports.ServiceUnavailableError = exports.ResourceNotFoundError = exports.ResourceAlreadyExistError = exports.PaymentNotApprovedError = exports.PayerNotFoundError = exports.PayerLimitReachedError = exports.PayeeNotAllowedToReceiveError = exports.PayeeNotFoundError = exports.NotEnoughFundsError = exports.NotAllowedError = exports.NotAllowedTargetEnvironmentError = exports.InvalidCurrencyError = exports.InvalidCallbackUrlHostError = exports.InternalProcessingError = exports.ExpiredError = exports.ApprovalRejectedError = exports.MtnMoMoError = void 0;
4
+ exports.handleError = handleError;
5
+ exports.getError = getError;
6
+ exports.getTransactionError = getTransactionError;
7
+ const common_1 = require("./common");
8
+ class MtnMoMoError extends Error {
9
+ constructor(message) {
10
+ super(message);
11
+ Object.setPrototypeOf(this, new.target.prototype);
12
+ }
13
+ }
14
+ exports.MtnMoMoError = MtnMoMoError;
15
+ class ApprovalRejectedError extends MtnMoMoError {
16
+ constructor() {
17
+ super(...arguments);
18
+ this.name = "ApprovalRejectedError";
19
+ }
20
+ }
21
+ exports.ApprovalRejectedError = ApprovalRejectedError;
22
+ class ExpiredError extends MtnMoMoError {
23
+ constructor() {
24
+ super(...arguments);
25
+ this.name = "ExpiredError";
26
+ }
27
+ }
28
+ exports.ExpiredError = ExpiredError;
29
+ class InternalProcessingError extends MtnMoMoError {
30
+ constructor() {
31
+ super(...arguments);
32
+ this.name = "InternalProcessingError";
33
+ }
34
+ }
35
+ exports.InternalProcessingError = InternalProcessingError;
36
+ class InvalidCallbackUrlHostError extends MtnMoMoError {
37
+ constructor() {
38
+ super(...arguments);
39
+ this.name = "InvalidCallbackUrlHostError";
40
+ }
41
+ }
42
+ exports.InvalidCallbackUrlHostError = InvalidCallbackUrlHostError;
43
+ class InvalidCurrencyError extends MtnMoMoError {
44
+ constructor() {
45
+ super(...arguments);
46
+ this.name = "InvalidCurrencyError";
47
+ }
48
+ }
49
+ exports.InvalidCurrencyError = InvalidCurrencyError;
50
+ class NotAllowedTargetEnvironmentError extends MtnMoMoError {
51
+ constructor() {
52
+ super(...arguments);
53
+ this.name = "NotAllowedTargetEnvironmentError";
54
+ }
55
+ }
56
+ exports.NotAllowedTargetEnvironmentError = NotAllowedTargetEnvironmentError;
57
+ class NotAllowedError extends MtnMoMoError {
58
+ constructor() {
59
+ super(...arguments);
60
+ this.name = "NotAllowedError";
61
+ }
62
+ }
63
+ exports.NotAllowedError = NotAllowedError;
64
+ class NotEnoughFundsError extends MtnMoMoError {
65
+ constructor() {
66
+ super(...arguments);
67
+ this.name = "NotEnoughFundsError";
68
+ }
69
+ }
70
+ exports.NotEnoughFundsError = NotEnoughFundsError;
71
+ class PayeeNotFoundError extends MtnMoMoError {
72
+ constructor() {
73
+ super(...arguments);
74
+ this.name = "PayeeNotFoundError";
75
+ }
76
+ }
77
+ exports.PayeeNotFoundError = PayeeNotFoundError;
78
+ class PayeeNotAllowedToReceiveError extends MtnMoMoError {
79
+ constructor() {
80
+ super(...arguments);
81
+ this.name = "PayeeNotAllowedToReceiveError";
82
+ }
83
+ }
84
+ exports.PayeeNotAllowedToReceiveError = PayeeNotAllowedToReceiveError;
85
+ class PayerLimitReachedError extends MtnMoMoError {
86
+ constructor() {
87
+ super(...arguments);
88
+ this.name = "PayerLimitReachedError";
89
+ }
90
+ }
91
+ exports.PayerLimitReachedError = PayerLimitReachedError;
92
+ class PayerNotFoundError extends MtnMoMoError {
93
+ constructor() {
94
+ super(...arguments);
95
+ this.name = "PayerNotFoundError";
96
+ }
97
+ }
98
+ exports.PayerNotFoundError = PayerNotFoundError;
99
+ class PaymentNotApprovedError extends MtnMoMoError {
100
+ constructor() {
101
+ super(...arguments);
102
+ this.name = "PaymentNotApprovedError";
103
+ }
104
+ }
105
+ exports.PaymentNotApprovedError = PaymentNotApprovedError;
106
+ class ResourceAlreadyExistError extends MtnMoMoError {
107
+ constructor() {
108
+ super(...arguments);
109
+ this.name = "ResourceAlreadyExistError";
110
+ }
111
+ }
112
+ exports.ResourceAlreadyExistError = ResourceAlreadyExistError;
113
+ class ResourceNotFoundError extends MtnMoMoError {
114
+ constructor() {
115
+ super(...arguments);
116
+ this.name = "ResourceNotFoundError";
117
+ }
118
+ }
119
+ exports.ResourceNotFoundError = ResourceNotFoundError;
120
+ class ServiceUnavailableError extends MtnMoMoError {
121
+ constructor() {
122
+ super(...arguments);
123
+ this.name = "ServiceUnavailableError";
124
+ }
125
+ }
126
+ exports.ServiceUnavailableError = ServiceUnavailableError;
127
+ class TransactionCancelledError extends MtnMoMoError {
128
+ constructor() {
129
+ super(...arguments);
130
+ this.name = "TransactionCancelledError";
131
+ }
132
+ }
133
+ exports.TransactionCancelledError = TransactionCancelledError;
134
+ class UnspecifiedError extends MtnMoMoError {
135
+ constructor() {
136
+ super(...arguments);
137
+ this.name = "UnspecifiedError";
138
+ }
139
+ }
140
+ exports.UnspecifiedError = UnspecifiedError;
141
+ function handleError(error) {
142
+ if (!error.response) {
143
+ return error;
144
+ }
145
+ const { code, message } = (error.response.data || {});
146
+ return getError(code, message);
147
+ }
148
+ function getError(code, message) {
149
+ if (code === common_1.FailureReason.APPROVAL_REJECTED) {
150
+ return new ApprovalRejectedError(message);
151
+ }
152
+ if (code === common_1.FailureReason.EXPIRED) {
153
+ return new ExpiredError(message);
154
+ }
155
+ if (code === common_1.FailureReason.INTERNAL_PROCESSING_ERROR) {
156
+ return new InternalProcessingError(message);
157
+ }
158
+ if (code === common_1.FailureReason.INVALID_CALLBACK_URL_HOST) {
159
+ return new InvalidCallbackUrlHostError(message);
160
+ }
161
+ if (code === common_1.FailureReason.INVALID_CURRENCY) {
162
+ return new InvalidCurrencyError(message);
163
+ }
164
+ if (code === common_1.FailureReason.NOT_ALLOWED) {
165
+ return new NotAllowedError(message);
166
+ }
167
+ if (code === common_1.FailureReason.NOT_ALLOWED_TARGET_ENVIRONMENT) {
168
+ return new NotAllowedTargetEnvironmentError(message);
169
+ }
170
+ if (code === common_1.FailureReason.NOT_ENOUGH_FUNDS) {
171
+ return new NotEnoughFundsError(message);
172
+ }
173
+ if (code === common_1.FailureReason.PAYEE_NOT_FOUND) {
174
+ return new PayeeNotFoundError(message);
175
+ }
176
+ if (code === common_1.FailureReason.PAYEE_NOT_ALLOWED_TO_RECEIVE) {
177
+ return new PayeeNotAllowedToReceiveError(message);
178
+ }
179
+ if (code === common_1.FailureReason.PAYER_LIMIT_REACHED) {
180
+ return new PayerLimitReachedError(message);
181
+ }
182
+ if (code === common_1.FailureReason.PAYER_NOT_FOUND) {
183
+ return new PayerNotFoundError(message);
184
+ }
185
+ if (code === common_1.FailureReason.PAYMENT_NOT_APPROVED) {
186
+ return new PaymentNotApprovedError(message);
187
+ }
188
+ if (code === common_1.FailureReason.RESOURCE_ALREADY_EXIST) {
189
+ return new ResourceAlreadyExistError(message);
190
+ }
191
+ if (code === common_1.FailureReason.RESOURCE_NOT_FOUND) {
192
+ return new ResourceNotFoundError(message);
193
+ }
194
+ if (code === common_1.FailureReason.SERVICE_UNAVAILABLE) {
195
+ return new ServiceUnavailableError(message);
196
+ }
197
+ if (code === common_1.FailureReason.TRANSACTION_CANCELED) {
198
+ return new TransactionCancelledError(message);
199
+ }
200
+ return new UnspecifiedError(message);
201
+ }
202
+ function getTransactionError(transaction) {
203
+ const error = getError(transaction.reason);
204
+ error.transaction = transaction;
205
+ return error;
206
+ }
207
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js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AAC,CAAC;IACpD,CAAC;IAED,IAAI,IAAI,KAAK,sBAAa,CAAC,mBAAmB,EAAE,CAAC;QAC/C,OAAO,IAAI,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC;IAED,IAAI,IAAI,KAAK,sBAAa,CAAC,eAAe,EAAE,CAAC;QAC3C,OAAO,IAAI,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAED,IAAI,IAAI,KAAK,sBAAa,CAAC,oBAAoB,EAAE,CAAC;QAChD,OAAO,IAAI,uBAAuB,CAAC,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED,IAAI,IAAI,KAAK,sBAAa,CAAC,sBAAsB,EAAE,CAAC;QAClD,OAAO,IAAI,yBAAyB,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC;IAED,IAAI,IAAI,KAAK,sBAAa,CAAC,kBAAkB,EAAE,CAAC;QAC9C,OAAO,IAAI,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAC5C,CAAC;IAED,IAAI,IAAI,KAAK,sBAAa,CAAC,mBAAmB,EAAE,CAAC;QAC/C,OAAO,IAAI,uBAAuB,CAAC,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED,IAAI,IAAI,KAAK,sBAAa,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,SAAgB,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,87 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.Environment = exports.Status = exports.PayerType = void 0;
21
+ exports.create = create;
22
+ __exportStar(require("./errors"), exports);
23
+ var common_1 = require("./common");
24
+ Object.defineProperty(exports, "PayerType", { enumerable: true, get: function () { return common_1.PartyIdType; } });
25
+ Object.defineProperty(exports, "Status", { enumerable: true, get: function () { return common_1.TransactionStatus; } });
26
+ Object.defineProperty(exports, "Environment", { enumerable: true, get: function () { return common_1.Environment; } });
27
+ const collections_1 = __importDefault(require("./collections"));
28
+ const disbursements_1 = __importDefault(require("./disbursements"));
29
+ const remittance_1 = __importDefault(require("./remittance"));
30
+ const users_1 = __importDefault(require("./users"));
31
+ const auth_1 = require("./auth");
32
+ const client_1 = require("./client");
33
+ const validate_1 = require("./validate");
34
+ const common_2 = require("./common");
35
+ const defaultGlobalConfig = {
36
+ baseUrl: "https://sandbox.momodeveloper.mtn.com",
37
+ environment: common_2.Environment.SANDBOX,
38
+ };
39
+ /**
40
+ * Initialise the library
41
+ *
42
+ * @param globalConfig Global configuration required to use any product
43
+ */
44
+ function create(globalConfig) {
45
+ (0, validate_1.validateGlobalConfig)(globalConfig);
46
+ return {
47
+ Collections(productConfig) {
48
+ (0, validate_1.validateProductConfig)(productConfig);
49
+ const config = {
50
+ ...defaultGlobalConfig,
51
+ ...globalConfig,
52
+ ...productConfig,
53
+ };
54
+ const client = (0, client_1.createAuthClient)((0, auth_1.createTokenRefresher)(auth_1.authorizeCollections, config), (0, client_1.createClient)(config));
55
+ return new collections_1.default(client, config);
56
+ },
57
+ Disbursements(productConfig) {
58
+ const config = {
59
+ ...defaultGlobalConfig,
60
+ ...globalConfig,
61
+ ...productConfig,
62
+ };
63
+ const client = (0, client_1.createAuthClient)((0, auth_1.createTokenRefresher)(auth_1.authorizeDisbursements, config), (0, client_1.createClient)(config));
64
+ return new disbursements_1.default(client, config);
65
+ },
66
+ Remittance(productConfig) {
67
+ const config = {
68
+ ...defaultGlobalConfig,
69
+ ...globalConfig,
70
+ ...productConfig,
71
+ };
72
+ const client = (0, client_1.createAuthClient)((0, auth_1.createTokenRefresher)(auth_1.authorizeRemittance, config), (0, client_1.createClient)(config));
73
+ return new remittance_1.default(client, config);
74
+ },
75
+ Users(subscriptionConfig) {
76
+ (0, validate_1.validateSubscriptionConfig)(subscriptionConfig);
77
+ const config = {
78
+ ...defaultGlobalConfig,
79
+ ...globalConfig,
80
+ ...subscriptionConfig,
81
+ };
82
+ const client = (0, client_1.createClient)(config);
83
+ return new users_1.default(client);
84
+ },
85
+ };
86
+ }
87
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AA8EA,wBAgEC;AAlID,2CAAyB;AACzB,mCAIkB;AAHhB,mGAAA,WAAW,OAAa;AACxB,gGAAA,iBAAiB,OAAU;AAC3B,qGAAA,WAAW,OAAA;AAmBb,gEAAwC;AACxC,oEAA4C;AAC5C,8DAAsC;AACtC,oDAA4B;AAE5B,iCAKgB;AAChB,qCAA0D;AAC1D,yCAIoB;AAEpB,qCAAuC;AAevC,MAAM,mBAAmB,GAAiB;IACxC,OAAO,EAAE,uCAAuC;IAChD,WAAW,EAAE,oBAAW,CAAC,OAAO;CACjC,CAAC;AAEF;;;;GAIG;AACH,SAAgB,MAAM,CAAC,YAA0B;IAC/C,IAAA,+BAAoB,EAAC,YAAY,CAAC,CAAC;IAEnC,OAAO;QACL,WAAW,CAAC,aAA4B;YACtC,IAAA,gCAAqB,EAAC,aAAa,CAAC,CAAC;YAErC,MAAM,MAAM,GAAW;gBACrB,GAAG,mBAAmB;gBACtB,GAAG,YAAY;gBACf,GAAG,aAAa;aACjB,CAAC;YAEF,MAAM,MAAM,GAAkB,IAAA,yBAAgB,EAC5C,IAAA,2BAAoB,EAAC,2BAAoB,EAAE,MAAM,CAAC,EAClD,IAAA,qBAAY,EAAC,MAAM,CAAC,CACrB,CAAC;YACF,OAAO,IAAI,qBAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACzC,CAAC;QAED,aAAa,CAAC,aAA4B;YACxC,MAAM,MAAM,GAAW;gBACrB,GAAG,mBAAmB;gBACtB,GAAG,YAAY;gBACf,GAAG,aAAa;aACjB,CAAC;YAEF,MAAM,MAAM,GAAkB,IAAA,yBAAgB,EAC5C,IAAA,2BAAoB,EAAC,6BAAsB,EAAE,MAAM,CAAC,EACpD,IAAA,qBAAY,EAAC,MAAM,CAAC,CACrB,CAAC;YAEF,OAAO,IAAI,uBAAa,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC3C,CAAC;QAED,UAAU,CAAC,aAA4B;YACrC,MAAM,MAAM,GAAW;gBACrB,GAAG,mBAAmB;gBACtB,GAAG,YAAY;gBACf,GAAG,aAAa;aACjB,CAAC;YAEF,MAAM,MAAM,GAAkB,IAAA,yBAAgB,EAC5C,IAAA,2BAAoB,EAAC,0BAAmB,EAAE,MAAM,CAAC,EACjD,IAAA,qBAAY,EAAC,MAAM,CAAC,CACrB,CAAC;YAEF,OAAO,IAAI,oBAAU,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACxC,CAAC;QAED,KAAK,CAAC,kBAAsC;YAC1C,IAAA,qCAA0B,EAAC,kBAAkB,CAAC,CAAC;YAE/C,MAAM,MAAM,GAAsC;gBAChD,GAAG,mBAAmB;gBACtB,GAAG,YAAY;gBACf,GAAG,kBAAkB;aACtB,CAAC;YAEF,MAAM,MAAM,GAAkB,IAAA,qBAAY,EAAC,MAAM,CAAC,CAAC;YAEnD,OAAO,IAAI,eAAK,CAAC,MAAM,CAAC,CAAC;QAC3B,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -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,145 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const common_1 = require("./common");
4
+ const errors_1 = require("./errors");
5
+ const auth_1 = require("./auth");
6
+ const uuid_1 = require("uuid");
7
+ /**
8
+ * Remittance product for cross-border money transfers with optional OAuth2 consent flows
9
+ */
10
+ class Remittance {
11
+ constructor(client, config) {
12
+ this.client = client;
13
+ this.config = config;
14
+ }
15
+ /**
16
+ * Send money across borders to a beneficiary
17
+ * @param request - The cash transfer request details (amount, currency, beneficiary, etc.)
18
+ * @returns A promise that resolves to the financial transaction ID (referenceId)
19
+ */
20
+ async transfer(request) {
21
+ const referenceId = (0, uuid_1.v4)();
22
+ const response = await this.client.post(`/remittance/v1_0/transfer`, {
23
+ amount: request.amount,
24
+ currency: request.currency,
25
+ externalId: request.externalId,
26
+ payee: request.payee,
27
+ originatingCountry: request.originatingCountry,
28
+ originalAmount: request.originalAmount,
29
+ originalCurrency: request.originalCurrency,
30
+ payerMessage: request.payerMessage,
31
+ payeeNote: request.payeeNote,
32
+ }, {
33
+ headers: {
34
+ "X-Reference-Id": referenceId,
35
+ "Content-Type": "application/json",
36
+ ...(request.callbackUrl
37
+ ? { "X-Callback-Url": request.callbackUrl }
38
+ : {}),
39
+ },
40
+ });
41
+ // In MoMo API, a 202 Accepted means the request was received successfully.
42
+ // The reference ID is what we supplied in the header.
43
+ if (response.status === 202) {
44
+ return referenceId;
45
+ }
46
+ throw new errors_1.MtnMoMoError("Failed to retrieve transfer reference ID");
47
+ }
48
+ /**
49
+ * Get the details and status of a specific transfer
50
+ * @param referenceId - The unique identifier of the transfer transaction
51
+ * @returns A promise that resolves to the transfer details and status
52
+ */
53
+ async getTransaction(referenceId) {
54
+ const response = await this.client.get(`/remittance/v1_0/transfer/${referenceId}`);
55
+ if (response.status !== 200) {
56
+ throw new errors_1.MtnMoMoError(`Failed to retrieve transfer: ${response.data?.message || "Unknown error"}`);
57
+ }
58
+ return response.data;
59
+ }
60
+ /**
61
+ * Get the current account balance
62
+ * @returns A promise that resolves to the account balance with currency information
63
+ */
64
+ async getBalance() {
65
+ const response = await this.client.get(`/remittance/v1_0/account/balance`);
66
+ if (response.status !== 200) {
67
+ throw new errors_1.MtnMoMoError(`Failed to retrieve balance: ${response.data?.message || "Unknown error"}`);
68
+ }
69
+ return response.data;
70
+ }
71
+ /**
72
+ * Check if a beneficiary is active and can receive transfers
73
+ * @param partyId - The ID of the beneficiary (in the format specified by partyIdType)
74
+ * @param partyIdType - The type of ID (MSISDN, EMAIL, or PARTY_CODE)
75
+ * @returns A promise that resolves to true if the beneficiary is active, false otherwise
76
+ */
77
+ async isPayerActive(partyId, partyIdType = common_1.PartyIdType.MSISDN) {
78
+ const type = String(partyIdType);
79
+ try {
80
+ const response = await this.client.get(`/remittance/v1_0/accountholder/${partyIdType}/${partyId}/active`);
81
+ return response.status === 200;
82
+ }
83
+ catch (error) {
84
+ if (error.response?.status === 404) {
85
+ return false;
86
+ }
87
+ throw error;
88
+ }
89
+ }
90
+ /**
91
+ * Get basic user information for an account holder.
92
+ * Remittance only supports MSISDN for this endpoint in some versions.
93
+ *
94
+ * @param partyId The party identifier (MSISDN)
95
+ * @returns A promise that resolves to the basic user information
96
+ */
97
+ getBasicUserInfo(partyId) {
98
+ return this.client
99
+ .get(`/remittance/v1_0/accountholder/MSISDN/${partyId}/basicuserinfo`)
100
+ .then((response) => response.data);
101
+ }
102
+ /**
103
+ * Get the balance of the account in a specific currency.
104
+ *
105
+ * @param currency The ISO4217 currency code
106
+ * @returns A promise that resolves to the account balance in the specified currency
107
+ */
108
+ getBalanceInCurrency(currency) {
109
+ return this.client
110
+ .get(`/remittance/v1_0/account/balance/${currency}`)
111
+ .then((response) => response.data);
112
+ }
113
+ /**
114
+ * Retrieve user information with KYC consent (OAuth2-gated endpoint)
115
+ * Requires prior OAuth2 user consent/login flow to obtain authorization
116
+ * @returns A promise that resolves to the user's information and KYC consent details
117
+ */
118
+ async getUserInfoWithConsent() {
119
+ const response = await this.client.get(`/remittance/oauth2/v1_0/userinfo`);
120
+ if (response.status !== 200) {
121
+ throw new errors_1.MtnMoMoError(`Failed to retrieve user info: ${response.data?.message || "Unknown error"}`);
122
+ }
123
+ return response.data;
124
+ }
125
+ bcAuthorize(request) {
126
+ const params = new URLSearchParams();
127
+ params.append("login_hint", request.login_hint);
128
+ params.append("scope", request.scope);
129
+ params.append("access_type", request.access_type);
130
+ if (request.consent_valid_in) {
131
+ params.append("consent_valid_in", String(request.consent_valid_in));
132
+ }
133
+ const basicAuthToken = (0, auth_1.createBasicAuthToken)(this.config);
134
+ return this.client
135
+ .post("/remittance/v1_0/bc-authorize", params, {
136
+ headers: {
137
+ Authorization: `Basic ${basicAuthToken}`,
138
+ "Content-Type": "application/x-www-form-urlencoded",
139
+ },
140
+ })
141
+ .then((response) => response.data);
142
+ }
143
+ }
144
+ exports.default = Remittance;
145
+ //# sourceMappingURL=remittance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remittance.js","sourceRoot":"","sources":["../../src/remittance.ts"],"names":[],"mappings":";;AAaA,qCAA0D;AAC1D,qCAAwC;AACxC,iCAA8C;AAG9C,+BAAkC;AAElC;;GAEG;AACH,MAAqB,UAAU;IAI7B,YAAY,MAAqB,EAAE,MAAc;QAC/C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,QAAQ,CAAC,OAA4B;QACzC,MAAM,WAAW,GAAG,IAAA,SAAI,GAAE,CAAC;QAC3B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CACrC,2BAA2B,EAC3B;YACE,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,UAAU,EAAE,O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AAM,KAAK,GAAG,EAAE,CAAC;YAC5B,MAAM,IAAI,qBAAY,CACpB,iCAAiC,QAAQ,CAAC,IAAI,EAAE,OAAO,IAAI,eAAe,EAAE,CAC7E,CAAC;QACJ,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IACM,WAAW,CAChB,OAA2B;QAE3B,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;QACrC,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;QAChD,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;QACtC,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;QAClD,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;YAC7B,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC;QACtE,CAAC;QAED,MAAM,cAAc,GAAW,IAAA,2BAAoB,EAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAEjE,OAAO,IAAI,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;AA5KD,6BA4KC"}
@@ -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,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const uuid_1 = require("uuid");
4
+ class Users {
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ /**
9
+ * Used to create an API user in the sandbox target environment
10
+ * @param host The provider callback host
11
+ */
12
+ create(host) {
13
+ const userId = (0, uuid_1.v4)();
14
+ return this.client
15
+ .post("/v1_0/apiuser", { providerCallbackHost: host }, {
16
+ headers: {
17
+ "X-Reference-Id": userId,
18
+ },
19
+ })
20
+ .then(() => userId);
21
+ }
22
+ /**
23
+ * Used to create an API key for an API user in the sandbox target environment.
24
+ * @param userId
25
+ */
26
+ login(userId) {
27
+ return this.client
28
+ .post(`/v1_0/apiuser/${userId}/apikey`)
29
+ .then((response) => response.data);
30
+ }
31
+ /**
32
+ * Used to retrieve an API user by reference id in the sandbox target environment.
33
+ * @param referenceId API user reference id (X-Reference-Id used at creation)
34
+ */
35
+ getApiUser(referenceId) {
36
+ return this.client
37
+ .get(`/v1_0/apiuser/${referenceId}`)
38
+ .then((response) => response.data);
39
+ }
40
+ }
41
+ exports.default = Users;
42
+ //# sourceMappingURL=users.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"users.js","sourceRoot":"","sources":["../../src/users.ts"],"names":[],"mappings":";;AACA,+BAAkC;AAIlC,MAAqB,KAAK;IAGxB,YAAY,MAAqB;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,IAAY;QACxB,MAAM,MAAM,GAAW,IAAA,SAAI,GAAE,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;AA7CD,wBA6CC"}
@@ -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"}