@inttegro/vue 0.1.0 → 0.4.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 CHANGED
@@ -13,3 +13,10 @@ import { Checkout } from '@inttegro/vue'
13
13
  <Checkout :order-id="orderId" @completed="onCompleted" />
14
14
  </template>
15
15
  ```
16
+
17
+ For a `customer_selected_amount` Buy link, pass `purchase-intent-id` instead of
18
+ `order-id`. This works in both embedded and modal presentations:
19
+
20
+ ```vue
21
+ <Checkout :purchase-intent-id="purchaseIntentId" presentation="modal" />
22
+ ```
package/dist/index.cjs CHANGED
@@ -31,12 +31,19 @@ var Checkout = (0, import_vue.defineComponent)({
31
31
  name: "InttegroCheckout",
32
32
  props: {
33
33
  appearance: Object,
34
+ features: Object,
34
35
  locale: String,
35
- orderId: { type: String, required: true },
36
+ orderId: String,
37
+ purchaseIntentId: String,
38
+ presentation: {
39
+ type: String,
40
+ default: "embedded"
41
+ },
36
42
  timeout: Number,
37
43
  title: String
38
44
  },
39
45
  emits: {
46
+ canceled: (_event) => true,
40
47
  completed: (_event) => true,
41
48
  error: (_event) => true,
42
49
  event: (_event) => true,
@@ -58,6 +65,7 @@ var Checkout = (0, import_vue.defineComponent)({
58
65
  destroyCheckout();
59
66
  const target = container.value;
60
67
  const currentGeneration = generation;
68
+ let canceled = false;
61
69
  if (!target) return;
62
70
  try {
63
71
  const inttegro = await (0, import_js.loadInttegro)();
@@ -65,8 +73,10 @@ var Checkout = (0, import_vue.defineComponent)({
65
73
  const instance = inttegro.createCheckout(
66
74
  definedOptions({
67
75
  appearance: props.appearance,
76
+ features: props.features,
68
77
  locale: props.locale,
69
78
  orderId: props.orderId,
79
+ purchaseIntentId: props.purchaseIntentId,
70
80
  timeout: props.timeout,
71
81
  title: props.title
72
82
  })
@@ -78,13 +88,18 @@ var Checkout = (0, import_vue.defineComponent)({
78
88
  checkout = instance;
79
89
  unsubscribe = instance.onEvent((event) => {
80
90
  emit("event", event);
91
+ if (event.type === "canceled") {
92
+ canceled = true;
93
+ emit("canceled", event);
94
+ }
81
95
  if (event.type === "ready") emit("ready", event);
82
96
  if (event.type === "completed") emit("completed", event);
83
97
  if (event.type === "error") emit("error", event);
84
98
  });
85
- await instance.mount(target);
99
+ if (props.presentation === "modal") await instance.present();
100
+ else await instance.mount(target);
86
101
  } catch (error) {
87
- if (generation !== currentGeneration) return;
102
+ if (generation !== currentGeneration || canceled) return;
88
103
  emit(
89
104
  "error",
90
105
  error instanceof Error ? error : new Error("Checkout failed to load.")
@@ -94,7 +109,14 @@ var Checkout = (0, import_vue.defineComponent)({
94
109
  (0, import_vue.onMounted)(mountCheckout);
95
110
  (0, import_vue.onBeforeUnmount)(destroyCheckout);
96
111
  (0, import_vue.watch)(
97
- () => [props.orderId, props.timeout, props.title],
112
+ () => [
113
+ props.features,
114
+ props.orderId,
115
+ props.purchaseIntentId,
116
+ props.presentation,
117
+ props.timeout,
118
+ props.title
119
+ ],
98
120
  () => void mountCheckout()
99
121
  );
100
122
  (0, import_vue.watch)(
@@ -105,6 +127,7 @@ var Checkout = (0, import_vue.defineComponent)({
105
127
  { deep: true }
106
128
  );
107
129
  expose({
130
+ dismiss: () => checkout?.dismiss(),
108
131
  focus: () => checkout?.focus(),
109
132
  update: (options) => checkout?.update(options)
110
133
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/Checkout.ts"],"sourcesContent":["/**\n * Vue component adapter for Inttegro-hosted Checkout.\n *\n * @module @inttegro/vue\n */\nexport { Checkout, type CheckoutExposed, type CheckoutProps } from './Checkout'\nexport type {\n CheckoutAppearance,\n CheckoutErrorEvent,\n CheckoutEvent,\n CheckoutTheme,\n} from '@inttegro/js'\n","import {\n loadInttegro,\n type CheckoutAppearance,\n type CheckoutController,\n type CheckoutErrorEvent,\n type CheckoutEvent,\n} from '@inttegro/js'\nimport {\n defineComponent,\n h,\n onBeforeUnmount,\n onMounted,\n ref,\n watch,\n type PropType,\n} from 'vue'\n\n/**\n * Props accepted by the Inttegro {@link Checkout} component.\n *\n * Changing `orderId`, `timeout`, or `title` replaces the hosted controller.\n * Changing `appearance` or `locale` updates it in place, preserving payer\n * progress where the hosted flow permits.\n *\n * @category Vue\n */\nexport interface CheckoutProps {\n /** Initial and reactive theme preference for hosted Checkout. */\n appearance?: CheckoutAppearance | undefined\n /** Initial and reactive BCP 47 locale preference. */\n locale?: string | undefined\n /** Client-safe reference for the finalized Order being paid. */\n orderId: string\n /** Mount timeout from 1,000–60,000 ms; defaults to 15,000 ms. */\n timeout?: number | undefined\n /** Accessible iframe title; defaults to `Checkout`. */\n title?: string | undefined\n}\n\n/**\n * Imperative operations exposed by {@link Checkout} through a Vue template ref.\n *\n * @category Vue\n */\nexport interface CheckoutExposed {\n /** Moves focus into Checkout when the controller is ready; otherwise does nothing. */\n focus(): void\n /** Applies a new locale or theme when a controller exists. */\n update(options: Parameters<CheckoutController['update']>[0]): void\n}\n\n/**\n * Embeds Inttegro-hosted Checkout in a Vue application.\n *\n * The component owns the loader and controller lifecycle. It emits:\n *\n * - `ready` once the iframe is interactive;\n * - `event` for every sanitized Checkout lifecycle event;\n * - `completed` at the successful hosted terminal state; and\n * - `error` for loader/mount failures or sanitized hosted errors.\n *\n * Keep the component mounted while payment or confirmation is pending. On\n * unmount it removes its event subscription and permanently destroys the\n * controller.\n *\n * @example Use native Vue events\n * ```vue\n * <script setup lang=\"ts\">\n * import { ref } from 'vue'\n * import { Checkout, type CheckoutExposed } from '@inttegro/vue'\n *\n * const props = defineProps<{ orderId: string }>()\n * const checkout = ref<CheckoutExposed>()\n * </script>\n *\n * <template>\n * <Checkout\n * ref=\"checkout\"\n * :order-id=\"props.orderId\"\n * :appearance=\"{ theme: 'system' }\"\n * @ready=\"checkout?.focus()\"\n * @completed=\"$router.push('/orders/complete')\"\n * @error=\"reportCheckoutError\"\n * />\n * </template>\n * ```\n *\n * @category Vue\n */\nexport const Checkout = defineComponent({\n name: 'InttegroCheckout',\n props: {\n appearance: Object as PropType<CheckoutAppearance>,\n locale: String,\n orderId: { type: String, required: true },\n timeout: Number,\n title: String,\n },\n emits: {\n completed: (_event: Extract<CheckoutEvent, { type: 'completed' }>) => true,\n error: (_event: CheckoutErrorEvent | Error) => true,\n event: (_event: CheckoutEvent) => true,\n ready: (_event: Extract<CheckoutEvent, { type: 'ready' }>) => true,\n },\n setup(props, { emit, expose }) {\n const container = ref<HTMLElement>()\n let checkout: CheckoutController | undefined\n let unsubscribe: (() => void) | undefined\n let generation = 0\n\n function destroyCheckout() {\n generation += 1\n unsubscribe?.()\n unsubscribe = undefined\n checkout?.destroy()\n checkout = undefined\n }\n\n async function mountCheckout() {\n destroyCheckout()\n const target = container.value\n const currentGeneration = generation\n if (!target) return\n try {\n const inttegro = await loadInttegro()\n if (generation !== currentGeneration || !inttegro) return\n const instance = inttegro.createCheckout(\n definedOptions({\n appearance: props.appearance,\n locale: props.locale,\n orderId: props.orderId,\n timeout: props.timeout,\n title: props.title,\n }),\n )\n if (generation !== currentGeneration) {\n instance.destroy()\n return\n }\n checkout = instance\n unsubscribe = instance.onEvent((event) => {\n emit('event', event)\n if (event.type === 'ready') emit('ready', event)\n if (event.type === 'completed') emit('completed', event)\n if (event.type === 'error') emit('error', event)\n })\n await instance.mount(target)\n } catch (error: unknown) {\n if (generation !== currentGeneration) return\n emit(\n 'error',\n error instanceof Error\n ? error\n : new Error('Checkout failed to load.'),\n )\n }\n }\n\n onMounted(mountCheckout)\n onBeforeUnmount(destroyCheckout)\n\n watch(\n () => [props.orderId, props.timeout, props.title],\n () => void mountCheckout(),\n )\n watch(\n () => [props.appearance, props.locale] as const,\n ([appearance, locale]) => {\n checkout?.update(definedOptions({ appearance, locale }))\n },\n { deep: true },\n )\n\n expose({\n focus: () => checkout?.focus(),\n update: (options: Parameters<CheckoutController['update']>[0]) =>\n checkout?.update(options),\n })\n\n return () => h('div', { ref: container })\n },\n})\n\nfunction definedOptions<Value extends object>(options: Value): Value {\n return Object.fromEntries(\n Object.ent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AS,MAAK,SAAS,KAAK;AAC/C,cAAI,MAAM,SAAS,YAAa,MAAK,aAAa,KAAK;AACvD,cAAI,MAAM,SAAS,QAAS,MAAK,SAAS,KAAK;AAAA,QACjD,CAAC;AACD,cAAM,SAAS,MAAM,MAAM;AAAA,MAC7B,SAAS,OAAgB;AACvB,YAAI,eAAe,kBAAmB;AACtC;AAAA,UACE;AAAA,UACA,iBAAiB,QACb,QACA,IAAI,MAAM,0BAA0B;AAAA,QAC1C;AAAA,MACF;AAAA,IACF;AAEA,8BAAU,aAAa;AACvB,oCAAgB,eAAe;AAE/B;AAAA,MACE,MAAM,CAAC,MAAM,SAAS,MAAM,SAAS,MAAM,KAAK;AAAA,MAChD,MAAM,KAAK,cAAc;AAAA,IAC3B;AACA;AAAA,MACE,MAAM,CAAC,MAAM,YAAY,MAAM,MAAM;AAAA,MACrC,CAAC,CAAC,YAAY,MAAM,MAAM;AACxB,kBAAU,OAAO,eAAe,EAAE,YAAY,OAAO,CAAC,CAAC;AAAA,MACzD;AAAA,MACA,EAAE,MAAM,KAAK;AAAA,IACf;AAEA,WAAO;AAAA,MACL,OAAO,MAAM,UAAU,MAAM;AAAA,MAC7B,QAAQ,CAAC,YACP,UAAU,OAAO,OAAO;AAAA,IAC5B,CAAC;AAED,WAAO,UAAM,cAAE,OAAO,EAAE,KAAK,UAAU,CAAC;AAAA,EAC1C;AACF,CAAC;AAED,SAAS,eAAqC,SAAuB;AACnE,SAAO,OAAO;AAAA,IACZ,OAAO,QAAQ,OAAO,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,MAAM,UAAU,MAAS;AAAA,EACnE;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/Checkout.ts"],"sourcesContent":["/**\n * Vue component adapter for Inttegro-hosted Checkout.\n *\n * @module @inttegro/vue\n */\nexport {\n Checkout,\n type CheckoutExposed,\n type CheckoutProps,\n type CheckoutPropsBase,\n} from './Checkout'\nexport type {\n CheckoutAppearance,\n CheckoutErrorEvent,\n CheckoutEvent,\n CheckoutFeatures,\n CheckoutPresentation,\n CheckoutTheme,\n} from '@inttegro/js'\n","import {\n loadInttegro,\n type CheckoutAppearance,\n type CheckoutController,\n type CheckoutErrorEvent,\n type CheckoutEvent,\n type CheckoutFeatures,\n type CheckoutOptions,\n type CheckoutPresentation,\n} from '@inttegro/js'\nimport {\n defineComponent,\n h,\n onBeforeUnmount,\n onMounted,\n ref,\n watch,\n type PropType,\n} from 'vue'\n\n/**\n * Props accepted by the Inttegro {@link Checkout} component.\n *\n * Changing `features`, the Checkout reference, `presentation`, `timeout`, or\n * `title` replaces the hosted controller. Changing `appearance` or `locale`\n * updates it in place, preserving payer progress where the hosted flow permits.\n *\n * @category Vue\n */\nexport interface CheckoutPropsBase {\n /** Initial and reactive theme preference for hosted Checkout. */\n appearance?: CheckoutAppearance | undefined\n /** Hosted Checkout content and actions. Changing it replaces the controller. */\n features?: CheckoutFeatures | undefined\n /** Initial and reactive BCP 47 locale preference. */\n locale?: string | undefined\n /** Displays Checkout inline by default or in an Inttegro-managed modal. */\n presentation?: CheckoutPresentation | undefined\n /** Mount timeout from 1,000–60,000 ms; defaults to 15,000 ms. */\n timeout?: number | undefined\n /** Accessible iframe title; defaults to `Checkout`. */\n title?: string | undefined\n}\n\nexport type CheckoutProps = CheckoutPropsBase &\n (\n | { orderId: string; purchaseIntentId?: never }\n | { orderId?: never; purchaseIntentId: string }\n )\n\n/**\n * Imperative operations exposed by {@link Checkout} through a Vue template ref.\n *\n * @category Vue\n */\nexport interface CheckoutExposed {\n /** Closes managed modal Checkout when it is open. */\n dismiss(): void\n /** Moves focus into Checkout when the controller is ready; otherwise does nothing. */\n focus(): void\n /** Applies a new locale or theme when a controller exists. */\n update(options: Parameters<CheckoutController['update']>[0]): void\n}\n\n/**\n * Displays Inttegro-hosted Checkout in a Vue application.\n *\n * The component owns the loader and controller lifecycle. It emits:\n *\n * - `ready` once the iframe is interactive;\n * - `event` for every sanitized Checkout lifecycle event;\n * - `canceled` when a payer dismisses managed modal Checkout;\n * - `completed` at the successful hosted terminal state; and\n * - `error` for loader/mount failures or sanitized hosted errors.\n *\n * Keep the component mounted while payment or confirmation is pending. On\n * unmount it removes its event subscription and permanently destroys the\n * controller.\n *\n * @example Use native Vue events\n * ```vue\n * <script setup lang=\"ts\">\n * import { ref } from 'vue'\n * import { Checkout, type CheckoutExposed } from '@inttegro/vue'\n *\n * const props = defineProps<{ orderId: string }>()\n * const checkout = ref<CheckoutExposed>()\n * </script>\n *\n * <template>\n * <Checkout\n * ref=\"checkout\"\n * :order-id=\"props.orderId\"\n * presentation=\"modal\"\n * :appearance=\"{ theme: 'system' }\"\n * @ready=\"checkout?.focus()\"\n * @completed=\"$router.push('/orders/complete')\"\n * @error=\"reportCheckoutError\"\n * />\n * </template>\n * ```\n *\n * @category Vue\n */\nexport const Checkout = defineComponent({\n name: 'InttegroCheckout',\n props: {\n appearance: Object as PropType<CheckoutAppearance>,\n features: Object as PropType<CheckoutFeatures>,\n locale: String,\n orderId: String,\n purchaseIntentId: String,\n presentation: {\n type: String as PropType<CheckoutPresentation>,\n default: 'embedded',\n },\n timeout: Number,\n title: String,\n },\n emits: {\n canceled: (_event: Extract<CheckoutEvent, { type: 'canceled' }>) => true,\n completed: (_event: Extract<CheckoutEvent, { type: 'completed' }>) => true,\n error: (_event: CheckoutErrorEvent | Error) => true,\n event: (_event: CheckoutEvent) => true,\n ready: (_event: Extract<CheckoutEvent, { type: 'ready' }>) => true,\n },\n setup(props, { emit, expose }) {\n const container = ref<HTMLElement>()\n let checkout: CheckoutController | undefined\n let unsubscribe: (() => void) | undefined\n let generation = 0\n\n function destroyCheckout() {\n generation += 1\n unsubscribe?.()\n unsubscribe = undefined\n checkout?.destroy()\n checkout = undefined\n }\n\n async function mountCheckout() {\n destroyCheckout()\n const target = container.value\n const currentGeneration = generation\n let canceled = false\n if (!target) return\n try {\n const inttegro = await loadInttegro()\n if (generation !== currentGeneration || !inttegro) return\n const instance = inttegro.createCheckout(\n definedOptions({\n appearance: props.appearance,\n features: props.features,\n locale: props.locale,\n orderId: props.orderId,\n purchaseIntentId: props.purchaseIntentId,\n timeout: props.timeout,\n title: props.title,\n }) as CheckoutOptions,\n )\n if (generation !== currentGeneration) {\n instance.destroy()\n return\n }\n checkout = instance\n unsubscribe = instance.onEvent((event) => {\n emit('event', event)\n if (event.type === 'canceled') {\n canceled = true\n emit('canceled', event)\n }\n if (event.type === 'ready') emit('ready', event)\n if (event.type === 'completed') emit('completed', event)\n if (event.type === 'error') emit('error', event)\n })\n if (props.presentation === 'modal') await instance.present()\n else await instance.mount(target)\n } catch (error: unknown) {\n if (generation !== currentGeneration || canceled) return\n emit(\n 'error',\n error instanceof Error\n ? error\n : new Error('Checkout failed to load.'),\n )\n }\n }\n\n onMounted(mountCheckout)\n onBeforeUnmount(destroyCheckout)\n\n watch(\n () => [\n props.features,\n props.orderId,\n props.purchaseIntentId,\n props.presentation,\n props.timeout,\n props.title,\n ],\n () => void mountCheckout(),\n )\n watch(\n () => [props.appearance, props.locale] as const,\n ([appearance, locale]) => {\n checkout?.update(definedOptions({ appearance, locale }))\n },\n { deep: true },\n )\n\n expose({\n dismiss: () => checkout?.dismiss(),\n focus: () => checkout?.focus(),\n update: (options: Parameters<CheckoutController['update']>[0]) =>\n checkout?.update(options),\n })\n\n return () => h('div', { ref: container })\n },\n})\n\nfunction definedOptions<Value extends object>(options: Value): Value {\n return Object.fromEntries(\n Object.entries(options).filter(([, value]) => value !== undefined),\n ) as Value\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,gBASO;AACP,iBAQO;AAsFA,IAAM,eAAW,4BAAgB;AAAA,EACtC,MAAM;AAAA,EACN,OAAO;AAAA,IACL,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,kBAAkB;AAAA,IAClB,cAAc;AAAA,MACZ,MAAM;AAAA,MACN,SAAS;AAAA,IACX;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S,MAAK,SAAS,KAAK;AAAA,QACjD,CAAC;AACD,YAAI,MAAM,iBAAiB,QAAS,OAAM,SAAS,QAAQ;AAAA,YACtD,OAAM,SAAS,MAAM,MAAM;AAAA,MAClC,SAAS,OAAgB;AACvB,YAAI,eAAe,qBAAqB,SAAU;AAClD;AAAA,UACE;AAAA,UACA,iBAAiB,QACb,QACA,IAAI,MAAM,0BAA0B;AAAA,QAC1C;AAAA,MACF;AAAA,IACF;AAEA,8BAAU,aAAa;AACvB,oCAAgB,eAAe;AAE/B;AAAA,MACE,MAAM;AAAA,QACJ,MAAM;AAAA,QACN,MAAM;AAAA,QACN,MAAM;AAAA,QACN,MAAM;AAAA,QACN,MAAM;AAAA,QACN,MAAM;AAAA,MACR;AAAA,MACA,MAAM,KAAK,cAAc;AAAA,IAC3B;AACA;AAAA,MACE,MAAM,CAAC,MAAM,YAAY,MAAM,MAAM;AAAA,MACrC,CAAC,CAAC,YAAY,MAAM,MAAM;AACxB,kBAAU,OAAO,eAAe,EAAE,YAAY,OAAO,CAAC,CAAC;AAAA,MACzD;AAAA,MACA,EAAE,MAAM,KAAK;AAAA,IACf;AAEA,WAAO;AAAA,MACL,SAAS,MAAM,UAAU,QAAQ;AAAA,MACjC,OAAO,MAAM,UAAU,MAAM;AAAA,MAC7B,QAAQ,CAAC,YACP,UAAU,OAAO,OAAO;AAAA,IAC5B,CAAC;AAED,WAAO,UAAM,cAAE,OAAO,EAAE,KAAK,UAAU,CAAC;AAAA,EAC1C;AACF,CAAC;AAED,SAAS,eAAqC,SAAuB;AACnE,SAAO,OAAO;AAAA,IACZ,OAAO,QAAQ,OAAO,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,MAAM,UAAU,MAAS;AAAA,EACnE;AACF;","names":[]}
package/dist/index.d.cts CHANGED
@@ -1,48 +1,60 @@
1
1
  import * as _inttegro_js from '@inttegro/js';
