@paymos/nuxt 0.0.0-stage → 1.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/CHANGELOG.md +7 -0
- package/LICENSE +21 -0
- package/README.md +83 -2
- package/dist/chunk-AOJYF56M.mjs +113 -0
- package/dist/module.cjs +186 -0
- package/dist/module.d.cts +51 -0
- package/dist/module.d.ts +51 -0
- package/dist/module.mjs +63 -0
- package/dist/server.cjs +139 -0
- package/dist/server.d.cts +63 -0
- package/dist/server.d.ts +63 -0
- package/dist/server.mjs +18 -0
- package/package.json +82 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.0.0 (2026-12-06)
|
|
4
|
+
|
|
5
|
+
- Initial release of `@paymos/nuxt` for Nuxt 3 and Nuxt 4.
|
|
6
|
+
- Registers isolated private/public `runtimeConfig.paymos` without leaking API keys or secrets to the browser.
|
|
7
|
+
- Provides Nitro server helpers (`usePaymosServerClient`, `createPaymosCheckout`, `verifyPaymosNuxtWebhook`) powered by `@paymos/sdk`.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Paymos Labs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,84 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @paymos/nuxt
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Official [Paymos](https://paymos.io) non-custodial stablecoin payment module for **Nuxt 3** and **Nuxt 4**.
|
|
4
|
+
|
|
5
|
+
Accept **USDT, USDC, USD1, DAI, and gold-backed XAUT** across **13 blockchain networks** (TRON, Ethereum, Polygon, Arbitrum, Optimism, Base, BNB Smart Chain, Avalanche, Solana, TON, and more) with 0% chargeback risk and HMAC-SHA256 verified webhooks.
|
|
6
|
+
|
|
7
|
+
- Website: [paymos.io](https://paymos.io)
|
|
8
|
+
- Documentation: [paymos.io/docs/overview](https://paymos.io/docs/overview)
|
|
9
|
+
- Server SDK Docs: [paymos.io/docs/server-sdks](https://paymos.io/docs/server-sdks)
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- Typed private `runtimeConfig.paymos` (server-only) and safe `runtimeConfig.public.paymos` — API keys and secrets are never leaked to the client bundle.
|
|
14
|
+
- Nitro server helpers: `usePaymosServerClient()`, `createPaymosCheckout()`, `verifyPaymosNuxtWebhook()`, and `parsePaymosNuxtWebhook()`.
|
|
15
|
+
- Built on the official [`@paymos/sdk`](https://www.npmjs.com/package/@paymos/sdk) with `WebhookVerifier`.
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @paymos/nuxt @paymos/sdk
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Configuration
|
|
24
|
+
|
|
25
|
+
Add `@paymos/nuxt` to your `nuxt.config.ts`:
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
export default defineNuxtConfig({
|
|
29
|
+
modules: ['@paymos/nuxt'],
|
|
30
|
+
paymos: {
|
|
31
|
+
environment: 'live',
|
|
32
|
+
},
|
|
33
|
+
})
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Configure server credentials via environment variables:
|
|
37
|
+
|
|
38
|
+
```env
|
|
39
|
+
NUXT_PAYMOS_API_KEY=pm_live_...
|
|
40
|
+
NUXT_PAYMOS_API_SECRET=...
|
|
41
|
+
NUXT_PAYMOS_PROJECT_ID=...
|
|
42
|
+
NUXT_PAYMOS_WEBHOOK_SECRET=whsec_...
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Usage
|
|
46
|
+
|
|
47
|
+
### Create a Hosted Stablecoin Checkout (`server/api/checkout.post.ts`)
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
import { createPaymosCheckout } from '@paymos/nuxt/server'
|
|
51
|
+
|
|
52
|
+
export default defineEventHandler(async (event) => {
|
|
53
|
+
const config = useRuntimeConfig(event)
|
|
54
|
+
const body = await readBody<{ amount: string; orderId: string }>(event)
|
|
55
|
+
|
|
56
|
+
return await createPaymosCheckout(
|
|
57
|
+
{
|
|
58
|
+
amount: body.amount,
|
|
59
|
+
currency: 'USD',
|
|
60
|
+
externalOrderId: body.orderId,
|
|
61
|
+
},
|
|
62
|
+
config.paymos
|
|
63
|
+
)
|
|
64
|
+
})
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Verify Incoming Webhooks (`server/api/paymos/webhook.post.ts`)
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
import { parsePaymosNuxtWebhook } from '@paymos/nuxt/server'
|
|
71
|
+
|
|
72
|
+
export default defineEventHandler(async (event) => {
|
|
73
|
+
const config = useRuntimeConfig(event)
|
|
74
|
+
const rawBody = (await readRawBody(event, 'utf8')) ?? ''
|
|
75
|
+
const headers = getHeaders(event)
|
|
76
|
+
|
|
77
|
+
const webhookEvent = parsePaymosNuxtWebhook(rawBody, headers, config.paymos.webhookSecret)
|
|
78
|
+
return { ok: true, eventType: webhookEvent.eventType }
|
|
79
|
+
})
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## License
|
|
83
|
+
|
|
84
|
+
MIT — © 2026 Paymos Labs
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// src/server.ts
|
|
2
|
+
import {
|
|
3
|
+
Paymos,
|
|
4
|
+
WebhookVerifier,
|
|
5
|
+
externalOrderId as generateExternalOrderId
|
|
6
|
+
} from "@paymos/sdk";
|
|
7
|
+
var DEFAULT_PAYMOS_BASE_URL = "https://api.paymos.io";
|
|
8
|
+
function firstHeader(value) {
|
|
9
|
+
if (Array.isArray(value)) {
|
|
10
|
+
return value[0] ?? "";
|
|
11
|
+
}
|
|
12
|
+
return value ?? "";
|
|
13
|
+
}
|
|
14
|
+
function resolveEnvConfig(overrides) {
|
|
15
|
+
const apiKey = (overrides?.apiKey ?? process.env.NUXT_PAYMOS_API_KEY ?? process.env.PAYMOS_API_KEY ?? "").trim();
|
|
16
|
+
const apiSecret = (overrides?.apiSecret ?? process.env.NUXT_PAYMOS_API_SECRET ?? process.env.PAYMOS_API_SECRET ?? "").trim();
|
|
17
|
+
const projectId = (overrides?.projectId ?? process.env.NUXT_PAYMOS_PROJECT_ID ?? process.env.PAYMOS_PROJECT_ID ?? "").trim();
|
|
18
|
+
const webhookSecret = (overrides?.webhookSecret ?? process.env.NUXT_PAYMOS_WEBHOOK_SECRET ?? process.env.PAYMOS_WEBHOOK_SECRET ?? "").trim();
|
|
19
|
+
const baseUrl = (overrides?.baseUrl ?? process.env.NUXT_PAYMOS_BASE_URL ?? process.env.PAYMOS_BASE_URL ?? DEFAULT_PAYMOS_BASE_URL).trim().replace(/\/+$/, "");
|
|
20
|
+
if (!apiKey || !apiSecret) {
|
|
21
|
+
throw new Error(
|
|
22
|
+
"Paymos Nuxt module requires apiKey and apiSecret (via runtimeConfig.paymos or NUXT_PAYMOS_API_KEY / NUXT_PAYMOS_API_SECRET)."
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
apiKey,
|
|
27
|
+
apiSecret,
|
|
28
|
+
projectId: projectId || void 0,
|
|
29
|
+
webhookSecret: webhookSecret || void 0,
|
|
30
|
+
baseUrl: baseUrl || DEFAULT_PAYMOS_BASE_URL,
|
|
31
|
+
timeoutMs: overrides?.timeoutMs
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function usePaymosServerClient(config) {
|
|
35
|
+
const resolved = resolveEnvConfig(config);
|
|
36
|
+
return new Paymos({
|
|
37
|
+
apiKey: resolved.apiKey,
|
|
38
|
+
apiSecret: resolved.apiSecret,
|
|
39
|
+
baseUrl: resolved.baseUrl,
|
|
40
|
+
timeoutMs: resolved.timeoutMs
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
async function createPaymosCheckout(input, config, clientOverride) {
|
|
44
|
+
const projectId = (input.projectId ?? config?.projectId ?? process.env.NUXT_PAYMOS_PROJECT_ID ?? process.env.PAYMOS_PROJECT_ID ?? "").trim();
|
|
45
|
+
if (!projectId) {
|
|
46
|
+
throw new Error("Paymos createPaymosCheckout requires projectId (via input, runtimeConfig.paymos.projectId, or NUXT_PAYMOS_PROJECT_ID).");
|
|
47
|
+
}
|
|
48
|
+
const client = clientOverride ?? usePaymosServerClient(config);
|
|
49
|
+
const currency = (input.currency ?? "USD").trim().toUpperCase();
|
|
50
|
+
const extId = input.externalOrderId?.trim() || generateExternalOrderId("nuxt");
|
|
51
|
+
const invoice = await client.invoices.create({
|
|
52
|
+
projectId,
|
|
53
|
+
amount: input.amount,
|
|
54
|
+
currency,
|
|
55
|
+
externalOrderId: extId,
|
|
56
|
+
network: input.network ?? void 0,
|
|
57
|
+
customerFeePercent: input.customerFeePercent ?? void 0,
|
|
58
|
+
clientId: input.clientId ?? void 0
|
|
59
|
+
});
|
|
60
|
+
if (!invoice.invoiceId || !invoice.paymentUrl) {
|
|
61
|
+
throw new Error("Paymos invoices.create returned incomplete checkout response (missing invoiceId or paymentUrl).");
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
invoiceId: invoice.invoiceId,
|
|
65
|
+
paymentUrl: invoice.paymentUrl,
|
|
66
|
+
status: invoice.status,
|
|
67
|
+
amount: invoice.order?.amount ?? input.amount,
|
|
68
|
+
currency: invoice.order?.currency ?? currency
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function extractWebhookSignatureHeader(headers) {
|
|
72
|
+
for (const [k, v] of Object.entries(headers)) {
|
|
73
|
+
const lower = k.toLowerCase();
|
|
74
|
+
if (lower === "x-webhook-signature" || lower === "x-paymos-signature") {
|
|
75
|
+
const val = firstHeader(v).trim();
|
|
76
|
+
if (val) {
|
|
77
|
+
return val;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return "";
|
|
82
|
+
}
|
|
83
|
+
function verifyPaymosNuxtWebhook(rawBody, headers, webhookSecret, toleranceSeconds) {
|
|
84
|
+
const secret = (webhookSecret ?? process.env.NUXT_PAYMOS_WEBHOOK_SECRET ?? process.env.PAYMOS_WEBHOOK_SECRET ?? "").trim();
|
|
85
|
+
if (!secret) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
const signatureHeader = extractWebhookSignatureHeader(headers);
|
|
89
|
+
if (!signatureHeader) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
const verifier = new WebhookVerifier(secret, toleranceSeconds);
|
|
93
|
+
return verifier.verify(signatureHeader, rawBody);
|
|
94
|
+
}
|
|
95
|
+
function parsePaymosNuxtWebhook(rawBody, headers, webhookSecret, toleranceSeconds) {
|
|
96
|
+
const secret = (webhookSecret ?? process.env.NUXT_PAYMOS_WEBHOOK_SECRET ?? process.env.PAYMOS_WEBHOOK_SECRET ?? "").trim();
|
|
97
|
+
if (!secret) {
|
|
98
|
+
throw new Error("Paymos webhook secret is not configured.");
|
|
99
|
+
}
|
|
100
|
+
const signatureHeader = extractWebhookSignatureHeader(headers);
|
|
101
|
+
const verifier = new WebhookVerifier(secret, toleranceSeconds);
|
|
102
|
+
return verifier.constructEvent(signatureHeader, rawBody);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export {
|
|
106
|
+
Paymos,
|
|
107
|
+
WebhookVerifier,
|
|
108
|
+
DEFAULT_PAYMOS_BASE_URL,
|
|
109
|
+
usePaymosServerClient,
|
|
110
|
+
createPaymosCheckout,
|
|
111
|
+
verifyPaymosNuxtWebhook,
|
|
112
|
+
parsePaymosNuxtWebhook
|
|
113
|
+
};
|
package/dist/module.cjs
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/module.ts
|
|
21
|
+
var module_exports = {};
|
|
22
|
+
__export(module_exports, {
|
|
23
|
+
DEFAULT_PAYMOS_BASE_URL: () => DEFAULT_PAYMOS_BASE_URL,
|
|
24
|
+
Paymos: () => import_sdk.Paymos,
|
|
25
|
+
WebhookVerifier: () => import_sdk.WebhookVerifier,
|
|
26
|
+
createPaymosCheckout: () => createPaymosCheckout,
|
|
27
|
+
default: () => module_default,
|
|
28
|
+
parsePaymosNuxtWebhook: () => parsePaymosNuxtWebhook,
|
|
29
|
+
usePaymosServerClient: () => usePaymosServerClient,
|
|
30
|
+
verifyPaymosNuxtWebhook: () => verifyPaymosNuxtWebhook
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(module_exports);
|
|
33
|
+
|
|
34
|
+
// src/server.ts
|
|
35
|
+
var import_sdk = require("@paymos/sdk");
|
|
36
|
+
var DEFAULT_PAYMOS_BASE_URL = "https://api.paymos.io";
|
|
37
|
+
function firstHeader(value) {
|
|
38
|
+
if (Array.isArray(value)) {
|
|
39
|
+
return value[0] ?? "";
|
|
40
|
+
}
|
|
41
|
+
return value ?? "";
|
|
42
|
+
}
|
|
43
|
+
function resolveEnvConfig(overrides) {
|
|
44
|
+
const apiKey = (overrides?.apiKey ?? process.env.NUXT_PAYMOS_API_KEY ?? process.env.PAYMOS_API_KEY ?? "").trim();
|
|
45
|
+
const apiSecret = (overrides?.apiSecret ?? process.env.NUXT_PAYMOS_API_SECRET ?? process.env.PAYMOS_API_SECRET ?? "").trim();
|
|
46
|
+
const projectId = (overrides?.projectId ?? process.env.NUXT_PAYMOS_PROJECT_ID ?? process.env.PAYMOS_PROJECT_ID ?? "").trim();
|
|
47
|
+
const webhookSecret = (overrides?.webhookSecret ?? process.env.NUXT_PAYMOS_WEBHOOK_SECRET ?? process.env.PAYMOS_WEBHOOK_SECRET ?? "").trim();
|
|
48
|
+
const baseUrl = (overrides?.baseUrl ?? process.env.NUXT_PAYMOS_BASE_URL ?? process.env.PAYMOS_BASE_URL ?? DEFAULT_PAYMOS_BASE_URL).trim().replace(/\/+$/, "");
|
|
49
|
+
if (!apiKey || !apiSecret) {
|
|
50
|
+
throw new Error(
|
|
51
|
+
"Paymos Nuxt module requires apiKey and apiSecret (via runtimeConfig.paymos or NUXT_PAYMOS_API_KEY / NUXT_PAYMOS_API_SECRET)."
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
apiKey,
|
|
56
|
+
apiSecret,
|
|
57
|
+
projectId: projectId || void 0,
|
|
58
|
+
webhookSecret: webhookSecret || void 0,
|
|
59
|
+
baseUrl: baseUrl || DEFAULT_PAYMOS_BASE_URL,
|
|
60
|
+
timeoutMs: overrides?.timeoutMs
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function usePaymosServerClient(config) {
|
|
64
|
+
const resolved = resolveEnvConfig(config);
|
|
65
|
+
return new import_sdk.Paymos({
|
|
66
|
+
apiKey: resolved.apiKey,
|
|
67
|
+
apiSecret: resolved.apiSecret,
|
|
68
|
+
baseUrl: resolved.baseUrl,
|
|
69
|
+
timeoutMs: resolved.timeoutMs
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
async function createPaymosCheckout(input, config, clientOverride) {
|
|
73
|
+
const projectId = (input.projectId ?? config?.projectId ?? process.env.NUXT_PAYMOS_PROJECT_ID ?? process.env.PAYMOS_PROJECT_ID ?? "").trim();
|
|
74
|
+
if (!projectId) {
|
|
75
|
+
throw new Error("Paymos createPaymosCheckout requires projectId (via input, runtimeConfig.paymos.projectId, or NUXT_PAYMOS_PROJECT_ID).");
|
|
76
|
+
}
|
|
77
|
+
const client = clientOverride ?? usePaymosServerClient(config);
|
|
78
|
+
const currency = (input.currency ?? "USD").trim().toUpperCase();
|
|
79
|
+
const extId = input.externalOrderId?.trim() || (0, import_sdk.externalOrderId)("nuxt");
|
|
80
|
+
const invoice = await client.invoices.create({
|
|
81
|
+
projectId,
|
|
82
|
+
amount: input.amount,
|
|
83
|
+
currency,
|
|
84
|
+
externalOrderId: extId,
|
|
85
|
+
network: input.network ?? void 0,
|
|
86
|
+
customerFeePercent: input.customerFeePercent ?? void 0,
|
|
87
|
+
clientId: input.clientId ?? void 0
|
|
88
|
+
});
|
|
89
|
+
if (!invoice.invoiceId || !invoice.paymentUrl) {
|
|
90
|
+
throw new Error("Paymos invoices.create returned incomplete checkout response (missing invoiceId or paymentUrl).");
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
invoiceId: invoice.invoiceId,
|
|
94
|
+
paymentUrl: invoice.paymentUrl,
|
|
95
|
+
status: invoice.status,
|
|
96
|
+
amount: invoice.order?.amount ?? input.amount,
|
|
97
|
+
currency: invoice.order?.currency ?? currency
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function extractWebhookSignatureHeader(headers) {
|
|
101
|
+
for (const [k, v] of Object.entries(headers)) {
|
|
102
|
+
const lower = k.toLowerCase();
|
|
103
|
+
if (lower === "x-webhook-signature" || lower === "x-paymos-signature") {
|
|
104
|
+
const val = firstHeader(v).trim();
|
|
105
|
+
if (val) {
|
|
106
|
+
return val;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return "";
|
|
111
|
+
}
|
|
112
|
+
function verifyPaymosNuxtWebhook(rawBody, headers, webhookSecret, toleranceSeconds) {
|
|
113
|
+
const secret = (webhookSecret ?? process.env.NUXT_PAYMOS_WEBHOOK_SECRET ?? process.env.PAYMOS_WEBHOOK_SECRET ?? "").trim();
|
|
114
|
+
if (!secret) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
const signatureHeader = extractWebhookSignatureHeader(headers);
|
|
118
|
+
if (!signatureHeader) {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
const verifier = new import_sdk.WebhookVerifier(secret, toleranceSeconds);
|
|
122
|
+
return verifier.verify(signatureHeader, rawBody);
|
|
123
|
+
}
|
|
124
|
+
function parsePaymosNuxtWebhook(rawBody, headers, webhookSecret, toleranceSeconds) {
|
|
125
|
+
const secret = (webhookSecret ?? process.env.NUXT_PAYMOS_WEBHOOK_SECRET ?? process.env.PAYMOS_WEBHOOK_SECRET ?? "").trim();
|
|
126
|
+
if (!secret) {
|
|
127
|
+
throw new Error("Paymos webhook secret is not configured.");
|
|
128
|
+
}
|
|
129
|
+
const signatureHeader = extractWebhookSignatureHeader(headers);
|
|
130
|
+
const verifier = new import_sdk.WebhookVerifier(secret, toleranceSeconds);
|
|
131
|
+
return verifier.constructEvent(signatureHeader, rawBody);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// src/module.ts
|
|
135
|
+
var MODULE_META = {
|
|
136
|
+
name: "@paymos/nuxt",
|
|
137
|
+
configKey: "paymos",
|
|
138
|
+
compatibility: {
|
|
139
|
+
nuxt: ">=3.0.0"
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
var MODULE_DEFAULTS = {
|
|
143
|
+
apiKey: "",
|
|
144
|
+
apiSecret: "",
|
|
145
|
+
projectId: "",
|
|
146
|
+
webhookSecret: "",
|
|
147
|
+
baseUrl: DEFAULT_PAYMOS_BASE_URL,
|
|
148
|
+
environment: "live"
|
|
149
|
+
};
|
|
150
|
+
var paymosNuxtModule = Object.assign(
|
|
151
|
+
function setupPaymosNuxtModule(inlineOptions = {}, nuxt) {
|
|
152
|
+
const merged = {
|
|
153
|
+
...MODULE_DEFAULTS,
|
|
154
|
+
...inlineOptions
|
|
155
|
+
};
|
|
156
|
+
const existingPrivate = nuxt.options.runtimeConfig.paymos ?? {};
|
|
157
|
+
const existingPublic = nuxt.options.runtimeConfig.public.paymos ?? {};
|
|
158
|
+
nuxt.options.runtimeConfig.paymos = {
|
|
159
|
+
apiKey: existingPrivate.apiKey ?? merged.apiKey ?? "",
|
|
160
|
+
apiSecret: existingPrivate.apiSecret ?? merged.apiSecret ?? "",
|
|
161
|
+
projectId: existingPrivate.projectId ?? merged.projectId ?? "",
|
|
162
|
+
webhookSecret: existingPrivate.webhookSecret ?? merged.webhookSecret ?? "",
|
|
163
|
+
baseUrl: existingPrivate.baseUrl ?? merged.baseUrl ?? DEFAULT_PAYMOS_BASE_URL
|
|
164
|
+
};
|
|
165
|
+
nuxt.options.runtimeConfig.public.paymos = {
|
|
166
|
+
baseUrl: existingPublic.baseUrl ?? merged.baseUrl ?? DEFAULT_PAYMOS_BASE_URL,
|
|
167
|
+
environment: existingPublic.environment ?? merged.environment ?? "live"
|
|
168
|
+
};
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
meta: MODULE_META,
|
|
172
|
+
getMeta: () => MODULE_META,
|
|
173
|
+
defaults: MODULE_DEFAULTS
|
|
174
|
+
}
|
|
175
|
+
);
|
|
176
|
+
var module_default = paymosNuxtModule;
|
|
177
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
178
|
+
0 && (module.exports = {
|
|
179
|
+
DEFAULT_PAYMOS_BASE_URL,
|
|
180
|
+
Paymos,
|
|
181
|
+
WebhookVerifier,
|
|
182
|
+
createPaymosCheckout,
|
|
183
|
+
parsePaymosNuxtWebhook,
|
|
184
|
+
usePaymosServerClient,
|
|
185
|
+
verifyPaymosNuxtWebhook
|
|
186
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export { CheckoutResult, CreateCheckoutInput, DEFAULT_PAYMOS_BASE_URL, PaymosServerConfig, PaymosWebhookHeaders, createPaymosCheckout, parsePaymosNuxtWebhook, usePaymosServerClient, verifyPaymosNuxtWebhook } from './server.cjs';
|
|
2
|
+
export { Invoice, NetworkCode, Paymos, WebhookEvent, WebhookVerifier } from '@paymos/sdk';
|
|
3
|
+
|
|
4
|
+
interface PaymosNuxtModuleOptions {
|
|
5
|
+
/** Paymos Merchant API key (overrideable at runtime via NUXT_PAYMOS_API_KEY) */
|
|
6
|
+
apiKey?: string;
|
|
7
|
+
/** Paymos Merchant API secret (overrideable at runtime via NUXT_PAYMOS_API_SECRET) */
|
|
8
|
+
apiSecret?: string;
|
|
9
|
+
/** Default Paymos Project ID (overrideable via NUXT_PAYMOS_PROJECT_ID) */
|
|
10
|
+
projectId?: string;
|
|
11
|
+
/** Paymos webhook signing secret (overrideable via NUXT_PAYMOS_WEBHOOK_SECRET) */
|
|
12
|
+
webhookSecret?: string;
|
|
13
|
+
/** Paymos API base URL (defaults to https://api.paymos.io) */
|
|
14
|
+
baseUrl?: string;
|
|
15
|
+
/** Target environment exposed to public runtimeConfig */
|
|
16
|
+
environment?: "live" | "sandbox";
|
|
17
|
+
}
|
|
18
|
+
interface NuxtLike {
|
|
19
|
+
options: {
|
|
20
|
+
runtimeConfig: {
|
|
21
|
+
paymos?: Record<string, unknown>;
|
|
22
|
+
public: {
|
|
23
|
+
paymos?: Record<string, unknown>;
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
};
|
|
26
|
+
[key: string]: unknown;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
interface NuxtModuleMeta {
|
|
31
|
+
name: string;
|
|
32
|
+
configKey: string;
|
|
33
|
+
compatibility: {
|
|
34
|
+
nuxt: string;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
interface PaymosNuxtModule {
|
|
38
|
+
(inlineOptions: Partial<PaymosNuxtModuleOptions>, nuxt: NuxtLike): void;
|
|
39
|
+
meta: NuxtModuleMeta;
|
|
40
|
+
getMeta: () => NuxtModuleMeta;
|
|
41
|
+
defaults: Required<Pick<PaymosNuxtModuleOptions, "baseUrl" | "environment">> & PaymosNuxtModuleOptions;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Official Nuxt 3 / Nuxt 4 module for Paymos non-custodial stablecoin payments.
|
|
45
|
+
*
|
|
46
|
+
* Registers private server runtimeConfig (`runtimeConfig.paymos`) and safe public
|
|
47
|
+
* runtimeConfig (`runtimeConfig.public.paymos`) without leaking secrets to the client bundle.
|
|
48
|
+
*/
|
|
49
|
+
declare const paymosNuxtModule: PaymosNuxtModule;
|
|
50
|
+
|
|
51
|
+
export { type NuxtLike, type NuxtModuleMeta, type PaymosNuxtModule, type PaymosNuxtModuleOptions, paymosNuxtModule as default };
|
package/dist/module.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export { CheckoutResult, CreateCheckoutInput, DEFAULT_PAYMOS_BASE_URL, PaymosServerConfig, PaymosWebhookHeaders, createPaymosCheckout, parsePaymosNuxtWebhook, usePaymosServerClient, verifyPaymosNuxtWebhook } from './server.js';
|
|
2
|
+
export { Invoice, NetworkCode, Paymos, WebhookEvent, WebhookVerifier } from '@paymos/sdk';
|
|
3
|
+
|
|
4
|
+
interface PaymosNuxtModuleOptions {
|
|
5
|
+
/** Paymos Merchant API key (overrideable at runtime via NUXT_PAYMOS_API_KEY) */
|
|
6
|
+
apiKey?: string;
|
|
7
|
+
/** Paymos Merchant API secret (overrideable at runtime via NUXT_PAYMOS_API_SECRET) */
|
|
8
|
+
apiSecret?: string;
|
|
9
|
+
/** Default Paymos Project ID (overrideable via NUXT_PAYMOS_PROJECT_ID) */
|
|
10
|
+
projectId?: string;
|
|
11
|
+
/** Paymos webhook signing secret (overrideable via NUXT_PAYMOS_WEBHOOK_SECRET) */
|
|
12
|
+
webhookSecret?: string;
|
|
13
|
+
/** Paymos API base URL (defaults to https://api.paymos.io) */
|
|
14
|
+
baseUrl?: string;
|
|
15
|
+
/** Target environment exposed to public runtimeConfig */
|
|
16
|
+
environment?: "live" | "sandbox";
|
|
17
|
+
}
|
|
18
|
+
interface NuxtLike {
|
|
19
|
+
options: {
|
|
20
|
+
runtimeConfig: {
|
|
21
|
+
paymos?: Record<string, unknown>;
|
|
22
|
+
public: {
|
|
23
|
+
paymos?: Record<string, unknown>;
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
};
|
|
26
|
+
[key: string]: unknown;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
interface NuxtModuleMeta {
|
|
31
|
+
name: string;
|
|
32
|
+
configKey: string;
|
|
33
|
+
compatibility: {
|
|
34
|
+
nuxt: string;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
interface PaymosNuxtModule {
|
|
38
|
+
(inlineOptions: Partial<PaymosNuxtModuleOptions>, nuxt: NuxtLike): void;
|
|
39
|
+
meta: NuxtModuleMeta;
|
|
40
|
+
getMeta: () => NuxtModuleMeta;
|
|
41
|
+
defaults: Required<Pick<PaymosNuxtModuleOptions, "baseUrl" | "environment">> & PaymosNuxtModuleOptions;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Official Nuxt 3 / Nuxt 4 module for Paymos non-custodial stablecoin payments.
|
|
45
|
+
*
|
|
46
|
+
* Registers private server runtimeConfig (`runtimeConfig.paymos`) and safe public
|
|
47
|
+
* runtimeConfig (`runtimeConfig.public.paymos`) without leaking secrets to the client bundle.
|
|
48
|
+
*/
|
|
49
|
+
declare const paymosNuxtModule: PaymosNuxtModule;
|
|
50
|
+
|
|
51
|
+
export { type NuxtLike, type NuxtModuleMeta, type PaymosNuxtModule, type PaymosNuxtModuleOptions, paymosNuxtModule as default };
|
package/dist/module.mjs
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_PAYMOS_BASE_URL,
|
|
3
|
+
Paymos,
|
|
4
|
+
WebhookVerifier,
|
|
5
|
+
createPaymosCheckout,
|
|
6
|
+
parsePaymosNuxtWebhook,
|
|
7
|
+
usePaymosServerClient,
|
|
8
|
+
verifyPaymosNuxtWebhook
|
|
9
|
+
} from "./chunk-AOJYF56M.mjs";
|
|
10
|
+
|
|
11
|
+
// src/module.ts
|
|
12
|
+
var MODULE_META = {
|
|
13
|
+
name: "@paymos/nuxt",
|
|
14
|
+
configKey: "paymos",
|
|
15
|
+
compatibility: {
|
|
16
|
+
nuxt: ">=3.0.0"
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
var MODULE_DEFAULTS = {
|
|
20
|
+
apiKey: "",
|
|
21
|
+
apiSecret: "",
|
|
22
|
+
projectId: "",
|
|
23
|
+
webhookSecret: "",
|
|
24
|
+
baseUrl: DEFAULT_PAYMOS_BASE_URL,
|
|
25
|
+
environment: "live"
|
|
26
|
+
};
|
|
27
|
+
var paymosNuxtModule = Object.assign(
|
|
28
|
+
function setupPaymosNuxtModule(inlineOptions = {}, nuxt) {
|
|
29
|
+
const merged = {
|
|
30
|
+
...MODULE_DEFAULTS,
|
|
31
|
+
...inlineOptions
|
|
32
|
+
};
|
|
33
|
+
const existingPrivate = nuxt.options.runtimeConfig.paymos ?? {};
|
|
34
|
+
const existingPublic = nuxt.options.runtimeConfig.public.paymos ?? {};
|
|
35
|
+
nuxt.options.runtimeConfig.paymos = {
|
|
36
|
+
apiKey: existingPrivate.apiKey ?? merged.apiKey ?? "",
|
|
37
|
+
apiSecret: existingPrivate.apiSecret ?? merged.apiSecret ?? "",
|
|
38
|
+
projectId: existingPrivate.projectId ?? merged.projectId ?? "",
|
|
39
|
+
webhookSecret: existingPrivate.webhookSecret ?? merged.webhookSecret ?? "",
|
|
40
|
+
baseUrl: existingPrivate.baseUrl ?? merged.baseUrl ?? DEFAULT_PAYMOS_BASE_URL
|
|
41
|
+
};
|
|
42
|
+
nuxt.options.runtimeConfig.public.paymos = {
|
|
43
|
+
baseUrl: existingPublic.baseUrl ?? merged.baseUrl ?? DEFAULT_PAYMOS_BASE_URL,
|
|
44
|
+
environment: existingPublic.environment ?? merged.environment ?? "live"
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
meta: MODULE_META,
|
|
49
|
+
getMeta: () => MODULE_META,
|
|
50
|
+
defaults: MODULE_DEFAULTS
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
var module_default = paymosNuxtModule;
|
|
54
|
+
export {
|
|
55
|
+
DEFAULT_PAYMOS_BASE_URL,
|
|
56
|
+
Paymos,
|
|
57
|
+
WebhookVerifier,
|
|
58
|
+
createPaymosCheckout,
|
|
59
|
+
module_default as default,
|
|
60
|
+
parsePaymosNuxtWebhook,
|
|
61
|
+
usePaymosServerClient,
|
|
62
|
+
verifyPaymosNuxtWebhook
|
|
63
|
+
};
|
package/dist/server.cjs
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/server.ts
|
|
21
|
+
var server_exports = {};
|
|
22
|
+
__export(server_exports, {
|
|
23
|
+
DEFAULT_PAYMOS_BASE_URL: () => DEFAULT_PAYMOS_BASE_URL,
|
|
24
|
+
Paymos: () => import_sdk.Paymos,
|
|
25
|
+
WebhookVerifier: () => import_sdk.WebhookVerifier,
|
|
26
|
+
createPaymosCheckout: () => createPaymosCheckout,
|
|
27
|
+
parsePaymosNuxtWebhook: () => parsePaymosNuxtWebhook,
|
|
28
|
+
usePaymosServerClient: () => usePaymosServerClient,
|
|
29
|
+
verifyPaymosNuxtWebhook: () => verifyPaymosNuxtWebhook
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(server_exports);
|
|
32
|
+
var import_sdk = require("@paymos/sdk");
|
|
33
|
+
var DEFAULT_PAYMOS_BASE_URL = "https://api.paymos.io";
|
|
34
|
+
function firstHeader(value) {
|
|
35
|
+
if (Array.isArray(value)) {
|
|
36
|
+
return value[0] ?? "";
|
|
37
|
+
}
|
|
38
|
+
return value ?? "";
|
|
39
|
+
}
|
|
40
|
+
function resolveEnvConfig(overrides) {
|
|
41
|
+
const apiKey = (overrides?.apiKey ?? process.env.NUXT_PAYMOS_API_KEY ?? process.env.PAYMOS_API_KEY ?? "").trim();
|
|
42
|
+
const apiSecret = (overrides?.apiSecret ?? process.env.NUXT_PAYMOS_API_SECRET ?? process.env.PAYMOS_API_SECRET ?? "").trim();
|
|
43
|
+
const projectId = (overrides?.projectId ?? process.env.NUXT_PAYMOS_PROJECT_ID ?? process.env.PAYMOS_PROJECT_ID ?? "").trim();
|
|
44
|
+
const webhookSecret = (overrides?.webhookSecret ?? process.env.NUXT_PAYMOS_WEBHOOK_SECRET ?? process.env.PAYMOS_WEBHOOK_SECRET ?? "").trim();
|
|
45
|
+
const baseUrl = (overrides?.baseUrl ?? process.env.NUXT_PAYMOS_BASE_URL ?? process.env.PAYMOS_BASE_URL ?? DEFAULT_PAYMOS_BASE_URL).trim().replace(/\/+$/, "");
|
|
46
|
+
if (!apiKey || !apiSecret) {
|
|
47
|
+
throw new Error(
|
|
48
|
+
"Paymos Nuxt module requires apiKey and apiSecret (via runtimeConfig.paymos or NUXT_PAYMOS_API_KEY / NUXT_PAYMOS_API_SECRET)."
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
apiKey,
|
|
53
|
+
apiSecret,
|
|
54
|
+
projectId: projectId || void 0,
|
|
55
|
+
webhookSecret: webhookSecret || void 0,
|
|
56
|
+
baseUrl: baseUrl || DEFAULT_PAYMOS_BASE_URL,
|
|
57
|
+
timeoutMs: overrides?.timeoutMs
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function usePaymosServerClient(config) {
|
|
61
|
+
const resolved = resolveEnvConfig(config);
|
|
62
|
+
return new import_sdk.Paymos({
|
|
63
|
+
apiKey: resolved.apiKey,
|
|
64
|
+
apiSecret: resolved.apiSecret,
|
|
65
|
+
baseUrl: resolved.baseUrl,
|
|
66
|
+
timeoutMs: resolved.timeoutMs
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
async function createPaymosCheckout(input, config, clientOverride) {
|
|
70
|
+
const projectId = (input.projectId ?? config?.projectId ?? process.env.NUXT_PAYMOS_PROJECT_ID ?? process.env.PAYMOS_PROJECT_ID ?? "").trim();
|
|
71
|
+
if (!projectId) {
|
|
72
|
+
throw new Error("Paymos createPaymosCheckout requires projectId (via input, runtimeConfig.paymos.projectId, or NUXT_PAYMOS_PROJECT_ID).");
|
|
73
|
+
}
|
|
74
|
+
const client = clientOverride ?? usePaymosServerClient(config);
|
|
75
|
+
const currency = (input.currency ?? "USD").trim().toUpperCase();
|
|
76
|
+
const extId = input.externalOrderId?.trim() || (0, import_sdk.externalOrderId)("nuxt");
|
|
77
|
+
const invoice = await client.invoices.create({
|
|
78
|
+
projectId,
|
|
79
|
+
amount: input.amount,
|
|
80
|
+
currency,
|
|
81
|
+
externalOrderId: extId,
|
|
82
|
+
network: input.network ?? void 0,
|
|
83
|
+
customerFeePercent: input.customerFeePercent ?? void 0,
|
|
84
|
+
clientId: input.clientId ?? void 0
|
|
85
|
+
});
|
|
86
|
+
if (!invoice.invoiceId || !invoice.paymentUrl) {
|
|
87
|
+
throw new Error("Paymos invoices.create returned incomplete checkout response (missing invoiceId or paymentUrl).");
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
invoiceId: invoice.invoiceId,
|
|
91
|
+
paymentUrl: invoice.paymentUrl,
|
|
92
|
+
status: invoice.status,
|
|
93
|
+
amount: invoice.order?.amount ?? input.amount,
|
|
94
|
+
currency: invoice.order?.currency ?? currency
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function extractWebhookSignatureHeader(headers) {
|
|
98
|
+
for (const [k, v] of Object.entries(headers)) {
|
|
99
|
+
const lower = k.toLowerCase();
|
|
100
|
+
if (lower === "x-webhook-signature" || lower === "x-paymos-signature") {
|
|
101
|
+
const val = firstHeader(v).trim();
|
|
102
|
+
if (val) {
|
|
103
|
+
return val;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return "";
|
|
108
|
+
}
|
|
109
|
+
function verifyPaymosNuxtWebhook(rawBody, headers, webhookSecret, toleranceSeconds) {
|
|
110
|
+
const secret = (webhookSecret ?? process.env.NUXT_PAYMOS_WEBHOOK_SECRET ?? process.env.PAYMOS_WEBHOOK_SECRET ?? "").trim();
|
|
111
|
+
if (!secret) {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
const signatureHeader = extractWebhookSignatureHeader(headers);
|
|
115
|
+
if (!signatureHeader) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
const verifier = new import_sdk.WebhookVerifier(secret, toleranceSeconds);
|
|
119
|
+
return verifier.verify(signatureHeader, rawBody);
|
|
120
|
+
}
|
|
121
|
+
function parsePaymosNuxtWebhook(rawBody, headers, webhookSecret, toleranceSeconds) {
|
|
122
|
+
const secret = (webhookSecret ?? process.env.NUXT_PAYMOS_WEBHOOK_SECRET ?? process.env.PAYMOS_WEBHOOK_SECRET ?? "").trim();
|
|
123
|
+
if (!secret) {
|
|
124
|
+
throw new Error("Paymos webhook secret is not configured.");
|
|
125
|
+
}
|
|
126
|
+
const signatureHeader = extractWebhookSignatureHeader(headers);
|
|
127
|
+
const verifier = new import_sdk.WebhookVerifier(secret, toleranceSeconds);
|
|
128
|
+
return verifier.constructEvent(signatureHeader, rawBody);
|
|
129
|
+
}
|
|
130
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
131
|
+
0 && (module.exports = {
|
|
132
|
+
DEFAULT_PAYMOS_BASE_URL,
|
|
133
|
+
Paymos,
|
|
134
|
+
WebhookVerifier,
|
|
135
|
+
createPaymosCheckout,
|
|
136
|
+
parsePaymosNuxtWebhook,
|
|
137
|
+
usePaymosServerClient,
|
|
138
|
+
verifyPaymosNuxtWebhook
|
|
139
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { NetworkCode, CreateInvoiceParams, Invoice, WebhookEvent, Paymos } from '@paymos/sdk';
|
|
2
|
+
export { Invoice, NetworkCode, Paymos, WebhookEvent, WebhookVerifier } from '@paymos/sdk';
|
|
3
|
+
|
|
4
|
+
interface PaymosServerConfig {
|
|
5
|
+
/** Paymos Merchant API key (e.g. pm_live_... or pm_test_...) */
|
|
6
|
+
apiKey: string;
|
|
7
|
+
/** Paymos Merchant API secret */
|
|
8
|
+
apiSecret: string;
|
|
9
|
+
/** Paymos Project ID (UUID) used as default for invoice creation */
|
|
10
|
+
projectId?: string;
|
|
11
|
+
/** Paymos webhook signing secret (whsec_...) for X-Paymos-Signature verification */
|
|
12
|
+
webhookSecret?: string;
|
|
13
|
+
/** Optional API base URL (defaults to https://api.paymos.io) */
|
|
14
|
+
baseUrl?: string;
|
|
15
|
+
/** Optional request timeout in milliseconds */
|
|
16
|
+
timeoutMs?: number;
|
|
17
|
+
}
|
|
18
|
+
interface PaymosWebhookHeaders {
|
|
19
|
+
"x-webhook-signature"?: string | string[];
|
|
20
|
+
"x-paymos-signature"?: string | string[];
|
|
21
|
+
[key: string]: string | string[] | undefined;
|
|
22
|
+
}
|
|
23
|
+
interface CreateCheckoutInput {
|
|
24
|
+
projectId?: string;
|
|
25
|
+
amount: string;
|
|
26
|
+
currency?: string;
|
|
27
|
+
externalOrderId?: string;
|
|
28
|
+
network?: NetworkCode | null;
|
|
29
|
+
customerFeePercent?: number | null;
|
|
30
|
+
clientId?: string | null;
|
|
31
|
+
}
|
|
32
|
+
interface CheckoutResult {
|
|
33
|
+
invoiceId: string;
|
|
34
|
+
paymentUrl: string;
|
|
35
|
+
status: string;
|
|
36
|
+
amount: string;
|
|
37
|
+
currency: string;
|
|
38
|
+
}
|
|
39
|
+
interface PaymosInvoicesLike {
|
|
40
|
+
create(params: CreateInvoiceParams): Promise<Invoice>;
|
|
41
|
+
get(invoiceId: string): Promise<Invoice>;
|
|
42
|
+
}
|
|
43
|
+
declare const DEFAULT_PAYMOS_BASE_URL = "https://api.paymos.io";
|
|
44
|
+
/**
|
|
45
|
+
* Create a typed Paymos SDK client for use inside Nuxt / Nitro server routes.
|
|
46
|
+
*/
|
|
47
|
+
declare function usePaymosServerClient(config?: Partial<PaymosServerConfig>): Paymos;
|
|
48
|
+
/**
|
|
49
|
+
* Create a hosted Paymos stablecoin checkout invoice and return canonical wire fields.
|
|
50
|
+
*/
|
|
51
|
+
declare function createPaymosCheckout(input: CreateCheckoutInput, config?: Partial<PaymosServerConfig>, clientOverride?: {
|
|
52
|
+
invoices: Pick<PaymosInvoicesLike, "create">;
|
|
53
|
+
}): Promise<CheckoutResult>;
|
|
54
|
+
/**
|
|
55
|
+
* Verify an incoming Paymos webhook request from raw body and headers using `WebhookVerifier`.
|
|
56
|
+
*/
|
|
57
|
+
declare function verifyPaymosNuxtWebhook(rawBody: string | Buffer, headers: PaymosWebhookHeaders, webhookSecret?: string, toleranceSeconds?: number): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Verify and parse a typed Paymos webhook event in Nitro handlers.
|
|
60
|
+
*/
|
|
61
|
+
declare function parsePaymosNuxtWebhook<T = unknown>(rawBody: string | Buffer, headers: PaymosWebhookHeaders, webhookSecret?: string, toleranceSeconds?: number): WebhookEvent<T>;
|
|
62
|
+
|
|
63
|
+
export { type CheckoutResult, type CreateCheckoutInput, DEFAULT_PAYMOS_BASE_URL, type PaymosInvoicesLike, type PaymosServerConfig, type PaymosWebhookHeaders, createPaymosCheckout, parsePaymosNuxtWebhook, usePaymosServerClient, verifyPaymosNuxtWebhook };
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { NetworkCode, CreateInvoiceParams, Invoice, WebhookEvent, Paymos } from '@paymos/sdk';
|
|
2
|
+
export { Invoice, NetworkCode, Paymos, WebhookEvent, WebhookVerifier } from '@paymos/sdk';
|
|
3
|
+
|
|
4
|
+
interface PaymosServerConfig {
|
|
5
|
+
/** Paymos Merchant API key (e.g. pm_live_... or pm_test_...) */
|
|
6
|
+
apiKey: string;
|
|
7
|
+
/** Paymos Merchant API secret */
|
|
8
|
+
apiSecret: string;
|
|
9
|
+
/** Paymos Project ID (UUID) used as default for invoice creation */
|
|
10
|
+
projectId?: string;
|
|
11
|
+
/** Paymos webhook signing secret (whsec_...) for X-Paymos-Signature verification */
|
|
12
|
+
webhookSecret?: string;
|
|
13
|
+
/** Optional API base URL (defaults to https://api.paymos.io) */
|
|
14
|
+
baseUrl?: string;
|
|
15
|
+
/** Optional request timeout in milliseconds */
|
|
16
|
+
timeoutMs?: number;
|
|
17
|
+
}
|
|
18
|
+
interface PaymosWebhookHeaders {
|
|
19
|
+
"x-webhook-signature"?: string | string[];
|
|
20
|
+
"x-paymos-signature"?: string | string[];
|
|
21
|
+
[key: string]: string | string[] | undefined;
|
|
22
|
+
}
|
|
23
|
+
interface CreateCheckoutInput {
|
|
24
|
+
projectId?: string;
|
|
25
|
+
amount: string;
|
|
26
|
+
currency?: string;
|
|
27
|
+
externalOrderId?: string;
|
|
28
|
+
network?: NetworkCode | null;
|
|
29
|
+
customerFeePercent?: number | null;
|
|
30
|
+
clientId?: string | null;
|
|
31
|
+
}
|
|
32
|
+
interface CheckoutResult {
|
|
33
|
+
invoiceId: string;
|
|
34
|
+
paymentUrl: string;
|
|
35
|
+
status: string;
|
|
36
|
+
amount: string;
|
|
37
|
+
currency: string;
|
|
38
|
+
}
|
|
39
|
+
interface PaymosInvoicesLike {
|
|
40
|
+
create(params: CreateInvoiceParams): Promise<Invoice>;
|
|
41
|
+
get(invoiceId: string): Promise<Invoice>;
|
|
42
|
+
}
|
|
43
|
+
declare const DEFAULT_PAYMOS_BASE_URL = "https://api.paymos.io";
|
|
44
|
+
/**
|
|
45
|
+
* Create a typed Paymos SDK client for use inside Nuxt / Nitro server routes.
|
|
46
|
+
*/
|
|
47
|
+
declare function usePaymosServerClient(config?: Partial<PaymosServerConfig>): Paymos;
|
|
48
|
+
/**
|
|
49
|
+
* Create a hosted Paymos stablecoin checkout invoice and return canonical wire fields.
|
|
50
|
+
*/
|
|
51
|
+
declare function createPaymosCheckout(input: CreateCheckoutInput, config?: Partial<PaymosServerConfig>, clientOverride?: {
|
|
52
|
+
invoices: Pick<PaymosInvoicesLike, "create">;
|
|
53
|
+
}): Promise<CheckoutResult>;
|
|
54
|
+
/**
|
|
55
|
+
* Verify an incoming Paymos webhook request from raw body and headers using `WebhookVerifier`.
|
|
56
|
+
*/
|
|
57
|
+
declare function verifyPaymosNuxtWebhook(rawBody: string | Buffer, headers: PaymosWebhookHeaders, webhookSecret?: string, toleranceSeconds?: number): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Verify and parse a typed Paymos webhook event in Nitro handlers.
|
|
60
|
+
*/
|
|
61
|
+
declare function parsePaymosNuxtWebhook<T = unknown>(rawBody: string | Buffer, headers: PaymosWebhookHeaders, webhookSecret?: string, toleranceSeconds?: number): WebhookEvent<T>;
|
|
62
|
+
|
|
63
|
+
export { type CheckoutResult, type CreateCheckoutInput, DEFAULT_PAYMOS_BASE_URL, type PaymosInvoicesLike, type PaymosServerConfig, type PaymosWebhookHeaders, createPaymosCheckout, parsePaymosNuxtWebhook, usePaymosServerClient, verifyPaymosNuxtWebhook };
|
package/dist/server.mjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_PAYMOS_BASE_URL,
|
|
3
|
+
Paymos,
|
|
4
|
+
WebhookVerifier,
|
|
5
|
+
createPaymosCheckout,
|
|
6
|
+
parsePaymosNuxtWebhook,
|
|
7
|
+
usePaymosServerClient,
|
|
8
|
+
verifyPaymosNuxtWebhook
|
|
9
|
+
} from "./chunk-AOJYF56M.mjs";
|
|
10
|
+
export {
|
|
11
|
+
DEFAULT_PAYMOS_BASE_URL,
|
|
12
|
+
Paymos,
|
|
13
|
+
WebhookVerifier,
|
|
14
|
+
createPaymosCheckout,
|
|
15
|
+
parsePaymosNuxtWebhook,
|
|
16
|
+
usePaymosServerClient,
|
|
17
|
+
verifyPaymosNuxtWebhook
|
|
18
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,84 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paymos/nuxt",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Official Paymos stablecoin payment integration for Nuxt (USDT, USDC, USD1, DAI, and XAUT across 13 networks).",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"nuxt",
|
|
7
|
+
"nuxt-module",
|
|
8
|
+
"nuxt3",
|
|
9
|
+
"nuxt4",
|
|
10
|
+
"paymos",
|
|
11
|
+
"stablecoins",
|
|
12
|
+
"usdt",
|
|
13
|
+
"usdc",
|
|
14
|
+
"crypto",
|
|
15
|
+
"payments",
|
|
16
|
+
"ecommerce"
|
|
17
|
+
],
|
|
18
|
+
"homepage": "https://paymos.io",
|
|
19
|
+
"bugs": "https://github.com/Paymos-labs/nuxt-paymos/issues",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/Paymos-labs/nuxt-paymos.git"
|
|
23
|
+
},
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"author": "Paymos Labs <support@paymos.io>",
|
|
26
|
+
"type": "module",
|
|
27
|
+
"main": "./dist/module.cjs",
|
|
28
|
+
"module": "./dist/module.mjs",
|
|
29
|
+
"types": "./dist/module.d.ts",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"import": {
|
|
33
|
+
"types": "./dist/module.d.ts",
|
|
34
|
+
"default": "./dist/module.mjs"
|
|
35
|
+
},
|
|
36
|
+
"require": {
|
|
37
|
+
"types": "./dist/module.d.cts",
|
|
38
|
+
"default": "./dist/module.cjs"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"./server": {
|
|
42
|
+
"import": {
|
|
43
|
+
"types": "./dist/server.d.ts",
|
|
44
|
+
"default": "./dist/server.mjs"
|
|
45
|
+
},
|
|
46
|
+
"require": {
|
|
47
|
+
"types": "./dist/server.d.cts",
|
|
48
|
+
"default": "./dist/server.cjs"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"./package.json": "./package.json"
|
|
52
|
+
},
|
|
53
|
+
"files": [
|
|
54
|
+
"dist",
|
|
55
|
+
"README.md",
|
|
56
|
+
"LICENSE",
|
|
57
|
+
"CHANGELOG.md"
|
|
58
|
+
],
|
|
59
|
+
"sideEffects": false,
|
|
60
|
+
"engines": {
|
|
61
|
+
"node": ">=20.0.0"
|
|
62
|
+
},
|
|
63
|
+
"scripts": {
|
|
64
|
+
"build": "tsup",
|
|
65
|
+
"check": "tsc --noEmit",
|
|
66
|
+
"test": "vitest run",
|
|
67
|
+
"prepack": "npm run check && npm run build && npm test"
|
|
68
|
+
},
|
|
69
|
+
"dependencies": {
|
|
70
|
+
"@paymos/sdk": "^2.7.1"
|
|
71
|
+
},
|
|
72
|
+
"peerDependencies": {
|
|
73
|
+
"nuxt": ">=3.0.0"
|
|
74
|
+
},
|
|
75
|
+
"devDependencies": {
|
|
76
|
+
"@types/node": "^22.10.0",
|
|
77
|
+
"tsup": "^8.5.0",
|
|
78
|
+
"typescript": "^5.8.0",
|
|
79
|
+
"vitest": "^3.2.4"
|
|
80
|
+
},
|
|
81
|
+
"publishConfig": {
|
|
82
|
+
"access": "public"
|
|
83
|
+
}
|
|
84
|
+
}
|