telebirr-nodejs 1.0.5 → 1.0.6

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 (2) hide show
  1. package/README.md +60 -29
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -10,11 +10,15 @@ A simple, opinionated Node.js SDK for integrating **Telebirr C2B payments** with
10
10
  npm install telebirr-nodejs
11
11
  ```
12
12
 
13
+ ---
14
+
13
15
  ## Required Configuration
14
16
 
15
17
  Telebirr requires credentials and callback URLs.
16
18
  You should never hard-code secrets. Always load them from process.env.
17
19
 
20
+ ---
21
+
18
22
  ### Required Credentials
19
23
 
20
24
  | Name | Description |
@@ -25,6 +29,8 @@ You should never hard-code secrets. Always load them from process.env.
25
29
  | `MERCHANT_CODE` | Merchant code |
26
30
  | `MERCHANT_PRIVATE_KEY` | RSA private key (PEM string) |
27
31
 
32
+ ---
33
+
28
34
  ### Required URLs
29
35
 
30
36
  | Name | Description |
@@ -32,6 +38,8 @@ You should never hard-code secrets. Always load them from process.env.
32
38
  | `TELEBIRR_NOTIFY_URL` | Server-to-server callback URL |
33
39
  | `TELEBIRR_REDIRECT_URL` | User redirect URL after payment |
34
40
 
41
+ ---
42
+
35
43
  ### Basic Setup
36
44
 
37
45
  ```bash
@@ -51,6 +59,8 @@ const client = new TelebirrClient({
51
59
  });
52
60
  ```
53
61
 
62
+ ---
63
+
54
64
  ### Important
55
65
 
56
66
  MERCHANT_PRIVATE_KEY must be the full PEM string, including:
@@ -61,13 +71,17 @@ MERCHANT_PRIVATE_KEY must be the full PEM string, including:
61
71
  -----END RSA PRIVATE KEY-----
62
72
  ```
63
73
 
74
+ ---
75
+
64
76
  ### Example API Routes
65
77
 
66
78
  Below is a complete demo using three routes:
67
79
 
68
- POST /payment/initiate
69
- GET /payment/status/:merchOrderId
70
- POST /payment/refund
80
+ 1. POST /payment/initiate
81
+ 2. GET /payment/status/:merchOrderId
82
+ 3. POST /payment/refund
83
+
84
+ ---
71
85
 
72
86
  ### 1 Initiate Payment
73
87
 
@@ -76,11 +90,11 @@ Creates an order and redirects the user to the Telebirr checkout page.
76
90
  ```bash
77
91
  app.post("/payment/initiate", async (req, res) => {
78
92
  const checkoutUrl = await client.preOrder({
79
- merchOrderId: "order123",
80
- title: "Phone",
81
- amount: "12",
82
- callbackInfo: "from web checkout",
83
- });
93
+ merchOrderId: "order123",
94
+ title: "Phone",
95
+ amount: "12",
96
+ callbackInfo: "from web checkout",
97
+ });
84
98
 
85
99
  res.redirect(checkoutUrl);
86
100
  });
@@ -88,6 +102,8 @@ app.post("/payment/initiate", async (req, res) => {
88
102
 
89
103
  If you are using a frontend framework (for example React) and do not want to lose application state, return the checkout URL as JSON and let the frontend handle the redirection.
90
104
 
105
+ ---
106
+
91
107
  ### 2 Query Payment Status
92
108
 
93
109
  Used to check the payment result using the merchant order ID.
@@ -102,6 +118,11 @@ app.get("/payment/status/:merchOrderId", async (req, res) => {
102
118
  });
103
119
  ```
104
120
 
121
+ Please refer to Telebirr’s official documentation to correctly handle the query order json response:
122
+ https://developer.ethiotelecom.et/docs/H5%20C2B%20Web%20Payment%20Integration%20Quick%20Guide/queryOrder
123
+
124
+ ---
125
+
105
126
  ### 3 Refund Payment
106
127
 
107
128
  Refunds a completed transaction.
@@ -117,10 +138,14 @@ app.post("/payment/refund", async (req, res) => {
117
138
  });
118
139
 
119
140
  res.json(refundData);
120
- });
141
+ });
142
+
121
143
  ```
122
144
 
123
- Refund amount must not exceed the original payment amount
145
+ Please refer to Telebirr’s official documentation to correctly handle the refund order json response:
146
+ https://developer.ethiotelecom.et/docs/H5%20C2B%20Web%20Payment%20Integration%20Quick%20Guide/RefundOrder
147
+
148
+ ---
124
149
 
125
150
  ### Simulator Mode
126
151
 
@@ -130,31 +155,36 @@ To use the simulator provided by this package, set the mode to simulate.
130
155
  import { TelebirrClient } from "telebirr-nodejs";
131
156
 
132
157
  const client = new TelebirrClient({
133
- mode: "simulate",
134
- notifyUrl: "https://example.com/notify",
135
- redirectUrl: "https://example.com/redirect",
136
- http: true,
137
- IntegrationOption: "C2B",
138
- });
158
+ mode: "simulate",
159
+ notifyUrl: "https://example.com/notify",
160
+ redirectUrl: "https://example.com/redirect",
161
+ http: true,
162
+ IntegrationOption: "C2B",
163
+ });
164
+
139
165
  ```
140
166
 
141
167
  This simulator is for learning and development purposes only.
142
168
  The simulation server is provided by this package, not by Telebirr. For real testing, use Telebirr’s sandbox mode and whitelist your public IP address in the Telebirr portal.
143
169
 
170
+ ---
171
+
144
172
  ### Supported Features
145
173
 
146
- Fabric token handling
147
- RSA-SHA256 request signing
148
- C2B checkout
149
- Order query
150
- Refunds
151
- Simulator support
152
- Notify URL Handling
174
+ - Fabric token handling
175
+ - RSA-SHA256 request signing
176
+ - C2B checkout
177
+ - Order query
178
+ - Refunds
179
+ - Simulator support
180
+ - Notify URL Handling
153
181
 
154
182
  Please refer to Telebirr’s official documentation to correctly handle notify callbacks:
155
183
 
156
184
  https://developer.ethiotelecom.et/docs/H5%20C2B%20Web%20Payment%20Integration%20Quick%20Guide/Notify_Callback
157
185
 
186
+ ---
187
+
158
188
  ### RSA Key Generation
159
189
 
160
190
  You can generate private and public keys instantly.
@@ -162,12 +192,13 @@ You can generate private and public keys instantly.
162
192
  ```bash
163
193
  import { generateKeys } from "telebirr-nodejs";
164
194
 
165
- generateKeys({
166
- dir: process.cwd(),
167
- privateKeyName: "telefy_private.pem",
168
- publicKeyName: "telefy_public.pem",
169
- overwrite: false,
170
- });
195
+ generateKeys({
196
+ dir: process.cwd(),
197
+ privateKeyName: "telefy_private.pem",
198
+ publicKeyName: "telefy_public.pem",
199
+ overwrite: false,
200
+ });
201
+
171
202
  ```
172
203
 
173
204
  This will generate two .pem files in your root directory.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "telebirr-nodejs",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "Unofficial Telebirr Node.js SDK.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",