2
- import { CheckoutAppearance, CheckoutEvent, CheckoutErrorEvent, CheckoutController } from '@inttegro/js';
3
- export { CheckoutAppearance, CheckoutErrorEvent, CheckoutEvent, CheckoutTheme } from '@inttegro/js';
2
+ import { CheckoutAppearance, CheckoutFeatures, CheckoutPresentation, CheckoutEvent, CheckoutErrorEvent, CheckoutController } from '@inttegro/js';
3
+ export { CheckoutAppearance, CheckoutErrorEvent, CheckoutEvent, CheckoutFeatures, CheckoutPresentation, CheckoutTheme } from '@inttegro/js';
4
4
  import * as vue from 'vue';
5
5
  import { PropType } from 'vue';
6
6
 
7
7
  /**
8
8
  * Props accepted by the Inttegro {@link Checkout} component.
9
9
  *
10
- * Changing `orderId`, `timeout`, or `title` replaces the hosted controller.
11
- * Changing `appearance` or `locale` updates it in place, preserving payer
12
- * progress where the hosted flow permits.
10
+ * Changing `features`, the Checkout reference, `presentation`, `timeout`, or
11
+ * `title` replaces the hosted controller. Changing `appearance` or `locale`
12
+ * updates it in place, preserving payer progress where the hosted flow permits.
13
13
  *
14
14
  * @category Vue
15
15
  */
