vxgate 1.0.0 → 2.0.0
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 +33 -1
- package/package.json +1 -1
- package/src/index.js +11 -11
- package/src/index.mjs +2 -2
package/README.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
Violetics Payment Gateway SDK — terima pembayaran QRIS via Orderkuota dengan 3 baris kode.
|
|
4
4
|
|
|
5
|
+
## Get API Key
|
|
6
|
+
|
|
7
|
+
1. Daftar di **[pg.vltcx.eu.cc/register](https://pg.vltcx.eu.cc/register)**
|
|
8
|
+
2. Verifikasi akun kamu
|
|
9
|
+
3. Buka **Dashboard → API Keys** → Generate key baru
|
|
10
|
+
4. Copy key dengan format `vlt_xxx` — siap dipakai
|
|
11
|
+
|
|
5
12
|
## Install
|
|
6
13
|
|
|
7
14
|
```bash
|
|
@@ -82,15 +89,38 @@ const result = await pay.poll('ORDER-001', {
|
|
|
82
89
|
|
|
83
90
|
### `.createAndWait(paymentOpts, [pollOpts])` → `Promise<{payment, result}>`
|
|
84
91
|
|
|
85
|
-
Shortcut: buat + poll sekaligus.
|
|
92
|
+
Shortcut: buat + poll sekaligus. Return object `{ payment, result }` — `payment` berisi data QR dan `result` berisi status akhir.
|
|
86
93
|
|
|
87
94
|
```js
|
|
88
95
|
const { payment, result } = await pay.createAndWait(
|
|
89
96
|
{ amount: 15000, referenceId: 'ORDER-001' },
|
|
90
97
|
{ intervalMs: 3000, timeoutMs: 300_000 }
|
|
91
98
|
);
|
|
99
|
+
|
|
100
|
+
// Data QR & order ada di `payment`:
|
|
101
|
+
console.log(payment.qrisUrl); // URL gambar QR → tampilkan ke customer
|
|
102
|
+
console.log(payment.qrisString); // string QRIS raw (untuk generate QR sendiri)
|
|
103
|
+
console.log(payment.referenceId); // reference ID order
|
|
104
|
+
console.log(payment.amount); // nominal actual (bisa ada suffix unik)
|
|
105
|
+
|
|
106
|
+
// Status pembayaran ada di `result`:
|
|
107
|
+
console.log(result.paid); // true jika lunas
|
|
108
|
+
console.log(result.payerBrand); // 'GOPAY' | 'OVO' | 'DANA' | ...
|
|
92
109
|
```
|
|
93
110
|
|
|
111
|
+
> **Catatan:** `createAndWait` akan **menunggu** sampai pembayaran `paid` atau `expired`. QR sudah tersedia di `payment` segera setelah fungsi mulai polling — tapi kalau kamu perlu **menampilkan QR dulu** sebelum menunggu, gunakan `.create()` + `.poll()` secara terpisah:
|
|
112
|
+
>
|
|
113
|
+
> ```js
|
|
114
|
+
> // Pattern: tampilkan QR dulu, baru poll
|
|
115
|
+
> const payment = await pay.create({ amount: 15000 });
|
|
116
|
+
> tampilkanQR(payment.qrisUrl); // langsung tampilkan ke user
|
|
117
|
+
>
|
|
118
|
+
> const result = await pay.poll(payment.referenceId, {
|
|
119
|
+
> onPoll: (n, status) => console.log(`[#${n}] ${status}`),
|
|
120
|
+
> });
|
|
121
|
+
> if (result.paid) console.log('Lunas!');
|
|
122
|
+
> ```
|
|
123
|
+
|
|
94
124
|
### `.list([opts])` → `Promise<Transaction[]>`
|
|
95
125
|
|
|
96
126
|
Daftar transaksi.
|
|
@@ -170,5 +200,7 @@ const { VioleticsPayment } = require('vxgate');
|
|
|
170
200
|
|
|
171
201
|
## Links
|
|
172
202
|
|
|
203
|
+
- [Register](https://pg.vltcx.eu.cc/register) — daftar & dapatkan API key
|
|
173
204
|
- [Documentation](https://pg.vltcx.eu.cc/docs)
|
|
174
205
|
- [Dashboard](https://pg.vltcx.eu.cc/dashboard)
|
|
206
|
+
- [GitHub](https://github.com/cv3inx/VXGate)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vxgate",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
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",
|
package/src/index.js
CHANGED
|
@@ -42,7 +42,7 @@ const DEFAULT_BASE_URL = 'https://pg.vltcx.eu.cc/api';
|
|
|
42
42
|
* @property {function} [onPoll] (attempt: number, status: string) => void
|
|
43
43
|
*/
|
|
44
44
|
|
|
45
|
-
class
|
|
45
|
+
class VXGatePayment {
|
|
46
46
|
/**
|
|
47
47
|
* @param {string} apiKey - Violetics API Key (format: vlt_xxx)
|
|
48
48
|
* @param {string} [baseUrl]
|
|
@@ -60,7 +60,7 @@ class VioleticsPayment {
|
|
|
60
60
|
const res = await fetch(`${this._baseUrl}?${qs}`);
|
|
61
61
|
const data = await res.json();
|
|
62
62
|
if (!data.status && !data.success)
|
|
63
|
-
throw new
|
|
63
|
+
throw new VXGateError(data.message ?? `HTTP ${res.status}`, res.status, data);
|
|
64
64
|
return data;
|
|
65
65
|
}
|
|
66
66
|
|
|
@@ -72,7 +72,7 @@ class VioleticsPayment {
|
|
|
72
72
|
});
|
|
73
73
|
const data = await res.json();
|
|
74
74
|
if (!data.status && !data.success)
|
|
75
|
-
throw new
|
|
75
|
+
throw new VXGateError(data.message ?? `HTTP ${res.status}`, res.status, data);
|
|
76
76
|
return data;
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -148,7 +148,7 @@ class VioleticsPayment {
|
|
|
148
148
|
await new Promise(r => setTimeout(r, wait));
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
throw new
|
|
151
|
+
throw new VXGateTimeoutError(
|
|
152
152
|
`Polling timeout setelah ${timeoutMs / 1000}s`,
|
|
153
153
|
referenceId,
|
|
154
154
|
timeoutMs,
|
|
@@ -228,7 +228,7 @@ class VioleticsPayment {
|
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
230
|
// Browser (Web Crypto — async, use verifyWebhookAsync instead)
|
|
231
|
-
throw new Error('Use
|
|
231
|
+
throw new Error('Use VXGatePayment.verifyWebhookAsync() in browser environments');
|
|
232
232
|
}
|
|
233
233
|
|
|
234
234
|
/**
|
|
@@ -250,23 +250,23 @@ class VioleticsPayment {
|
|
|
250
250
|
|
|
251
251
|
// ── Custom errors ─────────────────────────────────────────────────────────
|
|
252
252
|
|
|
253
|
-
class
|
|
253
|
+
class VXGateError extends Error {
|
|
254
254
|
constructor(message, statusCode, response) {
|
|
255
255
|
super(message);
|
|
256
|
-
this.name = '
|
|
256
|
+
this.name = 'VXGateError';
|
|
257
257
|
this.statusCode = statusCode;
|
|
258
258
|
this.response = response;
|
|
259
259
|
}
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
-
class
|
|
262
|
+
class VXGateTimeoutError extends Error {
|
|
263
263
|
constructor(message, referenceId, timeoutMs) {
|
|
264
264
|
super(message);
|
|
265
|
-
this.name = '
|
|
265
|
+
this.name = 'VXGateTimeoutError';
|
|
266
266
|
this.referenceId = referenceId;
|
|
267
267
|
this.timeoutMs = timeoutMs;
|
|
268
268
|
}
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
-
module.exports = {
|
|
272
|
-
module.exports.default =
|
|
271
|
+
module.exports = { VXGatePayment, VXGateError, VXGateTimeoutError };
|
|
272
|
+
module.exports.default = VXGatePayment;
|
package/src/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// ESM re-export wrapper
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
2
|
+
export { VXGatePayment, VXGateError, VXGateTimeoutError } from './index.js';
|
|
3
|
+
export { VXGatePayment as default } from './index.js';
|