@primer-io/primer-js 0.3.12 → 0.5.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/CHANGELOG.md +16 -0
- package/README.md +83 -101
- package/dist/custom-elements.json +1671 -364
- package/dist/jsx/index.d.ts +102 -1
- package/dist/primer-loader.d.ts +687 -14
- package/dist/primer-loader.js +10 -10
- package/dist/vscode.html-custom-data.json +61 -1
- package/dist/web-types.json +219 -6
- package/package.json +5 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @primer-io/primer-js
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 791a212: BLIK support
|
|
8
|
+
|
|
9
|
+
## 0.4.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 6fa6c1c: Billing address released, SDK core is default now.
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- c72066e: billing address for primer-js
|
|
18
|
+
|
|
3
19
|
## 0.3.12
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,19 +1,8 @@
|
|
|
1
|
-
# Primer
|
|
1
|
+
# Primer Checkout SDK
|
|
2
2
|
|
|
3
3
|

|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Primer Composable Checkout is a web component-based SDK that enables you to build customizable, PCI-compliant checkout experiences quickly and easily. With Primer's flexible component architecture, you can create branded payment experiences that work consistently across all modern browsers.
|
|
8
|
-
|
|
9
|
-
## Features
|
|
10
|
-
|
|
11
|
-
- 🧩 **Component-Based Architecture**: Modular web components built on modern web standards
|
|
12
|
-
- 🎨 **Highly Customizable**: Extensive theming options through CSS custom properties
|
|
13
|
-
- 🔒 **Secure by Design**: PCI-compliant payment flows with secure form handling
|
|
14
|
-
- 📱 **Responsive**: Works seamlessly across devices and screen sizes
|
|
15
|
-
- 🌐 **Framework Agnostic**: Integrates with any JavaScript environment or framework
|
|
16
|
-
- 🔄 **Multiple Payment Methods**: Support for cards, digital wallets, and alternative payment methods
|
|
5
|
+
A modern web component-based SDK for integrating Primer's Checkout into your web application. Support for cards, digital wallets, and 100+ payment methods with minimal code.
|
|
17
6
|
|
|
18
7
|
## Installation
|
|
19
8
|
|
|
@@ -21,126 +10,119 @@ Primer Composable Checkout is a web component-based SDK that enables you to buil
|
|
|
21
10
|
npm install @primer-io/primer-js
|
|
22
11
|
```
|
|
23
12
|
|
|
24
|
-
|
|
13
|
+
## Quick Start
|
|
25
14
|
|
|
26
15
|
```javascript
|
|
27
16
|
import { loadPrimer } from '@primer-io/primer-js';
|
|
28
|
-
loadPrimer();
|
|
29
|
-
```
|
|
30
17
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
Import the css styles:
|
|
18
|
+
// Load the SDK
|
|
19
|
+
loadPrimer();
|
|
34
20
|
|
|
35
|
-
|
|
36
|
-
<
|
|
37
|
-
rel="stylesheet"
|
|
38
|
-
href="https://sdk.primer.io/web/primer-js/v0-latest/styles.css"
|
|
39
|
-
/>
|
|
40
|
-
<!-- The dark theme import below is optional -->
|
|
41
|
-
<link
|
|
42
|
-
rel="stylesheet"
|
|
43
|
-
href="https://sdk.primer.io/web/primer-js/v0-latest/dark.css"
|
|
44
|
-
/>
|
|
21
|
+
// Add checkout to your page
|
|
22
|
+
// <primer-checkout client-token="your-client-token"></primer-checkout>
|
|
45
23
|
```
|
|
46
24
|
|
|
47
|
-
Render the checkout:
|
|
48
|
-
|
|
49
25
|
```html
|
|
50
26
|
<primer-checkout client-token="your-client-token"></primer-checkout>
|
|
51
27
|
```
|
|
52
28
|
|
|
53
|
-
|
|
29
|
+
That's it! The SDK handles payment method rendering, validation, and payment processing.
|
|
54
30
|
|
|
55
|
-
|
|
31
|
+
## Prerequisites
|
|
56
32
|
|
|
57
|
-
|
|
58
|
-
<primer-checkout client-token="your-client-token">
|
|
59
|
-
<primer-main slot="main">
|
|
60
|
-
<div slot="payments">
|
|
61
|
-
<primer-payment-method type="PAYMENT_CARD"></primer-payment-method>
|
|
62
|
-
<primer-payment-method type="PAYPAL"></primer-payment-method>
|
|
63
|
-
<primer-payment-method type="GOOGLE_PAY"></primer-payment-method>
|
|
64
|
-
</div>
|
|
65
|
-
</primer-main>
|
|
66
|
-
</primer-checkout>
|
|
67
|
-
```
|
|
33
|
+
Before using the SDK, you'll need:
|
|
68
34
|
|
|
69
|
-
|
|
35
|
+
1. A Primer account with [Universal Checkout configuration](https://primer.io/docs/payments/universal-checkout/configure-universal-checkout-without-code)
|
|
36
|
+
2. A client token from the [Client Session API](https://primer.io/docs/api/api-reference/client-session-api/create-client-side-token)
|
|
70
37
|
|
|
71
|
-
|
|
72
|
-
<primer-checkout client-token="your-client-token">
|
|
73
|
-
<primer-main slot="main">
|
|
74
|
-
<div slot="payments">
|
|
75
|
-
<primer-payment-method type="PAYMENT_CARD">
|
|
76
|
-
<primer-card-form>
|
|
77
|
-
<div slot="card-form-content">
|
|
78
|
-
<primer-input-card-number></primer-input-card-number>
|
|
79
|
-
<div style="display: flex; gap: 8px;">
|
|
80
|
-
<primer-input-card-expiry></primer-input-card-expiry>
|
|
81
|
-
<primer-input-cvv></primer-input-cvv>
|
|
82
|
-
</div>
|
|
83
|
-
<primer-input-card-holder-name></primer-input-card-holder-name>
|
|
84
|
-
<primer-button buttonType="submit">Pay Now</primer-button>
|
|
85
|
-
</div>
|
|
86
|
-
</primer-card-form>
|
|
87
|
-
</primer-payment-method>
|
|
88
|
-
</div>
|
|
89
|
-
</primer-main>
|
|
90
|
-
</primer-checkout>
|
|
91
|
-
```
|
|
38
|
+
## Browser Support
|
|
92
39
|
|
|
93
|
-
|
|
40
|
+
Works with all modern browsers (Chrome, Firefox, Safari, Edge). Internet Explorer 11 and legacy Edge are not supported.
|
|
94
41
|
|
|
95
|
-
|
|
96
|
-
const checkout = document.querySelector('primer-checkout');
|
|
42
|
+
## Key Features
|
|
97
43
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
44
|
+
- **Universal Checkout**: Support for 100+ payment methods with a single integration
|
|
45
|
+
- **Web Components**: Works with React, Vue, Svelte, Next.js, and vanilla JavaScript
|
|
46
|
+
- **Customizable**: Full styling control via CSS variables
|
|
47
|
+
- **Event-Driven**: Listen to payment lifecycle events
|
|
48
|
+
- **TypeScript**: Full type definitions included
|
|
49
|
+
- **Vault Mode**: Save payment methods for future use
|
|
103
50
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
51
|
+
## Documentation
|
|
52
|
+
|
|
53
|
+
📚 [Web Components Documentation](https://web-components.primer.io)
|
|
54
|
+
|
|
55
|
+
### Quick Links
|
|
56
|
+
|
|
57
|
+
- [Getting Started Guide](https://web-components.primer.io/documentation/getting-started)
|
|
58
|
+
- [SDK Options Reference](https://web-components.primer.io/sdk-reference/sdk-options-reference)
|
|
59
|
+
- [Events Guide](https://web-components.primer.io/guides/events-guide)
|
|
60
|
+
- [React Integration Guide](https://web-components.primer.io/guides/react-guide)
|
|
61
|
+
- [Styling API Documentation](https://web-components.primer.io/sdk-reference/styling-api-docs)
|
|
62
|
+
|
|
63
|
+
## Examples
|
|
64
|
+
|
|
65
|
+
See working examples with different frameworks and use cases:
|
|
110
66
|
|
|
111
|
-
|
|
67
|
+
🔗 [GitHub Examples Repository](https://github.com/primer-io/examples)
|
|
112
68
|
|
|
113
|
-
|
|
69
|
+
### Available Examples
|
|
114
70
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
71
|
+
- Vanilla JavaScript + TypeScript
|
|
72
|
+
- React with custom layouts
|
|
73
|
+
- Theme customization
|
|
74
|
+
- Vaulted payments
|
|
75
|
+
- Server-side rendering
|
|
119
76
|
|
|
120
|
-
|
|
121
|
-
--primer-typography-brand: 'Roboto', sans-serif;
|
|
77
|
+
## TypeScript Support
|
|
122
78
|
|
|
123
|
-
|
|
124
|
-
--primer-radius-base: 8px;
|
|
79
|
+
TypeScript definitions are included. For JSX/TSX projects, add type declarations:
|
|
125
80
|
|
|
126
|
-
|
|
127
|
-
|
|
81
|
+
```typescript
|
|
82
|
+
import type { CheckoutElement } from '@primer-io/primer-js';
|
|
83
|
+
|
|
84
|
+
declare global {
|
|
85
|
+
namespace JSX {
|
|
86
|
+
interface IntrinsicElements {
|
|
87
|
+
'primer-checkout': CheckoutElement;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
128
90
|
}
|
|
129
91
|
```
|
|
130
92
|
|
|
131
|
-
##
|
|
93
|
+
## Event Handling
|
|
132
94
|
|
|
133
|
-
|
|
95
|
+
Listen to payment lifecycle events:
|
|
134
96
|
|
|
135
|
-
|
|
97
|
+
```javascript
|
|
98
|
+
const checkout = document.querySelector('primer-checkout');
|
|
136
99
|
|
|
137
|
-
|
|
100
|
+
checkout.addEventListener('primer:ready', () => {
|
|
101
|
+
console.log('Checkout ready');
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
checkout.addEventListener('primer:state-change', (event) => {
|
|
105
|
+
const { isProcessing, isSuccessful, error } = event.detail;
|
|
106
|
+
// Handle payment state changes
|
|
107
|
+
});
|
|
108
|
+
```
|
|
138
109
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
-
|
|
142
|
-
-
|
|
110
|
+
## Support
|
|
111
|
+
|
|
112
|
+
- **Documentation**: [Web Components Documentation](https://web-components.primer.io)
|
|
113
|
+
- **API Reference**: [Primer API Docs](https://primer.io/docs/api)
|
|
114
|
+
- **Support**: Contact your Primer account manager
|
|
143
115
|
|
|
144
116
|
## License
|
|
145
117
|
|
|
146
|
-
|
|
118
|
+
**BSD 3-Clause License**
|
|
119
|
+
|
|
120
|
+
Copyright (c) 2021 Primer API Ltd. All rights reserved.
|
|
121
|
+
|
|
122
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
123
|
+
|
|
124
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
125
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
126
|
+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
127
|
+
|
|
128
|
+
> **Disclaimer**: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|