@meddleware/chain-payments-kit 0.0.0-rename.0 → 0.0.1
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 +19 -0
- package/LICENSE +14 -0
- package/README.md +19 -0
- package/SECURITY.md +29 -0
- package/package.json +85 -1
- package/src/ChainCheckout.vue +324 -0
- package/src/env.d.ts +7 -0
- package/src/index.ts +6 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.0.1 — 2026-11-17 (first npm release)
|
|
4
|
+
|
|
5
|
+
After the first pass of the security audit:
|
|
6
|
+
|
|
7
|
+
- Built and tested against `@meddleware/chain-payments-client` 0.0.1 from npm (no longer a sibling folder, FU-0129).
|
|
8
|
+
- The platform fee row stacks its label over the amount, so it reflows at 320 CSS pixels.
|
|
9
|
+
- `suiClient` (required): the checkout reads the platform fee from the chain (`readPlatformFee`) when it shows a quote
|
|
10
|
+
and again just before the wallet opens. It shows "Platform fee (included)" with the amount and treasury, and signs
|
|
11
|
+
nothing if the fee cannot be read.
|
|
12
|
+
- A payment that arrives for a checkout already paid or closed (`unapplied`) is shown as such: it bought nothing here,
|
|
13
|
+
the seller has been told, and `failed` is emitted with `unapplied`.
|
|
14
|
+
- The quote shows the network the payment is on ("Network: Sui testnet.") before the wallet is asked to sign.
|
|
15
|
+
|
|
16
|
+
First built 2026-11-16:
|
|
17
|
+
|
|
18
|
+
- First release: `ChainCheckout` (choose a coin, exact quote with a countdown and re-quote, pay through the host's wallet,
|
|
19
|
+
follow to confirmation), its gallery and the AAA accessibility sweep.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
BSD Zero Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MeddleWare
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted.
|
|
7
|
+
|
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
9
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
10
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
11
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
12
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
13
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
|
+
PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# @meddleware/chain-payments-kit
|
|
2
|
+
|
|
3
|
+
A Vue checkout for [Chain Payments](https://github.com/meddleware-org/chain-payments-service): exact crypto prices, paid
|
|
4
|
+
from the buyer's own wallet, followed to on-chain confirmation.
|
|
5
|
+
|
|
6
|
+
```vue
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
import { ChainCheckout } from '@meddleware/chain-payments-kit'
|
|
9
|
+
import { createToolWallet } from '@meddleware/wallet-adapter'
|
|
10
|
+
const { signAndExecute, getSuiClient } = createToolWallet()
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<template>
|
|
14
|
+
<ChainCheckout :session-id="id" base-url="https://chain-payments.example.org" :sui-client="getSuiClient()" :sign-and-execute="signAndExecute" @paid="done" />
|
|
15
|
+
</template>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
The merchant's backend creates the session (merchant API); the component needs only its id. Peer dependencies:
|
|
19
|
+
`@meddleware/chain-payments-client`, `@meddleware/ui`, `@meddleware/design-tokens`, `vue`. Licence: [0BSD](LICENSE).
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Scope
|
|
4
|
+
|
|
5
|
+
`@meddleware/chain-payments-kit` (`ChainCheckout`), from this repository's `main` and its npm releases. Out of scope: the
|
|
6
|
+
host application and its wallet connection, the Chain Payments service, SDK and Move package (their own policies).
|
|
7
|
+
|
|
8
|
+
## Security model
|
|
9
|
+
|
|
10
|
+
- The component holds no keys and builds no transaction itself: the chain module of `@meddleware/chain-payments-client`
|
|
11
|
+
builds it from a quote the service signed, and the host's `signAndExecute` signs it. The Move package verifies the
|
|
12
|
+
quote, so a tampered display cannot change what is paid.
|
|
13
|
+
- Before the wallet is asked to sign, the checkout shows the exact amount, how long the price is held and the network.
|
|
14
|
+
The host must connect the wallet to that network; the component cannot see the wallet.
|
|
15
|
+
- Session text (the merchant's description) is rendered as text, never as HTML. Nothing is stored in the browser.
|
|
16
|
+
|
|
17
|
+
## Supported versions
|
|
18
|
+
|
|
19
|
+
The latest npm release. Older releases are not patched.
|
|
20
|
+
|
|
21
|
+
## Reporting a vulnerability
|
|
22
|
+
|
|
23
|
+
Use GitHub's private vulnerability reporting on this repository. Please do not open a public issue. Expect an
|
|
24
|
+
acknowledgement within a week.
|
|
25
|
+
|
|
26
|
+
## Disclosure
|
|
27
|
+
|
|
28
|
+
Coordinated: a fixed release is published first; the report and the fix are then described in `CHANGELOG.md` and the
|
|
29
|
+
audit's re-verification log.
|
package/package.json
CHANGED
|
@@ -1 +1,85 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"name": "@meddleware/chain-payments-kit",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Vue checkout for Chain Payments: shows the exact price, builds the payment through the chain modules, follows it to confirmation.",
|
|
5
|
+
"license": "0BSD",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/meddleware-org/chain-payments-kit.git"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"sideEffects": [
|
|
12
|
+
"*.css",
|
|
13
|
+
"*.vue"
|
|
14
|
+
],
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./src/index.ts",
|
|
18
|
+
"default": "./src/index.ts"
|
|
19
|
+
},
|
|
20
|
+
"./package.json": "./package.json"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"src",
|
|
24
|
+
"CHANGELOG.md",
|
|
25
|
+
"SECURITY.md"
|
|
26
|
+
],
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"browserslist": [
|
|
31
|
+
"extends @meddleware/frontend-config/browserslist-config"
|
|
32
|
+
],
|
|
33
|
+
"scripts": {
|
|
34
|
+
"type-check": "vue-tsc --noEmit",
|
|
35
|
+
"test": "vitest run",
|
|
36
|
+
"lint:css": "stylelint \"src/**/*.{css,vue}\"",
|
|
37
|
+
"lint:js": "eslint .",
|
|
38
|
+
"lint:html": "html-validate \"src/**/*.vue\"",
|
|
39
|
+
"lint": "npm run lint:css && npm run lint:js && npm run lint:html",
|
|
40
|
+
"build:gallery": "vite build --config vite.gallery.config.ts",
|
|
41
|
+
"test:e2e": "playwright test",
|
|
42
|
+
"shots": "SHOTS=1 playwright test"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"@meddleware/chain-payments-client": "^0.0.1",
|
|
46
|
+
"@meddleware/design-tokens": "^0.1.13",
|
|
47
|
+
"@meddleware/ui": "^0.1.43",
|
|
48
|
+
"vue": "^3.5.0"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@meddleware/chain-payments-client": "0.0.1",
|
|
52
|
+
"@meddleware/design-tokens": "^0.1.13",
|
|
53
|
+
"@meddleware/frontend-config": "^0.0.10",
|
|
54
|
+
"@meddleware/ui": "^0.1.43",
|
|
55
|
+
"@mysten/sui": "^2.39.1",
|
|
56
|
+
"@playwright/test": "~1.64.1",
|
|
57
|
+
"@types/node": "~26.6.5",
|
|
58
|
+
"@vitejs/plugin-vue": "^6.0.10",
|
|
59
|
+
"@vue/eslint-config-typescript": "^14.9.0",
|
|
60
|
+
"@vue/test-utils": "^2.5.1",
|
|
61
|
+
"autoprefixer": "^10.6.2",
|
|
62
|
+
"eslint": "^10.14.0",
|
|
63
|
+
"eslint-plugin-vue": "^10.12.0",
|
|
64
|
+
"eslint-plugin-vuejs-accessibility": "^2.6.2",
|
|
65
|
+
"html-validate": "^11.18.0",
|
|
66
|
+
"html-validate-vue": "^9.3.1",
|
|
67
|
+
"jiti": "^2.7.0",
|
|
68
|
+
"jsdom": "^30.1.3",
|
|
69
|
+
"postcss": "^8.5.32",
|
|
70
|
+
"postcss-html": "^2.0.0",
|
|
71
|
+
"stylelint": "^17.16.0",
|
|
72
|
+
"stylelint-config-standard": "^40.0.0",
|
|
73
|
+
"typescript": "~6.0.0",
|
|
74
|
+
"vite": "^8.3.4",
|
|
75
|
+
"vitest": "~5.1.0",
|
|
76
|
+
"vue": "^3.5.44",
|
|
77
|
+
"vue-eslint-parser": "^10.4.1",
|
|
78
|
+
"vue-tsc": "~3.3.14"
|
|
79
|
+
},
|
|
80
|
+
"overrides": {
|
|
81
|
+
"basic-ftp": "^6.2.4",
|
|
82
|
+
"tmp": "^0.2.7",
|
|
83
|
+
"zod": "^4.6.7"
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
// Checkout for one Chain Payments session: choose a coin, see the exact amount (held for a short time), pay from the
|
|
3
|
+
// wallet the host app connects, then follow the payment to confirmation. The kit builds no transaction itself: the chain
|
|
4
|
+
// module from @meddleware/chain-payments-client does, and the host's `signAndExecute` signs it.
|
|
5
|
+
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
|
6
|
+
import { UiButton, UiNotice, UiSegmentedControl } from '@meddleware/ui'
|
|
7
|
+
import { ChainPaymentsError, createSessionClient, loadChain, supported } from '@meddleware/chain-payments-client'
|
|
8
|
+
import type { CheckoutSession, Quote, SessionClient } from '@meddleware/chain-payments-client'
|
|
9
|
+
import type { PlatformFee, SuiObjectReader } from '@meddleware/chain-payments-client/sui'
|
|
10
|
+
|
|
11
|
+
const props = defineProps<{
|
|
12
|
+
sessionId: string
|
|
13
|
+
/** The Chain Payments public origin. Ignored when `client` is given. */
|
|
14
|
+
baseUrl?: string
|
|
15
|
+
/** Signs and executes the chain module's transaction with the buyer's wallet; resolves with the digest. */
|
|
16
|
+
signAndExecute: (tx: unknown) => Promise<{ digest: string }>
|
|
17
|
+
/** Reads chain objects (the platform fee's terms) before signing: the wallet adapter's Sui client. */
|
|
18
|
+
suiClient: SuiObjectReader
|
|
19
|
+
/** Injected session client (tests and galleries). */
|
|
20
|
+
client?: SessionClient
|
|
21
|
+
/** Heading level of the checkout's title. */
|
|
22
|
+
level?: 2 | 3 | 4
|
|
23
|
+
}>()
|
|
24
|
+
|
|
25
|
+
const emit = defineEmits<{
|
|
26
|
+
paid: [{ digest: string; quote: Quote }]
|
|
27
|
+
failed: [reason: string]
|
|
28
|
+
}>()
|
|
29
|
+
|
|
30
|
+
type Step = 'loading' | 'choose' | 'quoting' | 'ready' | 'signing' | 'confirming' | 'paid' | 'rejected' | 'unapplied' | 'closed' | 'error'
|
|
31
|
+
|
|
32
|
+
const client = props.client ?? createSessionClient({ baseUrl: props.baseUrl ?? '' })
|
|
33
|
+
const step = ref<Step>('loading')
|
|
34
|
+
const session = ref<CheckoutSession | null>(null)
|
|
35
|
+
const method = ref('')
|
|
36
|
+
const quote = ref<Quote | null>(null)
|
|
37
|
+
const problem = ref('')
|
|
38
|
+
const fee = ref<PlatformFee | null>(null)
|
|
39
|
+
const now = ref(Date.now())
|
|
40
|
+
const announcement = ref('')
|
|
41
|
+
let timer: ReturnType<typeof setInterval> | undefined
|
|
42
|
+
|
|
43
|
+
const usable = computed(() => {
|
|
44
|
+
const m = session.value?.methods ?? []
|
|
45
|
+
const ok = supported(m)
|
|
46
|
+
return m.filter((_, i) => ok[i])
|
|
47
|
+
})
|
|
48
|
+
const options = computed(() => usable.value.map((m) => ({ id: m.id, label: m.symbol })))
|
|
49
|
+
const secondsLeft = computed(() => (quote.value ? Math.max(0, Math.floor((Number(quote.value.expiresMs) - now.value) / 1000)) : 0))
|
|
50
|
+
const countdown = computed(() => `${Math.floor(secondsLeft.value / 60)}:${String(secondsLeft.value % 60).padStart(2, '0')}`)
|
|
51
|
+
const expired = computed(() => step.value === 'ready' && secondsLeft.value === 0)
|
|
52
|
+
const headingTag = computed(() => `h${props.level ?? 2}`)
|
|
53
|
+
/** "Sui testnet": the network the wallet must be on, shown before it is asked to sign. */
|
|
54
|
+
const CHAIN_NAMES: Record<string, string> = { sui: 'Sui' }
|
|
55
|
+
const networkText = computed(() => {
|
|
56
|
+
const m = quote.value?.method
|
|
57
|
+
if (!m) return ''
|
|
58
|
+
return `${Object.hasOwn(CHAIN_NAMES, m.chain) ? CHAIN_NAMES[m.chain] : m.chain} ${m.network}`
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
/** A smallest-unit amount in whole coins, e.g. 11084426n with 9 decimals → "0.011084426". */
|
|
62
|
+
function coins(v: bigint, decimals: number): string {
|
|
63
|
+
const s = v.toString().padStart(decimals + 1, '0')
|
|
64
|
+
const whole = s.slice(0, s.length - decimals)
|
|
65
|
+
const frac = s.slice(s.length - decimals).replace(/0+$/, '')
|
|
66
|
+
return frac ? `${whole}.${frac}` : whole
|
|
67
|
+
}
|
|
68
|
+
const feeText = computed(() => {
|
|
69
|
+
const q = quote.value
|
|
70
|
+
return q && fee.value ? `${coins(fee.value.fee, q.method.decimals)} ${q.method.symbol}` : ''
|
|
71
|
+
})
|
|
72
|
+
const treasuryText = computed(() => (fee.value ? `${fee.value.treasury.slice(0, 6)}…${fee.value.treasury.slice(-4)}` : ''))
|
|
73
|
+
|
|
74
|
+
/** The platform fee of a quote, read from the chain (Sui methods). */
|
|
75
|
+
async function readFee(q: Quote): Promise<PlatformFee | null> {
|
|
76
|
+
if (q.method.chain !== 'sui') return null
|
|
77
|
+
const { readPlatformFee } = await import('@meddleware/chain-payments-client/sui')
|
|
78
|
+
return readPlatformFee(props.suiClient, q)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** "1 minute 59 seconds" for a screen reader. */
|
|
82
|
+
function spoken(total: number): string {
|
|
83
|
+
const m = Math.floor(total / 60)
|
|
84
|
+
const s = total % 60
|
|
85
|
+
const part = (n: number, unit: string) => `${n} ${unit}${n === 1 ? '' : 's'}`
|
|
86
|
+
return [m ? part(m, 'minute') : '', s || !m ? part(s, 'second') : ''].filter(Boolean).join(' ')
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function message(e: unknown): string {
|
|
90
|
+
if (e instanceof ChainPaymentsError) return e.message
|
|
91
|
+
if (e instanceof Error && /reject|denied|cancel/i.test(e.message)) return 'The wallet did not sign the payment.'
|
|
92
|
+
return e instanceof Error ? e.message : 'Something went wrong.'
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async function load() {
|
|
96
|
+
step.value = 'loading'
|
|
97
|
+
try {
|
|
98
|
+
session.value = await client.getSession(props.sessionId)
|
|
99
|
+
if (session.value.status !== 'open') {
|
|
100
|
+
step.value = session.value.status === 'paid' ? 'paid' : 'closed'
|
|
101
|
+
return
|
|
102
|
+
}
|
|
103
|
+
if (!usable.value.length) {
|
|
104
|
+
problem.value = 'This checkout offers no payment method this page can use.'
|
|
105
|
+
step.value = 'error'
|
|
106
|
+
return
|
|
107
|
+
}
|
|
108
|
+
method.value = usable.value[0]!.id
|
|
109
|
+
step.value = 'choose'
|
|
110
|
+
} catch (e) {
|
|
111
|
+
problem.value = message(e)
|
|
112
|
+
step.value = 'error'
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async function getQuote() {
|
|
117
|
+
step.value = 'quoting'
|
|
118
|
+
problem.value = ''
|
|
119
|
+
try {
|
|
120
|
+
const q = await client.requestQuote(props.sessionId, method.value)
|
|
121
|
+
fee.value = await readFee(q)
|
|
122
|
+
quote.value = q
|
|
123
|
+
now.value = Date.now()
|
|
124
|
+
step.value = 'ready'
|
|
125
|
+
announcement.value = `Pay exactly ${quote.value.amountText}. This price is held for ${spoken(secondsLeft.value)}.`
|
|
126
|
+
} catch (e) {
|
|
127
|
+
problem.value = message(e)
|
|
128
|
+
step.value = 'choose'
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
async function pay() {
|
|
133
|
+
const q = quote.value
|
|
134
|
+
if (!q || expired.value) return
|
|
135
|
+
step.value = 'signing'
|
|
136
|
+
problem.value = ''
|
|
137
|
+
// Read the fee again just before the wallet opens, so what is shown is what the chain says now.
|
|
138
|
+
try {
|
|
139
|
+
fee.value = await readFee(q)
|
|
140
|
+
} catch {
|
|
141
|
+
problem.value = 'The platform fee could not be read from the network, so nothing was signed. Try again.'
|
|
142
|
+
step.value = 'ready'
|
|
143
|
+
return
|
|
144
|
+
}
|
|
145
|
+
let digest: string
|
|
146
|
+
try {
|
|
147
|
+
const chain = await loadChain(q.method.chain)
|
|
148
|
+
digest = (await props.signAndExecute(chain.buildPayment(q))).digest
|
|
149
|
+
} catch (e) {
|
|
150
|
+
problem.value = message(e)
|
|
151
|
+
step.value = 'ready'
|
|
152
|
+
return
|
|
153
|
+
}
|
|
154
|
+
step.value = 'confirming'
|
|
155
|
+
announcement.value = 'Payment sent. Waiting for the network to confirm it.'
|
|
156
|
+
try {
|
|
157
|
+
let status = await client.submitPayment(props.sessionId, q.nonce, digest)
|
|
158
|
+
if (status === 'pending') status = await client.waitForPayment(props.sessionId, digest)
|
|
159
|
+
if (status === 'confirmed') {
|
|
160
|
+
step.value = 'paid'
|
|
161
|
+
announcement.value = 'Payment confirmed.'
|
|
162
|
+
emit('paid', { digest, quote: q })
|
|
163
|
+
} else if (status === 'rejected') {
|
|
164
|
+
step.value = 'rejected'
|
|
165
|
+
emit('failed', 'rejected')
|
|
166
|
+
} else if (status === 'unapplied') {
|
|
167
|
+
step.value = 'unapplied'
|
|
168
|
+
announcement.value = 'Payment received, but this checkout was already paid or closed.'
|
|
169
|
+
emit('failed', 'unapplied')
|
|
170
|
+
} else {
|
|
171
|
+
problem.value = 'The network has not confirmed the payment yet. It will be checked again; you can close this page.'
|
|
172
|
+
}
|
|
173
|
+
} catch (e) {
|
|
174
|
+
problem.value = message(e)
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
watch(method, () => {
|
|
179
|
+
if (step.value === 'ready') {
|
|
180
|
+
quote.value = null
|
|
181
|
+
step.value = 'choose'
|
|
182
|
+
}
|
|
183
|
+
})
|
|
184
|
+
|
|
185
|
+
watch(expired, (isExpired) => {
|
|
186
|
+
if (isExpired) announcement.value = 'The price is no longer held. Get a new price to continue.'
|
|
187
|
+
})
|
|
188
|
+
|
|
189
|
+
onMounted(() => {
|
|
190
|
+
void load()
|
|
191
|
+
timer = setInterval(() => (now.value = Date.now()), 1000)
|
|
192
|
+
})
|
|
193
|
+
onBeforeUnmount(() => clearInterval(timer))
|
|
194
|
+
</script>
|
|
195
|
+
|
|
196
|
+
<template>
|
|
197
|
+
<section class="chain-checkout" aria-labelledby="chain-checkout-title" :aria-busy="step === 'loading' || step === 'quoting' || step === 'confirming'">
|
|
198
|
+
<component :is="headingTag" id="chain-checkout-title" class="title">Pay with crypto</component>
|
|
199
|
+
<p v-if="step === 'loading'" class="muted">Loading the checkout…</p>
|
|
200
|
+
|
|
201
|
+
<template v-else-if="session">
|
|
202
|
+
<p class="summary">
|
|
203
|
+
<span class="description">{{ session.description }}</span>
|
|
204
|
+
<strong class="price">{{ session.amountText }}</strong>
|
|
205
|
+
</p>
|
|
206
|
+
|
|
207
|
+
<template v-if="step === 'choose' || step === 'quoting' || step === 'ready' || step === 'signing'">
|
|
208
|
+
<UiSegmentedControl
|
|
209
|
+
v-if="options.length > 1"
|
|
210
|
+
v-model="method"
|
|
211
|
+
:options="options"
|
|
212
|
+
label="Coin"
|
|
213
|
+
:label-hidden="false"
|
|
214
|
+
/>
|
|
215
|
+
<p v-else class="muted">Paid in {{ options[0]?.label }}.</p>
|
|
216
|
+
|
|
217
|
+
<div v-if="step === 'ready' || step === 'signing'" class="quote">
|
|
218
|
+
<p class="amount">Pay exactly <strong>{{ quote?.amountText }}</strong></p>
|
|
219
|
+
<dl v-if="fee" class="split">
|
|
220
|
+
<dt>Platform fee (included)</dt>
|
|
221
|
+
<dd>{{ feeText }} to the platform ({{ treasuryText }}); the seller receives the rest.</dd>
|
|
222
|
+
</dl>
|
|
223
|
+
<p class="muted">Network: {{ networkText }}.</p>
|
|
224
|
+
<p v-if="!expired" class="muted">This price is held for <span class="countdown">{{ countdown }}</span>.</p>
|
|
225
|
+
<p class="muted">Your wallet shows the same amount. Any coin left over is returned to you in the same transaction.</p>
|
|
226
|
+
</div>
|
|
227
|
+
|
|
228
|
+
<p class="actions">
|
|
229
|
+
<UiButton v-if="step === 'choose' || step === 'quoting' || expired" :busy="step === 'quoting'" @click="getQuote">
|
|
230
|
+
{{ expired ? 'Get a new price' : 'Get the exact price' }}
|
|
231
|
+
</UiButton>
|
|
232
|
+
<UiButton v-else :busy="step === 'signing'" @click="pay">Pay with your wallet</UiButton>
|
|
233
|
+
</p>
|
|
234
|
+
</template>
|
|
235
|
+
|
|
236
|
+
<UiNotice v-if="step === 'confirming'" type="info" message="Payment sent. Waiting for the network to confirm it…" />
|
|
237
|
+
<UiNotice v-if="step === 'paid'" type="ok" message="Paid. Thank you." />
|
|
238
|
+
<UiNotice
|
|
239
|
+
v-if="step === 'unapplied'"
|
|
240
|
+
type="warning"
|
|
241
|
+
message="Your payment arrived, but this checkout had already been paid or closed, so it bought nothing here. The seller has been told and can credit it or refund it to the address that paid; contact them if you have not heard back."
|
|
242
|
+
/>
|
|
243
|
+
<UiNotice v-if="step === 'rejected'" type="error" message="That transaction did not pay this checkout. Nothing was charged by this page; check your wallet's history." />
|
|
244
|
+
<UiNotice v-if="step === 'closed'" type="warning" message="This checkout is closed. Start a new one to pay." />
|
|
245
|
+
</template>
|
|
246
|
+
|
|
247
|
+
<UiNotice v-if="problem" type="error" :message="problem" />
|
|
248
|
+
<p class="visually-hidden" aria-live="polite">{{ announcement }}</p>
|
|
249
|
+
</section>
|
|
250
|
+
</template>
|
|
251
|
+
|
|
252
|
+
<style scoped>
|
|
253
|
+
.chain-checkout {
|
|
254
|
+
display: grid;
|
|
255
|
+
gap: var(--space-sm);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.title {
|
|
259
|
+
margin: 0;
|
|
260
|
+
font-size: var(--font-size-lg, 1.25rem);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.summary {
|
|
264
|
+
display: flex;
|
|
265
|
+
flex-wrap: wrap;
|
|
266
|
+
justify-content: space-between;
|
|
267
|
+
gap: var(--space-xs);
|
|
268
|
+
margin: 0;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
.price {
|
|
272
|
+
font-size: var(--font-size-lg, 1.25rem);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
.quote {
|
|
276
|
+
padding: var(--space-sm) var(--space-md);
|
|
277
|
+
border: 1px solid var(--border);
|
|
278
|
+
border-radius: var(--radius);
|
|
279
|
+
background: var(--surface);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
.split {
|
|
283
|
+
margin: 0;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.split dt {
|
|
287
|
+
font-weight: 600;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
.split dd {
|
|
291
|
+
margin: 0;
|
|
292
|
+
overflow-wrap: anywhere;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
.quote p {
|
|
296
|
+
margin: var(--space-2xs) 0;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
.amount {
|
|
300
|
+
overflow-wrap: anywhere;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
.countdown {
|
|
304
|
+
font-variant-numeric: tabular-nums;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
.muted {
|
|
308
|
+
margin: 0;
|
|
309
|
+
color: var(--muted);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
.actions {
|
|
313
|
+
margin: 0;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
.visually-hidden {
|
|
317
|
+
position: absolute;
|
|
318
|
+
width: 1px;
|
|
319
|
+
height: 1px;
|
|
320
|
+
overflow: hidden;
|
|
321
|
+
clip-path: inset(50%);
|
|
322
|
+
white-space: nowrap;
|
|
323
|
+
}
|
|
324
|
+
</style>
|
package/src/env.d.ts
ADDED
package/src/index.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@meddleware/chain-payments-kit`: the Vue checkout for Chain Payments. `ChainCheckout` lists whatever payment methods a
|
|
3
|
+
* session offers (and this version's `@meddleware/chain-payments-client` can pay on), shows the exact amount with how long it
|
|
4
|
+
* is held, has the host's wallet sign the chain module's transaction, and follows the payment to confirmation.
|
|
5
|
+
*/
|
|
6
|
+
export { default as ChainCheckout } from './ChainCheckout.vue'
|