moosyl 0.0.1 → 0.0.2
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 +49 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](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
|
|
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.
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -10,6 +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
14
|
- **Lightweight**: No UI; use your own front end or backend flows.
|
|
14
15
|
- **ESM**: Native ES modules (`import`).
|
|
15
16
|
|
|
@@ -31,6 +32,7 @@ npm install moosyl
|
|
|
31
32
|
import {
|
|
32
33
|
GetPaymentMethodsService,
|
|
33
34
|
GetPaymentRequestService,
|
|
35
|
+
PayService,
|
|
34
36
|
PaymentRequestModel,
|
|
35
37
|
PaymentMethodTitles,
|
|
36
38
|
} from "moosyl";
|
|
@@ -87,6 +89,43 @@ curl -X POST https://api.moosyl.com/payment-request \
|
|
|
87
89
|
|
|
88
90
|
Once created, use the returned **transactionId** with `GetPaymentRequestService` and your payment flow.
|
|
89
91
|
|
|
92
|
+
### Process payment (auto)
|
|
93
|
+
|
|
94
|
+
For automatic payment methods (e.g. Bankily), send the transaction ID, customer phone number, passcode, and the selected payment method (configuration) ID:
|
|
95
|
+
|
|
96
|
+
```javascript
|
|
97
|
+
import { PayService } from "moosyl";
|
|
98
|
+
|
|
99
|
+
const pay = new PayService("YOUR_PUBLISHABLE_API_KEY");
|
|
100
|
+
|
|
101
|
+
await pay.pay(
|
|
102
|
+
"TRANSACTION_ID",
|
|
103
|
+
"+22212345678",
|
|
104
|
+
"PASSCODE",
|
|
105
|
+
"PAYMENT_METHOD_ID" // configuration ID from GetPaymentMethodsService
|
|
106
|
+
);
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Process manual payment
|
|
110
|
+
|
|
111
|
+
For manual payment methods, send the transaction ID, payment method ID, and a screenshot of the payment (File in the browser, or `{ name, data, type? }` in Node):
|
|
112
|
+
|
|
113
|
+
```javascript
|
|
114
|
+
import { PayService } from "moosyl";
|
|
115
|
+
|
|
116
|
+
const pay = new PayService("YOUR_PUBLISHABLE_API_KEY");
|
|
117
|
+
|
|
118
|
+
// Browser: pass a File from an input
|
|
119
|
+
await pay.manualPay("TRANSACTION_ID", "PAYMENT_METHOD_ID", fileInput.files[0]);
|
|
120
|
+
|
|
121
|
+
// Node: pass { name, data (Buffer), type? }
|
|
122
|
+
await pay.manualPay("TRANSACTION_ID", "PAYMENT_METHOD_ID", {
|
|
123
|
+
name: "proof.png",
|
|
124
|
+
data: imageBuffer,
|
|
125
|
+
type: "image/png",
|
|
126
|
+
});
|
|
127
|
+
```
|
|
128
|
+
|
|
90
129
|
---
|
|
91
130
|
|
|
92
131
|
## API overview
|
|
@@ -94,19 +133,20 @@ Once created, use the returned **transactionId** with `GetPaymentRequestService`
|
|
|
94
133
|
| Export | Description |
|
|
95
134
|
| ---------------------------------------------------------- | ------------------------------------------------------ |
|
|
96
135
|
| `GetPaymentMethodsService` | Fetches available payment methods. |
|
|
97
|
-
| `GetPaymentRequestService` | Fetches payment request by transaction ID.
|
|
98
|
-
| `
|
|
99
|
-
| `
|
|
100
|
-
| `
|
|
101
|
-
| `
|
|
102
|
-
| `
|
|
103
|
-
| `
|
|
136
|
+
| `GetPaymentRequestService` | Fetches payment request by transaction ID. |
|
|
137
|
+
| `PayService` | Processes payments: `pay()` (auto) and `manualPay()` (with screenshot). |
|
|
138
|
+
| `PaymentRequestModel` | Model for payment request (id, amount, phoneNumber). |
|
|
139
|
+
| `PaymentMethod`, `BankilyConfigModel`, `ManualConfigModel` | Payment method models. |
|
|
140
|
+
| `PaymentMethodTitles` | Display names for payment method types. |
|
|
141
|
+
| `PaymentType`, `PaymentMethodTypes` | Enums/constants for method and type. |
|
|
142
|
+
| `Fetcher`, `Endpoints` | Low-level HTTP client and API URLs (for advanced use). |
|
|
143
|
+
| `AppException` | Error type thrown on failed API calls. |
|
|
104
144
|
|
|
105
145
|
---
|
|
106
146
|
|
|
107
147
|
## Configuration
|
|
108
148
|
|
|
109
|
-
- **API key**: Use your **publishable** API key for `GetPaymentMethodsService` and `
|
|
149
|
+
- **API key**: Use your **publishable** API key for `GetPaymentMethodsService`, `GetPaymentRequestService`, and `PayService`. Get keys at [moosyl.com](https://moosyl.com).
|
|
110
150
|
- **Testing mode**: Pass `true` to `GetPaymentMethodsService#get(isTestingMode)` for test configuration.
|
|
111
151
|
|
|
112
152
|
---
|