@chainrails/vanilla 0.0.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.
Files changed (2) hide show
  1. package/README.md +54 -0
  2. package/package.json +50 -0
package/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # @chainrails/vanilla
2
+
3
+ Vanilla Web Component integration for Chainrails payments.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add @chainrails/vanilla
9
+ # or
10
+ npm install @chainrails/vanilla
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```ts
16
+ import { Chainrails, createPaymentSession } from "@chainrails/vanilla";
17
+ import "@chainrails/vanilla";
18
+
19
+ Chainrails.config({ api_key: "your_api_key" });
20
+
21
+ const modal = document.createElement("chainrails-payment-modal");
22
+ document.body.appendChild(modal);
23
+
24
+ const session = createPaymentSession({
25
+ session_url: "http://localhost:4000/create-session",
26
+ onSuccess: () => console.log("Payment Successful"),
27
+ onCancel: () => console.log("Payment Cancelled"),
28
+ });
29
+
30
+ session.bind(modal);
31
+
32
+ document.getElementById("pay-btn")?.addEventListener("click", () => {
33
+ session.open();
34
+ });
35
+ ```
36
+
37
+ ## Element attributes
38
+
39
+ - `session-token`
40
+ - `amount`
41
+ - `session-url`
42
+ - `is-open`
43
+ - `is-pending`
44
+ - `theme`
45
+ - `accent-color`
46
+ - `exclude-chains`
47
+ - `env` (`production` or `internal`)
48
+
49
+ ## Re-exports
50
+
51
+ - `Chainrails`
52
+ - `crapi`
53
+ - `Chains`
54
+ - `AmountSymbols`
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@chainrails/vanilla",
3
+ "sideEffects": [
4
+ "**/*.css"
5
+ ],
6
+ "version": "0.0.0",
7
+ "description": "Vanilla Web Component bindings for Chainrails payments",
8
+ "license": "MIT",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/horuslabsio/chainrails-sdk",
12
+ "directory": "vanilla"
13
+ },
14
+ "scripts": {
15
+ "dev": "vite --port=9091 --open",
16
+ "build": "rm -rf dist && vite build && cp ./dist/chainrails-sdk.es.js ./dist/chainrails-sdk.es.mjs && tsc --emitDeclarationOnly --declarationDir dist",
17
+ "preview": "vite preview",
18
+ "type-check": "tsc --pretty --noEmit",
19
+ "lint": "eslint --ext .ts,.js ./src",
20
+ "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
21
+ },
22
+ "main": "./dist/chainrails-sdk.umd.js",
23
+ "module": "./dist/chainrails-sdk.es.mjs",
24
+ "source": "./src/index.ts",
25
+ "types": "./dist/index.d.ts",
26
+ "files": [
27
+ "dist"
28
+ ],
29
+ "exports": {
30
+ ".": {
31
+ "types": "./dist/index.d.ts",
32
+ "import": "./dist/chainrails-sdk.es.mjs",
33
+ "require": "./dist/chainrails-sdk.umd.js"
34
+ },
35
+ "./src": {
36
+ "types": "./src/index.ts",
37
+ "import": "./src/index.ts",
38
+ "require": "./src/index.ts"
39
+ }
40
+ },
41
+ "dependencies": {
42
+ "@chainrails/sdk": "^0.3.3",
43
+ "dotenv": "^17.2.3",
44
+ "vite": "^7.1.9"
45
+ },
46
+ "devDependencies": {
47
+ "typescript": "^5.9.0-beta",
48
+ "vite-plugin-lib-inject-css": "^2.2.2"
49
+ }
50
+ }