16
- interface CheckoutProps {
16
+ interface CheckoutPropsBase {
17
17
  /** Initial and reactive theme preference for hosted Checkout. */
18
18
  appearance?: CheckoutAppearance | undefined;
19
+ /** Hosted Checkout content and actions. Changing it replaces the controller. */
20
+ features?: CheckoutFeatures | undefined;
19
21
  /** Initial and reactive BCP 47 locale preference. */
20
22
  locale?: string | undefined;
21
- /** Client-safe reference for the finalized Order being paid. */
22
- orderId: string;
23
+ /** Displays Checkout inline by default or in an Inttegro-managed modal. */
24
+ presentation?: CheckoutPresentation | undefined;
23
25
  /** Mount timeout from 1,000–60,000 ms; defaults to 15,000 ms. */
24
26
  timeout?: number | undefined;
25
27
  /** Accessible iframe title; defaults to `Checkout`. */
26
28
  title?: string | undefined;
27
29
  }
30
+ type CheckoutProps = CheckoutPropsBase & ({
31
+ orderId: string;
32
+ purchaseIntentId?: never;
33
+ } | {
34
+ orderId?: never;
35
+ purchaseIntentId: string;
36
+ });
28
37
  /**
29
38
  * Imperative operations exposed by {@link Checkout} through a Vue template ref.
30
39
  *
31
40
  * @category Vue
32
41
  */
33
42
  interface CheckoutExposed {
43
+ /** Closes managed modal Checkout when it is open. */
44
+ dismiss(): void;
34
45
  /** Moves focus into Checkout when the controller is ready; otherwise does nothing. */
35
46
  focus(): void;
36
47
  /** Applies a new locale or theme when a controller exists. */
37
48
  update(options: Parameters<CheckoutController['update']>[0]): void;
38
49
  }
39
50
  /**
40
- * Embeds Inttegro-hosted Checkout in a Vue application.
51
+ * Displays Inttegro-hosted Checkout in a Vue application.
41
52
  *
42
53
  * The component owns the loader and controller lifecycle. It emits:
43
54
  *
44
55
  * - `ready` once the iframe is interactive;
45
56
  * - `event` for every sanitized Checkout lifecycle event;
57
+ * - `canceled` when a payer dismisses managed modal Checkout;
46
58
  * - `completed` at the successful hosted terminal state; and
47
59
  * - `error` for loader/mount failures or sanitized hosted errors.
48
60
  *
@@ -64,6 +76,7 @@ interface CheckoutExposed {
64
76
  * <Checkout
65
77
  * ref="checkout"
66
78
  * :order-id="props.orderId"
79
+ * presentation="modal"
67
80
  * :appearance="{ theme: 'system' }"
68
81
  * @ready="checkout?.focus()"
69
82
  * @completed="$router.push('/orders/complete')"
@@ -76,16 +89,22 @@ interface CheckoutExposed {
76
89
  */
77
90
  declare const Checkout: vue.DefineComponent<vue.ExtractPropTypes<{
78
91
  appearance: PropType<CheckoutAppearance>;
92
+ features: PropType<CheckoutFeatures>;
79
93
  locale: StringConstructor;
80
- orderId: {
81
- type: StringConstructor;
82
- required: true;
94
+ orderId: StringConstructor;
95
+ purchaseIntentId: StringConstructor;
96
+ presentation: {
97
+ type: PropType<CheckoutPresentation>;
98
+ default: string;
83
99
  };
84
100
  timeout: NumberConstructor;
85
101
  title: StringConstructor;
86
102
  }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
87
103
  [key: string]: any;
88
104
  }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
105
+ canceled: (_event: Extract<CheckoutEvent, {
106
+ type: "canceled";
107
+ }>) => true;
89
108
  completed: (_event: Extract<CheckoutEvent, {
90
109
  type: "completed";
91
110
  }>) => true;
@@ -96,18 +115,24 @@ declare const Checkout: vue.DefineComponent<vue.ExtractPropTypes<{
96
115
  }>) => true;
