@openhive-eu/payment 1.0.0-beta.3 → 1.0.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +150 -0
- package/dist/index.js +598 -582
- package/dist/index.js.gz +0 -0
- package/dist/index.min.js +48 -48
- package/dist/index.min.js.gz +0 -0
- package/dist/lib/api-client.d.ts +1 -1
- package/dist/lib/i18n.d.ts +73 -3
- package/dist/payment-widget.d.ts +1 -0
- package/dist/react.js +637 -621
- package/dist/styles.css +1 -1
- package/dist/styles.css.gz +0 -0
- package/package.json +18 -9
- package/react.js +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# @openhive-eu/payment
|
|
2
|
+
|
|
3
|
+
Payment terminal widget — Lit web component with optional React wrapper.
|
|
4
|
+
|
|
5
|
+
📖 **[Full documentation](https://docs.openhive.eu/docs/services/payment/intro)**
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @openhive-eu/payment
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### Vanilla / HTML
|
|
16
|
+
|
|
17
|
+
```html
|
|
18
|
+
<script type="module">
|
|
19
|
+
import '@openhive-eu/payment';
|
|
20
|
+
import '@openhive-eu/payment/styles.css';
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<openhive-pay
|
|
24
|
+
token="your-api-token"
|
|
25
|
+
locale="en"
|
|
26
|
+
default-amount="150"
|
|
27
|
+
default-reference="FA-2025-001"
|
|
28
|
+
></openhive-pay>
|
|
29
|
+
|
|
30
|
+
<script>
|
|
31
|
+
document.querySelector('openhive-pay').addEventListener('request-to-pay', (e) => {
|
|
32
|
+
console.log(e.detail); // RequestToPay
|
|
33
|
+
});
|
|
34
|
+
</script>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Via CDN
|
|
38
|
+
|
|
39
|
+
CSS is bundled inside the JS — only one file to load.
|
|
40
|
+
|
|
41
|
+
```html
|
|
42
|
+
<script src="https://cdn.jsdelivr.net/npm/@openhive-eu/payment/dist/index.min.js"></script>
|
|
43
|
+
|
|
44
|
+
<openhive-pay token="your-api-token"></openhive-pay>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### React
|
|
48
|
+
|
|
49
|
+
```tsx
|
|
50
|
+
import { Payment } from '@openhive-eu/payment/react';
|
|
51
|
+
import '@openhive-eu/payment/styles.css';
|
|
52
|
+
|
|
53
|
+
function App() {
|
|
54
|
+
return (
|
|
55
|
+
<Payment
|
|
56
|
+
token="your-api-token"
|
|
57
|
+
locale="en"
|
|
58
|
+
defaultAmount="150"
|
|
59
|
+
defaultReference="FA-2025-001"
|
|
60
|
+
onRequestToPay={(e) => console.log(e.detail)}
|
|
61
|
+
onClose={() => console.log('closed')}
|
|
62
|
+
/>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Properties
|
|
68
|
+
|
|
69
|
+
| Attribute | Type | Default | Description |
|
|
70
|
+
|----------------------|-----------|---------|--------------------------------------------------|
|
|
71
|
+
| `token` | `string` | `""` | API authentication token |
|
|
72
|
+
| `locale` | `string` | `"fr"` | UI language (`"fr"` or `"en"`) |
|
|
73
|
+
| `currency` | `string` | `"EUR"` | Currency |
|
|
74
|
+
| `default-amount` | `string` | `""` | Pre-filled amount |
|
|
75
|
+
| `default-reference` | `string` | `""` | Pre-filled order reference |
|
|
76
|
+
| `read-only-amount` | `boolean` | `false` | Lock the amount field |
|
|
77
|
+
| `customer-email` | `string` | `""` | Pre-filled customer email |
|
|
78
|
+
| `customer-phone` | `string` | `""` | Pre-filled customer phone number |
|
|
79
|
+
| `customer-name` | `string` | `""` | Pre-filled customer name |
|
|
80
|
+
| `pay-client-ref` | `string` | `""` | Reference to a global `PayClient` instance |
|
|
81
|
+
|
|
82
|
+
> In React, kebab-case attributes become camelCase (`default-amount` → `defaultAmount`).
|
|
83
|
+
|
|
84
|
+
## Events
|
|
85
|
+
|
|
86
|
+
| Event | Type | Description |
|
|
87
|
+
|-------------------|-------------------------------|----------------------------------------------|
|
|
88
|
+
| `request-to-pay` | `CustomEvent<RequestToPay>` | Fired when the form is submitted |
|
|
89
|
+
| `close` | `Event` | Fired when the user closes the widget |
|
|
90
|
+
|
|
91
|
+
### `RequestToPay` type
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
type RequestToPay = {
|
|
95
|
+
order_reference: string;
|
|
96
|
+
amount: number; // in cents
|
|
97
|
+
currency: string;
|
|
98
|
+
method: string;
|
|
99
|
+
partner: 'adyen' | 'stripe' | 'fintecture';
|
|
100
|
+
channel: 'email' | 'sms' | 'link';
|
|
101
|
+
customer_contact: string;
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## CSS Customization
|
|
106
|
+
|
|
107
|
+
The widget adapts to your SaaS brand via **CSS variables**.
|
|
108
|
+
|
|
109
|
+
### Target all OpenHive widgets
|
|
110
|
+
|
|
111
|
+
```css
|
|
112
|
+
:root {
|
|
113
|
+
--openhive-primary: #your-brand;
|
|
114
|
+
--openhive-radius: 0.5rem;
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Target the payment widget only
|
|
119
|
+
|
|
120
|
+
```css
|
|
121
|
+
openhive-pay {
|
|
122
|
+
--pay-primary: #your-brand;
|
|
123
|
+
--pay-primary-foreground: #ffffff;
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Available variables
|
|
128
|
+
|
|
129
|
+
| Variable | Default |
|
|
130
|
+
|-------------------------------|--------------------------------------|
|
|
131
|
+
| `--pay-primary` | `var(--openhive-primary)` |
|
|
132
|
+
| `--pay-primary-foreground` | `var(--openhive-primary-foreground)` |
|
|
133
|
+
| `--pay-background` | `var(--openhive-background)` |
|
|
134
|
+
| `--pay-foreground` | `var(--openhive-foreground)` |
|
|
135
|
+
| `--pay-muted` | `var(--openhive-muted)` |
|
|
136
|
+
| `--pay-muted-foreground` | `var(--openhive-muted-foreground)` |
|
|
137
|
+
| `--pay-accent` | `var(--openhive-accent)` |
|
|
138
|
+
| `--pay-accent-foreground` | `var(--openhive-accent-foreground)` |
|
|
139
|
+
| `--pay-border` | `var(--openhive-border)` |
|
|
140
|
+
| `--pay-input` | `var(--openhive-input)` |
|
|
141
|
+
| `--pay-ring` | `var(--openhive-ring)` |
|
|
142
|
+
| `--pay-radius` | `var(--openhive-radius)` |
|
|
143
|
+
|
|
144
|
+
## npm tags
|
|
145
|
+
|
|
146
|
+
| Tag | Command | Use case |
|
|
147
|
+
|-----------|---------------------------------------------|-----------------------------------|
|
|
148
|
+
| `latest` | `npm install @openhive-eu/payment` | Production |
|
|
149
|
+
| `beta` | `npm install @openhive-eu/payment@beta` | Staging / pre-release validation |
|
|
150
|
+
| `next` | `npm install @openhive-eu/payment@next` | Early testing |
|