hono-stripe-elements 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +60 -0
- package/package.json +9 -10
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# hono-stripe-elements
|
|
2
|
+
|
|
3
|
+
[hono/jsx](https://hono.dev/docs/guides/jsx) components that wrap the [`stripe-pwa-elements`](https://github.com/hideokamoto/stripe-pwa-elements) Web Components.
|
|
4
|
+
Use Stripe Card, Payment, Express Checkout, Address, Link Authentication and Currency Selector elements from Hono, HonoX islands and any other hono/jsx app.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm install hono-stripe-elements stripe-pwa-elements hono
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
`hono` (>= 4.0.0) and `stripe-pwa-elements` (>= 4.0.1) are peer dependencies.
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import { StripePaymentElement } from 'hono-stripe-elements';
|
|
18
|
+
|
|
19
|
+
export default function Checkout({ clientSecret }: { clientSecret: string }) {
|
|
20
|
+
return (
|
|
21
|
+
<StripePaymentElement
|
|
22
|
+
publishableKey="pk_test_..."
|
|
23
|
+
intentClientSecret={clientSecret}
|
|
24
|
+
intentType="payment"
|
|
25
|
+
buttonLabel="Pay"
|
|
26
|
+
onFormSubmit={event => console.log(event.detail)}
|
|
27
|
+
fallback={<p>Loading payment form…</p>}
|
|
28
|
+
/>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Components
|
|
34
|
+
|
|
35
|
+
| Component | Web Component |
|
|
36
|
+
| --------------------------------- | -------------------------------------- |
|
|
37
|
+
| `StripeCardElement` | `<stripe-card-element>` |
|
|
38
|
+
| `StripePaymentElement` | `<stripe-payment-element>` |
|
|
39
|
+
| `StripeExpressCheckoutElement` | `<stripe-express-checkout-element>` |
|
|
40
|
+
| `StripeAddressElement` | `<stripe-address-element>` |
|
|
41
|
+
| `StripeLinkAuthenticationElement` | `<stripe-link-authentication-element>` |
|
|
42
|
+
| `StripeCurrencySelector` | `<stripe-currency-selector>` |
|
|
43
|
+
|
|
44
|
+
Each component accepts the props of the underlying Web Component. See the [stripe-pwa-elements documentation](https://github.com/hideokamoto/stripe-pwa-elements#readme) for the full list.
|
|
45
|
+
|
|
46
|
+
## How props are mapped
|
|
47
|
+
|
|
48
|
+
- **SSR safe**: the custom element is registered lazily on the client. Until then, the `fallback` node (or nothing) is rendered.
|
|
49
|
+
- **Attributes**: primitive props become kebab-case attributes (`buttonLabel` → `button-label`, `true` → empty attribute).
|
|
50
|
+
- **Events**: `onXxx` props subscribe to the camelCase custom events the element emits (`onFormSubmit` → `formSubmit`). Listeners are bound as soon as the element is created, so early events such as `stripeLoaded` are not missed.
|
|
51
|
+
- **Properties**: function, array and object props are assigned as element properties (for example `handleSubmit`, `stripeDidLoaded` and `allowedCountries`).
|
|
52
|
+
- **`ref`**: forwarded to the element instance (object ref or callback ref).
|
|
53
|
+
|
|
54
|
+
## Custom components
|
|
55
|
+
|
|
56
|
+
`createStripeElementComponent(tag, loader)` is exported for wrapping other elements with the same behaviour.
|
|
57
|
+
|
|
58
|
+
## License
|
|
59
|
+
|
|
60
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hono-stripe-elements",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "hono/jsx components wrapping stripe-pwa-elements Web Components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -8,11 +8,6 @@
|
|
|
8
8
|
"files": [
|
|
9
9
|
"dist/"
|
|
10
10
|
],
|
|
11
|
-
"scripts": {
|
|
12
|
-
"build": "tsc",
|
|
13
|
-
"typecheck": "tsc --noEmit",
|
|
14
|
-
"prepublishOnly": "pnpm run build"
|
|
15
|
-
},
|
|
16
11
|
"peerDependencies": {
|
|
17
12
|
"hono": ">=4.0.0",
|
|
18
13
|
"stripe-pwa-elements": ">=4.0.1"
|
|
@@ -20,8 +15,8 @@
|
|
|
20
15
|
"devDependencies": {
|
|
21
16
|
"@stripe/stripe-js": "^9.17.0",
|
|
22
17
|
"hono": "^4.13.13",
|
|
23
|
-
"
|
|
24
|
-
"
|
|
18
|
+
"typescript": "^5.9.3",
|
|
19
|
+
"stripe-pwa-elements": "4.0.1"
|
|
25
20
|
},
|
|
26
21
|
"keywords": [
|
|
27
22
|
"hono",
|
|
@@ -44,5 +39,9 @@
|
|
|
44
39
|
"publishConfig": {
|
|
45
40
|
"access": "public"
|
|
46
41
|
},
|
|
47
|
-
"license": "MIT"
|
|
48
|
-
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsc",
|
|
45
|
+
"typecheck": "tsc --noEmit"
|
|
46
|
+
}
|
|
47
|
+
}
|