97
116
  }, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
98
117
  appearance: PropType<CheckoutAppearance>;
118
+ features: PropType<CheckoutFeatures>;
99
119
  locale: StringConstructor;
100
- orderId: {
101
- type: StringConstructor;
102
- required: true;
120
+ orderId: StringConstructor;
121
+ purchaseIntentId: StringConstructor;
122
+ presentation: {
123
+ type: PropType<CheckoutPresentation>;
124
+ default: string;
103
125
  };
104
126
  timeout: NumberConstructor;
105
127
  title: StringConstructor;
106
128
  }>> & Readonly<{
107
- onCompleted?: (_event: _inttegro_js.CheckoutCompletedEvent) => any;
129
+ onCanceled?: (_event: _inttegro_js.CheckoutCanceledEvent) => any;
108
130
  onReady?: (_event: _inttegro_js.CheckoutReadyEvent) => any;
131
+ onCompleted?: (_event: _inttegro_js.CheckoutCompletedEvent) => any;
109
132
  onError?: (_event: CheckoutErrorEvent | Error) => any;
110
133
  onEvent?: (_event: CheckoutEvent) => any;
111
- }>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
134
+ }>, {
135
+ presentation: CheckoutPresentation;
136
+ }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
112
137
 
113
- export { Checkout, type CheckoutExposed, type CheckoutProps };
138
+ export { Checkout, type CheckoutExposed, type CheckoutProps, type CheckoutPropsBase };
package/dist/index.d.ts CHANGED
@@ -1,48 +1,60 @@
1
1
  import * as _inttegro_js from '@inttegro/js';
2
- import { CheckoutAppearance, CheckoutEvent, CheckoutErrorEvent, CheckoutController } from '@inttegro/js';
3
- export { CheckoutAppearance, CheckoutErrorEvent, CheckoutEvent, CheckoutTheme } from '@inttegro/js';
2
+ import { CheckoutAppearance, CheckoutFeatures, CheckoutPresentation, CheckoutEvent, CheckoutErrorEvent, CheckoutController } from '@inttegro/js';
3
+ export { CheckoutAppearance, CheckoutErrorEvent, CheckoutEvent, CheckoutFeatures, CheckoutPresentation, CheckoutTheme } from '@inttegro/js';
4
4
  import * as vue from 'vue';
