@bizzsv/bizz-payment 1.2.2
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 +191 -0
- package/dist/index.cjs +445 -0
- package/dist/index.d.ts +174 -0
- package/dist/index.global.js +445 -0
- package/dist/index.js +11996 -0
- package/dist/package.json +71 -0
- package/package.json +64 -0
package/README.md
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
# BizPaymentForm SDK
|
|
2
|
+
|
|
3
|
+
The BizPaymentForm SDK is designed to provide a secure and isolated form for payment integration.
|
|
4
|
+
|
|
5
|
+
## Technologies version required
|
|
6
|
+
|
|
7
|
+
- **Node.js:** 24.14.0 or higher
|
|
8
|
+
- **Vite:** 8.0.1 or higher
|
|
9
|
+
- **TypeScript:** 5.9.3 or higher
|
|
10
|
+
|
|
11
|
+
In the root of the project, we have .nvmrc file, if you have installed nvm, you can run
|
|
12
|
+
```bash
|
|
13
|
+
nvm use
|
|
14
|
+
```
|
|
15
|
+
to use the correct version of Node.js. If you don't have nvm installed, you can install it [here](https://github.com/nvm-sh/nvm).
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## Plugins/packages used
|
|
19
|
+
|
|
20
|
+
This package is the only one that uses for productions.
|
|
21
|
+
|
|
22
|
+
- **Maska:** Used to mask the input fields, like credit card, number, expiration date, CVV, etc.
|
|
23
|
+
- **Node-Forge:** Used to generate the PKCE challenge and verifier for the OAuth 2.0 flow.
|
|
24
|
+
- **Dompurify:** Used to sanitize the HTML for prevent XSS attacks.
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
## Features includes
|
|
28
|
+
- **Payments without 3DS:** show the form without 3DS if the commerce does not have 3DS enabled.
|
|
29
|
+
- **Payments with 3DS:** show the form with 3DS if the commerce has 3DS enabled.
|
|
30
|
+
|
|
31
|
+
## Development Workflow: Vite Bundle Plugin
|
|
32
|
+
|
|
33
|
+
To keep the project scalable and maintainable while using `srcdoc`, we implemented a custom Vite plugin:
|
|
34
|
+
|
|
35
|
+
1. **TypeScript Native:** We write the iframe logic using modern TypeScript and imports.
|
|
36
|
+
2. **IIFE Transformation:** Vite compiles the entire dependency tree of the iframe into a single, minified, self-executing string (IIFE).
|
|
37
|
+
3. **Dynamic Injection:** This string is injected into the `iframeContent.html` generator, making it available for the `srcdoc` at runtime.
|
|
38
|
+
|
|
39
|
+
## How run the project
|
|
40
|
+
|
|
41
|
+
Native development server with Vite:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pnpm dev
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
React development server with Vite:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pnpm examples:react:dev
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Vue development server with Vite:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pnpm examples:vue:dev
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Angular development server with Vite:
|
|
60
|
+
|
|
61
|
+
You need have installed the Angular CLI globally to run the development server. Read more about how to install the Angular CLI [here](https://angular.dev/installation).
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
pnpm install -g @angular/cli
|
|
65
|
+
```
|
|
66
|
+
then:
|
|
67
|
+
```bash
|
|
68
|
+
pnpm examples:angular:dev
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Note: for run the examples (React, Vue, Angular), you need to build the project first.
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
pnpm build
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Testing
|
|
78
|
+
|
|
79
|
+
The project has two types of tests:
|
|
80
|
+
- Unit tests: for testing the iframe logic.
|
|
81
|
+
- End-to-end tests: for testing the iframe in the browser.
|
|
82
|
+
|
|
83
|
+
To run the tests, you need to run the following command:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
pnpm test
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
To run the tests in watch mode, you need to run the following command:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
pnpm test:watch
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
To run the end-to-end tests, you need to run the following command:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
pnpm test:e2e
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
To run the end-to-end tests, you need to run the following command:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
pnpm test:e2e
|
|
105
|
+
```
|
|
106
|
+
or run the tests with the UI:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
pnpm test:e2e:ui
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Documentation website
|
|
113
|
+
|
|
114
|
+
The documentation is built with Starlight and is hosted in the `docs` directory, run on Astro, and its SSR.
|
|
115
|
+
|
|
116
|
+
To run the documentation server, you need to run the following command:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
pnpm docs:dev
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
To build the documentation, you need to run the following command:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
pnpm docs:build
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
To preview the documentation, you need to run the following command:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
pnpm docs:preview
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Build the project
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
pnpm build
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Serfinsa cards documentation for 3ds implementation
|
|
141
|
+
|
|
142
|
+
[Read more](https://developer.cardinaltrusted.com/reference/emv-3ds-test-cases-challenge)
|
|
143
|
+
[Read documentation for Cardinal integration](https://developer.cardinaltrusted.com/docs/cardinal-cruise-integration)
|
|
144
|
+
|
|
145
|
+
### Cards for testing
|
|
146
|
+
|
|
147
|
+
The expiration data can be 01/2027 or 01/2028, always the year must be in the future.
|
|
148
|
+
|
|
149
|
+
| Card type | PAN | Cvv | Fecha | Friction |
|
|
150
|
+
|-----------|-----|-----|-------|----------|
|
|
151
|
+
| Visa | 4000000000002701 | 123 | 01 / 2027 | No |
|
|
152
|
+
| Mastercard | 5200000000002235 | 123 | 01 / 2027 | No |
|
|
153
|
+
| Visa | 4000000000002503 | 123 | 01 / 2027 | Yes |
|
|
154
|
+
| Mastercard | 5200000000002151 | 123 | 01 / 2027 | Yes |
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
For no 3DS cards
|
|
158
|
+
|
|
159
|
+
| Card type | PAN | Cvv | Fecha | Friction | Failed |
|
|
160
|
+
|-----------|-----|-----|-------|----------|--------|
|
|
161
|
+
| Visa | 4242000000000851 | 123 | 01 / 2027 | No | Yes |
|
|
162
|
+
| Visa | 4242000000000000 | 123 | 01 / 2027 | No | No |
|
|
163
|
+
| UnionPay | 6215000000003218 | 123 | 01 / 2027 | No | No |
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
## Security: The `srcdoc` Approach
|
|
167
|
+
|
|
168
|
+
The package encapsulates the payment form inside an `iframe` with the `srcdoc` attribute. This architectural decision provides several critical security and operational benefits:
|
|
169
|
+
|
|
170
|
+
### 1. Isolation & Anti-XSS
|
|
171
|
+
By using `srcdoc`, the form lives in a separate environment (`about:srcdoc`). This acts as a "firewall" that prevents:
|
|
172
|
+
- **Script Interception:** External scripts (trackers, malicious ads, or browser extensions) cannot access the data inside the iframe, that means that the commerces can't get access to the data inside the iframe
|
|
173
|
+
- **Keyloggers:** It's significantly harder for generic DOM-based keyloggers to capture inputs inside an isolated iframe.
|
|
174
|
+
- ** CSS Integrity:** The host website's CSS (e.g., `input { margin: 50px !important }`) cannot leak into or break the payment form's layout.
|
|
175
|
+
|
|
176
|
+
### 2. Style Integrity (Zero Conflict CSS)
|
|
177
|
+
The `srcdoc` ensures that the content is loaded in a "clean room" environment.
|
|
178
|
+
- **CSS Encapsulation:** The host website's CSS (e.g., `input { margin: 50px !important }`) cannot leak into or break the payment form's layout.
|
|
179
|
+
- **Deterministic UI:** The form will look exactly the same on any website, whether it's a WordPress site, a React app, or a legacy HTML page.
|
|
180
|
+
|
|
181
|
+
### 3. High Portability (Single-File SDK)
|
|
182
|
+
Unlike traditional `iframe.src` approaches used by other packages (which require hosting an external HTML file), our `srcdoc` architecture:
|
|
183
|
+
- **No Extra Hosting:** The entire form (HTML + CSS + JS) is bundled into your final `dist/index.js`.
|
|
184
|
+
- **Instant Load:** There is no additional network request to fetch the iframe content; it renders as soon as the JS is executed.
|
|
185
|
+
|
|
186
|
+
### 4 Data storage
|
|
187
|
+
The data never is stored in the browser (localStorage, sessionStorage, cookies, etc.), all data keep in the memory, that means that for each page reload, the data is lost, and each page reload, is a new instance of the form.
|
|
188
|
+
|
|
189
|
+
Information commerce, access token, authorize code, etc, keep in the memory.
|
|
190
|
+
|
|
191
|
+
When an user fields the form, the data is keeping in memory too, and after submit the form, all data is cleaned.
|