vxgate 2.0.1 → 2.0.3
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 +12 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,9 +18,9 @@ npm install vxgate
|
|
|
18
18
|
## Quick Start
|
|
19
19
|
|
|
20
20
|
```js
|
|
21
|
-
import {
|
|
21
|
+
import { VXGatePayment } from 'vxgate';
|
|
22
22
|
|
|
23
|
-
const pay = new
|
|
23
|
+
const pay = new VXGatePayment('vlt_YOUR_API_KEY');
|
|
24
24
|
|
|
25
25
|
// Buat order + poll sampai lunas
|
|
26
26
|
const { payment, result } = await pay.createAndWait({
|
|
@@ -38,7 +38,7 @@ if (result.paid) {
|
|
|
38
38
|
|
|
39
39
|
## API
|
|
40
40
|
|
|
41
|
-
### `new
|
|
41
|
+
### `new VXGatePayment(apiKey, [baseUrl])`
|
|
42
42
|
|
|
43
43
|
| Param | Type | Description |
|
|
44
44
|
|-------|------|-------------|
|
|
@@ -147,15 +147,15 @@ const { webhookSecret } = await pay.setWebhook('https://yourapp.com/webhook');
|
|
|
147
147
|
// Simpan webhookSecret untuk verifikasi signature
|
|
148
148
|
```
|
|
149
149
|
|
|
150
|
-
### `
|
|
150
|
+
### `VXGatePayment.verifyWebhook(rawBody, signature, secret)` → `boolean`
|
|
151
151
|
|
|
152
152
|
Verifikasi HMAC-SHA256 webhook signature (Node.js).
|
|
153
153
|
|
|
154
154
|
```js
|
|
155
155
|
// Express handler
|
|
156
156
|
app.post('/webhook', express.raw({ type: '*/*' }), (req, res) => {
|
|
157
|
-
const sig = req.headers['x-
|
|
158
|
-
if (!
|
|
157
|
+
const sig = req.headers['x-vxgate-signature'];
|
|
158
|
+
if (!VXGatePayment.verifyWebhook(req.body, sig, process.env.WEBHOOK_SECRET))
|
|
159
159
|
return res.sendStatus(401);
|
|
160
160
|
|
|
161
161
|
const event = JSON.parse(req.body);
|
|
@@ -166,21 +166,21 @@ app.post('/webhook', express.raw({ type: '*/*' }), (req, res) => {
|
|
|
166
166
|
});
|
|
167
167
|
```
|
|
168
168
|
|
|
169
|
-
### `
|
|
169
|
+
### `VXGatePayment.verifyWebhookAsync(rawBody, signature, secret)` → `Promise<boolean>`
|
|
170
170
|
|
|
171
171
|
Verifikasi webhook (browser-compatible, Web Crypto API).
|
|
172
172
|
|
|
173
173
|
## Error Handling
|
|
174
174
|
|
|
175
175
|
```js
|
|
176
|
-
import {
|
|
176
|
+
import { VXGatePayment, VXGateError, VXGateTimeoutError } from 'vxgate';
|
|
177
177
|
|
|
178
178
|
try {
|
|
179
179
|
const result = await pay.poll('ORDER-001', { timeoutMs: 60_000 });
|
|
180
180
|
} catch (err) {
|
|
181
|
-
if (err instanceof
|
|
181
|
+
if (err instanceof VXGateTimeoutError) {
|
|
182
182
|
console.log('Payment belum masuk setelah 60 detik');
|
|
183
|
-
} else if (err instanceof
|
|
183
|
+
} else if (err instanceof VXGateError) {
|
|
184
184
|
console.log(`API Error ${err.statusCode}: ${err.message}`);
|
|
185
185
|
}
|
|
186
186
|
}
|
|
@@ -192,10 +192,10 @@ Package support keduanya:
|
|
|
192
192
|
|
|
193
193
|
```js
|
|
194
194
|
// ESM
|
|
195
|
-
import {
|
|
195
|
+
import { VXGatePayment } from 'vxgate';
|
|
196
196
|
|
|
197
197
|
// CJS
|
|
198
|
-
const {
|
|
198
|
+
const { VXGatePayment } = require('vxgate');
|
|
199
199
|
```
|
|
200
200
|
|
|
201
201
|
## Links
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vxgate",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "Violetics Payment Gateway SDK — QRIS payment via Orderkuota API",
|
|
5
5
|
"keywords": ["qris", "payment", "orderkuota", "violetics", "indonesia", "payment-gateway"],
|
|
6
6
|
"author": "Violetics",
|