@vonpay/checkout-node 0.1.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 +48 -0
- package/dist/client.d.ts +60 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +336 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +11 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +19 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +130 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +37 -0
package/README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# @vonpay/checkout-node
|
|
2
|
+
|
|
3
|
+
Node.js / TypeScript SDK for the [Von Payments Checkout API](https://docs.vonpay.com). Create hosted checkout sessions, verify webhook signatures, and validate signed return redirects.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @vonpay/checkout-node
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
**Requires:** Node 20+. ESM only. Zero runtime dependencies.
|
|
12
|
+
|
|
13
|
+
## Quick start
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { VonPayCheckout, VonPayError } from "@vonpay/checkout-node";
|
|
17
|
+
|
|
18
|
+
const vonpay = new VonPayCheckout("vp_sk_test_...");
|
|
19
|
+
|
|
20
|
+
const session = await vonpay.sessions.create({
|
|
21
|
+
amount: 1499,
|
|
22
|
+
currency: "USD",
|
|
23
|
+
country: "US",
|
|
24
|
+
successUrl: "https://example.com/order/123/confirm",
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
console.log(session.checkoutUrl);
|
|
28
|
+
// https://checkout.vonpay.com/checkout?session=vp_cs_test_...
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Features
|
|
32
|
+
|
|
33
|
+
- **Typed session / webhook / error objects** — full `CheckoutSession`, `SessionStatus`, `WebhookEvent`, `VonPayError`, discriminated-union `ErrorCode`.
|
|
34
|
+
- **Webhook verification** — HMAC-SHA256 with ±5 minute timestamp replay protection via `webhooks.constructEvent()`.
|
|
35
|
+
- **Signed return URL verification (v1 + v2)** — `VonPayCheckout.verifyReturnSignature()` supports both legacy v1 signatures and v2 signatures that bind `successUrl`, `keyMode`, and `iat` freshness.
|
|
36
|
+
- **Auto-retry** — exponential backoff on 429 / 5xx with `Retry-After` header support.
|
|
37
|
+
- **Request ID tracing** — every response includes `X-Request-Id` for support tickets.
|
|
38
|
+
- **Rate-limit info** — parsed from response headers into `VonPayError.rateLimit`.
|
|
39
|
+
|
|
40
|
+
## Documentation
|
|
41
|
+
|
|
42
|
+
- [Node SDK reference](https://docs.vonpay.com/sdks/node-sdk)
|
|
43
|
+
- [API reference](https://docs.vonpay.com/reference/api)
|
|
44
|
+
- [Quickstart](https://docs.vonpay.com/quickstart)
|
|
45
|
+
|
|
46
|
+
## License
|
|
47
|
+
|
|
48
|
+
MIT
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { VonPayCheckoutConfig, CreateSessionParams, CheckoutSession, SessionStatus, DryRunResult, WebhookEvent, HealthStatus, RequestOptions, ReturnParams } from "./types.js";
|
|
2
|
+
export declare class VonPayCheckout {
|
|
3
|
+
private readonly config;
|
|
4
|
+
constructor(config: VonPayCheckoutConfig | string);
|
|
5
|
+
private request;
|
|
6
|
+
/** Retry delay: uses Retry-After on 429 (capped at 60s), otherwise exponential backoff (1s, 5s) with jitter */
|
|
7
|
+
private getRetryDelay;
|
|
8
|
+
sessions: {
|
|
9
|
+
create: (params: CreateSessionParams, options?: RequestOptions) => Promise<CheckoutSession>;
|
|
10
|
+
/** Retrieve the current state of a checkout session. Requires a secret key (vp_sk_*). Publishable keys are rejected with 403. */
|
|
11
|
+
get: (sessionId: string) => Promise<SessionStatus>;
|
|
12
|
+
validate: (params: CreateSessionParams) => Promise<DryRunResult>;
|
|
13
|
+
};
|
|
14
|
+
webhooks: {
|
|
15
|
+
/**
|
|
16
|
+
* Verify that a webhook payload was signed by Von Payments.
|
|
17
|
+
* Uses timing-safe comparison to prevent timing attacks.
|
|
18
|
+
*
|
|
19
|
+
* @param payload - Raw request body string
|
|
20
|
+
* @param signature - Value of the X-VonPay-Signature header
|
|
21
|
+
* @param secret - Your merchant API key (vp_sk_*), used as the HMAC secret
|
|
22
|
+
*/
|
|
23
|
+
verifySignature: (payload: string, signature: string, secret: string) => boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Verify the signature and timestamp, then parse the webhook payload into a typed event.
|
|
26
|
+
* Throws VonPayError if verification fails or timestamp is outside tolerance (±5 minutes).
|
|
27
|
+
*
|
|
28
|
+
* @param payload - Raw request body string
|
|
29
|
+
* @param signature - Value of the X-VonPay-Signature header
|
|
30
|
+
* @param secret - Your merchant API key (vp_sk_*), used as the HMAC secret
|
|
31
|
+
* @param timestamp - Value of the X-VonPay-Timestamp header (ISO 8601)
|
|
32
|
+
*/
|
|
33
|
+
constructEvent: (payload: string, signature: string, secret: string, timestamp: string) => WebhookEvent;
|
|
34
|
+
};
|
|
35
|
+
health(): Promise<HealthStatus>;
|
|
36
|
+
/**
|
|
37
|
+
* Verify a return URL signature from a checkout redirect.
|
|
38
|
+
*
|
|
39
|
+
* Supports both v1 (plain hex HMAC) and v2 ("v2.<payload>.<hmac>")
|
|
40
|
+
* signature formats. If `params.sig` starts with "v2.", v2 verification
|
|
41
|
+
* runs; otherwise v1 is used.
|
|
42
|
+
*
|
|
43
|
+
* v1 signs: `sessionId.status.amount.currency.transactionId` (joined with `.`)
|
|
44
|
+
*
|
|
45
|
+
* v2 additionally binds `successUrl`, `keyMode`, and `issuedAt` into the
|
|
46
|
+
* signature. Callers MUST supply `expectedSuccessUrl` and `expectedKeyMode`
|
|
47
|
+
* for v2 verification — without them v2 signatures are rejected.
|
|
48
|
+
*
|
|
49
|
+
* @param params - URL search params from the redirect (session, status, amount, currency, transaction_id, sig)
|
|
50
|
+
* @param secret - Your session signing secret, NOT your API key
|
|
51
|
+
* @param options - v2-only: expectedSuccessUrl (required for v2), expectedKeyMode (required for v2), maxAgeSeconds (default 600)
|
|
52
|
+
*/
|
|
53
|
+
static verifyReturnSignature(params: ReturnParams | Record<string, string>, secret: string, options?: {
|
|
54
|
+
expectedSuccessUrl?: string;
|
|
55
|
+
expectedKeyMode?: "test" | "live";
|
|
56
|
+
maxAgeSeconds?: number;
|
|
57
|
+
}): boolean;
|
|
58
|
+
private static verifyReturnSignatureV2;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,cAAc,EAGd,YAAY,EACb,MAAM,YAAY,CAAC;AAyFpB,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;gBAE5B,MAAM,EAAE,oBAAoB,GAAG,MAAM;YAenC,OAAO;IAgHrB,+GAA+G;IAC/G,OAAO,CAAC,aAAa;IASrB,QAAQ;yBAEI,mBAAmB,YACjB,cAAc,KACvB,OAAO,CAAC,eAAe,CAAC;QAY3B,iIAAiI;yBAC1G,MAAM,KAAG,OAAO,CAAC,aAAa,CAAC;2BAQ7B,mBAAmB,KAAG,OAAO,CAAC,YAAY,CAAC;MAWpE;IAEF,QAAQ;QACN;;;;;;;WAOG;mCAEQ,MAAM,aACJ,MAAM,UACT,MAAM,KACb,OAAO;QAWV;;;;;;;;WAQG;kCAEQ,MAAM,aACJ,MAAM,UACT,MAAM,aACH,MAAM,KAChB,YAAY;MA4Bf;IAEI,MAAM,IAAI,OAAO,CAAC,YAAY,CAAC;IAarC;;;;;;;;;;;;;;;;OAgBG;IACH,MAAM,CAAC,qBAAqB,CAC1B,MAAM,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC7C,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE;QACR,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QAClC,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB,GACA,OAAO;IA2BV,OAAO,CAAC,MAAM,CAAC,uBAAuB;CAkEvC"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
5
|
+
import { VonPayError } from "./errors.js";
|
|
6
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
const pkg = JSON.parse(readFileSync(join(__dirname, "..", "package.json"), "utf-8"));
|
|
8
|
+
const SDK_VERSION = pkg.version;
|
|
9
|
+
const DEFAULT_BASE_URL = "https://checkout.vonpay.com";
|
|
10
|
+
const DEFAULT_API_VERSION = "2026-04-14";
|
|
11
|
+
const DEFAULT_MAX_RETRIES = 2;
|
|
12
|
+
const DEFAULT_TIMEOUT = 30_000;
|
|
13
|
+
const RETRYABLE_STATUS_CODES = new Set([429, 500, 502, 503, 504]);
|
|
14
|
+
const WEBHOOK_TIMESTAMP_TOLERANCE_SECONDS = 300; // 5 minutes
|
|
15
|
+
const VALID_KEY_PREFIXES = [
|
|
16
|
+
"vp_sk_test_",
|
|
17
|
+
"vp_sk_live_",
|
|
18
|
+
"vp_pk_test_",
|
|
19
|
+
"vp_pk_live_",
|
|
20
|
+
];
|
|
21
|
+
function resolveConfig(config) {
|
|
22
|
+
if (typeof config === "string") {
|
|
23
|
+
return {
|
|
24
|
+
apiKey: config,
|
|
25
|
+
apiVersion: DEFAULT_API_VERSION,
|
|
26
|
+
baseUrl: DEFAULT_BASE_URL,
|
|
27
|
+
maxRetries: DEFAULT_MAX_RETRIES,
|
|
28
|
+
timeout: DEFAULT_TIMEOUT,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
apiKey: config.apiKey,
|
|
33
|
+
apiVersion: config.apiVersion ?? DEFAULT_API_VERSION,
|
|
34
|
+
baseUrl: config.baseUrl?.replace(/\/+$/, "") ?? DEFAULT_BASE_URL,
|
|
35
|
+
maxRetries: config.maxRetries ?? DEFAULT_MAX_RETRIES,
|
|
36
|
+
timeout: config.timeout ?? DEFAULT_TIMEOUT,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function sleep(ms) {
|
|
40
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Canonicalise a success URL the same way the checkout signer does. Rules:
|
|
44
|
+
* origin + path (trailing slash stripped unless root) + sorted query params;
|
|
45
|
+
* fragment dropped. Must match vonpay-checkout src/lib/session-tokens.ts
|
|
46
|
+
* `normaliseSuccessUrl` byte-for-byte.
|
|
47
|
+
*/
|
|
48
|
+
function normaliseSuccessUrl(raw) {
|
|
49
|
+
const u = new URL(raw);
|
|
50
|
+
const params = Array.from(u.searchParams.entries()).sort(([a], [b]) => a.localeCompare(b));
|
|
51
|
+
const qs = new URLSearchParams(params).toString();
|
|
52
|
+
const path = u.pathname.endsWith("/") && u.pathname !== "/"
|
|
53
|
+
? u.pathname.replace(/\/$/, "")
|
|
54
|
+
: u.pathname;
|
|
55
|
+
return `${u.origin}${path}${qs ? `?${qs}` : ""}`;
|
|
56
|
+
}
|
|
57
|
+
function parseRateLimitHeaders(headers) {
|
|
58
|
+
const limit = headers.get("X-RateLimit-Limit");
|
|
59
|
+
if (!limit)
|
|
60
|
+
return undefined;
|
|
61
|
+
return {
|
|
62
|
+
limit: parseInt(limit, 10),
|
|
63
|
+
remaining: parseInt(headers.get("X-RateLimit-Remaining") ?? "0", 10),
|
|
64
|
+
reset: parseInt(headers.get("X-RateLimit-Reset") ?? "0", 10),
|
|
65
|
+
retryAfter: headers.has("Retry-After")
|
|
66
|
+
? (() => {
|
|
67
|
+
const val = parseInt(headers.get("Retry-After"), 10);
|
|
68
|
+
return isNaN(val) ? undefined : val;
|
|
69
|
+
})()
|
|
70
|
+
: undefined,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
export class VonPayCheckout {
|
|
74
|
+
config;
|
|
75
|
+
constructor(config) {
|
|
76
|
+
this.config = resolveConfig(config);
|
|
77
|
+
if (!this.config.apiKey) {
|
|
78
|
+
throw new Error("API key is required");
|
|
79
|
+
}
|
|
80
|
+
if (!VALID_KEY_PREFIXES.some((p) => this.config.apiKey.startsWith(p))) {
|
|
81
|
+
throw new Error("Invalid API key format. Keys must start with one of: " +
|
|
82
|
+
VALID_KEY_PREFIXES.join(", "));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
async request(method, path, options) {
|
|
86
|
+
let url = `${this.config.baseUrl}${path}`;
|
|
87
|
+
if (options?.query) {
|
|
88
|
+
const params = new URLSearchParams(options.query);
|
|
89
|
+
url += `?${params.toString()}`;
|
|
90
|
+
}
|
|
91
|
+
const headers = {
|
|
92
|
+
Authorization: `Bearer ${this.config.apiKey}`,
|
|
93
|
+
"Von-Pay-Version": this.config.apiVersion,
|
|
94
|
+
"User-Agent": `vonpay-node/${SDK_VERSION}`,
|
|
95
|
+
Accept: "application/json",
|
|
96
|
+
};
|
|
97
|
+
if (options?.body) {
|
|
98
|
+
headers["Content-Type"] = "application/json";
|
|
99
|
+
}
|
|
100
|
+
if (options?.idempotencyKey) {
|
|
101
|
+
headers["Idempotency-Key"] = options.idempotencyKey;
|
|
102
|
+
}
|
|
103
|
+
let lastError;
|
|
104
|
+
for (let attempt = 0; attempt <= this.config.maxRetries; attempt++) {
|
|
105
|
+
if (attempt > 0) {
|
|
106
|
+
const backoff = this.getRetryDelay(attempt, lastError);
|
|
107
|
+
await sleep(backoff);
|
|
108
|
+
}
|
|
109
|
+
const controller = new AbortController();
|
|
110
|
+
const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
|
|
111
|
+
try {
|
|
112
|
+
const response = await fetch(url, {
|
|
113
|
+
method,
|
|
114
|
+
headers,
|
|
115
|
+
body: options?.body ? JSON.stringify(options.body) : undefined,
|
|
116
|
+
signal: controller.signal,
|
|
117
|
+
});
|
|
118
|
+
clearTimeout(timeoutId);
|
|
119
|
+
const requestId = response.headers.get("X-Request-Id") ?? "";
|
|
120
|
+
const rateLimit = parseRateLimitHeaders(response.headers);
|
|
121
|
+
if (response.ok) {
|
|
122
|
+
const data = (await response.json());
|
|
123
|
+
return { data, requestId, rateLimit };
|
|
124
|
+
}
|
|
125
|
+
// Parse error response
|
|
126
|
+
let errorData;
|
|
127
|
+
try {
|
|
128
|
+
errorData = (await response.json());
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
errorData = {
|
|
132
|
+
error: `HTTP ${response.status}`,
|
|
133
|
+
code: "internal_error",
|
|
134
|
+
fix: "Check the API status page",
|
|
135
|
+
docs: "https://docs.vonpay.com",
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
lastError = new VonPayError(response.status, errorData, requestId, rateLimit);
|
|
139
|
+
// Only retry on retryable status codes
|
|
140
|
+
if (!RETRYABLE_STATUS_CODES.has(response.status)) {
|
|
141
|
+
throw lastError;
|
|
142
|
+
}
|
|
143
|
+
// Don't retry if we've exhausted attempts
|
|
144
|
+
if (attempt === this.config.maxRetries) {
|
|
145
|
+
throw lastError;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
catch (err) {
|
|
149
|
+
clearTimeout(timeoutId);
|
|
150
|
+
if (err instanceof VonPayError) {
|
|
151
|
+
throw err;
|
|
152
|
+
}
|
|
153
|
+
// Network/timeout error — retryable
|
|
154
|
+
lastError =
|
|
155
|
+
err instanceof Error ? err : new Error("Unknown fetch error");
|
|
156
|
+
if (attempt === this.config.maxRetries) {
|
|
157
|
+
throw lastError;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
// Should be unreachable, but TypeScript needs it
|
|
162
|
+
throw lastError ?? new Error("Request failed");
|
|
163
|
+
}
|
|
164
|
+
/** Retry delay: uses Retry-After on 429 (capped at 60s), otherwise exponential backoff (1s, 5s) with jitter */
|
|
165
|
+
getRetryDelay(attempt, lastError) {
|
|
166
|
+
if (lastError instanceof VonPayError && lastError.rateLimit?.retryAfter) {
|
|
167
|
+
return Math.min(lastError.rateLimit.retryAfter * 1000, 60_000);
|
|
168
|
+
}
|
|
169
|
+
const base = Math.pow(5, attempt - 1) * 1000;
|
|
170
|
+
const jitter = Math.random() * base * 0.1;
|
|
171
|
+
return base + jitter;
|
|
172
|
+
}
|
|
173
|
+
sessions = {
|
|
174
|
+
create: async (params, options) => {
|
|
175
|
+
const { data } = await this.request("POST", "/v1/sessions", {
|
|
176
|
+
body: params,
|
|
177
|
+
idempotencyKey: options?.idempotencyKey,
|
|
178
|
+
});
|
|
179
|
+
return data;
|
|
180
|
+
},
|
|
181
|
+
/** Retrieve the current state of a checkout session. Requires a secret key (vp_sk_*). Publishable keys are rejected with 403. */
|
|
182
|
+
get: async (sessionId) => {
|
|
183
|
+
const { data } = await this.request("GET", `/v1/sessions/${encodeURIComponent(sessionId)}`);
|
|
184
|
+
return data;
|
|
185
|
+
},
|
|
186
|
+
validate: async (params) => {
|
|
187
|
+
const { data } = await this.request("POST", "/v1/sessions", {
|
|
188
|
+
body: params,
|
|
189
|
+
query: { dry_run: "true" },
|
|
190
|
+
});
|
|
191
|
+
return data;
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
webhooks = {
|
|
195
|
+
/**
|
|
196
|
+
* Verify that a webhook payload was signed by Von Payments.
|
|
197
|
+
* Uses timing-safe comparison to prevent timing attacks.
|
|
198
|
+
*
|
|
199
|
+
* @param payload - Raw request body string
|
|
200
|
+
* @param signature - Value of the X-VonPay-Signature header
|
|
201
|
+
* @param secret - Your merchant API key (vp_sk_*), used as the HMAC secret
|
|
202
|
+
*/
|
|
203
|
+
verifySignature: (payload, signature, secret) => {
|
|
204
|
+
if (!/^[0-9a-f]{64}$/i.test(signature))
|
|
205
|
+
return false;
|
|
206
|
+
const expected = createHmac("sha256", secret)
|
|
207
|
+
.update(payload)
|
|
208
|
+
.digest("hex");
|
|
209
|
+
return timingSafeEqual(Buffer.from(signature, "hex"), Buffer.from(expected, "hex"));
|
|
210
|
+
},
|
|
211
|
+
/**
|
|
212
|
+
* Verify the signature and timestamp, then parse the webhook payload into a typed event.
|
|
213
|
+
* Throws VonPayError if verification fails or timestamp is outside tolerance (±5 minutes).
|
|
214
|
+
*
|
|
215
|
+
* @param payload - Raw request body string
|
|
216
|
+
* @param signature - Value of the X-VonPay-Signature header
|
|
217
|
+
* @param secret - Your merchant API key (vp_sk_*), used as the HMAC secret
|
|
218
|
+
* @param timestamp - Value of the X-VonPay-Timestamp header (ISO 8601)
|
|
219
|
+
*/
|
|
220
|
+
constructEvent: (payload, signature, secret, timestamp) => {
|
|
221
|
+
// Verify timestamp is within tolerance
|
|
222
|
+
const eventTime = new Date(timestamp).getTime();
|
|
223
|
+
const now = Date.now();
|
|
224
|
+
if (isNaN(eventTime) ||
|
|
225
|
+
Math.abs(now - eventTime) > WEBHOOK_TIMESTAMP_TOLERANCE_SECONDS * 1000) {
|
|
226
|
+
throw new VonPayError(401, {
|
|
227
|
+
error: "Webhook timestamp outside tolerance (±5 minutes)",
|
|
228
|
+
code: "webhook_invalid_signature",
|
|
229
|
+
fix: "Ensure server clock is synchronized and process webhooks promptly",
|
|
230
|
+
docs: "https://docs.vonpay.com/reference/webhooks#signature-verification",
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
// Verify HMAC signature
|
|
234
|
+
if (!this.webhooks.verifySignature(payload, signature, secret)) {
|
|
235
|
+
throw new VonPayError(401, {
|
|
236
|
+
error: "Webhook signature verification failed",
|
|
237
|
+
code: "webhook_invalid_signature",
|
|
238
|
+
fix: "Ensure you are using your merchant API key (vp_sk_*) as the secret",
|
|
239
|
+
docs: "https://docs.vonpay.com/reference/webhooks#signature-verification",
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
return JSON.parse(payload);
|
|
243
|
+
},
|
|
244
|
+
};
|
|
245
|
+
async health() {
|
|
246
|
+
const start = Date.now();
|
|
247
|
+
const { data } = await this.request("GET", "/api/health");
|
|
248
|
+
return {
|
|
249
|
+
status: data.status ?? "ok",
|
|
250
|
+
latencyMs: Date.now() - start,
|
|
251
|
+
version: data.version ?? "",
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Verify a return URL signature from a checkout redirect.
|
|
256
|
+
*
|
|
257
|
+
* Supports both v1 (plain hex HMAC) and v2 ("v2.<payload>.<hmac>")
|
|
258
|
+
* signature formats. If `params.sig` starts with "v2.", v2 verification
|
|
259
|
+
* runs; otherwise v1 is used.
|
|
260
|
+
*
|
|
261
|
+
* v1 signs: `sessionId.status.amount.currency.transactionId` (joined with `.`)
|
|
262
|
+
*
|
|
263
|
+
* v2 additionally binds `successUrl`, `keyMode`, and `issuedAt` into the
|
|
264
|
+
* signature. Callers MUST supply `expectedSuccessUrl` and `expectedKeyMode`
|
|
265
|
+
* for v2 verification — without them v2 signatures are rejected.
|
|
266
|
+
*
|
|
267
|
+
* @param params - URL search params from the redirect (session, status, amount, currency, transaction_id, sig)
|
|
268
|
+
* @param secret - Your session signing secret, NOT your API key
|
|
269
|
+
* @param options - v2-only: expectedSuccessUrl (required for v2), expectedKeyMode (required for v2), maxAgeSeconds (default 600)
|
|
270
|
+
*/
|
|
271
|
+
static verifyReturnSignature(params, secret, options) {
|
|
272
|
+
const { sig, session, status, amount, currency, transaction_id } = params;
|
|
273
|
+
if (!sig || !session || !status || !amount || !currency)
|
|
274
|
+
return false;
|
|
275
|
+
if (sig.startsWith("v2.")) {
|
|
276
|
+
return VonPayCheckout.verifyReturnSignatureV2(sig, { session, status, amount, currency, transaction_id: transaction_id ?? "" }, secret, options ?? {});
|
|
277
|
+
}
|
|
278
|
+
if (!/^[0-9a-f]{64}$/i.test(sig))
|
|
279
|
+
return false;
|
|
280
|
+
const data = [session, status, amount, currency, transaction_id ?? ""].join(".");
|
|
281
|
+
const expected = createHmac("sha256", secret).update(data).digest("hex");
|
|
282
|
+
return timingSafeEqual(Buffer.from(sig, "hex"), Buffer.from(expected, "hex"));
|
|
283
|
+
}
|
|
284
|
+
static verifyReturnSignatureV2(sig, urlFields, secret, options) {
|
|
285
|
+
const parts = sig.split(".");
|
|
286
|
+
if (parts.length !== 3 || parts[0] !== "v2")
|
|
287
|
+
return false;
|
|
288
|
+
const [, payloadB64, hexHmac] = parts;
|
|
289
|
+
if (!/^[0-9a-f]{64}$/i.test(hexHmac))
|
|
290
|
+
return false;
|
|
291
|
+
const signedInput = `v2.${payloadB64}`;
|
|
292
|
+
const expected = createHmac("sha256", secret).update(signedInput).digest("hex");
|
|
293
|
+
if (!timingSafeEqual(Buffer.from(hexHmac, "hex"), Buffer.from(expected, "hex"))) {
|
|
294
|
+
return false;
|
|
295
|
+
}
|
|
296
|
+
let payload;
|
|
297
|
+
try {
|
|
298
|
+
const padded = payloadB64 + "=".repeat((4 - (payloadB64.length % 4)) % 4);
|
|
299
|
+
const json = Buffer.from(padded.replace(/-/g, "+").replace(/_/g, "/"), "base64").toString("utf-8");
|
|
300
|
+
payload = JSON.parse(json);
|
|
301
|
+
}
|
|
302
|
+
catch {
|
|
303
|
+
return false;
|
|
304
|
+
}
|
|
305
|
+
if (payload.sid !== urlFields.session)
|
|
306
|
+
return false;
|
|
307
|
+
if (payload.status !== urlFields.status)
|
|
308
|
+
return false;
|
|
309
|
+
if (String(payload.amount ?? "") !== urlFields.amount)
|
|
310
|
+
return false;
|
|
311
|
+
if (payload.currency !== urlFields.currency)
|
|
312
|
+
return false;
|
|
313
|
+
if (String(payload.transactionId ?? "") !== (urlFields.transaction_id ?? ""))
|
|
314
|
+
return false;
|
|
315
|
+
if (!options.expectedSuccessUrl)
|
|
316
|
+
return false;
|
|
317
|
+
if (payload.successUrl !== normaliseSuccessUrl(options.expectedSuccessUrl)) {
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
if (!options.expectedKeyMode)
|
|
321
|
+
return false;
|
|
322
|
+
if (payload.keyMode !== options.expectedKeyMode)
|
|
323
|
+
return false;
|
|
324
|
+
const iat = payload.iat;
|
|
325
|
+
if (typeof iat !== "number")
|
|
326
|
+
return false;
|
|
327
|
+
const nowSec = Math.floor(Date.now() / 1000);
|
|
328
|
+
const maxAge = options.maxAgeSeconds ?? 600;
|
|
329
|
+
if (nowSec - iat > maxAge)
|
|
330
|
+
return false;
|
|
331
|
+
if (iat > nowSec + 60)
|
|
332
|
+
return false;
|
|
333
|
+
return true;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAc1C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC1D,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CACpB,YAAY,CAAC,IAA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AE3F,IAAI,CAAC,OAAO,CAAC,kBAAkB;YAAE,OAAO,KAAK,CAAC;QAC9C,IAAI,OAAO,CAAC,UAAU,KAAK,mBAAmB,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAAE,CAAC;YAC3E,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,eAAe;YAAE,OAAO,KAAK,CAAC;QAC3C,IAAI,OAAO,CAAC,OAAO,KAAK,OAAO,CAAC,eAAe;YAAE,OAAO,KAAK,CAAC;QAE9D,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;QACxB,IAAI,OAAO,GAAG,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC;QAC1C,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;QAC7C,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,IAAI,GAAG,CAAC;QAC5C,IAAI,MAAM,GAAG,GAAG,GAAG,MAAM;YAAE,OAAO,KAAK,CAAC;QACxC,IAAI,GAAG,GAAG,MAAM,GAAG,EAAE;YAAE,OAAO,KAAK,CAAC;QAEpC,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ErrorCode, VonPayErrorData, RateLimitInfo } from "./types.js";
|
|
2
|
+
export declare class VonPayError extends Error {
|
|
3
|
+
readonly status: number;
|
|
4
|
+
readonly code: ErrorCode;
|
|
5
|
+
readonly fix: string;
|
|
6
|
+
readonly docs: string;
|
|
7
|
+
readonly requestId?: string;
|
|
8
|
+
readonly rateLimit?: RateLimitInfo;
|
|
9
|
+
constructor(status: number, data: VonPayErrorData, requestId?: string, rateLimit?: RateLimitInfo);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE5E,qBAAa,WAAY,SAAQ,KAAK;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC;gBAGjC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,eAAe,EACrB,SAAS,CAAC,EAAE,MAAM,EAClB,SAAS,CAAC,EAAE,aAAa;CAW5B"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export class VonPayError extends Error {
|
|
2
|
+
status;
|
|
3
|
+
code;
|
|
4
|
+
fix;
|
|
5
|
+
docs;
|
|
6
|
+
requestId;
|
|
7
|
+
rateLimit;
|
|
8
|
+
constructor(status, data, requestId, rateLimit) {
|
|
9
|
+
super(data.error);
|
|
10
|
+
this.name = "VonPayError";
|
|
11
|
+
this.status = status;
|
|
12
|
+
this.code = data.code;
|
|
13
|
+
this.fix = data.fix;
|
|
14
|
+
this.docs = data.docs;
|
|
15
|
+
this.requestId = requestId;
|
|
16
|
+
this.rateLimit = rateLimit;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,WAAY,SAAQ,KAAK;IAC3B,MAAM,CAAS;IACf,IAAI,CAAY;IAChB,GAAG,CAAS;IACZ,IAAI,CAAS;IACb,SAAS,CAAU;IACnB,SAAS,CAAiB;IAEnC,YACE,MAAc,EACd,IAAqB,EACrB,SAAkB,EAClB,SAAyB;QAEzB,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAClB,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACtB,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACtB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { VonPayCheckout } from "./client.js";
|
|
2
|
+
export type { VonPayCheckoutConfig, CreateSessionParams, LineItem, CheckoutSession, SessionState, SessionStatus, ShippingAddress, DryRunResult, WebhookEvent, WebhookSessionSucceeded, WebhookSessionFailed, WebhookSessionExpired, WebhookRefundCreated, HealthStatus, ErrorCode, VonPayErrorData, RequestOptions, RateLimitInfo, ReturnParams, } from "./types.js";
|
|
3
|
+
export { VonPayError } from "./errors.js";
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,YAAY,EACV,oBAAoB,EACpB,mBAAmB,EACnB,QAAQ,EACR,eAAe,EACf,YAAY,EACZ,aAAa,EACb,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,uBAAuB,EACvB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,YAAY,EACZ,SAAS,EACT,eAAe,EACf,cAAc,EACd,aAAa,EACb,YAAY,GACb,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAsB7C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
export interface VonPayCheckoutConfig {
|
|
2
|
+
apiKey: string;
|
|
3
|
+
apiVersion?: string;
|
|
4
|
+
baseUrl?: string;
|
|
5
|
+
maxRetries?: number;
|
|
6
|
+
timeout?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface CreateSessionParams {
|
|
9
|
+
amount: number;
|
|
10
|
+
currency: string;
|
|
11
|
+
country?: string;
|
|
12
|
+
mode?: "payment";
|
|
13
|
+
description?: string;
|
|
14
|
+
locale?: string;
|
|
15
|
+
successUrl?: string;
|
|
16
|
+
cancelUrl?: string;
|
|
17
|
+
buyerId?: string;
|
|
18
|
+
buyerName?: string;
|
|
19
|
+
buyerEmail?: string;
|
|
20
|
+
lineItems?: LineItem[];
|
|
21
|
+
collectShipping?: boolean;
|
|
22
|
+
metadata?: Record<string, string>;
|
|
23
|
+
expiresIn?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface LineItem {
|
|
26
|
+
name: string;
|
|
27
|
+
quantity: number;
|
|
28
|
+
unitAmount: number;
|
|
29
|
+
imageUrl?: string;
|
|
30
|
+
}
|
|
31
|
+
/** Response from POST /v1/sessions */
|
|
32
|
+
export interface CheckoutSession {
|
|
33
|
+
id: string;
|
|
34
|
+
checkoutUrl: string;
|
|
35
|
+
expiresAt: string;
|
|
36
|
+
}
|
|
37
|
+
export type SessionState = "pending" | "succeeded" | "failed" | "expired";
|
|
38
|
+
export interface ShippingAddress {
|
|
39
|
+
firstName: string;
|
|
40
|
+
lastName: string;
|
|
41
|
+
address: string;
|
|
42
|
+
address2?: string;
|
|
43
|
+
city: string;
|
|
44
|
+
state: string;
|
|
45
|
+
zip: string;
|
|
46
|
+
country: string;
|
|
47
|
+
}
|
|
48
|
+
/** Response from GET /v1/sessions/:id */
|
|
49
|
+
export interface SessionStatus {
|
|
50
|
+
id: string;
|
|
51
|
+
status: SessionState;
|
|
52
|
+
mode: string;
|
|
53
|
+
merchantId: string;
|
|
54
|
+
amount: number;
|
|
55
|
+
currency: string;
|
|
56
|
+
country?: string;
|
|
57
|
+
description?: string;
|
|
58
|
+
collectShipping?: boolean;
|
|
59
|
+
shippingAddress?: ShippingAddress;
|
|
60
|
+
transactionId?: string;
|
|
61
|
+
metadata?: Record<string, string>;
|
|
62
|
+
createdAt: string;
|
|
63
|
+
updatedAt: string;
|
|
64
|
+
expiresAt: string;
|
|
65
|
+
}
|
|
66
|
+
/** Response from POST /v1/sessions?dry_run=true */
|
|
67
|
+
export interface DryRunResult {
|
|
68
|
+
valid: boolean;
|
|
69
|
+
warnings: string[];
|
|
70
|
+
}
|
|
71
|
+
interface WebhookEventBase {
|
|
72
|
+
sessionId: string;
|
|
73
|
+
merchantId: string;
|
|
74
|
+
amount: number;
|
|
75
|
+
currency: string;
|
|
76
|
+
status: string;
|
|
77
|
+
metadata?: Record<string, string> | null;
|
|
78
|
+
timestamp: string;
|
|
79
|
+
}
|
|
80
|
+
export interface WebhookSessionSucceeded extends WebhookEventBase {
|
|
81
|
+
event: "session.succeeded";
|
|
82
|
+
transactionId: string;
|
|
83
|
+
}
|
|
84
|
+
export interface WebhookSessionFailed extends WebhookEventBase {
|
|
85
|
+
event: "session.failed";
|
|
86
|
+
error?: string;
|
|
87
|
+
failureCode?: string;
|
|
88
|
+
}
|
|
89
|
+
export interface WebhookSessionExpired extends WebhookEventBase {
|
|
90
|
+
event: "session.expired";
|
|
91
|
+
}
|
|
92
|
+
export interface WebhookRefundCreated extends WebhookEventBase {
|
|
93
|
+
event: "refund.created";
|
|
94
|
+
refundId: string;
|
|
95
|
+
transactionId?: string;
|
|
96
|
+
}
|
|
97
|
+
export type WebhookEvent = WebhookSessionSucceeded | WebhookSessionFailed | WebhookSessionExpired | WebhookRefundCreated;
|
|
98
|
+
export interface HealthStatus {
|
|
99
|
+
status: "ok" | "degraded" | "down";
|
|
100
|
+
latencyMs: number;
|
|
101
|
+
version: string;
|
|
102
|
+
}
|
|
103
|
+
export type ErrorCode = "auth_missing_bearer" | "auth_invalid_key" | "auth_key_expired" | "auth_key_type_forbidden" | "auth_merchant_inactive" | "auth_service_unavailable" | "session_not_found" | "session_expired" | "session_wrong_state" | "session_integrity_error" | "validation_error" | "validation_missing_field" | "validation_invalid_amount" | "merchant_not_configured" | "rate_limit_exceeded" | "rate_limit_exceeded_per_key" | "provider_unavailable" | "internal_error" | "webhook_missing_signature" | "webhook_invalid_signature" | "webhook_not_configured" | "origin_forbidden" | "transaction_verification_failed" | "unsupported_media_type";
|
|
104
|
+
export interface VonPayErrorData {
|
|
105
|
+
error: string;
|
|
106
|
+
code: ErrorCode;
|
|
107
|
+
fix: string;
|
|
108
|
+
docs: string;
|
|
109
|
+
}
|
|
110
|
+
export interface RequestOptions {
|
|
111
|
+
idempotencyKey?: string;
|
|
112
|
+
}
|
|
113
|
+
/** Parameters from a checkout return redirect URL */
|
|
114
|
+
export interface ReturnParams {
|
|
115
|
+
session: string;
|
|
116
|
+
status: string;
|
|
117
|
+
amount: string;
|
|
118
|
+
currency: string;
|
|
119
|
+
transaction_id?: string;
|
|
120
|
+
sig: string;
|
|
121
|
+
[key: string]: string | undefined;
|
|
122
|
+
}
|
|
123
|
+
export interface RateLimitInfo {
|
|
124
|
+
limit: number;
|
|
125
|
+
remaining: number;
|
|
126
|
+
reset: number;
|
|
127
|
+
retryAfter?: number;
|
|
128
|
+
}
|
|
129
|
+
export {};
|
|
130
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1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E,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,cAAc;IAC7B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,qDAAqD;AACrD,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CACnC;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vonpay/checkout-node",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Von Payments Checkout SDK for Node.js",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=20"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"typescript": "^5.7.0",
|
|
23
|
+
"vitest": "^3.0.0"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"vonpay",
|
|
27
|
+
"payments",
|
|
28
|
+
"checkout",
|
|
29
|
+
"sdk"
|
|
30
|
+
],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsc",
|
|
33
|
+
"typecheck": "tsc --noEmit",
|
|
34
|
+
"test": "vitest run",
|
|
35
|
+
"clean": "rm -rf dist"
|
|
36
|
+
}
|
|
37
|
+
}
|