recur-tw 0.1.0 → 0.2.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/LICENSE +93 -21
- package/README.md +9 -1
- package/dist/index.cjs +0 -2
- package/dist/index.js +0 -2
- package/dist/recur.umd.js +0 -1
- package/package.json +2 -2
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/recur.umd.js.map +0 -1
package/LICENSE
CHANGED
|
@@ -1,21 +1,93 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Copyright
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
Elastic License 2.0 (ELv2)
|
|
2
|
+
|
|
3
|
+
Copyright 2025 Recur
|
|
4
|
+
|
|
5
|
+
## Acceptance
|
|
6
|
+
|
|
7
|
+
By using the software, you agree to all of the terms and conditions below.
|
|
8
|
+
|
|
9
|
+
## Copyright License
|
|
10
|
+
|
|
11
|
+
The licensor grants you a non-exclusive, royalty-free, worldwide,
|
|
12
|
+
non-sublicensable, non-transferable license to use, copy, distribute, make
|
|
13
|
+
available, and prepare derivative works of the software, in each case subject to
|
|
14
|
+
the limitations and conditions below.
|
|
15
|
+
|
|
16
|
+
## Limitations
|
|
17
|
+
|
|
18
|
+
You may not provide the software to third parties as a hosted or managed
|
|
19
|
+
service, where the service provides users with access to any substantial set of
|
|
20
|
+
the features or functionality of the software.
|
|
21
|
+
|
|
22
|
+
You may not move, change, disable, or circumvent the license key functionality
|
|
23
|
+
in the software, and you may not remove or obscure any functionality in the
|
|
24
|
+
software that is protected by the license key.
|
|
25
|
+
|
|
26
|
+
You may not alter, remove, or obscure any licensing, copyright, or other notices
|
|
27
|
+
of the licensor in the software. Any use of the licensor's trademarks is subject
|
|
28
|
+
to applicable law.
|
|
29
|
+
|
|
30
|
+
## Patents
|
|
31
|
+
|
|
32
|
+
The licensor grants you a license, under any patent claims the licensor can
|
|
33
|
+
license, or becomes able to license, to make, have made, use, sell, offer for
|
|
34
|
+
sale, import and have imported the software, in each case subject to the
|
|
35
|
+
limitations and conditions in this license. This license does not cover any
|
|
36
|
+
patent claims that you cause to be infringed by modifications or additions to
|
|
37
|
+
the software. If you or your company make any written claim that the software
|
|
38
|
+
infringes or contributes to infringement of any patent, your patent license for
|
|
39
|
+
the software granted under these terms ends immediately. If your company makes
|
|
40
|
+
such a claim, your patent license ends immediately for work on behalf of your
|
|
41
|
+
company.
|
|
42
|
+
|
|
43
|
+
## Notices
|
|
44
|
+
|
|
45
|
+
You must ensure that anyone who gets a copy of any part of the software from you
|
|
46
|
+
also gets a copy of these terms.
|
|
47
|
+
|
|
48
|
+
If you modify the software, you must include in any modified copies of the
|
|
49
|
+
software prominent notices stating that you have modified the software.
|
|
50
|
+
|
|
51
|
+
## No Other Rights
|
|
52
|
+
|
|
53
|
+
These terms do not imply any licenses other than those expressly granted in
|
|
54
|
+
these terms.
|
|
55
|
+
|
|
56
|
+
## Termination
|
|
57
|
+
|
|
58
|
+
If you use the software in violation of these terms, such use is not licensed,
|
|
59
|
+
and your licenses will automatically terminate. If the licensor provides you
|
|
60
|
+
with a notice of your violation, and you cease all violation of this license no
|
|
61
|
+
later than 30 days after you receive that notice, your licenses will be
|
|
62
|
+
reinstated retroactively. However, if you violate these terms after such
|
|
63
|
+
reinstatement, any additional violation of these terms will cause your licenses
|
|
64
|
+
to terminate automatically and permanently.
|
|
65
|
+
|
|
66
|
+
## No Liability
|
|
67
|
+
|
|
68
|
+
*As far as the law allows, the software comes as is, without any warranty or
|
|
69
|
+
condition, and the licensor will not be liable to you for any damages arising
|
|
70
|
+
out of these terms or the use or nature of the software, under any kind of
|
|
71
|
+
legal claim.*
|
|
72
|
+
|
|
73
|
+
## Definitions
|
|
74
|
+
|
|
75
|
+
The **licensor** is the entity offering these terms, and the **software** is the
|
|
76
|
+
software the licensor makes available under these terms, including any portion
|
|
77
|
+
of it.
|
|
78
|
+
|
|
79
|
+
**you** refers to the individual or entity agreeing to these terms.
|
|
80
|
+
|
|
81
|
+
**your company** is any legal entity, sole proprietorship, or other kind of
|
|
82
|
+
organization that you work for, plus all organizations that have control over,
|
|
83
|
+
are under the control of, or are under common control with that organization.
|
|
84
|
+
**control** means ownership of substantially all the assets of an entity, or the
|
|
85
|
+
power to direct its management and policies by vote, contract, or otherwise.
|
|
86
|
+
Control can be direct or indirect.
|
|
87
|
+
|
|
88
|
+
**your licenses** are all the licenses granted to you for the software under
|
|
89
|
+
these terms.
|
|
90
|
+
|
|
91
|
+
**use** means anything you do with the software requiring one of your licenses.
|
|
92
|
+
|
|
93
|
+
**trademark** means trademarks, service marks, and similar rights.
|
package/README.md
CHANGED
|
@@ -747,7 +747,15 @@ This is part of the Recur project. Please see the main repository for contributi
|
|
|
747
747
|
|
|
748
748
|
## License
|
|
749
749
|
|
|
750
|
-
|
|
750
|
+
This project is licensed under the [Elastic License 2.0](./LICENSE).
|
|
751
|
+
|
|
752
|
+
**你可以:**
|
|
753
|
+
- 在你的應用程式中使用此 SDK
|
|
754
|
+
- 修改程式碼供自己使用
|
|
755
|
+
|
|
756
|
+
**你不可以:**
|
|
757
|
+
- 將此 SDK 作為託管服務提供給第三方
|
|
758
|
+
- 移除或規避授權機制
|
|
751
759
|
|
|
752
760
|
---
|
|
753
761
|
|
package/dist/index.cjs
CHANGED
package/dist/index.js
CHANGED
package/dist/recur.umd.js
CHANGED
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "recur-tw",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "React & Vanilla JS SDK for embedding subscription checkout flows (Taiwan / PAYUNi)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
7
7
|
"author": "Recur",
|
|
8
|
-
"license": "
|
|
8
|
+
"license": "Elastic-2.0",
|
|
9
9
|
"keywords": [
|
|
10
10
|
"react",
|
|
11
11
|
"vanilla-js",
|
package/dist/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/base/loading-spinner.ts","../src/components/base/success-message.ts","../src/components/base/error-display.ts","../src/components/base/skeleton-loader.ts","../src/components/base/payment-form-skeleton.ts","../src/components/base/toast.ts","../src/components/payment-form.ts","../src/components/checkout-button.ts","../src/components/index.ts","../src/payuni-loader.ts","../src/context.tsx","../src/use-recur.ts","../src/hooks/use-plans.ts","../src/hooks/use-subscribe.ts"],"names":["createContext","useState","React","useCallback","useMemo","jsx","useContext","isLoading","error","useEffect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,IAAA,uBAAA,GAAA,EAAA;AAAA,QAAA,CAAA,uBAAA,EAAA;AAAA,EAAA,mBAAA,EAAA,MAAA;AAAA,CAAA,CAAA;AAAA,IAOa,mBAAA;AAPb,IAAA,oBAAA,GAAA,KAAA,CAAA;AAAA,EAAA,wCAAA,GAAA;AAOO,IAAM,mBAAA,GAAN,cAAkC,WAAA,CAAY;AAAA,MACnD,WAAW,kBAAA,GAAqB;AAC9B,QAAA,OAAO,CAAC,WAAW,MAAM,CAAA;AAAA,MAC3B;AAAA,MAEA,WAAA,GAAc;AACZ,QAAA,KAAA,EAAM;AACN,QAAA,IAAA,CAAK,YAAA,CAAa,EAAE,IAAA,EAAM,MAAA,EAAQ,CAAA;AAAA,MACpC;AAAA,MAEA,iBAAA,GAAoB;AAClB,QAAA,IAAA,CAAK,MAAA,EAAO;AAAA,MACd;AAAA,MAEA,wBAAA,CAAyB,IAAA,EAAc,QAAA,EAAkB,QAAA,EAAkB;AACzE,QAAA,IAAI,aAAa,QAAA,EAAU;AACzB,UAAA,IAAA,CAAK,MAAA,EAAO;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nC,YAAA,iBAAA,GAAoB,YAAY,CAAA;AAAA,UAClC,CAAA;AAAA,UACA,OAAA,EAAS,CAAC,GAAA,KAAQ;AAChB,YAAA,QAAA,CAAS,GAAG,CAAA;AACZ,YAAA,OAAA,GAAU,GAAG,CAAA;AAAA,UACf,CAAA;AAAA,UACA,iBAAiB,MAAM;AACrB,YAAA,eAAA,IAAkB;AAAA,UACpB;AAAA,SACD,CAAA;AAAA,MACH,SAAS,GAAA,EAAK;AACZ,QAAA,MAAM,aAAA,GAA+B;AAAA,UACnC,IAAA,EAAM,iBAAA;AAAA,UACN,OAAA,EAAS,GAAA,YAAe,KAAA,GAAQ,GAAA,CAAI,OAAA,GAAU;AAAA,SAChD;AACA,QAAA,QAAA,CAAS,aAAa,CAAA;AACtB,QAAA,OAAA,GAAU,aAAa,CAAA;AAAA,MACzB;AAAA,IACF,CAAA;AAAA,IACA,CAAC,QAAA,EAAU,SAAA,EAAW,OAAA,EAAS,mBAAmB,eAAe;AAAA,GACnE;AAEA,EAAA,MAAM,KAAA,GAAQA,kBAAY,MAAM;AAC9B,IAAA,QAAA,CAAS,IAAI,CAAA;AAAA,EACf,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,OAAO;AAAA,IACL,MAAA;AAAA,IACA,SAAA,EAAW,MAAA;AAAA,IACX,SAAA,EAAW,aAAA;AAAA,IACX,KAAA;AAAA,IACA;AAAA,GACF;AACF","file":"index.cjs","sourcesContent":["/**\n * Recur Loading Spinner Web Component\n *\n * A reusable loading spinner with customizable message and size.\n * Eliminates code duplication across the SDK.\n */\n\nexport class RecurLoadingSpinner extends HTMLElement {\n static get observedAttributes() {\n return ['message', 'size'];\n }\n\n constructor() {\n super();\n this.attachShadow({ mode: 'open' });\n }\n\n connectedCallback() {\n this.render();\n }\n\n attributeChangedCallback(name: string, oldValue: string, newValue: string) {\n if (oldValue !== newValue) {\n this.render();\n }\n }\n\n private get message(): string {\n return this.getAttribute('message') || '正在處理訂閱...';\n }\n\n private get size(): 'small' | 'medium' | 'large' {\n const sizeAttr = this.getAttribute('size');\n if (sizeAttr === 'small' || sizeAttr === 'large') return sizeAttr;\n return 'medium';\n }\n\n private getSizeValue(): number {\n const sizes = {\n small: 24,\n medium: 40,\n large: 56,\n };\n return sizes[this.size];\n }\n\n private render() {\n const size = this.getSizeValue();\n\n this.shadowRoot!.innerHTML = `\n <style>\n :host {\n display: block;\n text-align: center;\n }\n\n @keyframes recur-sdk-spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n\n .recur-sdk__spinner {\n border: 3px solid #e5e7eb;\n border-top: 3px solid var(--recur-primary-color, #3b82f6);\n border-radius: 50%;\n width: ${size}px;\n height: ${size}px;\n animation: recur-sdk-spin 1s linear infinite;\n margin: 0 auto 16px;\n }\n\n .recur-sdk__loading-text {\n color: var(--recur-text-secondary, #6b7280);\n font-size: ${this.size === 'small' ? '12px' : '14px'};\n margin: 0;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n }\n\n /* 支持主題化 */\n :host([theme=\"dark\"]) .recur-sdk__spinner {\n border-color: #374151;\n border-top-color: #60a5fa;\n }\n\n :host([theme=\"dark\"]) .recur-sdk__loading-text {\n color: #9ca3af;\n }\n </style>\n\n <div class=\"recur-sdk__spinner\"></div>\n ${this.message ? `<p class=\"recur-sdk__loading-text\">${this.message}</p>` : ''}\n `;\n }\n}\n\n// 自動註冊組件(如果還未註冊)\nif (typeof window !== 'undefined' && !customElements.get('recur-loading-spinner')) {\n customElements.define('recur-loading-spinner', RecurLoadingSpinner);\n}\n\n// TypeScript 類型聲明\ndeclare global {\n interface HTMLElementTagNameMap {\n 'recur-loading-spinner': RecurLoadingSpinner;\n }\n}\n","/**\n * Recur Success Message Web Component\n *\n * A reusable success message display with icon and customizable text.\n */\n\nexport class RecurSuccessMessage extends HTMLElement {\n static get observedAttributes() {\n return ['title', 'message', 'icon'];\n }\n\n constructor() {\n super();\n this.attachShadow({ mode: 'open' });\n }\n\n connectedCallback() {\n this.render();\n }\n\n attributeChangedCallback(name: string, oldValue: string, newValue: string) {\n if (oldValue !== newValue) {\n this.render();\n }\n }\n\n private get successTitle(): string {\n return this.getAttribute('title') || 'Subscription Complete!';\n }\n\n private get successMessage(): string {\n return this.getAttribute('message') || 'Thank you for subscribing. Your payment has been processed successfully.';\n }\n\n private get showIcon(): boolean {\n return this.getAttribute('icon') !== 'false';\n }\n\n private render() {\n this.shadowRoot!.innerHTML = `\n <style>\n :host {\n display: block;\n text-align: center;\n padding: var(--recur-spacing-lg, 48px) var(--recur-spacing-md, 24px);\n }\n\n .recur-sdk__success-container {\n max-width: 400px;\n margin: 0 auto;\n }\n\n .recur-sdk__success-icon {\n width: 64px;\n height: 64px;\n margin: 0 auto 24px;\n background: var(--recur-success-bg, #d1fae5);\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .recur-sdk__success-icon svg {\n width: 32px;\n height: 32px;\n color: var(--recur-success-color, #10b981);\n }\n\n .recur-sdk__success-title {\n font-size: 24px;\n font-weight: 600;\n color: var(--recur-text-primary, #1f2937);\n margin: 0 0 12px 0;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n }\n\n .recur-sdk__success-message {\n font-size: 16px;\n color: var(--recur-text-secondary, #6b7280);\n margin: 0;\n line-height: 1.5;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n }\n\n /* Slot for custom actions */\n ::slotted(button), ::slotted(a) {\n margin-top: 24px;\n }\n\n /* Dark theme support */\n :host([theme=\"dark\"]) .recur-sdk__success-icon {\n background: #065f46;\n }\n\n :host([theme=\"dark\"]) .recur-sdk__success-icon svg {\n color: #34d399;\n }\n\n :host([theme=\"dark\"]) .recur-sdk__success-title {\n color: #f3f4f6;\n }\n\n :host([theme=\"dark\"]) .recur-sdk__success-message {\n color: #d1d5db;\n }\n </style>\n\n <div class=\"recur-sdk__success-container\">\n ${this.showIcon ? `\n <div class=\"recur-sdk__success-icon\">\n <svg fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M5 13l4 4L19 7\" />\n </svg>\n </div>\n ` : ''}\n <h2 class=\"recur-sdk__success-title\">${this.successTitle}</h2>\n <p class=\"recur-sdk__success-message\">${this.successMessage}</p>\n <slot></slot>\n </div>\n `;\n }\n}\n\n// 自動註冊組件\nif (typeof window !== 'undefined' && !customElements.get('recur-success-message')) {\n customElements.define('recur-success-message', RecurSuccessMessage);\n}\n\n// TypeScript 類型聲明\ndeclare global {\n interface HTMLElementTagNameMap {\n 'recur-success-message': RecurSuccessMessage;\n }\n}\n","/**\n * Recur Error Display Web Component\n *\n * A reusable error message display with customizable styling and dismissible option.\n */\n\nexport class RecurErrorDisplay extends HTMLElement {\n static get observedAttributes() {\n return ['error', 'dismissible'];\n }\n\n constructor() {\n super();\n this.attachShadow({ mode: 'open' });\n }\n\n connectedCallback() {\n this.render();\n }\n\n attributeChangedCallback(name: string, oldValue: string, newValue: string) {\n if (oldValue !== newValue) {\n this.render();\n }\n }\n\n private get error(): string {\n return this.getAttribute('error') || '';\n }\n\n private get isDismissible(): boolean {\n return this.getAttribute('dismissible') === 'true';\n }\n\n private handleDismiss() {\n this.dispatchEvent(new CustomEvent('dismiss', {\n bubbles: true,\n composed: true,\n }));\n this.remove();\n }\n\n private render() {\n if (!this.error) {\n this.shadowRoot!.innerHTML = '';\n return;\n }\n\n this.shadowRoot!.innerHTML = `\n <style>\n :host {\n display: block;\n margin: var(--recur-spacing-sm, 16px) 0;\n }\n\n .recur-sdk__error {\n display: flex;\n align-items: flex-start;\n gap: 12px;\n padding: 12px 16px;\n background: var(--recur-error-bg, #fee2e2);\n border: 1px solid var(--recur-error-border, #fecaca);\n border-radius: var(--recur-border-radius, 6px);\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n }\n\n .recur-sdk__error-icon {\n flex-shrink: 0;\n width: 20px;\n height: 20px;\n color: var(--recur-error-color, #dc2626);\n }\n\n .recur-sdk__error-content {\n flex: 1;\n }\n\n .recur-sdk__error-message {\n margin: 0;\n font-size: 14px;\n color: var(--recur-error-text, #991b1b);\n line-height: 1.5;\n }\n\n .recur-sdk__error-dismiss {\n flex-shrink: 0;\n background: none;\n border: none;\n padding: 0;\n width: 20px;\n height: 20px;\n cursor: pointer;\n color: var(--recur-error-color, #dc2626);\n opacity: 0.7;\n transition: opacity 0.2s;\n }\n\n .recur-sdk__error-dismiss:hover {\n opacity: 1;\n }\n\n .recur-sdk__error-dismiss:focus {\n outline: 2px solid var(--recur-error-color, #dc2626);\n outline-offset: 2px;\n border-radius: 2px;\n }\n\n /* Dark theme support */\n :host([theme=\"dark\"]) .recur-sdk__error {\n background: #7f1d1d;\n border-color: #991b1b;\n }\n\n :host([theme=\"dark\"]) .recur-sdk__error-icon,\n :host([theme=\"dark\"]) .recur-sdk__error-dismiss {\n color: #fca5a5;\n }\n\n :host([theme=\"dark\"]) .recur-sdk__error-message {\n color: #fecaca;\n }\n </style>\n\n <div class=\"recur-sdk__error\" role=\"alert\">\n <svg class=\"recur-sdk__error-icon\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z\" />\n </svg>\n <div class=\"recur-sdk__error-content\">\n <p class=\"recur-sdk__error-message\">${this.error}</p>\n </div>\n ${this.isDismissible ? `\n <button class=\"recur-sdk__error-dismiss\" aria-label=\"Dismiss error\">\n <svg fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M6 18L18 6M6 6l12 12\" />\n </svg>\n </button>\n ` : ''}\n </div>\n `;\n\n if (this.isDismissible) {\n const dismissBtn = this.shadowRoot!.querySelector('.recur-sdk__error-dismiss');\n dismissBtn?.addEventListener('click', () => this.handleDismiss());\n }\n }\n}\n\n// 自動註冊組件\nif (typeof window !== 'undefined' && !customElements.get('recur-error-display')) {\n customElements.define('recur-error-display', RecurErrorDisplay);\n}\n\n// TypeScript 類型聲明\ndeclare global {\n interface HTMLElementTagNameMap {\n 'recur-error-display': RecurErrorDisplay;\n }\n}\n","/**\n * Recur Skeleton Loader Web Component\n *\n * A reusable skeleton loading animation for payment forms.\n * Provides visual feedback while content is being loaded.\n */\n\nexport class RecurSkeletonLoader extends HTMLElement {\n static get observedAttributes() {\n return ['type'];\n }\n\n constructor() {\n super();\n this.attachShadow({ mode: 'open' });\n }\n\n connectedCallback() {\n this.render();\n }\n\n attributeChangedCallback(name: string, oldValue: string, newValue: string) {\n if (oldValue !== newValue) {\n this.render();\n }\n }\n\n private get type(): 'payment-form' | 'list' | 'card' {\n const typeAttr = this.getAttribute('type');\n if (typeAttr === 'list' || typeAttr === 'card') return typeAttr;\n return 'payment-form';\n }\n\n private renderPaymentFormSkeleton(): string {\n return `\n <div class=\"skeleton-field\">\n <div class=\"skeleton-label\"></div>\n <div class=\"skeleton-input\"></div>\n </div>\n <div class=\"skeleton-field\">\n <div class=\"skeleton-label\"></div>\n <div class=\"skeleton-input\"></div>\n </div>\n <div class=\"skeleton-field\">\n <div class=\"skeleton-label\"></div>\n <div class=\"skeleton-input\"></div>\n </div>\n <div class=\"skeleton-divider\"></div>\n <div class=\"skeleton-field\">\n <div class=\"skeleton-label\"></div>\n <div class=\"skeleton-input\"></div>\n </div>\n <div class=\"skeleton-field\">\n <div class=\"skeleton-label\"></div>\n <div class=\"skeleton-row\">\n <div class=\"skeleton-input-half\"></div>\n <div class=\"skeleton-input-half\"></div>\n </div>\n </div>\n <div class=\"skeleton-button\"></div>\n `;\n }\n\n private renderListSkeleton(): string {\n return `\n <div class=\"skeleton-list-item\"></div>\n <div class=\"skeleton-list-item\"></div>\n <div class=\"skeleton-list-item\"></div>\n `;\n }\n\n private renderCardSkeleton(): string {\n return `\n <div class=\"skeleton-card-header\"></div>\n <div class=\"skeleton-card-body\">\n <div class=\"skeleton-text\"></div>\n <div class=\"skeleton-text\"></div>\n <div class=\"skeleton-text short\"></div>\n </div>\n `;\n }\n\n private render() {\n let content = '';\n switch (this.type) {\n case 'list':\n content = this.renderListSkeleton();\n break;\n case 'card':\n content = this.renderCardSkeleton();\n break;\n default:\n content = this.renderPaymentFormSkeleton();\n }\n\n this.shadowRoot!.innerHTML = `\n <style>\n :host {\n display: block;\n }\n\n @keyframes recur-sdk-pulse {\n 0%, 100% {\n opacity: 1;\n }\n 50% {\n opacity: 0.4;\n }\n }\n\n .skeleton-field {\n margin-bottom: 20px;\n }\n\n .skeleton-label {\n width: 80px;\n height: 14px;\n background: var(--recur-skeleton-bg, #e5e7eb);\n border-radius: 4px;\n margin-bottom: 8px;\n animation: recur-sdk-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;\n }\n\n .skeleton-input {\n width: 100%;\n height: 42px;\n background: var(--recur-skeleton-bg, #e5e7eb);\n border-radius: var(--recur-border-radius, 6px);\n animation: recur-sdk-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;\n animation-delay: 0.1s;\n }\n\n .skeleton-row {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 12px;\n }\n\n .skeleton-input-half {\n height: 42px;\n background: var(--recur-skeleton-bg, #e5e7eb);\n border-radius: var(--recur-border-radius, 6px);\n animation: recur-sdk-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;\n animation-delay: 0.15s;\n }\n\n .skeleton-divider {\n height: 1px;\n background: var(--recur-skeleton-bg, #e5e7eb);\n margin: 24px 0;\n animation: recur-sdk-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;\n animation-delay: 0.2s;\n }\n\n .skeleton-button {\n width: 100%;\n height: 48px;\n background: var(--recur-skeleton-bg, #e5e7eb);\n border-radius: 8px;\n margin-top: 8px;\n animation: recur-sdk-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;\n animation-delay: 0.25s;\n }\n\n /* List skeleton */\n .skeleton-list-item {\n width: 100%;\n height: 60px;\n background: var(--recur-skeleton-bg, #e5e7eb);\n border-radius: var(--recur-border-radius, 6px);\n margin-bottom: 12px;\n animation: recur-sdk-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;\n }\n\n .skeleton-list-item:nth-child(2) {\n animation-delay: 0.1s;\n }\n\n .skeleton-list-item:nth-child(3) {\n animation-delay: 0.2s;\n }\n\n /* Card skeleton */\n .skeleton-card-header {\n width: 100%;\n height: 120px;\n background: var(--recur-skeleton-bg, #e5e7eb);\n border-radius: var(--recur-border-radius, 6px) var(--recur-border-radius, 6px) 0 0;\n animation: recur-sdk-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;\n }\n\n .skeleton-card-body {\n padding: 16px;\n }\n\n .skeleton-text {\n width: 100%;\n height: 16px;\n background: var(--recur-skeleton-bg, #e5e7eb);\n border-radius: 4px;\n margin-bottom: 12px;\n animation: recur-sdk-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;\n animation-delay: 0.1s;\n }\n\n .skeleton-text.short {\n width: 60%;\n animation-delay: 0.2s;\n }\n\n /* Dark theme support */\n :host([theme=\"dark\"]) .skeleton-label,\n :host([theme=\"dark\"]) .skeleton-input,\n :host([theme=\"dark\"]) .skeleton-input-half,\n :host([theme=\"dark\"]) .skeleton-divider,\n :host([theme=\"dark\"]) .skeleton-button,\n :host([theme=\"dark\"]) .skeleton-list-item,\n :host([theme=\"dark\"]) .skeleton-card-header,\n :host([theme=\"dark\"]) .skeleton-text {\n background: #374151;\n }\n </style>\n\n ${content}\n `;\n }\n}\n\n// 自動註冊組件\nif (typeof window !== 'undefined' && !customElements.get('recur-skeleton-loader')) {\n customElements.define('recur-skeleton-loader', RecurSkeletonLoader);\n}\n\n// TypeScript 類型聲明\ndeclare global {\n interface HTMLElementTagNameMap {\n 'recur-skeleton-loader': RecurSkeletonLoader;\n }\n}\n","/**\n * Payment Form Skeleton Web Component\n *\n * Displays a loading skeleton that matches the structure of RecurPaymentForm\n * This provides better UX by showing the expected form layout during initial loading\n */\n\nexport class RecurPaymentFormSkeleton extends HTMLElement {\n constructor() {\n super();\n this.attachShadow({ mode: 'open' });\n }\n\n connectedCallback() {\n this.render();\n }\n\n private render() {\n this.shadowRoot!.innerHTML = `\n <style>\n :host {\n display: block;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n }\n\n .payment-form-wrapper {\n max-width: 500px;\n margin: 0 auto;\n padding: 24px;\n background: white;\n border-radius: 12px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n }\n\n .form-header {\n margin-bottom: 24px;\n }\n\n .form-section {\n margin-bottom: 24px;\n }\n\n .section-title {\n margin: 0 0 12px 0;\n font-size: 16px;\n font-weight: 600;\n color: #2d3748;\n }\n\n .label {\n font-size: 14px;\n color: #4a5568;\n margin-bottom: 4px;\n }\n\n /* Skeleton base styles */\n .skeleton {\n background: linear-gradient(\n 90deg,\n #f0f0f0 0%,\n #f8f8f8 50%,\n #f0f0f0 100%\n );\n background-size: 200% 100%;\n animation: skeleton-loading 1.5s ease-in-out infinite;\n border-radius: 4px;\n }\n\n @keyframes skeleton-loading {\n 0% {\n background-position: 200% 0;\n }\n 100% {\n background-position: -200% 0;\n }\n }\n\n .skeleton-title {\n height: 28px;\n width: 200px;\n margin-bottom: 8px;\n }\n\n .skeleton-subtitle {\n height: 18px;\n width: 320px;\n }\n\n .skeleton-order-summary {\n padding: 16px;\n background: #f7fafc;\n border-radius: 6px;\n margin-bottom: 24px;\n }\n\n .skeleton-order-row {\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin-bottom: 12px;\n }\n\n .skeleton-order-row:last-child {\n margin-bottom: 0;\n padding-top: 12px;\n border-top: 1px solid #e2e8f0;\n font-weight: 600;\n }\n\n .skeleton-order-value {\n height: 20px;\n width: 120px;\n }\n\n .input-group {\n margin-bottom: 16px;\n }\n\n .input-group:last-child {\n margin-bottom: 0;\n }\n\n .skeleton-input {\n height: 44px;\n width: 100%;\n }\n\n .card-fields-grid {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 12px;\n }\n\n .skeleton-button {\n height: 44px;\n width: 100%;\n border-radius: 6px;\n }\n\n .security-note {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 12px;\n background: #f7fafc;\n border-radius: 6px;\n margin-top: 16px;\n }\n\n .security-icon {\n color: #48bb78;\n }\n\n .security-text {\n font-size: 13px;\n color: #4a5568;\n margin: 0;\n }\n </style>\n\n <div class=\"payment-form-wrapper\">\n <!-- Header Skeleton -->\n <div class=\"form-header\">\n <div class=\"skeleton skeleton-title\"></div>\n <div class=\"skeleton skeleton-subtitle\"></div>\n </div>\n\n <!-- Order Summary - Static labels, skeleton values -->\n <div class=\"skeleton-order-summary\">\n <h3 class=\"section-title\">訂單摘要</h3>\n <div class=\"skeleton-order-row\">\n <span class=\"label\">方案</span>\n <div class=\"skeleton skeleton-order-value\"></div>\n </div>\n <div class=\"skeleton-order-row\">\n <span class=\"label\">金額</span>\n <div class=\"skeleton skeleton-order-value\"></div>\n </div>\n <div class=\"skeleton-order-row\">\n <span class=\"label\">週期</span>\n <div class=\"skeleton skeleton-order-value\"></div>\n </div>\n <div class=\"skeleton-order-row\">\n <span class=\"label\">總計</span>\n <div class=\"skeleton skeleton-order-value\"></div>\n </div>\n </div>\n\n <!-- Customer Info Section - Static labels, skeleton inputs -->\n <div class=\"form-section\">\n <h3 class=\"section-title\">客戶資訊</h3>\n <div class=\"input-group\">\n <div class=\"label\">姓名</div>\n <div class=\"skeleton skeleton-input\"></div>\n </div>\n <div class=\"input-group\">\n <div class=\"label\">Email</div>\n <div class=\"skeleton skeleton-input\"></div>\n </div>\n <div class=\"input-group\">\n <div class=\"label\">電話(選填)</div>\n <div class=\"skeleton skeleton-input\"></div>\n </div>\n </div>\n\n <!-- Card Fields Section - Static labels, skeleton inputs -->\n <div class=\"form-section\">\n <h3 class=\"section-title\">信用卡資訊</h3>\n <div class=\"input-group\">\n <div class=\"label\">信用卡號</div>\n <div class=\"skeleton skeleton-input\"></div>\n </div>\n <div class=\"card-fields-grid\">\n <div class=\"input-group\">\n <div class=\"label\">有效期限</div>\n <div class=\"skeleton skeleton-input\"></div>\n </div>\n <div class=\"input-group\">\n <div class=\"label\">安全碼</div>\n <div class=\"skeleton skeleton-input\"></div>\n </div>\n </div>\n </div>\n\n <!-- Submit Button Skeleton -->\n <div class=\"skeleton skeleton-button\"></div>\n\n <!-- Security Note -->\n <div class=\"security-note\">\n <svg class=\"security-icon\" width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z\" />\n </svg>\n <p class=\"security-text\">您的付款資訊經過加密保護</p>\n </div>\n </div>\n `;\n }\n}\n\n// Register component if not already registered\nif (typeof window !== 'undefined' && !customElements.get('recur-payment-form-skeleton')) {\n customElements.define('recur-payment-form-skeleton', RecurPaymentFormSkeleton);\n}\n\n// TypeScript type declaration\ndeclare global {\n interface HTMLElementTagNameMap {\n 'recur-payment-form-skeleton': RecurPaymentFormSkeleton;\n }\n}\n","/**\n * Recur Toast Notification Component\n *\n * A lightweight, non-intrusive toast notification for success, error, and info messages.\n * Auto-dismisses after a configurable duration.\n */\n\nexport class RecurToast extends HTMLElement {\n static get observedAttributes() {\n return ['message', 'type', 'duration'];\n }\n\n constructor() {\n super();\n this.attachShadow({ mode: 'open' });\n }\n\n connectedCallback() {\n this.render();\n this.setupAutoDismiss();\n }\n\n private get message(): string {\n return this.getAttribute('message') || 'Notification';\n }\n\n private get type(): 'success' | 'error' | 'info' {\n const typeAttr = this.getAttribute('type');\n if (typeAttr === 'success' || typeAttr === 'error') return typeAttr;\n return 'info';\n }\n\n private get duration(): number {\n const durationAttr = this.getAttribute('duration');\n return durationAttr ? parseInt(durationAttr, 10) : 5000;\n }\n\n private setupAutoDismiss() {\n const duration = this.duration;\n if (duration > 0) {\n setTimeout(() => this.dismiss(), duration);\n }\n }\n\n private dismiss() {\n // Add exit animation\n this.style.animation = 'recur-toast-slide-out 0.3s ease-in-out';\n setTimeout(() => this.remove(), 300);\n }\n\n private getTypeIcon(): string {\n switch (this.type) {\n case 'success':\n return `<svg width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M5 13l4 4L19 7\" />\n </svg>`;\n case 'error':\n return `<svg width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M6 18L18 6M6 6l12 12\" />\n </svg>`;\n case 'info':\n default:\n return `<svg width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z\" />\n </svg>`;\n }\n }\n\n private getTypeColor(): string {\n switch (this.type) {\n case 'success':\n return '#10b981'; // green-500\n case 'error':\n return '#ef4444'; // red-500\n case 'info':\n default:\n return '#3b82f6'; // blue-500\n }\n }\n\n private render() {\n const color = this.getTypeColor();\n\n this.shadowRoot!.innerHTML = `\n <style>\n :host {\n display: block;\n margin-bottom: 12px;\n animation: recur-toast-slide-in 0.3s ease-out;\n }\n\n @keyframes recur-toast-slide-in {\n from {\n transform: translateX(100%);\n opacity: 0;\n }\n to {\n transform: translateX(0);\n opacity: 1;\n }\n }\n\n @keyframes recur-toast-slide-out {\n from {\n transform: translateX(0);\n opacity: 1;\n }\n to {\n transform: translateX(100%);\n opacity: 0;\n }\n }\n\n .toast {\n display: flex;\n align-items: center;\n gap: 12px;\n padding: 12px 16px;\n background: white;\n border-left: 4px solid ${color};\n border-radius: 8px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n min-width: 280px;\n max-width: 420px;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n cursor: pointer;\n transition: transform 0.2s ease;\n }\n\n .toast:hover {\n transform: translateY(-2px);\n box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);\n }\n\n .toast-icon {\n flex-shrink: 0;\n color: ${color};\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .toast-message {\n flex: 1;\n color: #374151;\n font-size: 14px;\n line-height: 1.5;\n margin: 0;\n }\n\n .toast-close {\n flex-shrink: 0;\n color: #9ca3af;\n cursor: pointer;\n padding: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 4px;\n transition: all 0.2s;\n }\n\n .toast-close:hover {\n color: #6b7280;\n background: #f3f4f6;\n }\n\n /* Dark mode support */\n :host([theme=\"dark\"]) .toast {\n background: #1f2937;\n }\n\n :host([theme=\"dark\"]) .toast-message {\n color: #e5e7eb;\n }\n\n :host([theme=\"dark\"]) .toast-close {\n color: #6b7280;\n }\n\n :host([theme=\"dark\"]) .toast-close:hover {\n color: #9ca3af;\n background: #374151;\n }\n </style>\n\n <div class=\"toast\" role=\"alert\">\n <div class=\"toast-icon\">\n ${this.getTypeIcon()}\n </div>\n <p class=\"toast-message\">${this.message}</p>\n <button class=\"toast-close\" aria-label=\"Close\">\n <svg width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M6 18L18 6M6 6l12 12\" />\n </svg>\n </button>\n </div>\n `;\n\n // Add click handler for close button\n const closeBtn = this.shadowRoot!.querySelector('.toast-close');\n closeBtn?.addEventListener('click', (e) => {\n e.stopPropagation();\n this.dismiss();\n });\n\n // Click anywhere on toast to dismiss\n const toast = this.shadowRoot!.querySelector('.toast');\n toast?.addEventListener('click', () => this.dismiss());\n }\n\n /**\n * Static helper method to show toast\n */\n static show(\n message: string,\n type: 'success' | 'error' | 'info' = 'info',\n duration: number = 5000\n ): RecurToast {\n const container = RecurToastContainer.getInstance();\n\n const toast = document.createElement('recur-toast');\n toast.setAttribute('message', message);\n toast.setAttribute('type', type);\n toast.setAttribute('duration', duration.toString());\n\n container.appendChild(toast);\n\n return toast;\n }\n}\n\n/**\n * Toast Container - Manages toast stack positioning\n */\nexport class RecurToastContainer extends HTMLElement {\n private static instance: RecurToastContainer | null = null;\n\n constructor() {\n super();\n this.attachShadow({ mode: 'open' });\n }\n\n connectedCallback() {\n this.render();\n }\n\n private render() {\n this.shadowRoot!.innerHTML = `\n <style>\n :host {\n position: fixed;\n top: 24px;\n right: 24px;\n z-index: 9999;\n display: flex;\n flex-direction: column;\n pointer-events: none;\n }\n\n ::slotted(*) {\n pointer-events: auto;\n }\n\n /* Mobile responsive */\n @media (max-width: 640px) {\n :host {\n top: 16px;\n right: 16px;\n left: 16px;\n }\n }\n </style>\n\n <slot></slot>\n `;\n }\n\n /**\n * Get or create singleton instance\n */\n static getInstance(): RecurToastContainer {\n if (!RecurToastContainer.instance) {\n RecurToastContainer.instance = document.querySelector('recur-toast-container');\n\n if (!RecurToastContainer.instance) {\n RecurToastContainer.instance = document.createElement('recur-toast-container');\n document.body.appendChild(RecurToastContainer.instance);\n }\n }\n\n return RecurToastContainer.instance;\n }\n}\n\n// Auto-register components\nif (typeof window !== 'undefined' && !customElements.get('recur-toast')) {\n customElements.define('recur-toast', RecurToast);\n}\n\nif (typeof window !== 'undefined' && !customElements.get('recur-toast-container')) {\n customElements.define('recur-toast-container', RecurToastContainer);\n}\n\n// TypeScript type declarations\ndeclare global {\n interface HTMLElementTagNameMap {\n 'recur-toast': RecurToast;\n 'recur-toast-container': RecurToastContainer;\n }\n}\n","/**\n * Recur Payment Form Web Component (混合模式)\n *\n * 使用 Shadow DOM 包裝外層 UI,PAYUNi 容器保持在 Light DOM\n * 這樣既能享受樣式隔離,又能讓 PAYUNi SDK 正常工作\n */\n\nexport class RecurPaymentForm extends HTMLElement {\n private containerId: string;\n private customStyles: string;\n private _isInitializing = false;\n private _initializationAborted = false;\n\n constructor() {\n super();\n\n // 生成唯一的 container ID\n this.containerId = this.getAttribute('container-id') || `recur-${Date.now()}`;\n\n // 獲取自定義樣式(如果有提供)\n this.customStyles = this.getAttribute('custom-styles') || '';\n\n // 創建 Shadow DOM(用於外層 UI 和樣式隔離)\n this.attachShadow({ mode: 'open' });\n }\n\n connectedCallback() {\n this.render();\n }\n\n disconnectedCallback() {\n console.log('[PaymentForm] Component disconnected, cleaning up...');\n\n // Mark initialization as aborted to stop any ongoing operations\n this._initializationAborted = true;\n\n // Clear payment session reference\n (this as any)._paymentSession = null;\n\n // Remove event listeners from submit button by replacing with clone\n const submitBtn = document.getElementById(`${this.containerId}-submit-btn`);\n if (submitBtn) {\n const newBtn = submitBtn.cloneNode(true);\n submitBtn.parentNode?.replaceChild(newBtn, submitBtn);\n }\n }\n\n // 監聽 attribute 變化\n static get observedAttributes() {\n return ['custom-styles', 'customer-name', 'customer-email', 'plan-name', 'amount', 'billing-period'];\n }\n\n attributeChangedCallback(name: string, oldValue: string, newValue: string) {\n if (name === 'custom-styles' && oldValue !== newValue) {\n this.customStyles = newValue || '';\n this.updateCustomStyles();\n } else if (oldValue !== newValue) {\n // Re-render customer info section when customer/order data changes\n this.updateCustomerInfoSection();\n }\n }\n\n private render() {\n // Shadow DOM 內容:外層 UI 結構和樣式\n this.shadowRoot!.innerHTML = `\n <style>\n /* 這些樣式被隔離在 Shadow DOM 內,不會影響外部 */\n :host {\n display: block;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n }\n\n .payment-form-wrapper {\n max-width: 500px;\n margin: 0 auto;\n padding: 24px;\n background: white;\n border-radius: 12px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n }\n\n .form-header {\n margin-bottom: 24px;\n }\n\n .form-title {\n font-size: 24px;\n font-weight: 600;\n color: #1a202c;\n margin: 0 0 8px 0;\n }\n\n .form-subtitle {\n font-size: 14px;\n color: #718096;\n margin: 0;\n }\n\n .form-section {\n margin-bottom: 24px;\n }\n\n .section-title {\n font-size: 14px;\n font-weight: 600;\n color: #2d3748;\n margin: 0 0 12px 0;\n }\n\n /* Slot 樣式 - 這會應用到 slotted 內容 */\n ::slotted(*) {\n display: block;\n }\n\n .security-note {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 12px;\n background: #f7fafc;\n border-radius: 6px;\n margin-top: 16px;\n }\n\n .security-icon {\n color: #48bb78;\n }\n\n .security-text {\n font-size: 13px;\n color: #4a5568;\n margin: 0;\n }\n </style>\n\n <div class=\"payment-form-wrapper\">\n <div class=\"form-header\">\n <h2 class=\"form-title\">付款資訊</h2>\n <p class=\"form-subtitle\">請填寫您的信用卡資訊以完成訂閱</p>\n </div>\n\n <!-- Slot for order summary (Light DOM) -->\n <slot name=\"order-summary\"></slot>\n\n <div class=\"form-section\">\n <h3 class=\"section-title\">客戶資訊</h3>\n <!-- Slot for customer info fields (Light DOM) -->\n <slot name=\"customer-info\"></slot>\n </div>\n\n <div class=\"form-section\">\n <h3 class=\"section-title\">信用卡資訊</h3>\n <!-- Slot for PAYUNi card fields (Light DOM) -->\n <slot name=\"card-fields\"></slot>\n </div>\n\n <!-- Slot for submit button (Light DOM) -->\n <slot name=\"actions\"></slot>\n\n <div class=\"security-note\">\n <svg class=\"security-icon\" width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z\" />\n </svg>\n <p class=\"security-text\">您的付款資訊經過加密保護</p>\n </div>\n </div>\n `;\n\n // Light DOM 內容:PAYUNi 需要訪問的元素\n this.createLightDOMContent();\n }\n\n private createLightDOMContent() {\n // 清空現有 Light DOM 內容\n this.innerHTML = '';\n\n // 創建自定義樣式容器(Light DOM - 這樣可以影響 PAYUNi iframes)\n const styleElement = document.createElement('style');\n styleElement.id = `${this.containerId}-custom-styles`;\n\n // 組合自定義樣式和 ID 選擇器樣式\n const idSpecificStyles = `\n /* PAYUNi iframe 容器高度(使用實際的 container ID) */\n #${this.containerId}-card-no,\n #${this.containerId}-card-exp,\n #${this.containerId}-card-cvc {\n height: 36px !important;\n }\n `;\n\n styleElement.textContent = this.customStyles + '\\n' + idSpecificStyles;\n this.appendChild(styleElement);\n\n // 創建訂單摘要區塊(Light DOM)\n const orderSummary = this.createOrderSummarySection();\n orderSummary.slot = 'order-summary';\n this.appendChild(orderSummary);\n\n // 創建客戶資訊區塊(Light DOM)\n const customerInfo = this.createCustomerInfoSection();\n customerInfo.slot = 'customer-info';\n this.appendChild(customerInfo);\n\n // 創建信用卡欄位區塊(Light DOM - PAYUNi 會使用這些 ID)\n const cardFields = this.createCardFieldsSection();\n cardFields.slot = 'card-fields';\n this.appendChild(cardFields);\n\n // 創建操作按鈕區塊(Light DOM)\n const actions = this.createActionsSection();\n actions.slot = 'actions';\n this.appendChild(actions);\n }\n\n private updateCustomerInfoSection() {\n // Update customer info section when attributes change\n const existingSection = this.querySelector('[slot=\"customer-info\"]');\n if (existingSection) {\n const newSection = this.createCustomerInfoSection();\n newSection.slot = 'customer-info';\n existingSection.replaceWith(newSection);\n }\n }\n\n private updateCustomStyles() {\n const styleElement = this.querySelector(`#${this.containerId}-custom-styles`) as HTMLStyleElement;\n if (styleElement) {\n // 組合自定義樣式和 ID 選擇器樣式\n const idSpecificStyles = `\n /* PAYUNi iframe 容器高度(使用實際的 container ID) */\n #${this.containerId}-card-no,\n #${this.containerId}-card-exp,\n #${this.containerId}-card-cvc {\n height: 36px !important;\n }\n `;\n styleElement.textContent = this.customStyles + '\\n' + idSpecificStyles;\n }\n }\n\n private createOrderSummarySection(): HTMLElement {\n const section = document.createElement('div');\n section.className = 'order-summary-section';\n\n // Get order data from attributes\n const planName = this.getAttribute('plan-name');\n const amount = this.getAttribute('amount');\n const billingPeriod = this.getAttribute('billing-period');\n\n // Only show order summary if we have the data\n if (!planName || !amount) {\n return section;\n }\n\n // Format billing period in Chinese\n const billingPeriodMap: { [key: string]: string } = {\n 'MONTHLY': '月',\n 'QUARTERLY': '季',\n 'YEARLY': '年',\n 'WEEKLY': '週',\n };\n const periodText = billingPeriod ? billingPeriodMap[billingPeriod] || billingPeriod : '';\n\n section.innerHTML = `\n <style>\n .order-summary-section {\n background: #f7fafc;\n border: 1px solid #e2e8f0;\n border-radius: 8px;\n padding: 16px;\n margin-bottom: 24px;\n }\n\n .order-summary-title {\n font-size: 14px;\n font-weight: 600;\n color: #2d3748;\n margin: 0 0 12px 0;\n }\n\n .order-summary-item {\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin-bottom: 8px;\n }\n\n .order-summary-item:last-child {\n margin-bottom: 0;\n padding-top: 12px;\n border-top: 1px solid #e2e8f0;\n }\n\n .order-summary-label {\n font-size: 14px;\n color: #4a5568;\n }\n\n .order-summary-value {\n font-size: 14px;\n font-weight: 500;\n color: #2d3748;\n }\n\n .order-summary-total {\n font-size: 18px;\n font-weight: 700;\n color: #1a202c;\n }\n </style>\n\n <h3 class=\"order-summary-title\">訂單摘要</h3>\n <div class=\"order-summary-item\">\n <span class=\"order-summary-label\">訂閱方案</span>\n <span class=\"order-summary-value\">${planName}</span>\n </div>\n ${periodText ? `\n <div class=\"order-summary-item\">\n <span class=\"order-summary-label\">計費週期</span>\n <span class=\"order-summary-value\">每${periodText}</span>\n </div>\n ` : ''}\n <div class=\"order-summary-item\">\n <span class=\"order-summary-label\">總計</span>\n <span class=\"order-summary-total\">NT$ ${Number(amount).toLocaleString()}</span>\n </div>\n `;\n\n return section;\n }\n\n private createCustomerInfoSection(): HTMLElement {\n const section = document.createElement('div');\n section.className = 'customer-info-section';\n\n // Check if customer data is provided via attributes\n const customerName = this.getAttribute('customer-name');\n const customerEmail = this.getAttribute('customer-email');\n\n // If customer data is provided, show as read-only display\n if (customerName && customerEmail) {\n section.innerHTML = `\n <style>\n .recur-info-display {\n background: #f7fafc;\n border: 1px solid #e2e8f0;\n border-radius: 6px;\n padding: 12px;\n margin-bottom: 8px;\n }\n\n .recur-info-row {\n display: flex;\n align-items: center;\n margin-bottom: 6px;\n }\n\n .recur-info-row:last-child {\n margin-bottom: 0;\n }\n\n .recur-info-label {\n font-size: 13px;\n color: #718096;\n min-width: 80px;\n }\n\n .recur-info-value {\n font-size: 14px;\n color: #2d3748;\n font-weight: 500;\n }\n </style>\n\n <div class=\"recur-info-display\">\n <div class=\"recur-info-row\">\n <span class=\"recur-info-label\">客戶姓名:</span>\n <span class=\"recur-info-value\">${customerName}</span>\n </div>\n <div class=\"recur-info-row\">\n <span class=\"recur-info-label\">電子郵件:</span>\n <span class=\"recur-info-value\">${customerEmail}</span>\n </div>\n </div>\n `;\n } else {\n // Show input fields if customer data is not provided\n section.innerHTML = `\n <style>\n /* 這些樣式在 Light DOM 中,會影響全局 */\n /* 使用帶 prefix 的 class name 避免衝突 */\n .recur-form-group {\n margin-bottom: 16px;\n }\n\n .recur-form-label {\n display: block;\n font-size: 14px;\n font-weight: 500;\n color: #2d3748;\n margin-bottom: 6px;\n }\n\n .recur-form-input {\n width: 100%;\n padding: 10px 12px;\n font-size: 14px;\n border: 1px solid #d1d5db;\n border-radius: 6px;\n transition: border-color 0.2s;\n box-sizing: border-box;\n }\n\n .recur-form-input:focus {\n outline: none;\n border-color: #3b82f6;\n box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);\n }\n\n .recur-form-input:hover:not(:focus) {\n border-color: #9ca3af;\n }\n </style>\n\n <div class=\"recur-form-group\">\n <label class=\"recur-form-label\" for=\"${this.containerId}-email\">Email</label>\n <input\n type=\"email\"\n id=\"${this.containerId}-email\"\n class=\"recur-form-input\"\n placeholder=\"your@email.com\"\n required\n />\n </div>\n\n <div class=\"recur-form-group\">\n <label class=\"recur-form-label\" for=\"${this.containerId}-name\">姓名</label>\n <input\n type=\"text\"\n id=\"${this.containerId}-name\"\n class=\"recur-form-input\"\n placeholder=\"王小明\"\n required\n />\n </div>\n\n <div class=\"recur-form-group\">\n <label class=\"recur-form-label\" for=\"${this.containerId}-phone\">電話</label>\n <input\n type=\"tel\"\n id=\"${this.containerId}-phone\"\n class=\"recur-form-input\"\n placeholder=\"+886 912345678\"\n required\n />\n </div>\n `;\n }\n\n return section;\n }\n\n private createCardFieldsSection(): HTMLElement {\n const section = document.createElement('div');\n section.className = 'card-fields-section';\n\n section.innerHTML = `\n <style>\n .recur-card-field {\n margin-bottom: 16px;\n }\n\n .recur-card-field-label {\n display: block;\n font-size: 14px;\n font-weight: 500;\n color: #2d3748;\n margin-bottom: 6px;\n }\n\n /* PAYUNi iframe 容器樣式 */\n .recur-payuni-iframe {\n height: 36px;\n width: 100%;\n }\n\n .recur-card-row {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 12px;\n }\n </style>\n\n <div class=\"recur-card-field\">\n <label class=\"recur-card-field-label\">卡號</label>\n <div class=\"recur-card-field-container\" id=\"${this.containerId}-card-no-wrapper\">\n <!-- PAYUNi 會在這裡注入 iframe -->\n <div id=\"${this.containerId}-card-no\" class=\"recur-payuni-iframe\"></div>\n </div>\n </div>\n\n <div class=\"recur-card-row\">\n <div class=\"recur-card-field\">\n <label class=\"recur-card-field-label\">有效期限</label>\n <div class=\"recur-card-field-container\" id=\"${this.containerId}-card-exp-wrapper\">\n <div id=\"${this.containerId}-card-exp\" class=\"recur-payuni-iframe\"></div>\n </div>\n </div>\n\n <div class=\"recur-card-field\">\n <label class=\"recur-card-field-label\">安全碼</label>\n <div class=\"recur-card-field-container\" id=\"${this.containerId}-card-cvc-wrapper\">\n <div id=\"${this.containerId}-card-cvc\" class=\"recur-payuni-iframe\"></div>\n </div>\n </div>\n </div>\n `;\n\n return section;\n }\n\n private createActionsSection(): HTMLElement {\n const section = document.createElement('div');\n section.className = 'actions-section';\n\n section.innerHTML = `\n <style>\n .recur-submit-button {\n width: 100%;\n padding: 14px 20px;\n font-size: 16px;\n font-weight: 500;\n color: #ffffff;\n background: #18181b;\n border: none;\n border-radius: 6px;\n cursor: pointer;\n transition: background-color 0.2s;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n }\n\n .recur-submit-button:hover:not(:disabled) {\n background: #27272a;\n }\n\n .recur-submit-button:disabled {\n opacity: 0.6;\n cursor: not-allowed;\n }\n\n .recur-submit-button.loading {\n cursor: wait;\n }\n\n .recur-loading-spinner {\n width: 16px;\n height: 16px;\n border: 2px solid currentColor;\n border-top-color: transparent;\n border-radius: 50%;\n animation: recur-spin 0.6s linear infinite;\n }\n\n @keyframes recur-spin {\n to { transform: rotate(360deg); }\n }\n </style>\n\n <button\n type=\"submit\"\n id=\"${this.containerId}-submit-btn\"\n class=\"recur-submit-button\"\n disabled\n >\n <span id=\"${this.containerId}-submit-text\">確認付款</span>\n </button>\n `;\n\n return section;\n }\n\n /**\n * 初始化 PAYUNi SDK\n * 這個方法會在外部調用,傳入 SDK token\n */\n async initializePayment(sdkToken: string, environment: 'SANDBOX' | 'PRODUCTION') {\n // Checkpoint 1: Check if component was already disconnected before starting\n if (this._initializationAborted) {\n console.log('[PaymentForm] Initialization aborted before start');\n return null;\n }\n\n // Mark that initialization is in progress\n this._isInitializing = true;\n\n // 等待 DOM 完全準備好\n await this.updateComplete();\n\n // Checkpoint 2: Check if disconnected while waiting for DOM\n if (this._initializationAborted) {\n console.log('[PaymentForm] Initialization aborted after updateComplete');\n this._isInitializing = false;\n return null;\n }\n\n // 確認 PAYUNi SDK 已加載\n if (!window.UniPayment) {\n this._isInitializing = false;\n throw new Error('PAYUNi SDK not loaded');\n }\n\n try {\n // Checkpoint 3: Verify DOM elements exist before creating session\n const cardNoEl = document.getElementById(`${this.containerId}-card-no`);\n const cardExpEl = document.getElementById(`${this.containerId}-card-exp`);\n const cardCvcEl = document.getElementById(`${this.containerId}-card-cvc`);\n\n if (!cardNoEl || !cardExpEl || !cardCvcEl) {\n console.log('[PaymentForm] DOM elements not found, likely disconnected');\n this._isInitializing = false;\n return null;\n }\n\n // Checkpoint 4: Check again before creating session\n if (this._initializationAborted) {\n console.log('[PaymentForm] Initialization aborted before createSession');\n this._isInitializing = false;\n return null;\n }\n\n // 初始化 PAYUNi\n const paymentSession = window.UniPayment.createSession(sdkToken, {\n env: environment === 'SANDBOX' ? 'S' : 'P',\n elements: {\n // 這些 ID 在 Light DOM 中,document.getElementById 可以找到\n CardNo: `${this.containerId}-card-no`,\n CardExp: `${this.containerId}-card-exp`,\n CardCvc: `${this.containerId}-card-cvc`,\n },\n });\n\n // Checkpoint 5: Check before starting payment session (the critical async operation)\n if (this._initializationAborted) {\n console.log('[PaymentForm] Initialization aborted before paymentSession.start()');\n this._isInitializing = false;\n return null;\n }\n\n // Start payment session with error handling for 1008 timeout\n try {\n await paymentSession.start();\n } catch (startError: any) {\n // Check if this is the 1008 timeout error and component was disconnected\n const is1008Error = startError?.message?.includes('1008') ||\n startError?.message?.includes('timeout') ||\n startError?.code === 1008;\n\n if (is1008Error && this._initializationAborted) {\n // Component was disconnected during initialization, silently ignore the error\n console.log('[PaymentForm] Caught 1008 timeout error after component disconnect - ignoring');\n this._isInitializing = false;\n return null;\n }\n\n // For other errors or if component is still mounted, re-throw\n throw startError;\n }\n\n // Checkpoint 6: Check after start completes (this is where 1008 error would occur)\n if (this._initializationAborted) {\n console.log('[PaymentForm] Initialization aborted after paymentSession.start()');\n this._isInitializing = false;\n return null;\n }\n\n // 監聽 PAYUNi 事件\n paymentSession.onUpdate?.((data: any) => {\n // Check if component is still mounted when event fires\n if (this._initializationAborted) {\n console.log('[PaymentForm] Ignoring onUpdate event - component disconnected');\n return;\n }\n\n console.log('[PaymentForm] PAYUNi update:', data);\n\n // 檢查所有卡片欄位是否都已填寫完成\n const allFieldsComplete = data.status &&\n data.status.CardNo === true &&\n data.status.CardExp === true &&\n data.status.CardCvc === true;\n\n // 啟用/禁用提交按鈕\n const submitBtn = document.getElementById(`${this.containerId}-submit-btn`) as HTMLButtonElement;\n if (submitBtn) {\n submitBtn.disabled = !allFieldsComplete;\n console.log('[PaymentForm] Submit button disabled:', !allFieldsComplete);\n }\n });\n\n // Checkpoint 7: Final check before saving session\n if (this._initializationAborted) {\n console.log('[PaymentForm] Initialization aborted before saving session');\n this._isInitializing = false;\n return null;\n }\n\n // 保存 session 供後續使用\n (this as any)._paymentSession = paymentSession;\n\n // 設置表單提交處理\n this.setupFormSubmission();\n\n this._isInitializing = false;\n return paymentSession;\n } catch (error) {\n this._isInitializing = false;\n console.error('[PaymentForm] Failed to initialize payment:', error);\n throw error;\n }\n }\n\n private setupFormSubmission() {\n const submitBtn = document.getElementById(`${this.containerId}-submit-btn`) as HTMLButtonElement;\n if (!submitBtn) return;\n\n submitBtn.addEventListener('click', async (e) => {\n e.preventDefault();\n\n // Prevent double submission\n if (submitBtn.classList.contains('loading')) {\n return;\n }\n\n // 獲取客戶資訊 - 從輸入框或屬性\n let email: string | undefined;\n let name: string | undefined;\n let phone: string | undefined;\n\n // Try to get from input fields first\n const emailInput = document.getElementById(`${this.containerId}-email`) as HTMLInputElement;\n const nameInput = document.getElementById(`${this.containerId}-name`) as HTMLInputElement;\n const phoneInput = document.getElementById(`${this.containerId}-phone`) as HTMLInputElement;\n\n if (emailInput && nameInput) {\n // Customer info is in input fields (not pre-filled)\n email = emailInput.value;\n name = nameInput.value;\n phone = phoneInput?.value;\n\n // 驗證必填欄位\n if (!email || !name) {\n this.showError('請填寫姓名和電子郵件');\n return;\n }\n } else {\n // Customer info is pre-filled (use attributes)\n email = this.getAttribute('customer-email') || undefined;\n name = this.getAttribute('customer-name') || undefined;\n\n // 驗證必填欄位\n if (!email || !name) {\n this.showError('客戶資訊不完整');\n return;\n }\n }\n\n // Clear any previous errors\n this.clearError();\n\n // Show loading state\n this.setButtonLoading(true);\n\n // 觸發自定義事件,讓外部處理提交\n this.dispatchEvent(new CustomEvent('submit', {\n detail: {\n customerEmail: email,\n customerName: name,\n customerPhone: phone,\n paymentSession: (this as any)._paymentSession,\n },\n bubbles: true,\n composed: true, // 讓事件可以穿透 Shadow DOM\n }));\n });\n }\n\n /**\n * Set button loading state\n */\n private setButtonLoading(loading: boolean) {\n const submitBtn = document.getElementById(`${this.containerId}-submit-btn`) as HTMLButtonElement;\n\n if (!submitBtn) return;\n\n if (loading) {\n submitBtn.classList.add('loading');\n submitBtn.disabled = true;\n submitBtn.innerHTML = `\n <span class=\"recur-loading-spinner\"></span>\n <span>處理中...</span>\n `;\n } else {\n submitBtn.classList.remove('loading');\n submitBtn.disabled = false;\n submitBtn.innerHTML = '<span id=\"' + this.containerId + '-submit-text\">確認付款</span>';\n }\n }\n\n /**\n * Reset button to normal state (call this when payment completes or fails)\n */\n resetButton() {\n this.setButtonLoading(false);\n }\n\n /**\n * Show error message using RecurErrorDisplay component\n */\n private showError(message: string) {\n // Find or create error container in Light DOM\n let errorContainer = this.querySelector('.recur-sdk__error-container') as HTMLElement;\n\n if (!errorContainer) {\n errorContainer = document.createElement('div');\n errorContainer.className = 'recur-sdk__error-container';\n errorContainer.style.cssText = 'margin-bottom: 16px;';\n\n // Insert at the beginning of the component\n this.insertBefore(errorContainer, this.firstChild);\n }\n\n // Create error display component\n const errorDisplay = document.createElement('recur-error-display');\n errorDisplay.setAttribute('error', message);\n errorDisplay.setAttribute('dismissible', 'true');\n\n // Replace old error message\n errorContainer.innerHTML = '';\n errorContainer.appendChild(errorDisplay);\n\n // Scroll to error\n errorDisplay.scrollIntoView({ behavior: 'smooth', block: 'center' });\n }\n\n /**\n * Clear any displayed errors\n */\n private clearError() {\n const errorContainer = this.querySelector('.recur-sdk__error-container');\n if (errorContainer) {\n errorContainer.innerHTML = '';\n }\n }\n\n /**\n * 等待組件完全連接到 DOM\n */\n private updateComplete(): Promise<void> {\n return new Promise((resolve) => {\n if (this.isConnected) {\n // 使用 setTimeout 確保 Light DOM 也已渲染\n setTimeout(resolve, 0);\n } else {\n const observer = new MutationObserver(() => {\n if (this.isConnected) {\n observer.disconnect();\n setTimeout(resolve, 0);\n }\n });\n observer.observe(document.body, { childList: true, subtree: true });\n }\n });\n }\n\n /**\n * 獲取表單數據\n */\n getFormData() {\n return {\n email: (document.getElementById(`${this.containerId}-email`) as HTMLInputElement)?.value,\n name: (document.getElementById(`${this.containerId}-name`) as HTMLInputElement)?.value,\n phone: (document.getElementById(`${this.containerId}-phone`) as HTMLInputElement)?.value,\n };\n }\n\n /**\n * 設置表單數據\n */\n setFormData(data: { email?: string; name?: string; phone?: string }) {\n if (data.email) {\n const emailInput = document.getElementById(`${this.containerId}-email`) as HTMLInputElement;\n if (emailInput) emailInput.value = data.email;\n }\n if (data.name) {\n const nameInput = document.getElementById(`${this.containerId}-name`) as HTMLInputElement;\n if (nameInput) nameInput.value = data.name;\n }\n if (data.phone) {\n const phoneInput = document.getElementById(`${this.containerId}-phone`) as HTMLInputElement;\n if (phoneInput) phoneInput.value = data.phone;\n }\n }\n}\n\n// 註冊 Web Component\nif (!customElements.get('recur-payment-form')) {\n customElements.define('recur-payment-form', RecurPaymentForm);\n}\n\n// TypeScript 類型聲明\ndeclare global {\n interface HTMLElementTagNameMap {\n 'recur-payment-form': RecurPaymentForm;\n }\n}\n","/**\n * Recur Checkout Button Web Component\n *\n * A simple, drop-in checkout button for hosted checkout integration.\n * No backend required - uses Publishable Key for authentication.\n *\n * @example\n * ```html\n * <recur-checkout\n * publishable-key=\"pk_live_xxx\"\n * product-id=\"prod_xxx\"\n * success-url=\"https://yoursite.com/success\"\n * cancel-url=\"https://yoursite.com/cancel\">\n * 訂閱方案\n * </recur-checkout>\n * ```\n */\n\nexport class RecurCheckoutButton extends HTMLElement {\n private _isLoading = false;\n\n static get observedAttributes() {\n return [\n 'publishable-key',\n 'product-id',\n 'success-url',\n 'cancel-url',\n 'customer-email',\n 'mode',\n 'button-text',\n 'button-style',\n 'disabled',\n ];\n }\n\n constructor() {\n super();\n this.attachShadow({ mode: 'open' });\n }\n\n connectedCallback() {\n this.render();\n this.setupEventListeners();\n }\n\n disconnectedCallback() {\n // Cleanup event listeners\n const button = this.shadowRoot?.querySelector('button');\n if (button) {\n button.removeEventListener('click', this.handleClick);\n }\n }\n\n attributeChangedCallback(_name: string, oldValue: string, newValue: string) {\n if (oldValue !== newValue) {\n this.render();\n }\n }\n\n private render() {\n const buttonText = this.getAttribute('button-text') || this.textContent?.trim() || '訂閱';\n const buttonStyle = this.getAttribute('button-style') || 'primary';\n const isDisabled = this.hasAttribute('disabled') || this._isLoading;\n\n this.shadowRoot!.innerHTML = `\n <style>\n :host {\n display: inline-block;\n }\n\n button {\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n font-size: 16px;\n font-weight: 500;\n padding: 12px 24px;\n border-radius: 8px;\n cursor: pointer;\n transition: all 0.2s ease;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n min-width: 120px;\n border: none;\n }\n\n button:disabled {\n opacity: 0.6;\n cursor: not-allowed;\n }\n\n /* Primary style (default) */\n button.primary {\n background: #18181b;\n color: #ffffff;\n }\n\n button.primary:hover:not(:disabled) {\n background: #27272a;\n }\n\n button.primary:active:not(:disabled) {\n background: #3f3f46;\n }\n\n /* Outline style */\n button.outline {\n background: transparent;\n color: #18181b;\n border: 2px solid #18181b;\n }\n\n button.outline:hover:not(:disabled) {\n background: #f4f4f5;\n }\n\n button.outline:active:not(:disabled) {\n background: #e4e4e7;\n }\n\n /* Gradient style */\n button.gradient {\n background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n color: #ffffff;\n }\n\n button.gradient:hover:not(:disabled) {\n opacity: 0.9;\n }\n\n button.gradient:active:not(:disabled) {\n opacity: 0.8;\n }\n\n /* Loading spinner */\n .spinner {\n width: 16px;\n height: 16px;\n border: 2px solid currentColor;\n border-top-color: transparent;\n border-radius: 50%;\n animation: spin 0.6s linear infinite;\n }\n\n @keyframes spin {\n to { transform: rotate(360deg); }\n }\n\n /* Focus state */\n button:focus-visible {\n outline: 2px solid #3b82f6;\n outline-offset: 2px;\n }\n </style>\n\n <button\n class=\"${buttonStyle}\"\n ${isDisabled ? 'disabled' : ''}\n aria-busy=\"${this._isLoading}\"\n >\n ${this._isLoading ? '<span class=\"spinner\"></span>' : ''}\n <span>${this._isLoading ? '處理中...' : buttonText}</span>\n </button>\n `;\n }\n\n private setupEventListeners() {\n const button = this.shadowRoot?.querySelector('button');\n if (button) {\n button.addEventListener('click', this.handleClick);\n }\n }\n\n private handleClick = async (e: Event) => {\n e.preventDefault();\n\n if (this._isLoading || this.hasAttribute('disabled')) {\n return;\n }\n\n // Validate required attributes\n const publishableKey = this.getAttribute('publishable-key');\n const productId = this.getAttribute('product-id');\n const successUrl = this.getAttribute('success-url');\n const cancelUrl = this.getAttribute('cancel-url');\n\n if (!publishableKey) {\n this.dispatchError('Missing required attribute: publishable-key');\n return;\n }\n\n if (!productId) {\n this.dispatchError('Missing required attribute: product-id');\n return;\n }\n\n if (!successUrl) {\n this.dispatchError('Missing required attribute: success-url');\n return;\n }\n\n if (!cancelUrl) {\n this.dispatchError('Missing required attribute: cancel-url');\n return;\n }\n\n // Set loading state\n this._isLoading = true;\n this.render();\n this.setupEventListeners();\n\n try {\n // Create checkout session via API\n const session = await this.createCheckoutSession({\n publishableKey,\n productId,\n successUrl: this.resolveUrl(successUrl),\n cancelUrl: this.resolveUrl(cancelUrl),\n customerEmail: this.getAttribute('customer-email') || undefined,\n mode: this.getAttribute('mode') as 'PAYMENT' | 'SUBSCRIPTION' | 'SETUP' | undefined,\n });\n\n // Dispatch success event before redirect\n this.dispatchEvent(new CustomEvent('checkout-started', {\n detail: { sessionId: session.id, url: session.url },\n bubbles: true,\n composed: true,\n }));\n\n // Redirect to hosted checkout\n window.location.href = session.url;\n } catch (error: any) {\n this._isLoading = false;\n this.render();\n this.setupEventListeners();\n this.dispatchError(error.message || 'Failed to create checkout session');\n }\n };\n\n private async createCheckoutSession(options: {\n publishableKey: string;\n productId: string;\n successUrl: string;\n cancelUrl: string;\n customerEmail?: string;\n mode?: 'PAYMENT' | 'SUBSCRIPTION' | 'SETUP';\n }) {\n // Auto-detect API base URL\n const baseUrl = this.getApiBaseUrl();\n\n const response = await fetch(`${baseUrl}/v1/checkout/sessions`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'X-Recur-Publishable-Key': options.publishableKey,\n },\n body: JSON.stringify({\n productId: options.productId,\n mode: options.mode,\n successUrl: options.successUrl,\n cancelUrl: options.cancelUrl,\n customerEmail: options.customerEmail,\n }),\n });\n\n if (!response.ok) {\n const error = await response.json().catch(() => ({}));\n throw new Error(error.error?.message || `HTTP ${response.status}: Failed to create checkout session`);\n }\n\n return response.json();\n }\n\n private getApiBaseUrl(): string {\n // Check for custom base URL attribute\n const customBaseUrl = this.getAttribute('api-base-url');\n if (customBaseUrl) {\n return customBaseUrl;\n }\n\n // Auto-detect based on environment\n if (typeof window !== 'undefined') {\n const hostname = window.location.hostname;\n if (\n hostname === 'localhost' ||\n hostname.includes('.test') ||\n hostname.includes('.local') ||\n hostname === '127.0.0.1'\n ) {\n return `${window.location.protocol}//${window.location.host}/api`;\n }\n }\n\n return 'https://api.recur.tw';\n }\n\n private resolveUrl(url: string): string {\n // If URL is relative, make it absolute\n if (url.startsWith('/')) {\n return `${window.location.origin}${url}`;\n }\n return url;\n }\n\n private dispatchError(message: string) {\n console.error('[recur-checkout]', message);\n\n this.dispatchEvent(new CustomEvent('checkout-error', {\n detail: { message },\n bubbles: true,\n composed: true,\n }));\n }\n}\n\n// Register Web Component\nif (typeof window !== 'undefined' && !customElements.get('recur-checkout')) {\n customElements.define('recur-checkout', RecurCheckoutButton);\n}\n\n// TypeScript type declarations\ndeclare global {\n interface HTMLElementTagNameMap {\n 'recur-checkout': RecurCheckoutButton;\n }\n}\n","/**\n * Recur SDK Web Components\n *\n * This module exports all Web Components used in the Recur SDK.\n * Components are automatically registered when this module is imported.\n *\n * NOTE: Safe to import in SSR environments (Next.js, etc.)\n * Components are dynamically loaded only in browser environments.\n */\n\n/**\n * Register all Web Components\n *\n * This function loads and registers components dynamically to avoid\n * SSR issues with HTMLElement and other browser-only APIs.\n */\nexport async function registerComponents(): Promise<void> {\n if (typeof window === 'undefined') {\n console.warn('[Recur SDK] Cannot register Web Components: window is not defined');\n return;\n }\n\n // Dynamically import components (browser-only)\n await Promise.all([\n import('./base/loading-spinner.js'),\n import('./base/success-message.js'),\n import('./base/error-display.js'),\n import('./base/skeleton-loader.js'),\n import('./base/payment-form-skeleton.js'),\n import('./base/toast.js'),\n import('./payment-form.js'),\n import('./checkout-button.js'),\n ]);\n\n // Verify all components are registered\n const components = [\n 'recur-loading-spinner',\n 'recur-success-message',\n 'recur-error-display',\n 'recur-skeleton-loader',\n 'recur-payment-form-skeleton',\n 'recur-toast',\n 'recur-toast-container',\n 'recur-payment-form',\n 'recur-checkout',\n ];\n\n const unregistered = components.filter((name) => !customElements.get(name));\n\n if (unregistered.length > 0) {\n console.warn(\n `[Recur SDK] The following components are not registered:`,\n unregistered\n );\n }\n}\n\n// Auto-register on import (browser only)\nif (typeof window !== 'undefined') {\n registerComponents();\n}\n\n// Re-export types for TypeScript users (these don't cause SSR issues)\nexport type { RecurLoadingSpinner } from './base/loading-spinner.js';\nexport type { RecurSuccessMessage } from './base/success-message.js';\nexport type { RecurErrorDisplay } from './base/error-display.js';\nexport type { RecurSkeletonLoader } from './base/skeleton-loader.js';\nexport type { RecurPaymentFormSkeleton } from './base/payment-form-skeleton.js';\nexport type { RecurToast, RecurToastContainer } from './base/toast.js';\nexport type { RecurPaymentForm } from './payment-form.js';\nexport type { RecurCheckoutButton } from './checkout-button.js';\n","/**\n * PAYUNi SDK Loader\n * Dynamically loads and initializes the PAYUNi UNi Embed SDK\n */\n\nimport type { UniPaymentInstance } from './types.js';\n\nconst PAYUNI_SDK_URL = 'https://vendor.payuni.com.tw/sdk/uni-payment.js';\nconst PAYUNI_SANDBOX_SDK_URL = 'https://sandbox-vendor.payuni.com.tw/sdk/uni-payment.js';\n\nlet isLoaded = false;\nlet isLoading = false;\nlet loadPromise: Promise<void> | null = null;\n\n/**\n * Load PAYUNi SDK script\n * @param isSandbox - Use sandbox environment\n */\nexport async function loadPayUniSDK(isSandbox: boolean = false): Promise<void> {\n // Already loaded\n if (isLoaded && window.UniPayment) {\n return Promise.resolve();\n }\n\n // Currently loading\n if (isLoading && loadPromise) {\n return loadPromise;\n }\n\n // Start loading\n isLoading = true;\n loadPromise = new Promise((resolve, reject) => {\n const script = document.createElement('script');\n script.src = isSandbox ? PAYUNI_SANDBOX_SDK_URL : PAYUNI_SDK_URL;\n script.async = true;\n\n script.onload = () => {\n isLoaded = true;\n isLoading = false;\n resolve();\n };\n\n script.onerror = () => {\n isLoading = false;\n loadPromise = null;\n reject(new Error('Failed to load PAYUNi SDK'));\n };\n\n document.head.appendChild(script);\n });\n\n return loadPromise;\n}\n\n/**\n * Check if PAYUNi SDK is loaded\n */\nexport function isPayUniSDKLoaded(): boolean {\n return isLoaded && typeof window !== 'undefined' && !!window.UniPayment;\n}\n\n/**\n * Wait for PAYUNi SDK to be ready\n */\nexport async function waitForPayUniSDK(timeout: number = 10000): Promise<void> {\n const startTime = Date.now();\n\n while (!isPayUniSDKLoaded()) {\n if (Date.now() - startTime > timeout) {\n throw new Error('PAYUNi SDK load timeout');\n }\n await new Promise(resolve => setTimeout(resolve, 100));\n }\n}\n","'use client';\n\nimport React, { createContext, useCallback, useState, useMemo } from 'react';\nimport type {\n RecurConfig,\n RecurContextValue,\n CheckoutOptions,\n CheckoutResult,\n CheckoutError,\n PlansResult,\n SdkTokenResult,\n SubscriptionCompleteResult,\n UniPaymentInstance,\n} from './types.js';\nimport { loadPayUniSDK } from './payuni-loader.js';\n\nconst RecurContext = createContext<RecurContextValue | null>(null);\n\nexport interface RecurProviderProps {\n children: React.ReactNode;\n config?: RecurConfig;\n}\n\n/**\n * RecurProvider\n *\n * Provides Recur checkout functionality to your React application\n *\n * @example\n * ```tsx\n * <RecurProvider config={{ publishableKey: 'pk_test_xxx' }}>\n * <App />\n * </RecurProvider>\n * ```\n */\nexport function RecurProvider({ children, config: initialConfig = {} }: RecurProviderProps) {\n const [config, setConfig] = useState<RecurConfig>({\n checkoutMode: 'embedded',\n ...initialConfig,\n });\n\n const [isCheckingOut, setIsCheckingOut] = useState(false);\n\n // Update config when initialConfig changes (e.g., when user switches modes)\n React.useEffect(() => {\n setConfig({\n checkoutMode: 'embedded',\n ...initialConfig,\n });\n }, [initialConfig.checkoutMode, initialConfig.publishableKey, initialConfig.containerElementId]);\n\n // Reset isCheckingOut when checkout mode changes to allow re-testing\n React.useEffect(() => {\n setIsCheckingOut(false);\n }, [config.checkoutMode]);\n\n const updateConfig = useCallback((newConfig: Partial<RecurConfig>) => {\n setConfig((prev) => ({ ...prev, ...newConfig }));\n }, []);\n\n const checkout = useCallback(\n async (options: CheckoutOptions) => {\n let modalOverlay: HTMLElement | null = null;\n\n try {\n console.log('[Recur SDK] Starting checkout flow...', {\n planId: options.planId,\n checkoutMode: config.checkoutMode,\n containerElementId: config.containerElementId,\n });\n\n setIsCheckingOut(true);\n\n // Validate required fields\n if (!options.planId) {\n throw new Error('planId is required');\n }\n\n if (!config.publishableKey) {\n throw new Error('publishableKey is required');\n }\n\n if (!options.customerEmail || !options.customerName) {\n throw new Error('customerEmail and customerName are required');\n }\n\n // Use configured baseUrl or default to production API\n const baseUrl = config.baseUrl || 'https://api.recur.tw';\n console.log('[Recur SDK] Base URL:', baseUrl);\n\n const headers: HeadersInit = {\n 'Content-Type': 'application/json',\n 'X-Recur-Publishable-Key': config.publishableKey,\n };\n\n // Show loading state early for both modal and embedded modes\n let modalContent: HTMLElement | null = null;\n let loadingContainer: HTMLElement | null = null;\n let embeddedContainer: HTMLElement | null = null;\n\n if (config.checkoutMode === 'modal') {\n console.log('[Recur SDK] Mode is modal, creating modal with loading state...');\n\n // Create modal overlay\n modalOverlay = document.createElement('div');\n modalOverlay.id = 'recur-modal-overlay';\n modalOverlay.className = 'recur-sdk__modal-overlay';\n modalOverlay.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.5);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 9999;\n `;\n\n // Create modal content\n modalContent = document.createElement('div');\n modalContent.className = 'recur-sdk__modal-content';\n modalContent.style.cssText = `\n background: white;\n padding: 32px;\n border-radius: 12px;\n max-width: 500px;\n width: 90%;\n max-height: 90vh;\n overflow-y: auto;\n position: relative;\n `;\n\n // Create close button\n const closeButton = document.createElement('button');\n closeButton.className = 'recur-sdk__close-button';\n closeButton.innerHTML = '✕';\n closeButton.style.cssText = `\n position: absolute;\n top: 16px;\n right: 16px;\n background: none;\n border: none;\n font-size: 24px;\n cursor: pointer;\n color: #666;\n padding: 0;\n width: 32px;\n height: 32px;\n display: flex;\n align-items: center;\n justify-content: center;\n `;\n closeButton.onclick = () => {\n modalOverlay?.remove();\n setIsCheckingOut(false);\n options.onPaymentCancel?.();\n };\n\n // Create title\n const title = document.createElement('h2');\n title.className = 'recur-sdk__title';\n title.textContent = '訂閱付款';\n title.style.cssText = 'margin: 0 0 24px 0; font-size: 24px; font-weight: 600;';\n\n // Create loading container with payment form skeleton\n loadingContainer = document.createElement('div');\n loadingContainer.id = 'recur-modal-loading';\n loadingContainer.className = 'recur-sdk__loading-container';\n loadingContainer.style.cssText = 'padding: 0;';\n\n // Use payment form skeleton instead of simple spinner\n const skeleton = document.createElement('recur-payment-form-skeleton');\n loadingContainer.appendChild(skeleton);\n\n modalContent.appendChild(closeButton);\n modalContent.appendChild(title);\n modalContent.appendChild(loadingContainer);\n modalOverlay.appendChild(modalContent);\n document.body.appendChild(modalOverlay);\n\n console.log('[Recur SDK] Modal created with loading state');\n } else if (config.checkoutMode === 'embedded') {\n // For embedded mode, try to show loading in the container if it exists\n console.log('[Recur SDK] Mode is embedded, checking for container...');\n\n if (!config.containerElementId) {\n console.warn('[Recur SDK] No containerElementId provided for embedded mode');\n } else {\n // Poll for the container to appear (wait up to 500ms)\n embeddedContainer = document.getElementById(config.containerElementId);\n\n if (!embeddedContainer) {\n console.log('[Recur SDK] Container not found, polling for container...');\n for (let i = 0; i < 10; i++) {\n await new Promise(resolve => setTimeout(resolve, 50));\n embeddedContainer = document.getElementById(config.containerElementId);\n if (embeddedContainer) {\n console.log('[Recur SDK] Container found after polling');\n break;\n }\n }\n }\n\n if (embeddedContainer) {\n console.log('[Recur SDK] Container found, showing loading state...');\n\n // Show loading state with payment form skeleton in the embedded container\n loadingContainer = document.createElement('div');\n loadingContainer.id = 'recur-embedded-loading';\n loadingContainer.className = 'recur-sdk__loading-container';\n loadingContainer.style.cssText = 'padding: 0;';\n\n // Use payment form skeleton instead of simple spinner\n const embeddedSkeleton = document.createElement('recur-payment-form-skeleton');\n loadingContainer.appendChild(embeddedSkeleton);\n\n embeddedContainer.appendChild(loadingContainer);\n } else {\n console.log('[Recur SDK] Container not found after polling, will continue without early loading state');\n }\n }\n }\n\n // Step 1: Create checkout session\n console.log('[Recur SDK] Step 1: Creating checkout session...');\n\n const checkoutResponse = await fetch(`${baseUrl}/v1/checkouts`, {\n method: 'POST',\n headers,\n body: JSON.stringify({\n productId: options.planId,\n customerName: options.customerName,\n customerEmail: options.customerEmail,\n customerPhone: options.customerPhone,\n }),\n });\n\n if (!checkoutResponse.ok) {\n const errorData = await checkoutResponse.json().catch(() => ({}));\n console.error('[Recur SDK] Failed to create checkout:', errorData);\n const errorMessage = errorData.details || errorData.error || 'Failed to create checkout';\n throw new Error(errorMessage);\n }\n\n const checkoutResult: CheckoutResult = await checkoutResponse.json();\n console.log('[Recur SDK] Checkout created successfully:', checkoutResult);\n\n // Call onSuccess callback\n options.onSuccess?.(checkoutResult);\n\n // Extract SDK token from checkout result (no separate API call needed)\n console.log('[Recur SDK] Step 2: Extracting SDK token from checkout...');\n\n if (!checkoutResult.sdkToken) {\n console.error('[Recur SDK] SDK token missing from checkout response');\n throw new Error('SDK token missing from checkout response');\n }\n\n const tokenResult: SdkTokenResult = {\n sdkToken: checkoutResult.sdkToken,\n timestamp: Date.now(),\n tokenExpired: checkoutResult.sdkTokenExpiresAt,\n creditToken: '', // No longer needed - creditHash stored in database\n environment: 'SANDBOX', // Will be determined by organization settings\n };\n console.log('[Recur SDK] SDK token extracted:', {\n sdkToken: tokenResult.sdkToken.substring(0, 20) + '...',\n tokenExpired: tokenResult.tokenExpired,\n });\n\n // Step 3: Load PAYUNi SDK\n console.log('[Recur SDK] Step 3: Loading PAYUNi SDK...');\n const isSandbox = tokenResult.environment === 'SANDBOX';\n await loadPayUniSDK(isSandbox);\n console.log('[Recur SDK] PAYUNi SDK loaded successfully');\n\n if (!window.UniPayment) {\n console.error('[Recur SDK] window.UniPayment is not available after loading');\n throw new Error('PAYUNi SDK failed to load');\n }\n\n // Step 4: Determine container element based on checkout mode\n console.log('[Recur SDK] Step 4: Preparing container for checkout mode:', config.checkoutMode);\n console.log('[Recur SDK] Initial containerElementId from config:', config.containerElementId);\n\n let containerElementId = config.containerElementId;\n\n // For modal mode, update the existing modal with payment form container\n if (config.checkoutMode === 'modal') {\n console.log('[Recur SDK] Mode is modal, updating modal with payment form...');\n\n if (!loadingContainer || !modalContent) {\n throw new Error('Modal components not initialized');\n }\n\n // Remove loading spinner\n loadingContainer.remove();\n\n // Create container for payment form\n const formContainer = document.createElement('div');\n containerElementId = 'recur-modal-payment-container';\n formContainer.id = containerElementId;\n\n modalContent.appendChild(formContainer);\n\n console.log('[Recur SDK] Modal updated with container ID:', containerElementId);\n } else if (config.checkoutMode === 'embedded') {\n // For embedded mode, remove loading spinner if it exists\n console.log('[Recur SDK] Mode is embedded, preparing container...');\n\n if (!containerElementId) {\n throw new Error('containerElementId is required for embedded mode');\n }\n\n // Remove loading spinner if we showed it earlier\n if (loadingContainer && embeddedContainer) {\n console.log('[Recur SDK] Removing loading spinner from embedded container');\n loadingContainer.remove();\n }\n }\n\n // Step 5: Wait for container element\n console.log('[Recur SDK] Step 5: Waiting for container element...');\n\n if (!containerElementId) {\n throw new Error('containerElementId is required');\n }\n\n // For embedded mode, wait for the container to appear in DOM\n // (React needs time to render after onSuccess callback)\n let container = document.getElementById(containerElementId);\n if (!container && config.checkoutMode === 'embedded') {\n console.log('[Recur SDK] Container not found, waiting for React to render...');\n // Wait up to 2 seconds for container to appear\n for (let i = 0; i < 20; i++) {\n await new Promise(resolve => setTimeout(resolve, 100));\n container = document.getElementById(containerElementId);\n if (container) {\n console.log('[Recur SDK] Container found after waiting');\n break;\n }\n }\n }\n\n if (!container) {\n throw new Error(`Container element '${containerElementId}' not found`);\n }\n\n console.log('[Recur SDK] Creating RecurPaymentForm Web Component...');\n\n // Clear container and create Web Component\n container.innerHTML = '';\n\n // Create RecurPaymentForm Web Component\n const paymentForm = document.createElement('recur-payment-form');\n paymentForm.setAttribute('container-id', containerElementId);\n\n // Pass customer information if available\n if (options.customerName) {\n paymentForm.setAttribute('customer-name', options.customerName);\n }\n if (options.customerEmail) {\n paymentForm.setAttribute('customer-email', options.customerEmail);\n }\n\n // Pass order summary information from checkout result\n if (checkoutResult.plan?.name) {\n paymentForm.setAttribute('plan-name', checkoutResult.plan.name);\n }\n if (checkoutResult.checkout?.amount) {\n paymentForm.setAttribute('amount', checkoutResult.checkout.amount.toString());\n }\n if (checkoutResult.plan?.billingPeriod) {\n paymentForm.setAttribute('billing-period', checkoutResult.plan.billingPeriod);\n }\n\n // 設置自定義樣式(支持 shadcn 風格的 focus ring)\n const customStyles = `\n /* PAYUNi SDK focus 樣式 - shadcn 風格 */\n .form-input-focus {\n border-color: var(--ring, hsl(215 16% 47%)) !important;\n outline: 0 !important;\n box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring, hsl(215 16% 47%)) 50%, transparent) !important;\n transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out !important;\n }\n `;\n paymentForm.setAttribute('custom-styles', customStyles);\n\n container.appendChild(paymentForm);\n\n // Wait for component to be connected\n await new Promise(resolve => setTimeout(resolve, 100));\n\n console.log('[Recur SDK] Initializing PAYUNi SDK via Web Component...');\n\n // Initialize PAYUNi SDK through the Web Component\n const initResult = await (paymentForm as any).initializePayment(\n tokenResult.sdkToken,\n tokenResult.environment\n );\n\n // Check if initialization was aborted (component unmounted during init)\n if (initResult === null) {\n console.log('[Recur SDK] Initialization aborted - component was unmounted');\n return; // Exit checkout flow silently\n }\n\n console.log('[Recur SDK] PAYUNi SDK initialized successfully');\n\n // Step 7: Handle form submission via Web Component event\n console.log('[Recur SDK] Step 7: Setting up submit handler...');\n\n paymentForm.addEventListener('submit', (async (event: Event) => {\n console.log('[Recur SDK] Form submitted via Web Component');\n const customEvent = event as CustomEvent;\n const { paymentSession } = customEvent.detail;\n\n try {\n // Get card data from PAYUNi SDK (via payment session from Web Component)\n console.log('[Recur SDK] Getting trade result from PAYUNi...');\n const tradeResult = await paymentSession.getTradeResult();\n console.log('[Recur SDK] Trade result received:', tradeResult);\n\n // Step 8: Execute payment via checkout\n console.log('[Recur SDK] Step 8: Executing payment...');\n\n // For subscriptions, we need to send creditToken from the trade result\n // For one-time payments, empty body is fine\n const paymentBody = checkoutResult.checkout.productType === 'SUBSCRIPTION'\n ? {\n creditToken: tradeResult.creditToken,\n timestamp: tradeResult.timestamp,\n }\n : {};\n\n const paymentResponse = await fetch(\n `${baseUrl}/v1/checkouts/${checkoutResult.checkout.id}/pay`,\n {\n method: 'POST',\n headers,\n body: JSON.stringify(paymentBody),\n }\n );\n\n if (!paymentResponse.ok) {\n const errorData = await paymentResponse.json().catch(() => ({}));\n console.error('[Recur SDK] Failed to execute payment:', errorData);\n throw new Error(errorData.error || 'Failed to execute payment');\n }\n\n const paymentResult: any = await paymentResponse.json();\n console.log('[Recur SDK] Payment executed:', paymentResult);\n\n // Check if 3D verification is required\n if (paymentResult.requires3D && paymentResult.redirectUrl) {\n console.log('[Recur SDK] 3D verification required, redirecting to:', paymentResult.redirectUrl);\n\n // Redirect to 3D verification page\n window.location.href = paymentResult.redirectUrl;\n\n // Note: User will return to ReturnURL after completing 3D verification\n return;\n }\n\n // Call payment complete callback (no 3D required)\n console.log('[Recur SDK] Calling onPaymentComplete callback...');\n if (options.onPaymentComplete) {\n // For subscriptions, use subscription data; otherwise use checkout data\n if (paymentResult.subscription) {\n options.onPaymentComplete({\n id: paymentResult.subscription.id,\n status: paymentResult.subscription.status,\n planId: checkoutResult.checkout.productId,\n amount: checkoutResult.checkout.amount,\n billingPeriod: paymentResult.subscription.billingPeriod,\n currentPeriodStart: paymentResult.subscription.currentPeriodStart,\n currentPeriodEnd: paymentResult.subscription.currentPeriodEnd,\n });\n } else {\n // For non-subscription products (ONE_TIME, CREDITS, DONATION)\n options.onPaymentComplete({\n id: paymentResult.checkout.id,\n status: paymentResult.checkout.status,\n planId: checkoutResult.checkout.productId,\n amount: checkoutResult.checkout.amount,\n billingPeriod: checkoutResult.checkout.productType,\n currentPeriodStart: new Date().toISOString(),\n currentPeriodEnd: new Date().toISOString(),\n });\n }\n }\n\n console.log('[Recur SDK] Checkout flow completed successfully!');\n\n // Reset button state\n (paymentForm as any).resetButton?.();\n\n // Close modal if in modal mode\n if (modalOverlay) {\n modalOverlay.remove();\n }\n\n setIsCheckingOut(false);\n } catch (error) {\n console.error('[Recur SDK] Error in payment flow:', error);\n const checkoutError: CheckoutError = {\n code: 'PAYMENT_FAILED',\n message: error instanceof Error ? error.message : 'Payment failed',\n };\n options.onError?.(checkoutError);\n\n // Reset button state\n (paymentForm as any).resetButton?.();\n\n // Notify Web Component of error to reset form state\n paymentForm.dispatchEvent(new CustomEvent('error', {\n detail: { error: checkoutError },\n }));\n\n setIsCheckingOut(false);\n }\n }) as EventListener);\n\n console.log('[Recur SDK] Checkout flow initialized, waiting for user input...');\n } catch (error) {\n console.error('[Recur SDK] Checkout error:', error);\n\n // Clean up modal if it exists\n if (modalOverlay) {\n modalOverlay.remove();\n }\n\n const checkoutError: CheckoutError = {\n code: 'CHECKOUT_ERROR',\n message: error instanceof Error ? error.message : 'An unknown error occurred',\n };\n\n options.onError?.(checkoutError);\n setIsCheckingOut(false);\n throw error;\n }\n },\n [config]\n );\n\n const fetchPlans = useCallback(\n async (): Promise<PlansResult> => {\n // Check publishable key (required)\n if (!config.publishableKey) {\n throw new Error('publishableKey is required');\n }\n\n // Use configured baseUrl or default to production API\n const baseUrl = config.baseUrl || 'https://api.recur.tw';\n\n // Call the plans API (v1)\n const response = await fetch(`${baseUrl}/v1/plans`, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n 'X-Recur-Publishable-Key': config.publishableKey,\n },\n });\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({}));\n throw new Error(errorData.error || 'Failed to fetch plans');\n }\n\n return await response.json();\n },\n [config]\n );\n\n const value = useMemo(\n () => ({\n config,\n checkout,\n fetchPlans,\n isCheckingOut,\n updateConfig,\n }),\n [config, checkout, fetchPlans, isCheckingOut, updateConfig]\n );\n\n return <RecurContext.Provider value={value}>{children}</RecurContext.Provider>;\n}\n\nexport { RecurContext };\n","'use client';\n\nimport { useContext } from 'react';\nimport { RecurContext } from './context.js';\nimport type { RecurContextValue } from './types.js';\n\n/**\n * useRecur Hook\n *\n * Access Recur checkout functionality from within your components\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { checkout, isCheckingOut } = useRecur();\n *\n * return (\n * <button\n * onClick={() => checkout({ planId: 'pro' })}\n * disabled={isCheckingOut}\n * >\n * {isCheckingOut ? 'Processing...' : 'Subscribe'}\n * </button>\n * );\n * }\n * ```\n *\n * @throws {Error} If used outside of RecurProvider\n */\nexport function useRecur(): RecurContextValue {\n const context = useContext(RecurContext);\n\n if (!context) {\n throw new Error('useRecur must be used within a RecurProvider');\n }\n\n return context;\n}\n","'use client';\n\nimport { useState, useEffect, useCallback } from 'react';\nimport { useRecur } from '../use-recur.js';\nimport type { Plan } from '../types.js';\n\nexport interface UsePlansOptions {\n /**\n * Whether to fetch plans immediately on mount\n * @default true\n */\n enabled?: boolean;\n\n /**\n * Callback when plans are fetched successfully\n */\n onSuccess?: (plans: Plan[]) => void;\n\n /**\n * Callback when an error occurs\n */\n onError?: (error: Error) => void;\n}\n\nexport interface UsePlansResult {\n /**\n * The fetched plans data\n */\n data: Plan[] | undefined;\n\n /**\n * Whether the plans are currently being fetched\n */\n isLoading: boolean;\n\n /**\n * Error object if fetch failed\n */\n error: Error | null;\n\n /**\n * Manually trigger a refetch\n */\n refetch: () => Promise<void>;\n}\n\n/**\n * usePlans Hook\n *\n * Fetch available subscription plans with automatic state management\n *\n * @example\n * ```tsx\n * function PlansPage() {\n * const { data: plans, isLoading, error } = usePlans();\n *\n * if (isLoading) return <PlansSkeletonLoader />;\n * if (error) return <ErrorMessage error={error} />;\n *\n * return (\n * <div>\n * {plans?.map(plan => (\n * <PlanCard key={plan.id} plan={plan} />\n * ))}\n * </div>\n * );\n * }\n * ```\n */\nexport function usePlans(options: UsePlansOptions = {}): UsePlansResult {\n const { enabled = true, onSuccess, onError } = options;\n const { fetchPlans } = useRecur();\n\n const [data, setData] = useState<Plan[] | undefined>(undefined);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n\n const fetchData = useCallback(async () => {\n if (!enabled) return;\n\n setIsLoading(true);\n setError(null);\n\n try {\n const result = await fetchPlans();\n setData(result.plans);\n onSuccess?.(result.plans);\n } catch (err) {\n const error = err instanceof Error ? err : new Error('Failed to fetch plans');\n setError(error);\n onError?.(error);\n } finally {\n setIsLoading(false);\n }\n }, [enabled, fetchPlans, onSuccess, onError]);\n\n useEffect(() => {\n fetchData();\n }, [fetchData]);\n\n return {\n data,\n isLoading,\n error,\n refetch: fetchData,\n };\n}\n","'use client';\n\nimport { useState, useCallback } from 'react';\nimport { useRecur } from '../use-recur.js';\nimport type { CheckoutOptions, CheckoutResult, CheckoutError } from '../types.js';\n\nexport interface UseSubscribeOptions {\n /**\n * Callback when subscription is created successfully\n */\n onSuccess?: (result: CheckoutResult) => void;\n\n /**\n * Callback when payment is completed\n */\n onPaymentComplete?: (subscription: any) => void;\n\n /**\n * Callback when an error occurs\n */\n onError?: (error: CheckoutError) => void;\n\n /**\n * Callback when payment is cancelled\n */\n onPaymentCancel?: () => void;\n}\n\nexport interface UseSubscribeResult {\n /**\n * Function to initiate subscription checkout\n */\n mutate: (options: Omit<CheckoutOptions, 'onSuccess' | 'onError' | 'onPaymentComplete' | 'onPaymentCancel'>) => Promise<void>;\n\n /**\n * Alias for mutate (for better DX)\n */\n subscribe: (options: Omit<CheckoutOptions, 'onSuccess' | 'onError' | 'onPaymentComplete' | 'onPaymentCancel'>) => Promise<void>;\n\n /**\n * Whether subscription is in progress\n */\n isLoading: boolean;\n\n /**\n * Error object if subscription failed\n */\n error: CheckoutError | null;\n\n /**\n * Reset error state\n */\n reset: () => void;\n}\n\n/**\n * useSubscribe Hook\n *\n * Create a subscription with automatic state management\n *\n * @example\n * ```tsx\n * function SubscribePage() {\n * const { data: plans } = usePlans();\n * const { subscribe, isLoading, error } = useSubscribe({\n * onSuccess: () => {\n * console.log('Subscription created!');\n * },\n * onPaymentComplete: () => {\n * router.push('/account');\n * }\n * });\n *\n * return (\n * <div>\n * {plans?.map(plan => (\n * <PlanCard\n * key={plan.id}\n * plan={plan}\n * onSubscribe={() => subscribe({\n * planId: plan.id,\n * customerEmail: 'user@example.com',\n * customerName: 'John Doe'\n * })}\n * isLoading={isLoading}\n * />\n * ))}\n * {error && <ErrorMessage error={error} />}\n * </div>\n * );\n * }\n * ```\n */\nexport function useSubscribe(options: UseSubscribeOptions = {}): UseSubscribeResult {\n const { onSuccess, onError, onPaymentComplete, onPaymentCancel } = options;\n const { checkout, isCheckingOut } = useRecur();\n\n const [error, setError] = useState<CheckoutError | null>(null);\n\n const mutate = useCallback(\n async (checkoutOptions: Omit<CheckoutOptions, 'onSuccess' | 'onError' | 'onPaymentComplete' | 'onPaymentCancel'>) => {\n setError(null);\n\n try {\n await checkout({\n ...checkoutOptions,\n onSuccess: (result) => {\n onSuccess?.(result);\n },\n onPaymentComplete: (subscription) => {\n onPaymentComplete?.(subscription);\n },\n onError: (err) => {\n setError(err);\n onError?.(err);\n },\n onPaymentCancel: () => {\n onPaymentCancel?.();\n },\n });\n } catch (err) {\n const checkoutError: CheckoutError = {\n code: 'CHECKOUT_FAILED',\n message: err instanceof Error ? err.message : 'Unknown error occurred',\n };\n setError(checkoutError);\n onError?.(checkoutError);\n }\n },\n [checkout, onSuccess, onError, onPaymentComplete, onPaymentCancel]\n );\n\n const reset = useCallback(() => {\n setError(null);\n }, []);\n\n return {\n mutate,\n subscribe: mutate,\n isLoading: isCheckingOut,\n error,\n reset,\n };\n}\n"]}
|