@apiosk/checkout-vue 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 ADDED
@@ -0,0 +1,71 @@
1
+ # `@apiosk/checkout-vue`
2
+
3
+ Vue 3 wrapper for the Apiosk four-layer checkout button.
4
+
5
+ Like the React wrapper, this package stays thin and delegates the runtime UI to
6
+ `@apiosk/checkout-web`.
7
+
8
+ ## Install
9
+
10
+ After publish:
11
+
12
+ ```bash
13
+ npm install @apiosk/checkout-vue @apiosk/checkout-web @apiosk/checkout-core
14
+ ```
15
+
16
+ Before publish:
17
+
18
+ ```bash
19
+ npm install ./subs/checkout-vue ./subs/checkout-web ./subs/checkout-core
20
+ ```
21
+
22
+ ## Component usage
23
+
24
+ ```vue
25
+ <script setup>
26
+ import { ApioskCheckoutButton } from "@apiosk/checkout-vue";
27
+
28
+ const checkoutConfig = {
29
+ merchantName: "Northstar Marketplace",
30
+ productName: "Automation bundle",
31
+ amountLabel: "24.95 EUR",
32
+ orderReference: "ord_2048",
33
+ subtitle: "One trigger for humans, agents, and programmable rails.",
34
+ rails: [
35
+ {
36
+ id: "credits",
37
+ status: "live",
38
+ launchUrl: "https://gateway.apiosk.com/geocode/forward",
39
+ },
40
+ {
41
+ id: "x402",
42
+ status: "live",
43
+ launchUrl: "https://gateway.apiosk.com/geocode/forward",
44
+ },
45
+ {
46
+ id: "agent",
47
+ status: "pilot",
48
+ },
49
+ ],
50
+ };
51
+ </script>
52
+
53
+ <template>
54
+ <ApioskCheckoutButton :config="checkoutConfig" />
55
+ </template>
56
+ ```
57
+
58
+ ## Plugin usage
59
+
60
+ ```js
61
+ import { createApp } from "vue";
62
+ import App from "./App.vue";
63
+ import { ApioskCheckoutVuePlugin } from "@apiosk/checkout-vue";
64
+
65
+ createApp(App).use(ApioskCheckoutVuePlugin).mount("#app");
66
+ ```
67
+
68
+ ## Design rule
69
+
70
+ The Vue layer should not own checkout logic. Keep the contract in
71
+ `@apiosk/checkout-core` and the DOM runtime in `@apiosk/checkout-web`.
package/index.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ import type { DefineComponent, Plugin, Ref } from "vue";
2
+ import type { CheckoutConfigInput } from "@apiosk/checkout-core";
3
+
4
+ export interface ApioskCheckoutVueExpose {
5
+ element: Ref<HTMLElement | null>;
6
+ openCheckout(): void;
7
+ closeCheckout(): void;
8
+ }
9
+
10
+ export declare const ApioskCheckoutButton: DefineComponent<{
11
+ config: CheckoutConfigInput;
12
+ className?: string;
13
+ style?: string | Record<string, unknown> | Array<unknown>;
14
+ }>;
15
+
16
+ export declare const ApioskCheckoutVuePlugin: Plugin;
17
+ export declare function registerApioskCheckoutButton(): unknown;
18
+ export default ApioskCheckoutButton;
package/index.mjs ADDED
@@ -0,0 +1,78 @@
1
+ import { defineComponent, h, onMounted, ref, watch } from "vue";
2
+ import { normalizeCheckoutConfig } from "@apiosk/checkout-core";
3
+ import {
4
+ CHECKOUT_ELEMENT_TAG,
5
+ registerApioskCheckoutButton,
6
+ serializeCheckoutConfig,
7
+ } from "@apiosk/checkout-web";
8
+
9
+ export const ApioskCheckoutButton = defineComponent({
10
+ name: "ApioskCheckoutButton",
11
+ props: {
12
+ config: {
13
+ type: Object,
14
+ default: () => ({}),
15
+ },
16
+ className: {
17
+ type: String,
18
+ default: "",
19
+ },
20
+ style: {
21
+ type: [String, Object, Array],
22
+ default: undefined,
23
+ },
24
+ },
25
+ setup(props, { attrs, expose, slots }) {
26
+ const elementRef = ref(null);
27
+
28
+ const applyConfig = () => {
29
+ if (!elementRef.value) {
30
+ return;
31
+ }
32
+
33
+ elementRef.value.config = normalizeCheckoutConfig(props.config);
34
+ };
35
+
36
+ onMounted(() => {
37
+ registerApioskCheckoutButton();
38
+ applyConfig();
39
+ });
40
+
41
+ watch(
42
+ () => props.config,
43
+ () => {
44
+ applyConfig();
45
+ },
46
+ { deep: true },
47
+ );
48
+
49
+ expose({
50
+ element: elementRef,
51
+ openCheckout: () => elementRef.value?.openCheckout?.(),
52
+ closeCheckout: () => elementRef.value?.closeCheckout?.(),
53
+ });
54
+
55
+ return () =>
56
+ h(
57
+ CHECKOUT_ELEMENT_TAG,
58
+ {
59
+ ...attrs,
60
+ ref: elementRef,
61
+ config: serializeCheckoutConfig(props.config),
62
+ class: props.className,
63
+ style: props.style,
64
+ },
65
+ slots.default ? slots.default() : undefined,
66
+ );
67
+ },
68
+ });
69
+
70
+ export const ApioskCheckoutVuePlugin = {
71
+ install(app) {
72
+ registerApioskCheckoutButton();
73
+ app.component("ApioskCheckoutButton", ApioskCheckoutButton);
74
+ },
75
+ };
76
+
77
+ export { registerApioskCheckoutButton };
78
+ export default ApioskCheckoutButton;
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@apiosk/checkout-vue",
3
+ "version": "0.1.0",
4
+ "description": "Vue wrapper for the Apiosk four-layer checkout button",
5
+ "type": "module",
6
+ "main": "./index.mjs",
7
+ "types": "./index.d.ts",
8
+ "files": [
9
+ "index.mjs",
10
+ "index.d.ts",
11
+ "README.md"
12
+ ],
13
+ "exports": {
14
+ ".": {
15
+ "types": "./index.d.ts",
16
+ "default": "./index.mjs"
17
+ }
18
+ },
19
+ "scripts": {
20
+ "check": "node --check index.mjs"
21
+ },
22
+ "keywords": [
23
+ "apiosk",
24
+ "checkout",
25
+ "vue",
26
+ "payments",
27
+ "x402"
28
+ ],
29
+ "author": "Apiosk",
30
+ "license": "MIT",
31
+ "homepage": "https://docs.apiosk.com",
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "dependencies": {
36
+ "@apiosk/checkout-core": "^0.1.0",
37
+ "@apiosk/checkout-web": "^0.1.0"
38
+ },
39
+ "peerDependencies": {
40
+ "vue": "^3.4.0"
41
+ }
42
+ }