@primer-io/primer-js 0.0.1 → 0.0.3

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.md ADDED
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2021 Primer API Ltd, All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ - Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ - Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ - Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md ADDED
@@ -0,0 +1,146 @@
1
+ # Primer Composable Checkout
2
+
3
+ ![Primer Logo](https://goat-assets.production.core.primer.io/brand/icon/primer.svg)
4
+
5
+ > **BETA NOTICE**: Primer Composable Checkout is currently in beta. While the core architecture and design philosophy will remain stable, some aspects may evolve based on feedback, including variable naming, component naming, and API refinements. By using this beta version, you'll have the opportunity to influence its development before general release.
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
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ npm install @primer-io/primer-js
22
+ ```
23
+
24
+ Then import and initialize Primer in your application:
25
+
26
+ ```javascript
27
+ import { loadPrimer } from '@primer-io/primer-js';
28
+ loadPrimer();
29
+ ```
30
+
31
+ ## Quick Start
32
+
33
+ Import the css styles:
34
+
35
+ ```html
36
+ <link
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
+ />
45
+ ```
46
+
47
+ Render the checkout:
48
+
49
+ ```html
50
+ <primer-checkout client-token="your-client-token"></primer-checkout>
51
+ ```
52
+
53
+ ## Basic Usage
54
+
55
+ ### Complete Checkout Form
56
+
57
+ ```html
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
+ ```
68
+
69
+ ### Custom Card Form Layout
70
+
71
+ ```html
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
+ ```
92
+
93
+ ## Event Handling
94
+
95
+ ```javascript
96
+ const checkout = document.querySelector('primer-checkout');
97
+
98
+ // Listen for SDK state changes
99
+ checkout.addEventListener('primer-state-changed', (event) => {
100
+ const { isProcessing, isSuccessful, error } = event.detail;
101
+ // Handle state changes
102
+ });
103
+
104
+ // Listen for available payment methods
105
+ checkout.addEventListener('primer-payment-methods-updated', (event) => {
106
+ const paymentMethods = event.detail.toArray();
107
+ // Handle payment methods list
108
+ });
109
+ ```
110
+
111
+ ## Theming
112
+
113
+ Primer Composable Checkout supports both light and dark themes and can be easily customized to match your brand:
114
+
115
+ ```css
116
+ :root {
117
+ /* Brand colors */
118
+ --primer-color-brand: #663399; /* Purple brand color */
119
+
120
+ /* Typography */
121
+ --primer-typography-brand: 'Roboto', sans-serif;
122
+
123
+ /* Border radius */
124
+ --primer-radius-base: 8px;
125
+
126
+ /* Spacing */
127
+ --primer-space-base: 8px;
128
+ }
129
+ ```
130
+
131
+ ## Documentation
132
+
133
+ For comprehensive documentation, guides, and API reference, please visit:
134
+
135
+ [Primer Composable Checkout Documentation](https://composable-checkout.vercel.app)
136
+
137
+ ## Supported Browsers
138
+
139
+ - Chrome
140
+ - Firefox
141
+ - Safari
142
+ - Edge
143
+
144
+ ## License
145
+
146
+ Copyright © Primer API Ltd. All rights reserved.