moosyl 0.0.3 → 0.0.4

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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/moosyl.svg)](https://www.npmjs.com/package/moosyl)
4
4
 
5
- The **Moosyl JavaScript SDK** helps you integrate payment solutions with Mauritania's popular banking apps—such as **Bankily**, **Sedad**, and **Masrivi**—in Node.js or the browser. Use it to fetch available payment methods, payment request details, and process payments (auto or manual) via the Moosyl API.
5
+ The **Moosyl JavaScript SDK** helps you integrate payment solutions with Mauritania's popular banking apps—such as **Bankily**, **Sedad**, and **Masrivi**—in Node.js or the browser. Use it to fetch available payment methods, payment request details, and process payments via the Moosyl API.
6
6
 
7
7
  ---
8
8
 
@@ -10,7 +10,7 @@ The **Moosyl JavaScript SDK** helps you integrate payment solutions with Maurita
10
10
 
11
11
  - **Payment methods**: Fetch available payment methods (including testing mode).
12
12
  - **Payment request**: Get payment request details by transaction ID.
13
- - **Pay**: Process automatic payments (e.g. Bankily) or manual payments with a screenshot.
13
+ - **Pay**: Process payments (e.g. Bankily).
14
14
  - **Lightweight**: No UI; use your own front end or backend flows.
15
15
  - **ESM**: Native ES modules (`import`).
16
16
 
@@ -40,7 +40,7 @@ const moosyl = new Moosyl("YOUR_PUBLISHABLE_API_KEY");
40
40
 
41
41
  ## Usage
42
42
 
43
- All functionality is available on the **Moosyl** instance: `moosyl.getPaymentMethods()`, `moosyl.getPaymentRequest()`, `moosyl.pay()`, and `moosyl.manualPay()`.
43
+ All functionality is available on the **Moosyl** instance: `moosyl.getPaymentMethods()`, `moosyl.getPaymentRequest()`, `moosyl.pay()`.
44
44
 
45
45
  ### Fetch payment methods
46
46
 
@@ -89,9 +89,9 @@ curl -X POST https://api.moosyl.com/payment-request \
89
89
 
90
90
  Once created, use the returned **transactionId** with `moosyl.getPaymentRequest()` and your payment flow.
91
91
 
92
- ### Process payment (auto)
92
+ ### Process payment
93
93
 
94
- For automatic payment methods (e.g. Bankily):
94
+ For payment methods (e.g. Bankily):
95
95
 
96
96
  ```javascript
97
97
  import { Moosyl } from "moosyl";
@@ -102,34 +102,10 @@ await moosyl.pay(
102
102
  "TRANSACTION_ID",
103
103
  "+22212345678",
104
104
  "PASSCODE",
105
- "PAYMENT_METHOD_ID" // configuration ID from getPaymentMethods()
105
+ "PAYMENT_METHOD_ID", // configuration ID from getPaymentMethods()
106
106
  );
107
107
  ```
108
108
 
109
- ### Process manual payment
110
-
111
- For manual payment methods, send a screenshot (File in the browser, or `{ name, data, type? }` in Node):
112
-
113
- ```javascript
114
- import { Moosyl } from "moosyl";
115
-
116
- const moosyl = new Moosyl("YOUR_PUBLISHABLE_API_KEY");
117
-
118
- // Browser: pass a File from an input
119
- await moosyl.manualPay(
120
- "TRANSACTION_ID",
121
- "PAYMENT_METHOD_ID",
122
- fileInput.files[0]
123
- );
124
-
125
- // Node: pass { name, data (Buffer), type? }
126
- await moosyl.manualPay("TRANSACTION_ID", "PAYMENT_METHOD_ID", {
127
- name: "proof.png",
128
- data: imageBuffer,
129
- type: "image/png",
130
- });
131
- ```
132
-
133
109
  ---
134
110
 
135
111
  ## Configuration
package/dist/index.d.ts CHANGED
@@ -1,14 +1,12 @@
1
1
  /**
2
2
  * Moosyl JS – integrating payment solutions with Mauritania's popular banking apps.
3
3
  */
4
- export { Moosyl } from './src/moosyl.js';
5
- export { Fetcher, FetcherResponse, Endpoints } from './src/helpers/fetcher.js';
6
- export { AppException, AppExceptionCode } from './src/helpers/exceptions.js';
7
- export { PaymentType, PaymentMethodTypes, PaymentMethodTitles, paymentTypeFromString, paymentMethodTypesFromString, PaymentMethod, BankilyConfigModel, ManualConfigModel, } from './src/models/payment-method-model.js';
8
- export type { PaymentTypeValue, PaymentMethodTypesValue } from './src/models/payment-method-model.js';
9
- export { PaymentRequestModel } from './src/models/payment-request-model.js';
10
- export { GetPaymentMethodsService } from './src/services/get-payment-methods-service.js';
11
- export { GetPaymentRequestService } from './src/services/get-payment-request-service.js';
12
- export { PayService } from './src/services/pay-service.js';
13
- export type { ManualPayImageInput } from './src/services/pay-service.js';
4
+ export { Moosyl } from "./src/moosyl.js";
5
+ export { Fetcher, FetcherResponse, Endpoints } from "./src/helpers/fetcher.js";
6
+ export { AppException, AppExceptionCode } from "./src/helpers/exceptions.js";
7
+ export { PaymentMethodTypes, PaymentMethodTitles, paymentMethodTypesFromString, PaymentMethod, } from "./src/models/payment-method-model.js";
8
+ export { PaymentRequestModel } from "./src/models/payment-request-model.js";
9
+ export { GetPaymentMethodsService } from "./src/services/get-payment-methods-service.js";
10
+ export { GetPaymentRequestService } from "./src/services/get-payment-request-service.js";
11
+ export { PayService } from "./src/services/pay-service.js";
14
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE7E,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,4BAA4B,EAC5B,aAAa,EACb,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,sCAAsC,CAAC;AAC9C,YAAY,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAEtG,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAE5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AACzF,OAAO,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AACzF,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,YAAY,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE7E,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,4BAA4B,EAC5B,aAAa,GACd,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAE5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AACzF,OAAO,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AACzF,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC"}
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  /**
2
2
  * Moosyl JS – integrating payment solutions with Mauritania's popular banking apps.
3
3
  */
4
- export { Moosyl } from './src/moosyl.js';
5
- export { Fetcher, FetcherResponse, Endpoints } from './src/helpers/fetcher.js';
6
- export { AppException, AppExceptionCode } from './src/helpers/exceptions.js';
7
- export { PaymentType, PaymentMethodTypes, PaymentMethodTitles, paymentTypeFromString, paymentMethodTypesFromString, PaymentMethod, BankilyConfigModel, ManualConfigModel, } from './src/models/payment-method-model.js';
8
- export { PaymentRequestModel } from './src/models/payment-request-model.js';
9
- export { GetPaymentMethodsService } from './src/services/get-payment-methods-service.js';
10
- export { GetPaymentRequestService } from './src/services/get-payment-request-service.js';
11
- export { PayService } from './src/services/pay-service.js';
4
+ export { Moosyl } from "./src/moosyl.js";
5
+ export { Fetcher, FetcherResponse, Endpoints } from "./src/helpers/fetcher.js";
6
+ export { AppException, AppExceptionCode } from "./src/helpers/exceptions.js";
7
+ export { PaymentMethodTypes, PaymentMethodTitles, paymentMethodTypesFromString, PaymentMethod, } from "./src/models/payment-method-model.js";
8
+ export { PaymentRequestModel } from "./src/models/payment-request-model.js";
9
+ export { GetPaymentMethodsService } from "./src/services/get-payment-methods-service.js";
10
+ export { GetPaymentRequestService } from "./src/services/get-payment-request-service.js";
11
+ export { PayService } from "./src/services/pay-service.js";
12
12
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE7E,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,4BAA4B,EAC5B,aAAa,EACb,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,sCAAsC,CAAC;AAG9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAE5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AACzF,OAAO,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AACzF,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE7E,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,4BAA4B,EAC5B,aAAa,GACd,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAE5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AACzF,OAAO,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AACzF,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC"}
@@ -1,20 +1,35 @@
1
1
  /**
2
- * Exception codes returned by the API or used internally.
2
+ * Exception codes returned by the API or used for request failures.
3
3
  */
4
4
  export declare const AppExceptionCode: {
5
5
  readonly unknown: "unknown";
6
+ readonly connectionError: "connection_error";
7
+ readonly abortError: "abort_error";
8
+ readonly timeout: "timeout";
9
+ readonly invalidApiKey: "invalid_api_key";
6
10
  };
7
11
  export type AppExceptionCodeType = (typeof AppExceptionCode)[keyof typeof AppExceptionCode];
12
+ export interface AppExceptionOptions {
13
+ code?: string;
14
+ message?: string;
15
+ status?: number;
16
+ }
8
17
  /**
9
- * Application exception with code and message.
10
- * Thrown when API requests fail.
18
+ * Application exception with code, message, and optional HTTP status.
19
+ * Thrown when API requests fail (network, abort, timeout, or HTTP error response).
11
20
  */
12
21
  export declare class AppException extends Error {
13
22
  code: string;
14
23
  message: string;
15
- constructor(options: {
16
- code?: string;
17
- message?: string;
18
- });
24
+ /** HTTP status when error comes from a response (e.g. 400, 500). */
25
+ readonly status?: number;
26
+ constructor(options?: AppExceptionOptions);
27
+ get isConnectionError(): boolean;
28
+ get isAbortError(): boolean;
29
+ get isTimeout(): boolean;
30
+ get isServerError(): boolean;
31
+ get isClientError(): boolean;
32
+ /** True when the API rejected the request due to an invalid or missing API key. */
33
+ get isInvalidApiKey(): boolean;
19
34
  }
20
35
  //# sourceMappingURL=exceptions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"exceptions.d.ts","sourceRoot":"","sources":["../../../src/helpers/exceptions.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,gBAAgB;;CAEnB,CAAC;AAEX,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAC;AAE5F;;;GAGG;AACH,qBAAa,YAAa,SAAQ,KAAK;IACrC,IAAI,EAAE,MAAM,CAAC;IACJ,OAAO,EAAE,MAAM,CAAC;gBAEb,OAAO,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;CAOzD"}
1
+ {"version":3,"file":"exceptions.d.ts","sourceRoot":"","sources":["../../../src/helpers/exceptions.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;CAMnB,CAAC;AAEX,MAAM,MAAM,oBAAoB,GAC9B,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAC;AAE3D,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,qBAAa,YAAa,SAAQ,KAAK;IACrC,IAAI,EAAE,MAAM,CAAC;IACJ,OAAO,EAAE,MAAM,CAAC;IACzB,oEAAoE;IACpE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;gBAEb,OAAO,GAAE,mBAAwB;IAS7C,IAAI,iBAAiB,IAAI,OAAO,CAE/B;IAED,IAAI,YAAY,IAAI,OAAO,CAE1B;IAED,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,IAAI,aAAa,IAAI,OAAO,CAE3B;IAED,IAAI,aAAa,IAAI,OAAO,CAI3B;IAED,mFAAmF;IACnF,IAAI,eAAe,IAAI,OAAO,CAE7B;CACF"}
@@ -1,22 +1,48 @@
1
1
  /**
2
- * Exception codes returned by the API or used internally.
2
+ * Exception codes returned by the API or used for request failures.
3
3
  */
4
4
  export const AppExceptionCode = {
5
- unknown: 'unknown',
5
+ unknown: "unknown",
6
+ connectionError: "connection_error",
7
+ abortError: "abort_error",
8
+ timeout: "timeout",
9
+ invalidApiKey: "invalid_api_key",
6
10
  };
7
11
  /**
8
- * Application exception with code and message.
9
- * Thrown when API requests fail.
12
+ * Application exception with code, message, and optional HTTP status.
13
+ * Thrown when API requests fail (network, abort, timeout, or HTTP error response).
10
14
  */
11
15
  export class AppException extends Error {
12
16
  code;
13
17
  message;
14
- constructor(options) {
15
- const message = options.message ?? 'An error occurred';
18
+ /** HTTP status when error comes from a response (e.g. 400, 500). */
19
+ status;
20
+ constructor(options = {}) {
21
+ const message = options.message ?? "An error occurred";
16
22
  super(message);
17
- this.name = 'AppException';
23
+ this.name = "AppException";
18
24
  this.code = options.code ?? AppExceptionCode.unknown;
19
25
  this.message = message;
26
+ this.status = options.status;
27
+ }
28
+ get isConnectionError() {
29
+ return this.code === AppExceptionCode.connectionError;
30
+ }
31
+ get isAbortError() {
32
+ return this.code === AppExceptionCode.abortError;
33
+ }
34
+ get isTimeout() {
35
+ return this.code === AppExceptionCode.timeout;
36
+ }
37
+ get isServerError() {
38
+ return typeof this.status === "number" && this.status >= 500;
39
+ }
40
+ get isClientError() {
41
+ return (typeof this.status === "number" && this.status >= 400 && this.status < 500);
42
+ }
43
+ /** True when the API rejected the request due to an invalid or missing API key. */
44
+ get isInvalidApiKey() {
45
+ return this.code === AppExceptionCode.invalidApiKey;
20
46
  }
21
47
  }
22
48
  //# sourceMappingURL=exceptions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"exceptions.js","sourceRoot":"","sources":["../../../src/helpers/exceptions.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,OAAO,EAAE,SAAS;CACV,CAAC;AAIX;;;GAGG;AACH,MAAM,OAAO,YAAa,SAAQ,KAAK;IACrC,IAAI,CAAS;IACJ,OAAO,CAAS;I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ED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,IAAI,KAAK,gBAAgB,CAAC,OAAO,CAAC;IAChD,CAAC;IAED,IAAI,aAAa;QACf,OAAO,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,IAAI,GAAG,CAAC;IAC/D,CAAC;IAED,IAAI,aAAa;QACf,OAAO,CACL,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,MAAM,GAAG,GAAG,CAC3E,CAAC;IACJ,CAAC;IAED,mFAAmF;IACnF,IAAI,eAAe;QACjB,OAAO,IAAI,CAAC,IAAI,KAAK,gBAAgB,CAAC,aAAa,CAAC;IACtD,CAAC;CACF"}
@@ -1,4 +1,4 @@
1
- import { AppException } from './exceptions.js';
1
+ import { AppException } from "./exceptions.js";
2
2
  /**
3
3
  * Static API base URL and endpoint builders.
4
4
  */
@@ -6,7 +6,6 @@ export declare const Endpoints: {
6
6
  baseUrl: string;
7
7
  paymentMethods(isTestingMode: boolean): string;
8
8
  readonly pay: string;
9
- readonly manualPayment: string;
10
9
  paymentRequest(id: string): string;
11
10
  };
12
11
  /**
@@ -16,16 +15,12 @@ export declare class Fetcher {
16
15
  publishableApiKey: string;
17
16
  constructor(publishableApiKey: string);
18
17
  get headers(): Record<string, string>;
19
- static fromResponse(response: Response, bytes?: boolean): Promise<FetcherResponse>;
18
+ private fromResponse;
19
+ private wrapFetchError;
20
20
  get(url: string, options?: {
21
- bytes?: boolean;
21
+ raw?: boolean;
22
22
  }): Promise<FetcherResponse>;
23
23
  post(url: string, body?: Record<string, unknown>): Promise<FetcherResponse>;
24
- multipartPost(url: string, body: Record<string, string>, files?: {
25
- name: string;
26
- data: Buffer | Blob;
27
- filename?: string;
28
- }[]): Promise<FetcherResponse>;
29
24
  }
30
25
  /**
31
26
  * Wrapper for API response (url, status, data).
@@ -1 +1 @@
1
- {"version":3,"file":"fetcher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AM,GAAG,MAAM;IAIvC,WAAW,IAAI,YAAY;CAoB5B"}
@@ -1,18 +1,15 @@
1
- import { AppException, AppExceptionCode } from './exceptions.js';
1
+ import { AppException, AppExceptionCode } from "./exceptions.js";
2
2
  /**
3
3
  * Static API base URL and endpoint builders.
4
4
  */
5
5
  export const Endpoints = {
6
- baseUrl: 'https://moosyl.moosyl.workers.dev',
6
+ baseUrl: "https://moosyl.moosyl.workers.dev",
7
7
  paymentMethods(isTestingMode) {
8
8
  return `${this.baseUrl}/configuration?isTestingMode=${isTestingMode}`;
9
9
  },
10
10
  get pay() {
11
11
  return `${this.baseUrl}/payment`;
12
12
  },
13
- get manualPayment() {
14
- return `${this.baseUrl}/payment/manual`;
15
- },
16
13
  paymentRequest(id) {
17
14
  return `${this.baseUrl}/payment-request/by-transaction/${id}`;
18
15
  },
@@ -35,61 +32,79 @@ export class Fetcher {
35
32
  }
36
33
  get headers() {
37
34
  return {
38
- 'Content-Type': 'application/json',
35
+ "Content-Type": "application/json",
39
36
  Authorization: this.publishableApiKey,
40
37
  };
41
38
  }
42
- static async fromResponse(response, bytes = false) {
43
- const url = response.url ?? '';
39
+ async fromResponse(response, raw = false) {
40
+ const url = response.url ?? "";
44
41
  const status = response.status;
45
42
  const body = await response.text();
46
- const data = bytes ? body : parseResponseBody(body);
43
+ const data = raw ? body : parseResponseBody(body);
47
44
  return new FetcherResponse({ url, status, data });
48
45
  }
49
- async get(url, options = {}) {
50
- const { bytes = false } = options;
51
- const response = await fetch(url, {
52
- method: 'GET',
53
- headers: this.headers,
54
- signal: AbortSignal.timeout(60_000),
46
+ wrapFetchError(err) {
47
+ if (err instanceof Error) {
48
+ const name = err.name;
49
+ if (name === "AbortError") {
50
+ return new AppException({
51
+ code: AppExceptionCode.abortError,
52
+ message: err.message || "Request was aborted",
53
+ });
54
+ }
55
+ if (name === "TimeoutError") {
56
+ return new AppException({
57
+ code: AppExceptionCode.timeout,
58
+ message: err.message || "Request timed out",
59
+ });
60
+ }
61
+ return new AppException({
62
+ code: AppExceptionCode.connectionError,
63
+ message: err.message || "Network request failed",
64
+ });
65
+ }
66
+ return new AppException({
67
+ code: AppExceptionCode.connectionError,
68
+ message: "Network request failed",
55
69
  });
56
- const res = await Fetcher.fromResponse(response, bytes);
57
- if (!res.success)
58
- throw res.toException();
59
- return res;
60
70
  }
61
- async post(url, body) {
62
- const response = await fetch(url, {
63
- method: 'POST',
64
- headers: this.headers,
65
- body: body ? JSON.stringify(body) : undefined,
66
- signal: AbortSignal.timeout(60_000),
67
- });
68
- const res = await Fetcher.fromResponse(response);
69
- if (!res.success)
70
- throw res.toException();
71
- return res;
71
+ async get(url, options = {}) {
72
+ const { raw = false } = options;
73
+ try {
74
+ const response = await fetch(url, {
75
+ method: "GET",
76
+ headers: this.headers,
77
+ signal: AbortSignal.timeout(60_000),
78
+ });
79
+ const res = await this.fromResponse(response, raw);
80
+ if (!res.success)
81
+ throw res.toException();
82
+ return res;
83
+ }
84
+ catch (err) {
85
+ if (err instanceof AppException)
86
+ throw err;
87
+ throw this.wrapFetchError(err);
88
+ }
72
89
  }
73
- async multipartPost(url, body, files = []) {
74
- const form = new FormData();
75
- for (const [key, value] of Object.entries(body)) {
76
- form.append(key, value);
90
+ async post(url, body) {
91
+ try {
92
+ const response = await fetch(url, {
93
+ method: "POST",
94
+ headers: this.headers,
95
+ body: body ? JSON.stringify(body) : undefined,
96
+ signal: AbortSignal.timeout(60_000),
97
+ });
98
+ const res = await this.fromResponse(response);
99
+ if (!res.success)
100
+ throw res.toException();
101
+ return res;
77
102
  }
78
- for (const file of files) {
79
- const blob = file.data instanceof Blob ? file.data : new Blob([new Uint8Array(file.data)]);
80
- form.append('attachments', blob, file.filename ?? file.name);
103
+ catch (err) {
104
+ if (err instanceof AppException)
105
+ throw err;
106
+ throw this.wrapFetchError(err);
81
107
  }
82
- const headers = { Authorization: this.publishableApiKey };
83
- const response = await fetch(url, {
84
- method: 'POST',
85
- headers,
86
- body: form,
87
- signal: AbortSignal.timeout(60_000),
88
- });
89
- const res = await Fetcher.fromResponse(response);
90
- if (!res.success)
91
- throw res.toException();
92
- return res;
93
108
  }
94
109
  }
95
110
  /**
@@ -108,21 +123,25 @@ export class FetcherResponse {
108
123
  return this.status >= 200 && this.status <= 299;
109
124
  }
110
125
  stripHtmlIfNeeded(text) {
111
- return String(text).replace(/<[^>]*>|&[^;]+;/g, ' ');
126
+ return String(text).replace(/<[^>]*>|&[^;]+;/g, " ");
112
127
  }
113
128
  toException() {
114
129
  const data = this.data;
115
- const code = typeof data === 'string'
130
+ const code = typeof data === "string"
116
131
  ? data
117
- : (data && typeof data === 'object' && 'code' in data
132
+ : data && typeof data === "object" && "code" in data
118
133
  ? data.code
119
- : AppExceptionCode.unknown);
120
- const message = typeof data === 'string'
134
+ : AppExceptionCode.unknown;
135
+ const message = typeof data === "string"
121
136
  ? data
122
- : (data && typeof data === 'object' && 'message' in data
137
+ : data && typeof data === "object" && "message" in data
123
138
  ? data.message
124
- : 'An error occurred');
125
- return new AppException({ code, message: String(message) });
139
+ : "An error occurred";
140
+ return new AppException({
141
+ code,
142
+ message: String(message),
143
+ status: this.status,
144
+ });
126
145
  }
127
146
  }
128
147
  //# sourceMappingURL=fetcher.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetcher.js","sourceRoot":"","sources":["../../../src/helpers/fetcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEjE;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,OAAO,EAAE,mCAAmC;IAE5C,cAAc,CAAC,aAAsB;QACnC,OAAO,GAAG,IAAI,CAAC,OAAO,gCAAgC,aAAa,EAAE,CAAC;IACxE,CAAC;IAED,IAAI,GAAG;QACL,OAAO,GAAG,IAAI,CAAC,OAAO,UAAU,CAAC;IACnC,CAAC;IAED,IAAI,aAAa;QACf,OAAO,GAAG,IAAI,CAAC,OAAO,iBAAiB,CAAC;IAC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IAAI;gBACjC,CAAC,CAAC,gBAAgB,CAAC,OAAO,CAAC;QACjC,MAAM,OAAO,GACX,OAAO,IAAI,KAAK,QAAQ;YACtB,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,SAAS,IAAI,IAAI;gBACrD,CAAC,CAAE,IAA4B,CAAC,OAAO;gBACvC,CAAC,CAAC,mBAAmB,CAAC;QAC5B,OAAO,IAAI,YAAY,CAAC;YACtB,IAAI;YACJ,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC;YACxB,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -1,10 +1,4 @@
1
- export type PaymentTypeValue = 'manual' | 'auto';
2
- export declare const PaymentType: {
3
- readonly manual: "manual";
4
- readonly auto: "auto";
5
- };
6
- export declare function paymentTypeFromString(type: string): PaymentTypeValue;
7
- export type PaymentMethodTypesValue = 'masrivi' | 'bankily' | 'sedad' | 'bim_bank' | 'amanty' | 'bci_pay';
1
+ export type PaymentMethodTypesValue = "masrivi" | "bankily" | "sedad" | "bim_bank" | "amanty" | "bci_pay";
8
2
  export declare const PaymentMethodTypes: {
9
3
  readonly masrivi: "masrivi";
10
4
  readonly bankily: "bankily";
@@ -22,40 +16,12 @@ export declare function paymentMethodTypesFromString(method: string): PaymentMet
22
16
  export declare class PaymentMethod {
23
17
  readonly id: string;
24
18
  readonly method: PaymentMethodTypesValue;
25
- readonly type: PaymentTypeValue;
26
- constructor(options: {
27
- id: string;
28
- method: PaymentMethodTypesValue;
29
- type: PaymentTypeValue;
30
- });
31
- static fromMap(map: Record<string, unknown>): PaymentMethod;
32
- static fromPaymentMethod(map: Record<string, unknown>): PaymentMethod;
33
- static fromPaymentType(map: Record<string, unknown>): PaymentMethod;
34
- }
35
- /**
36
- * Bankily payment method config (adds bPayNumber).
37
- */
38
- export declare class BankilyConfigModel extends PaymentMethod {
39
19
  readonly bPayNumber: string;
40
20
  constructor(options: {
41
21
  id: string;
42
22
  method: PaymentMethodTypesValue;
43
- type: PaymentTypeValue;
44
- bPayNumber: string;
23
+ bPayNumber?: string;
45
24
  });
46
- static fromMap(map: Record<string, unknown>): BankilyConfigModel;
47
- }
48
- /**
49
- * Manual payment method config (adds merchantCode).
50
- */
51
- export declare class ManualConfigModel extends PaymentMethod {
52
- readonly merchantCode: string;
53
- constructor(options: {
54
- id: string;
55
- method: PaymentMethodTypesValue;
56
- type: PaymentTypeValue;
57
- merchantCode: string;
58
- });
59
- static fromMap(map: Record<string, unknown>): ManualConfigModel;
25
+ static fromMap(map: Record<string, unknown>): PaymentMethod;
60
26
  }
61
27
  //# sourceMappingURL=payment-method-model.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"payment-method-model.d.ts","sourceRoot":"","sources":["../../../src/models/payment-method-model.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEjD,eAAO,MAAM,WAAW;;;CAGd,CAAC;AAEX,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,CAGpE;AAED,MAAM,MAAM,uBAAuB,GAC/B,SAAS,GACT,SAAS,GACT,OAAO,GACP,UAAU,GACV,QAAQ,GACR,SAAS,CAAC;AAEd,eAAO,MAAM,kBAAkB;;;;;;;CAOrB,CAAC;AAWX,mEAAmE;AACnE,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAOtD,CAAC;AAEF,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,MAAM,GAAG,uBAAuB,CAIpF;AAED;;GAEG;AACH,qBAAa,aAAa;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,MAAM,EAAE,uBAAuB,CAAC;IACzC,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;gBAEpB,OAAO,EAAE;QAAE,EAAE,EAAE,MAAM,CA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CAOrB,CAAC;AAWX,mEAAmE;AACnE,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAOtD,CAAC;AAEF,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,MAAM,GACb,uBAAuB,CAIzB;AAED;;GAEG;AACH,qBAAa,aAAa;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,MAAM,EAAE,uBAAuB,CAAC;IACzC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;gBAEhB,OAAO,EAAE;QACnB,EAAE,EAAE,MAAM,CAAC;QACX,MAAM,EAAE,uBAAuB,CAAC;QAChC,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB;IAMD,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,aAAa;CAW5D"}
@@ -1,42 +1,33 @@
1
- export const PaymentType = {
2
- manual: 'manual',
3
- auto: 'auto',
4
- };
5
- export function paymentTypeFromString(type) {
6
- if (type === PaymentType.manual || type === PaymentType.auto)
7
- return type;
8
- throw new Error('This payment method is not supported');
9
- }
10
1
  export const PaymentMethodTypes = {
11
- masrivi: 'masrivi',
12
- bankily: 'bankily',
13
- sedad: 'sedad',
14
- bimBank: 'bim_bank',
15
- amanty: 'amanty',
16
- bCIpay: 'bci_pay',
2
+ masrivi: "masrivi",
3
+ bankily: "bankily",
4
+ sedad: "sedad",
5
+ bimBank: "bim_bank",
6
+ amanty: "amanty",
7
+ bCIpay: "bci_pay",
17
8
  };
18
9
  const METHOD_TO_STR = {
19
- [PaymentMethodTypes.masrivi]: 'masrivi',
20
- [PaymentMethodTypes.bankily]: 'bankily',
21
- [PaymentMethodTypes.sedad]: 'sedad',
22
- [PaymentMethodTypes.bimBank]: 'bim_bank',
23
- [PaymentMethodTypes.amanty]: 'amanty',
24
- [PaymentMethodTypes.bCIpay]: 'bci_pay',
10
+ [PaymentMethodTypes.masrivi]: "masrivi",
11
+ [PaymentMethodTypes.bankily]: "bankily",
12
+ [PaymentMethodTypes.sedad]: "sedad",
13
+ [PaymentMethodTypes.bimBank]: "bim_bank",
14
+ [PaymentMethodTypes.amanty]: "amanty",
15
+ [PaymentMethodTypes.bCIpay]: "bci_pay",
25
16
  };
26
17
  /** Human-readable titles for payment methods (no i18n in core). */
27
18
  export const PaymentMethodTitles = {
28
- masrivi: 'Masrivi',
29
- bankily: 'Bankily',
30
- sedad: 'Sedad',
31
- bim_bank: 'Bim Bank',
32
- amanty: 'Amanty',
33
- bci_pay: 'BCIpay',
19
+ masrivi: "Masrivi",
20
+ bankily: "Bankily",
21
+ sedad: "Sedad",
22
+ bim_bank: "Bim Bank",
23
+ amanty: "Amanty",
24
+ bci_pay: "BCIpay",
34
25
  };
35
26
  export function paymentMethodTypesFromString(method) {
36
27
  const entry = Object.entries(METHOD_TO_STR).find(([, v]) => v === method);
37
28
  if (entry)
38
29
  return entry[1];
39
- throw new Error('This payment method is not supported');
30
+ throw new Error("This payment method is not supported");
40
31
  }
41
32
  /**
42
33
  * Base payment method (id, method type, payment type).
@@ -44,68 +35,20 @@ export function paymentMethodTypesFromString(method) {
44
35
  export class PaymentMethod {
45
36
  id;
46
37
  method;
47
- type;
38
+ bPayNumber;
48
39
  constructor(options) {
49
40
  this.id = options.id;
50
41
  this.method = options.method;
51
- this.type = options.type;
42
+ this.bPayNumber = options.bPayNumber ?? "";
52
43
  }
53
44
  static fromMap(map) {
45
+ const config = map.config && typeof map.config === "object"
46
+ ? map.config
47
+ : {};
54
48
  return new PaymentMethod({
55
49
  id: String(map.id),
56
50
  method: paymentMethodTypesFromString(String(map.type)),
57
- type: paymentTypeFromString(String(map.configurationType)),
58
- });
59
- }
60
- static fromPaymentMethod(map) {
61
- paymentMethodTypesFromString(String(map.type));
62
- return BankilyConfigModel.fromMap(map);
63
- }
64
- static fromPaymentType(map) {
65
- const configType = paymentTypeFromString(String(map.configurationType));
66
- if (configType === PaymentType.auto) {
67
- return PaymentMethod.fromPaymentMethod(map);
68
- }
69
- return ManualConfigModel.fromMap(map);
70
- }
71
- }
72
- /**
73
- * Bankily payment method config (adds bPayNumber).
74
- */
75
- export class BankilyConfigModel extends PaymentMethod {
76
- bPayNumber;
77
- constructor(options) {
78
- super(options);
79
- this.bPayNumber = options.bPayNumber;
80
- }
81
- static fromMap(map) {
82
- const base = PaymentMethod.fromMap(map);
83
- const config = map.config && typeof map.config === 'object' ? map.config : {};
84
- return new BankilyConfigModel({
85
- id: base.id,
86
- method: base.method,
87
- type: base.type,
88
- bPayNumber: String(config.code ?? ''),
89
- });
90
- }
91
- }
92
- /**
93
- * Manual payment method config (adds merchantCode).
94
- */
95
- export class ManualConfigModel extends PaymentMethod {
96
- merchantCode;
97
- constructor(options) {
98
- super(options);
99
- this.merchantCode = options.merchantCode;
100
- }
101
- static fromMap(map) {
102
- const base = PaymentMethod.fromMap(map);
103
- const config = map.config && typeof map.config === 'object' ? map.config : {};
104
- return new ManualConfigModel({
105
- id: base.id,
106
- method: base.method,
107
- type: base.type,
108
- merchantCode: String(config.code ?? ''),
51
+ bPayNumber: String(config.code ?? ""),
109
52
  });
110
53
  }
111
54
  }
@@ -1 +1 @@
1
- {"version":3,"file":"payment-method-model.js","sourceRoot":"","sources":["../../../src/models/payment-method-model.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;CACJ,CAAC;AAEX,MAAM,UAAU,qBAAqB,CAAC,IAAY;IAChD,IAAI,IAAI,KAAK,WAAW,CAAC,MAAM,IAAI,IAAI,KAAK,WAAW,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IAC1E,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;AAC1D,CAAC;AAUD,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE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AkC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3G,OAAO,IAAI,kBAAkB,CAAC;YAC5B,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;SACtC,CAAC,CAAC;IACL,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,aAAa;IACzC,YAAY,CAAS;IAE9B,YAAY,OAKX;QACC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;IAC3C,CAAC;IAED,MAAM,CAAU,OAAO,CAAC,GAA4B;QAClD,MAAM,IAAI,GAAG,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACxC,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,IAAI,OAAO,GAAG,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAE,GAAG,CAAC,MAAkC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3G,OAAO,IAAI,iBAAiB,CAAC;YAC3B,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;SACxC,CAAC,CAAC;IACL,CAAC;CACF"}
1
+ {"version":3,"file":"payment-method-model.js","sourceRoot":"","sources":["../../../src/models/payment-method-model.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,UAAU;IACnB,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,SAAS;CACT,CAA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V,GAAG,CAAC,MAAM,IAAI,OAAO,GAAG,CAAC,MAAM,KAAK,QAAQ;YAC1C,CAAC,CAAE,GAAG,CAAC,MAAkC;YACzC,CAAC,CAAC,EAAE,CAAC;QACT,OAAO,IAAI,aAAa,CAAC;YACvB,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;YAClB,MAAM,EAAE,4BAA4B,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACtD,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;SACtC,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -1,7 +1,6 @@
1
- import type { PaymentMethod } from './models/payment-method-model.js';
2
- import type { PaymentRequestModel } from './models/payment-request-model.js';
3
- import type { FetcherResponse } from './helpers/fetcher.js';
4
- import type { ManualPayImageInput } from './services/pay-service.js';
1
+ import type { PaymentMethod } from "./models/payment-method-model.js";
2
+ import type { PaymentRequestModel } from "./models/payment-request-model.js";
3
+ import type { FetcherResponse } from "./helpers/fetcher.js";
5
4
  /**
6
5
  * Main Moosyl SDK client. Create an instance with your publishable API key,
7
6
  * then use the methods to fetch payment methods, payment requests, and process payments.
@@ -27,7 +26,7 @@ export declare class Moosyl {
27
26
  */
28
27
  getPaymentRequest(transactionId: string): Promise<PaymentRequestModel>;
29
28
  /**
30
- * Processes an automatic payment (e.g. Bankily).
29
+ * Processes a payment (e.g. Bankily).
31
30
  * @param transactionId - Transaction ID
32
31
  * @param phoneNumber - Customer phone number
33
32
  * @param passCode - Customer passcode
@@ -35,13 +34,5 @@ export declare class Moosyl {
35
34
  * @returns API response
36
35
  */
37
36
  pay(transactionId: string, phoneNumber: string, passCode: string, paymentMethodId: string): Promise<FetcherResponse>;
38
- /**
39
- * Processes a manual payment with a screenshot.
40
- * @param transactionId - Transaction ID
41
- * @param paymentMethodId - Configuration ID from getPaymentMethods()
42
- * @param selectedImage - File (browser) or { name, data, type? } (Node)
43
- * @returns API response
44
- */
45
- manualPay(transactionId: string, paymentMethodId: string, selectedImage: ManualPayImageInput): Promise<FetcherResponse>;
46
37
  }
47
38
  //# sourceMappingURL=moosyl.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"moosyl.d.ts","sourceRoot":"","sources":["../../src/moosyl.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE;;;GAGG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAA2B;IACpE,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAA2B;IACpE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IAExC;;OAEG;gBACS,MAAM,EAAE,MAAM;IAM1B;;;;OAIG;IACH,iBAAiB,CAAC,aAAa,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAInE;;;;OAIG;IACH,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAItE;;;;;;;OAOG;IACH,GAAG,CACD,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,eAAe,CAAC;IAI3B;;;;;;OAMG;IACH,SAAS,CACP,aAAa,EAAE,MAAM,EACrB,eAAe,EAAE,MAAM,EACvB,aAAa,EAAE,mBAAmB,GACjC,OAAO,CAAC,eAAe,CAAC;CAG5B"}
1
+ {"version":3,"file":"moosyl.d.ts","sourceRoot":"","sources":["../../src/moosyl.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D;;;GAGG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAA2B;IACpE,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAA2B;IACpE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IAExC;;OAEG;gBACS,MAAM,EAAE,MAAM;IAM1B;;;;OAIG;IACH,iBAAiB,CAAC,aAAa,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAInE;;;;OAIG;IACH,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAItE;;;;;;;OAOG;IACH,GAAG,CACD,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,eAAe,CAAC;CAQ5B"}
@@ -1,6 +1,6 @@
1
- import { GetPaymentMethodsService } from './services/get-payment-methods-service.js';
2
- import { GetPaymentRequestService } from './services/get-payment-request-service.js';
3
- import { PayService } from './services/pay-service.js';
1
+ import { GetPaymentMethodsService } from "./services/get-payment-methods-service.js";
2
+ import { GetPaymentRequestService } from "./services/get-payment-request-service.js";
3
+ import { PayService } from "./services/pay-service.js";
4
4
  /**
5
5
  * Main Moosyl SDK client. Create an instance with your publishable API key,
6
6
  * then use the methods to fetch payment methods, payment requests, and process payments.
@@ -34,7 +34,7 @@ export class Moosyl {
34
34
  return this.getPaymentRequestService.get(transactionId);
35
35
  }
36
36
  /**
37
- * Processes an automatic payment (e.g. Bankily).
37
+ * Processes a payment (e.g. Bankily).
38
38
  * @param transactionId - Transaction ID
39
39
  * @param phoneNumber - Customer phone number
40
40
  * @param passCode - Customer passcode
@@ -44,15 +44,5 @@ export class Moosyl {
44
44
  pay(transactionId, phoneNumber, passCode, paymentMethodId) {
45
45
  return this.payService.pay(transactionId, phoneNumber, passCode, paymentMethodId);
46
46
  }
47
- /**
48
- * Processes a manual payment with a screenshot.
49
- * @param transactionId - Transaction ID
50
- * @param paymentMethodId - Configuration ID from getPaymentMethods()
51
- * @param selectedImage - File (browser) or { name, data, type? } (Node)
52
- * @returns API response
53
- */
54
- manualPay(transactionId, paymentMethodId, selectedImage) {
55
- return this.payService.manualPay(transactionId, paymentMethodId, selectedImage);
56
- }
57
47
  }
58
48
  //# sourceMappingURL=moosyl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"moosyl.js","sourceRoot":"","sources":["../../src/moosyl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;AACrF,OAAO,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;AACrF,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAMvD;;;GAGG;AACH,MAAM,OAAO,MAAM;IACA,wBAAwB,CAA2B;IACnD,wBAAwB,CAA2B;IACnD,UAAU,CAAa;IAExC;;OAEG;IACH,YAAY,MAAc;QACxB,IAAI,CAAC,wBAAwB,GAAG,IAAI,wBAAwB,CAAC,MAAM,CAAC,CAAC;QACrE,IAAI,CAAC,wBAAwB,GAAG,IAAI,wBAAwB,CAAC,MAAM,CAAC,CAAC;QACrE,IAAI,CAAC,UAAU,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;IAED;;;;OAIG;IACH,iBAAiB,CAAC,aAAsB;QACtC,OAAO,IAAI,CAAC,wBAAwB,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAC1D,CAAC;IAED;;;;OAIG;IACH,iBAAiB,CAAC,aAAqB;QACrC,OAAO,IAAI,CAAC,wBAAwB,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAC1D,CAAC;IAED;;;;;;;OAOG;IACH,GAAG,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,EAChB,eAAuB;QAEvB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CACxB,aAAa,EACb,WAAW,EACX,QAAQ,EACR,eAAe,CAChB,CAAC;IACJ,CAAC;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-payment-methods-service.d.ts","sourceRoot":"","sources":["../../../src/services/get-payment-methods-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAElE;;GAEG;AACH,qBAAa,wBAAwB;aACP,iBAAiB,EAAE,MAAM;gBAAzB,iBAAiB,EAAE,MAAM;IAE/C,GAAG,CAAC,aAAa,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;CAU5D"}
1
+ {"version":3,"file":"get-payment-methods-service.d.ts","sourceRoot":"","sources":["../../../src/services/get-payment-methods-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAElE;;GAEG;AACH,qBAAa,wBAAwB;aACP,iBAAiB,EAAE,MAAM;gBAAzB,iBAAiB,EAAE,MAAM;IAE/C,GAAG,CAAC,aAAa,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;CAQ5D"}
@@ -12,7 +12,7 @@ export class GetPaymentMethodsService {
12
12
  const result = await new Fetcher(this.publishableApiKey).get(Endpoints.paymentMethods(isTestingMode));
13
13
  const data = result.data;
14
14
  const list = Array.isArray(data?.data) ? data.data : [];
15
- return list.map((e) => PaymentMethod.fromPaymentType(e));
15
+ return list.map((e) => PaymentMethod.fromMap(e));
16
16
  }
17
17
  }
18
18
  //# sourceMappingURL=get-payment-methods-service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-payment-methods-service.js","sourceRoot":"","sources":["../../../src/services/get-payment-methods-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAElE;;GAEG;AACH,MAAM,OAAO,wBAAwB;IACP;IAA5B,YAA4B,iBAAyB;QAAzB,sBAAiB,GAAjB,iBAAiB,CAAQ;IAAG,CAAC;IAEzD,KAAK,CAAC,GAAG,CAAC,aAAsB;QAC9B,MAAM,MAAM,GAAG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAC1D,SAAS,CAAC,cAAc,CAAC,aAAa,CAAC,CACxC,CAAC;QACF,MAAM,IAAI,GAAG,MAAM,CAAC,IAAwC,CAAC;QAC7D,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QACzD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACpB,aAAa,CAAC,eAAe,CAAC,CAA4B,CAAC,CAC5D,CAAC;IACJ,CAAC;CACF"}
1
+ {"version":3,"file":"get-payment-methods-service.js","sourceRoot":"","sources":["../../../src/services/get-payment-methods-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAElE;;GAEG;AACH,MAAM,OAAO,wBAAwB;IACP;IAA5B,YAA4B,iBAAyB;QAAzB,sBAAiB,GAAjB,iBAAiB,CAAQ;IAAG,CAAC;IAEzD,KAAK,CAAC,GAAG,CAAC,aAAsB;QAC9B,MAAM,MAAM,GAAG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAC1D,SAAS,CAAC,cAAc,CAAC,aAAa,CAAC,CACxC,CAAC;QACF,MAAM,IAAI,GAAG,MAAM,CAAC,IAAwC,CAAC;QAC7D,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QACzD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,CAA4B,CAAC,CAAC,CAAC;IAC9E,CAAC;CACF"}
@@ -1,16 +1,10 @@
1
- import { FetcherResponse } from '../helpers/fetcher.js';
2
- export type ManualPayImageInput = File | {
3
- name: string;
4
- data: Buffer | Uint8Array | ArrayBuffer;
5
- type?: string;
6
- };
1
+ import { FetcherResponse } from "../helpers/fetcher.js";
7
2
  /**
8
- * Service for processing payments (auto and manual) via the Moosyl API.
3
+ * Service for processing payments via the Moosyl API.
9
4
  */
10
5
  export declare class PayService {
11
6
  readonly publishableApiKey: string;
12
7
  constructor(publishableApiKey: string);
13
8
  pay(transactionId: string, phoneNumber: string, passCode: string, paymentMethodId: string): Promise<FetcherResponse>;
14
- manualPay(transactionId: string, paymentMethodId: string, selectedImage: ManualPayImageInput): Promise<FetcherResponse>;
15
9
  }
16
10
  //# sourceMappingURL=pay-service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pay-service.d.ts","sourceRoot":"","sources":["../../../src/services/pay-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE5E,MAAM,MAAM,mBAAmB,GAC3B,IAAI,GACJ;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7E;;GAEG;AACH,qBAAa,UAAU;aACO,iBAAiB,EAAE,MAAM;gBAAzB,iBAAiB,EAAE,MAAM;IAE/C,GAAG,CACP,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,eAAe,CAAC;IAUrB,SAAS,CACb,aAAa,EAAE,MAAM,EACrB,eAAe,EAAE,MAAM,EACvB,aAAa,EAAE,mBAAmB,GACjC,OAAO,CAAC,eAAe,CAAC;CAS5B"}
1
+ {"version":3,"file":"pay-service.d.ts","sourceRoot":"","sources":["../../../src/services/pay-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE5E;;GAEG;AACH,qBAAa,UAAU;aACO,iBAAiB,EAAE,MAAM;gBAAzB,iBAAiB,EAAE,MAAM;IAE/C,GAAG,CACP,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,eAAe,CAAC;CAY5B"}
@@ -1,6 +1,6 @@
1
- import { Fetcher, Endpoints } from '../helpers/fetcher.js';
1
+ import { Fetcher, Endpoints } from "../helpers/fetcher.js";
2
2
  /**
3
- * Service for processing payments (auto and manual) via the Moosyl API.
3
+ * Service for processing payments via the Moosyl API.
4
4
  */
5
5
  export class PayService {
6
6
  publishableApiKey;
@@ -16,46 +16,5 @@ export class PayService {
16
16
  });
17
17
  return response;
18
18
  }
19
- async manualPay(transactionId, paymentMethodId, selectedImage) {
20
- const attachment = await toAttachment(selectedImage);
21
- const response = await new Fetcher(this.publishableApiKey).post(Endpoints.manualPayment, {
22
- transactionId,
23
- configurationId: paymentMethodId,
24
- attachments: [attachment],
25
- });
26
- return response;
27
- }
28
- }
29
- async function toAttachment(input) {
30
- if (input instanceof File) {
31
- const buffer = await input.arrayBuffer();
32
- const base64 = bufferToBase64(buffer);
33
- return {
34
- name: input.name,
35
- type: input.type || 'application/octet-stream',
36
- size: input.size,
37
- data: base64,
38
- };
39
- }
40
- const { name, data, type = 'application/octet-stream' } = input;
41
- const buf = data instanceof Buffer ? data : new Uint8Array(data);
42
- const size = buf.byteLength ?? buf.length;
43
- return {
44
- name,
45
- type,
46
- size,
47
- data: bufferToBase64(buf),
48
- };
49
- }
50
- function bufferToBase64(buf) {
51
- if (typeof Buffer !== 'undefined') {
52
- return (Buffer.isBuffer(buf) ? buf : Buffer.from(buf)).toString('base64');
53
- }
54
- const bytes = buf instanceof Uint8Array ? buf : new Uint8Array(buf);
55
- let binary = '';
56
- for (let i = 0; i < bytes.length; i++) {
57
- binary += String.fromCharCode(bytes[i]);
58
- }
59
- return btoa(binary);
60
19
  }
61
20
  //# sourceMappingURL=pay-service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pay-service.js","sourceRoot":"","sources":["../../../src/services/pay-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAmB,MAAM,uBAAuB,CAAC;AAM5E;;GAEG;AACH,MAAM,OAAO,UAAU;IACO;IAA5B,YAA4B,iBAAyB;QAAzB,sBAAiB,GAAjB,iBAAiB,CAAQ;IAAG,CAAC;IAEzD,KAAK,CAAC,GAAG,CACP,aAAqB,EACrB,WAAmB,EACnB,QAAgB,EAChB,eAAuB;QAEvB,MAAM,QAAQ,GAAG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE;YAC7E,aAAa;YACb,WAAW;YACX,QAAQ;YACR,eAAe,EAAE,eAAe;SACjC,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,SAAS,CACb,aAAqB,EACrB,eAAuB,EACvB,aAAkC;QAElC,MAAM,UAAU,GAAG,MAAM,YAAY,CAAC,aAAa,CAAC,CAAC;QACrD,MAAM,QAAQ,GAAG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE;YACvF,aAAa;YACb,eAAe,EAAE,eAAe;YAChC,WAAW,EAAE,CAAC,UAAU,CAAC;SAC1B,CAAC,CAA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,CAAC;IAChB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC;AACtB,CAAC"}
1
+ {"version":3,"file":"pay-service.js","sourceRoot":"","sources":["../../../src/services/pay-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAmB,MAAM,uBAAuB,CAAC;AAE5E;;GAEG;AACH,MAAM,OAAO,UAAU;IACO;IAA5B,YAA4B,iBAAyB;QAAzB,sBAAiB,GAAjB,iBAAiB,CAAQ;IAAG,CAAC;IAEzD,KAAK,CAAC,GAAG,CACP,aAAqB,EACrB,WAAmB,EACnB,QAAgB,EAChB,eAAuB;QAEvB,MAAM,QAAQ,GAAG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAC7D,SAAS,CAAC,GAAG,EACb;YACE,aAAa;YACb,WAAW;YACX,QAAQ;YACR,eAAe,EAAE,eAAe;SACjC,CACF,CAAC;QACF,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "moosyl",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "integrating payment solutions with Mauritania's popular banking apps",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",