5
5
  import { PropType } from 'vue';
6
6
 
7
7
  /**
8
8
  * Props accepted by the Inttegro {@link Checkout} component.
9
9
  *
10
- * Changing `orderId`, `timeout`, or `title` replaces the hosted controller.
11
- * Changing `appearance` or `locale` updates it in place, preserving payer
12
- * progress where the hosted flow permits.
10
+ * Changing `features`, the Checkout reference, `presentation`, `timeout`, or
11
+ * `title` replaces the hosted controller. Changing `appearance` or `locale`
12
+ * updates it in place, preserving payer progress where the hosted flow permits.
13
13
  *
14
14
  * @category Vue
15
15
  */
16
- interface CheckoutProps {
16
+ interface CheckoutPropsBase {
17
17
  /** Initial and reactive theme preference for hosted Checkout. */
18
18
  appearance?: CheckoutAppearance | undefined;
19
+ /** Hosted Checkout content and actions. Changing it replaces the controller. */
20
+ features?: CheckoutFeatures | undefined;
19
21
  /** Initial and reactive BCP 47 locale preference. */
20
22
  locale?: string | undefined;
21
- /** Client-safe reference for the finalized Order being paid. */
22
- orderId: string;
23
+ /** Displays Checkout inline by default or in an Inttegro-managed modal. */
24
+ presentation?: CheckoutPresentation | undefined;
23
25
  /** Mount timeout from 1,000–60,000 ms; defaults to 15,000 ms. */
24
26
  timeout?: number | undefined;
25
27
  /** Accessible iframe title; defaults to `Checkout`. */
26
28
  title?: string | undefined;
27
29
  }
30
+ type CheckoutProps = CheckoutPropsBase & ({
31
+ orderId: string;
32
+ purchaseIntentId?: never;
33
+ } | {
34
+ orderId?: never;
35
+ purchaseIntentId: string;
36
+ });
28
37
  /**
29
38
  * Imperative operations exposed by {@link Checkout} through a Vue template ref.
30
39
  *
31
40
  * @category Vue
32
41
  */
33
42
  interface CheckoutExposed {
43
+ /** Closes managed modal Checkout when it is open. */
44
+ dismiss(): void;
34
45
  /** Moves focus into Checkout when the controller is ready; otherwise does nothing. */
35
46
  focus(): void;
36
47
  /** Applies a new locale or theme when a controller exists. */
37
48
  update(options: Parameters<CheckoutController['update']>[0]): void;
38
49
  }
39
50
  /**
40
- * Embeds Inttegro-hosted Checkout in a Vue application.
51
+ * Displays Inttegro-hosted Checkout in a Vue application.
41
52
  *
42
53
  * The component owns the loader and controller lifecycle. It emits:
43
54
  *
44
55
  * - `ready` once the iframe is interactive;
45
56
  * - `event` for every sanitized Checkout lifecycle event;
57
+ * - `canceled` when a payer dismisses managed modal Checkout;
46
58
  * - `completed` at the successful hosted terminal state; and
47
59
  * - `error` for loader/mount failures or sanitized hosted errors.
48
60
  *
@@ -64,6 +76,7 @@ interface CheckoutExposed {
64
76
  * <Checkout
65
77
  * ref="checkout"
66
78
  * :order-id="props.orderId"
79
+ * presentation="modal"
67
80
  * :appearance="{ theme: 'system' }"
68
81
  * @ready="checkout?.focus()"
69
82
  * @completed="$router.push('/orders/complete')"
@@ -76,16 +89,22 @@ interface CheckoutExposed {
76
89
  */
77
90
  declare const Checkout: vue.DefineComponent<vue.ExtractPropTypes<{
78
91
  appearance: PropType<CheckoutAppearance>;
92
+ features: PropType<CheckoutFeatures>;
79
93
  locale: StringConstructor;
80
- orderId: {
81
- type: StringConstructor;
82
- required: true;
94
+ orderId: StringConstructor;
95
+ purchaseIntentId: StringConstructor;
96
+ presentation: {
97
+ type: PropType<CheckoutPresentation>;
98
+ default: string;
83
99
  };
84
100
  timeout: NumberConstructor;
85
101
  title: StringConstructor;
86
102
  }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
87
103
  [key: string]: any;
88
104
  }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
105
+ canceled: (_event: Extract<CheckoutEvent, {
106
+ type: "canceled";
107
+ }>) => true;
89
108
  completed: (_event: Extract<CheckoutEvent, {
90
109
  type: "completed";
91
110
  }>) => true;
@@ -96,18 +115,24 @@ declare const Checkout: vue.DefineComponent<vue.ExtractPropTypes<{
96
115
  }>) => true;
97
116
  }, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
98
117
  appearance: PropType<CheckoutAppearance>;
118
+ features: PropType<CheckoutFeatures>;
99
119
  locale: StringConstructor;
100
- orderId: {
101
- type: StringConstructor;
102
- required: true;
120
+ orderId: StringConstructor;
121
+ purchaseIntentId: StringConstructor;
122
+ presentation: {
123
+ type: PropType<CheckoutPresentation>;
124
+ default: string;
103
125
  };
104
126
  timeout: NumberConstructor;
105
127
  title: StringConstructor;
106
128
  }>> & Readonly<{
107
- onCompleted?: (_event: _inttegro_js.CheckoutCompletedEvent) => any;
129
+ onCanceled?: (_event: _inttegro_js.CheckoutCanceledEvent) => any;
108
130
  onReady?: (_event: _inttegro_js.CheckoutReadyEvent) => any;
131
+ onCompleted?: (_event: _inttegro_js.CheckoutCompletedEvent) => any;
109
132
  onError?: (_event: CheckoutErrorEvent | Error) => any;
110
133
  onEvent?: (_event: CheckoutEvent) => any;
111
- }>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
134
+ }>, {
135
+ presentation: CheckoutPresentation;
136
+ }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
112
137
 
