@tatogi/bog-payment-js 1.0.0 → 1.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.
Files changed (2) hide show
  1. package/README.md +69 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -77,6 +77,75 @@ console.log(order._links.redirect.href);
77
77
  npm test
78
78
  ```
79
79
 
80
+ ## Manual Testing Without BOG Keys
81
+
82
+ If you do not have real BOG credentials yet, you can test integration flow with a local mock server.
83
+
84
+ 1. Create `mock-server.mjs`:
85
+
86
+ ```js
87
+ import http from "node:http";
88
+
89
+ const server = http.createServer((req, res) => {
90
+ res.setHeader("Content-Type", "application/json");
91
+
92
+ if (req.method === "POST" && req.url === "/oauth/token") {
93
+ return res.end(
94
+ JSON.stringify({
95
+ access_token: "mock_access_token",
96
+ token_type: "Bearer",
97
+ expires_in: 3600
98
+ })
99
+ );
100
+ }
101
+
102
+ if (req.method === "POST" && req.url === "/opay/api/v1/checkout/orders") {
103
+ return res.end(
104
+ JSON.stringify({
105
+ id: "mock_order_123",
106
+ status: "created",
107
+ _links: { redirect: { href: "https://example.test/mock-checkout" } }
108
+ })
109
+ );
110
+ }
111
+
112
+ if (req.method === "GET" && req.url.startsWith("/opay/api/v1/checkout/payment/")) {
113
+ const orderId = req.url.split("/").pop();
114
+ return res.end(JSON.stringify({ id: orderId, status: "completed", amount: 100, currency: "GEL" }));
115
+ }
116
+
117
+ res.statusCode = 404;
118
+ res.end(JSON.stringify({ message: "Not found" }));
119
+ });
120
+
121
+ server.listen(8787, () => {
122
+ console.log("Mock BOG server is running on http://127.0.0.1:8787");
123
+ });
124
+ ```
125
+
126
+ 2. Run the mock server:
127
+
128
+ ```bash
129
+ node mock-server.mjs
130
+ ```
131
+
132
+ 3. Point client to mock endpoints:
133
+
134
+ ```js
135
+ import { BogPaymentClient } from "@tatogi/bog-payment-js";
136
+
137
+ const bog = new BogPaymentClient({
138
+ clientId: "mock_client",
139
+ clientSecret: "mock_secret",
140
+ authUrl: "http://127.0.0.1:8787/oauth/token",
141
+ baseUrl: "http://127.0.0.1:8787/opay/api/v1"
142
+ });
143
+ ```
144
+
145
+ 4. Test full flow manually:
146
+ - call `createOrder(...)` and verify `redirect` link
147
+ - call `getOrderDetails("mock_order_123")` and verify `status: completed`
148
+
80
149
  ## Publish
81
150
 
82
151
  ```bash
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tatogi/bog-payment-js",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "JavaScript client for Bank of Georgia iPay API",
5
5
  "private": false,
6
6
  "type": "module",