113
- export { Checkout, type CheckoutExposed, type CheckoutProps };
138
+ export { Checkout, type CheckoutExposed, type CheckoutProps, type CheckoutPropsBase };
package/dist/index.js CHANGED
@@ -14,12 +14,19 @@ var Checkout = defineComponent({
14
14
  name: "InttegroCheckout",
15
15
  props: {
16
16
  appearance: Object,
17
+ features: Object,
17
18
  locale: String,
18
- orderId: { type: String, required: true },
19
+ orderId: String,
20
+ purchaseIntentId: String,
21
+ presentation: {
22
+ type: String,
23
+ default: "embedded"
24
+ },
19
25
  timeout: Number,
20
26
  title: String
21
27
  },
22
28
  emits: {
29
+ canceled: (_event) => true,
23
30
  completed: (_event) => true,
24
31
  error: (_event) => true,
25
32
  event: (_event) => true,
@@ -41,6 +48,7 @@ var Checkout = defineComponent({
41
48
  destroyCheckout();
42
49
  const target = container.value;
43
50
  const currentGeneration = generation;
51
+ let canceled = false;
44
52
  if (!target) return;
45
53
  try {
46
54
  const inttegro = await loadInttegro();
@@ -48,8 +56,10 @@ var Checkout = defineComponent({
48
56
  const instance = inttegro.createCheckout(
49
57
  definedOptions({
50
58
  appearance: props.appearance,
59
+ features: props.features,
51
60
  locale: props.locale,
52
61
  orderId: props.orderId,
62
+ purchaseIntentId: props.purchaseIntentId,
53
63
  timeout: props.timeout,
54
64
  title: props.title
55
65
  })
@@ -61,13 +71,18 @@ var Checkout = defineComponent({
61
71
  checkout = instance;
62
72
  unsubscribe = instance.onEvent((event) => {
63
73
  emit("event", event);
74
+ if (event.type === "canceled") {
75
+ canceled = true;
76
+ emit("canceled", event);
77
+ }
64
78
  if (event.type === "ready") emit("ready", event);
65
79
  if (event.type === "completed") emit("completed", event);
66
80
  if (event.type === "error") emit("error", event);
67
81
  });
68
- await instance.mount(target);
82
+ if (props.presentation === "modal") await instance.present();
83
+ else await instance.mount(target);
69
84
  } catch (error) {
70
- if (generation !== currentGeneration) return;
85
+ if (generation !== currentGeneration || canceled) return;
71
86
  emit(
72
87
  "error",
73
88
  error instanceof Error ? error : new Error("Checkout failed to load.")
@@ -77,7 +92,14 @@ var Checkout = defineComponent({
77
92
  onMounted(mountCheckout);
78
93
  onBeforeUnmount(destroyCheckout);
79
94
  watch(
80
- () => [props.orderId, props.timeout, props.title],
95
+ () => [
96
+ props.features,
97
+ props.orderId,
98
+ props.purchaseIntentId,
99
+ props.presentation,
100
+ props.timeout,
101
+ props.title
102
+ ],
81
103
  () => void mountCheckout()
82
104
  );
83
105
  watch(
@@ -88,6 +110,7 @@ var Checkout = defineComponent({
88
110
  { deep: true }
89
111
  );
90
112
  expose({
113
+ dismiss: () => checkout?.dismiss(),
91
114
  focus: () => checkout?.focus(),
92
115
  update: (options) => checkout?.update(options)
93
116
  });
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/Checkout.ts"],"sourcesContent":["import {\n loadInttegro,\n type CheckoutAppearance,\n type CheckoutController,\n type CheckoutErrorEvent,\n type CheckoutEvent,\n} from '@inttegro/js'\nimport {\n defineComponent,\n h,\n onBeforeUnmount,\n onMounted,\n ref,\n watch,\n type PropType,\n} from 'vue'\n\n/**\n * Props accepted by the Inttegro {@link Checkout} component.\n *\n * Changing `orderId`, `timeout`, or `title` replaces the hosted controller.\n * Changing `appearance` or `locale` updates it in place, preserving payer\n * progress where the hosted flow permits.\n *\n * @category Vue\n */\nexport interface CheckoutProps {\n /** Initial and reactive theme preference for hosted Checkout. */\n appearance?: CheckoutAppearance | undefined\n /** Initial and reactive BCP 47 locale preference. */\n locale?: string | undefined\n /** Client-safe reference for the finalized Order being paid. */\n orderId: string\n /** Mount timeout from 1,000–60,000 ms; defaults to 15,000 ms. */\n timeout?: number | undefined\n /** Accessible iframe title; defaults to `Checkout`. */\n title?: string | undefined\n}\n\n/**\n * Imperative operations exposed by {@link Checkout} through a Vue template ref.\n *\n * @category Vue\n */\nexport interface CheckoutExposed {\n /** Moves focus into Checkout when the controller is ready; otherwise does nothing. */\n focus(): void\n /** Applies a new locale or theme when a controller exists. */\n update(options: Parameters<CheckoutController['update']>[0]): void\n}\n\n/**\n * Embeds Inttegro-hosted Checkout in a Vue application.\n *\n * The component owns the loader and controller lifecycle. It emits:\n *\n * - `ready` once the iframe is interactive;\n * - `event` for every sanitized Checkout lifecycle event;\n * - `completed` at the successful hosted terminal state; and\n * - `error` for loader/mount failures or sanitized hosted errors.\n *\n * Keep the component mounted while payment or confirmation is pending. On\n * unmount it removes its event subscription and permanently destroys the\n * controller.\n *\n * @example Use native Vue events\n * ```vue\n * <script setup lang=\"ts\">\n * import { ref } from 'vue'\n * import { Checkout, type CheckoutExposed } from '@inttegro/vue'\n *\n * const props = defineProps<{ orderId: string }>()\n * const checkout = ref<CheckoutExposed>()\n * </script>\n *\n * <template>\n * <Checkout\n * ref=\"checkout\"\n * :order-id=\"props.orderId\"\n * :appearance=\"{ theme: 'system' }\"\n * @ready=\"checkout?.focus()\"\n * @completed=\"$router.push('/orders/complete')\"\n * @error=\"reportCheckoutError\"\n * />\n * </template>\n * ```\n *\n * @category Vue\n */\nexport const Checkout = defineComponent({\n name: 'InttegroCheckout',\n props: {\n appearance: Object as PropType<CheckoutAppearance>,\n locale: String,\n orderId: { type: String, required: true },\n timeout: Number,\n title: String,\n },\n emits: {\n completed: (_event: Extract<CheckoutEvent, { type: 'completed' }>) => true,\n error: (_event: CheckoutErrorEvent | Error) => true,\n event: (_event: CheckoutEvent) => true,\n ready: (_event: Extract<CheckoutEvent, { type: 'ready' }>) => true,\n },\n setup(props, { emit, expose }) {\n const container = ref<HTMLElement>()\n let checkout: CheckoutController | undefined\n let unsubscribe: (() => void) | undefined\n let generation = 0\n\n function destroyCheckout() {\n generation += 1\n unsubscribe?.()\n unsubscribe = undefined\n checkout?.destroy()\n checkout = undefined\n }\n\n async function mountCheckout() {\n destroyCheckout()\n const target = container.value\n const currentGeneration = generation\n if (!target) return\n try {\n const inttegro = await loadInttegro()\n if (generation !== currentGeneration || !inttegro) return\n const instance = inttegro.createCheckout(\n definedOptions({\n appearance: props.appearance,\n locale: props.locale,\n orderId: props.orderId,\n timeout: props.timeout,\n title: props.title,\n }),\n )\n if (generation !== currentGeneration) {\n instance.destroy()\n return\n }\n checkout = instance\n unsubscribe = instance.onEvent((event) => {\n emit('event', event)\n if (event.type === 'ready') emit('ready', event)\n if (event.type === 'completed') emit('completed', event)\n if (event.type === 'error') emit('error', event)\n })\n await instance.mount(target)\n } catch (error: unknown) {\n if (generation !== currentGeneration) return\n emit(\n 'error',\n error instanceof Error\n ? error\n : new Error('Checkout failed to load.'),\n )\n }\n }\n\n onMounted(mountCheckout)\n onBeforeUnmount(destroyCheckout)\n\n watch(\n () => [props.orderId, props.timeout, props.title],\n () => void mountCheckout(),\n )\n watch(\n () => [props.appearance, props.locale] as const,\n ([appearance, locale]) => {\n checkout?.update(definedOptions({ appearance, locale }))\n },\n { deep: true },\n )\n\n expose({\n focus: () => checkout?.focus(),\n update: (options: Parameters<CheckoutController['update']>[0]) =>\n checkout?.update(options),\n })\n\n return () => h('div', { ref: container })\n },\n})\n\nfunction definedOptions<Value extends object>(options: Value): Value {\n return Object.fromEntries(\n Object.entries(options).filter(([, value]) => value !== undefined),\n ) as Value\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,OAKK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AA0EA,IAAM,WAAW,gBAAgB;AAAA,EACtC,MAAM;AAAA,EACN,OAAO;AAAA,IACL,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR,SAAS,EAAE,MAAM,QAAQ,UAAU,KAAK;AAAA,IACxC,SAAS;AAAA,IACT,OAAO;AAAA,EACT;AAAA,EACA,OAAO;AAAA,IACL,WAAW,CAAC,WAA0D;AAAA,IACtE,OAAO,CAAC,WAAuC;AAAA,IAC/C,OAAO,CAAC,WAA0B;AAAA,IAClC,OAAO,CAAC,WAAsD;AAAA,EAChE;AAAA,EACA,MAAM,OAAO,EAAE,MAAM,OAAO,GAAG;AAC7B,UAAM,YAAY,IAAiB;AACnC,QAAI;AACJ,QAAI;AACJ,QAAI,aAAa;AAEjB,aAAS,kBAAkB;AACzB,oBAAc;AACd,oBAAc;AACd,oBAAc;AACd,gBAAU,QAAQ;AAClB,iBAAW;AAAA,IACb;AAEA,mBAAe,gBAAgB;AAC7B,sBAAgB;AAChB,YAAM,SAAS,UAAU;AACzB,YAAM,oBAAoB;AAC1B,UAAI,CAAC,OAAQ;AACb,UAAI;AACF,cAAM,WAAW,MAAM,aAAa;AACpC,YAAI,eAAe,qBAAqB,CAAC,SAAU;AACnD,cAAM,WAAW,SAAS;AAAA,UACxB,eAAe;AAAA,YACb,YAAY,MAAM;AAAA,YAClB,QAAQ,MAAM;AAAA,YACd,SAAS,MAAM;AAAA,YACf,SAAS,MAAM;AAAA,YACf,OAAO,MAAM;AAAA,UACf,CAAC;AAAA,QACH;AACA,YAAI,eAAe,mBAAmB;AACpC,mBAAS,QAAQ;AACjB;AAAA,QACF;AACA,mBAAW;AACX,sBAAc,SAAS,QAAQ,CAAC,UAAU;AACxC,eAAK,SAAS,KAAK;AACnB,cAAI,MAAM,SAAS,QAAS,MAAK,SAAS,KAAK;AAC/C,cAAI,MAAM,SAAS,YAAa,MAAK,aAAa,KAAK;AACvD,cAAI,MAAM,SAAS,QAAS,MAAK,SAAS,KAAK;AAAA,QACjD,CAAC;AACD,cAAM,SAAS,MAAM,MAAM;AAAA,MAC7B,SAAS,OAAgB;AACvB,YAAI,eAAe,kBAAmB;AACtC;AAAA,UACE;AAAA,UACA,iBAAiB,QACb,QACA,IAAI,MAAM,0BAA0B;AAAA,QAC1C;AAAA,MACF;AAAA,IACF;AAEA,cAAU,aAAa;AACvB,oBAAgB,eAAe;AAE/B;AAAA,MACE,MAAM,CAAC,MAAM,SAAS,MAAM,SAAS,MAAM,KAAK;AAAA,MAChD,MAAM,KAAK,cAAc;AAAA,IAC3B;AACA;AAAA,MACE,MAAM,CAAC,MAAM,YAAY,MAAM,MAAM;AAAA,MACrC,CAAC,CAAC,YAAY,MAAM,MAAM;AACxB,kBAAU,OAAO,eAAe,EAAE,YAAY,OAAO,CAAC,CAAC;AAAA,MACzD;AAAA,MACA,EAAE,MAAM,KAAK;AAAA,IACf;AAEA,WAAO;AAAA,MACL,OAAO,MAAM,UAAU,MAAM;AAAA,MAC7B,QAAQ,CAAC,YACP,UAAU,OAAO,OAAO;AAAA,IAC5B,CAAC;AAED,WAAO,MAAM,EAAE,OAAO,EAAE,KAAK,UAAU,CAAC;AAAA,EAC1C;AACF,CAAC;AAED,SAAS,eAAqC,SAAuB;AACnE,SAAO,OAAO;AAAA,IACZ,OAAO,QAAQ,OAAO,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,MAAM,UAAU,MAAS;AAAA,EACnE;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/Checkout.ts"],"sourcesContent":["import {\n loadInttegro,\n type CheckoutAppearance,\n type CheckoutController,\n type CheckoutErrorEvent,\n type CheckoutEvent,\n type CheckoutFeatures,\n type CheckoutOptions,\n type CheckoutPresentation,\n} from '@inttegro/js'\nimport {\n defineComponent,\n h,\n onBeforeUnmount,\n onMounted,\n ref,\n watch,\n type PropType,\n} from 'vue'\n\n/**\n * Props accepted by the Inttegro {@link Checkout} component.\n *\n * Changing `features`, the Checkout reference, `presentation`, `timeout`, or\n * `title` replaces the hosted controller. Changing `appearance` or `locale`\n * updates it in place, preserving payer progress where the hosted flow permits.\n *\n * @category Vue\n */\nexport interface CheckoutPropsBase {\n /** Initial and reactive theme preference for hosted Checkout. */\n appearance?: CheckoutAppearance | undefined\n /** Hosted Checkout content and actions. Changing it replaces the controller. */\n features?: CheckoutFeatures | undefined\n /** Initial and reactive BCP 47 locale preference. */\n locale?: string | undefined\n /** Displays Checkout inline by default or in an Inttegro-managed modal. */\n presentation?: CheckoutPresentation | undefined\n /** Mount timeout from 1,000–60,000 ms; defaults to 15,000 ms. */\n timeout?: number | undefined\n /** Accessible iframe title; defaults to `Checkout`. */\n title?: string | undefined\n}\n\nexport type CheckoutProps = CheckoutPropsBase &\n (\n | { orderId: string; purchaseIntentId?: never }\n | { orderId?: never; purchaseIntentId: string }\n )\n\n/**\n * Imperative operations exposed by {@link Checkout} through a Vue template ref.\n *\n * @category Vue\n */\nexport interface CheckoutExposed {\n /** Closes managed modal Checkout when it is open. */\n dismiss(): void\n /** Moves focus into Checkout when the controller is ready; otherwise does nothing. */\n focus(): void\n /** Applies a new locale or theme when a controller exists. */\n update(options: Parameters<CheckoutController['update']>[0]): void\n}\n\n/**\n * Displays Inttegro-hosted Checkout in a Vue application.\n *\n * The component owns the loader and controller lifecycle. It emits:\n *\n * - `ready` once the iframe is interactive;\n * - `event` for every sanitized Checkout lifecycle event;\n * - `canceled` when a payer dismisses managed modal Checkout;\n * - `completed` at the successful hosted terminal state; and\n * - `error` for loader/mount failures or sanitized hosted errors.\n *\n * Keep the component mounted while payment or confirmation is pending. On\n * unmount it removes its event subscription and permanently destroys the\n * controller.\n *\n * @example Use native Vue events\n * ```vue\n * <script setup lang=\"ts\">\n * import { ref } from 'vue'\n * import { Checkout, type CheckoutExposed } from '@inttegro/vue'\n *\n * const props = defineProps<{ orderId: string }>()\n * const checkout = ref<CheckoutExposed>()\n * </script>\n *\n * <template>\n * <Checkout\n * ref=\"checkout\"\n * :order-id=\"props.orderId\"\n * presentation=\"modal\"\n * :appearance=\"{ theme: 'system' }\"\n * @ready=\"checkout?.focus()\"\n * @completed=\"$router.push('/orders/complete')\"\n * @error=\"reportCheckoutError\"\n * />\n * </template>\n * ```\n *\n * @category Vue\n */\nexport const Checkout = defineComponent({\n name: 'InttegroCheckout',\n props: {\n appearance: Object as PropType<CheckoutAppearance>,\n features: Object as PropType<CheckoutFeatures>,\n locale: String,\n orderId: String,\n purchaseIntentId: String,\n presentation: {\n type: String as PropType<CheckoutPresentation>,\n default: 'embedded',\n },\n timeout: Number,\n title: String,\n },\n emits: {\n canceled: (_event: Extract<CheckoutEvent, { type: 'canceled' }>) => true,\n completed: (_event: Extract<CheckoutEvent, { type: 'completed' }>) => true,\n error: (_event: CheckoutErrorEvent | Error) => true,\n event: (_event: CheckoutEvent) => true,\n ready: (_event: Extract<CheckoutEvent, { type: 'ready' }>) => true,\n },\n setup(props, { emit, expose }) {\n const container = ref<HTMLElement>()\n let checkout: CheckoutController | undefined\n let unsubscribe: (() => void) | undefined\n let generation = 0\n\n function destroyCheckout() {\n generation += 1\n unsubscribe?.()\n unsubscribe = undefined\n checkout?.destroy()\n checkout = undefined\n }\n\n async function mountCheckout() {\n destroyCheckout()\n const target = container.value\n const currentGeneration = generation\n let canceled = false\n if (!target) return\n try {\n const inttegro = await loadInttegro()\n if (generation !== currentGeneration || !inttegro) return\n const instance = inttegro.createCheckout(\n definedOptions({\n appearance: props.appearance,\n features: props.features,\n locale: props.locale,\n orderId: props.orderId,\n purchaseIntentId: props.purchaseIntentId,\n timeout: props.timeout,\n title: props.title,\n }) as CheckoutOptions,\n )\n if (generation !== currentGeneration) {\n instance.destroy()\n return\n }\n checkout = instance\n unsubscribe = instance.onEvent((event) => {\n emit('event', event)\n if (event.type === 'canceled') {\n canceled = true\n emit('canceled', event)\n }\n if (event.type === 'ready') emit('ready', event)\n if (event.type === 'completed') emit('completed', event)\n if (event.type === 'error') emit('error', event)\n })\n if (props.presentation === 'modal') await instance.present()\n else await instance.mount(target)\n } catch (error: unknown) {\n if (generation !== currentGeneration || canceled) return\n emit(\n 'error',\n error instanceof Error\n ? error\n : new Error('Checkout failed to load.'),\n )\n }\n }\n\n onMounted(mountCheckout)\n onBeforeUnmount(destroyCheckout)\n\n watch(\n () => [\n props.features,\n props.orderId,\n props.purchaseIntentId,\n props.presentation,\n props.timeout,\n props.title,\n ],\n () => void mountCheckout(),\n )\n watch(\n () => [props.appearance, props.locale] as const,\n ([appearance, locale]) => {\n checkout?.update(definedOptions({ appearance, locale }))\n },\n { deep: true },\n )\n\n expose({\n dismiss: () => checkout?.dismiss(),\n focus: () => checkout?.focus(),\n update: (options: Parameters<CheckoutController['update']>[0]) =>\n checkout?.update(options),\n })\n\n return () => h('div', { ref: container })\n },\n})\n\nfunction definedOptions<Value extends object>(options: Value): Value {\n return Object.fromEntries(\n Object.entries(options).filter(([, value]) => value !== undefined),\n ) as Value\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,OAQK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAsFA,IAAM,WAAW,gBAAgB;AAAA,EACtC,MAAM;AAAA,EACN,OAAO;AAAA,IACL,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,kBAAkB;AAAA,IAClB,cAAc;AAAA,MACZ,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,IACA,SAAS;AAAA,IACT,OAAO;AAAA,EACT;AAAA,EACA,OAAO;AAAA,IACL,UAAU,CAAC,WAAyD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,YACtD,OAAM,SAAS,MAAM,MAAM;AAAA,MAClC,SAAS,OAAgB;AACvB,YAAI,eAAe,qBAAqB,SAAU;AAClD;AAAA,UACE;AAAA,UACA,iBAAiB,QACb,QACA,IAAI,MAAM,0BAA0B;AAAA,QAC1C;AAAA,MACF;AAAA,IACF;AAEA,cAAU,aAAa;AACvB,oBAAgB,eAAe;AAE/B;AAAA,MACE,MAAM;AAAA,QACJ,MAAM;AAAA,QACN,MAAM;AAAA,QACN,MAAM;AAAA,QACN,MAAM;AAAA,QACN,MAAM;AAAA,QACN,MAAM;AAAA,MACR;AAAA,MACA,MAAM,KAAK,cAAc;AAAA,IAC3B;AACA;AAAA,MACE,MAAM,CAAC,MAAM,YAAY,MAAM,MAAM;AAAA,MACrC,CAAC,CAAC,YAAY,MAAM,MAAM;AACxB,kBAAU,OAAO,eAAe,EAAE,YAAY,OAAO,CAAC,CAAC;AAAA,MACzD;AAAA,MACA,EAAE,MAAM,KAAK;AAAA,IACf;AAEA,WAAO;AAAA,MACL,SAAS,MAAM,UAAU,QAAQ;AAAA,MACjC,OAAO,MAAM,UAAU,MAAM;AAAA,MAC7B,QAAQ,CAAC,YACP,UAAU,OAAO,OAAO;AAAA,IAC5B,CAAC;AAED,WAAO,MAAM,EAAE,OAAO,EAAE,KAAK,UAAU,CAAC;AAAA,EAC1C;AACF,CAAC;AAED,SAAS,eAAqC,SAAuB;AACnE,SAAO,OAAO;AAAA,IACZ,OAAO,QAAQ,OAAO,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,MAAM,UAAU,MAAS;AAAA,EACnE;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inttegro/vue",
3
- "version": "0.1.0",
3
+ "version": "0.4.0",
4
4
  "description": "Vue components for Inttegro hosted workflows",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -32,14 +32,14 @@
32
32
  "typecheck": "tsc --noEmit"
33
33
  },
34
34
  "dependencies": {
35
- "@inttegro/js": "0.1.0"
35
+ "@inttegro/js": "0.4.0"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "vue": ">=3.4"
39
39
  },
40
40
  "repository": {
41
41
  "type": "git",
42
- "url": "git+https://github.com/zebodotdev/js.git",
42
+ "url": "git+https://github.com/inttegro/js.git",
43
43
  "directory": "packages/vue"
44
44
  },
45
45
  "homepage": "https://studio.inttegro.com/web/vue",