@coincircuit/checkout 0.1.0 → 0.2.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/README.md +77 -0
- package/package.json +1 -5
package/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# @coincircuit/checkout
|
|
2
|
+
|
|
3
|
+
CoinCircuit Checkout SDK. Add a payment modal to your site with a few lines of code.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @coincircuit/checkout
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage (Vanilla JS)
|
|
12
|
+
|
|
13
|
+
```javascript
|
|
14
|
+
import { CoinCircuitCheckout } from '@coincircuit/checkout';
|
|
15
|
+
|
|
16
|
+
const checkout = new CoinCircuitCheckout();
|
|
17
|
+
|
|
18
|
+
// Call from a click handler
|
|
19
|
+
button.addEventListener('click', () => {
|
|
20
|
+
checkout.open({
|
|
21
|
+
reference: 'cs_ref_abc123',
|
|
22
|
+
theme: 'dark',
|
|
23
|
+
onPaymentComplete: (data) => {
|
|
24
|
+
console.log('Paid!', data.transactionHash);
|
|
25
|
+
},
|
|
26
|
+
onClose: () => {
|
|
27
|
+
console.log('Checkout closed');
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Usage (React)
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
import { CoinCircuitCheckoutButton } from '@coincircuit/checkout/react';
|
|
37
|
+
|
|
38
|
+
function PayPage() {
|
|
39
|
+
return (
|
|
40
|
+
<CoinCircuitCheckoutButton
|
|
41
|
+
reference="cs_ref_abc123"
|
|
42
|
+
theme="dark"
|
|
43
|
+
label="Pay Now"
|
|
44
|
+
onPaymentComplete={(data) => console.log(data)}
|
|
45
|
+
onClose={() => console.log('closed')}
|
|
46
|
+
/>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## How it works
|
|
52
|
+
|
|
53
|
+
1. Your backend creates a payment session via the CoinCircuit API
|
|
54
|
+
2. You pass the session reference to the SDK
|
|
55
|
+
3. The SDK opens a full-screen modal with the checkout page in an iframe
|
|
56
|
+
4. The customer completes payment
|
|
57
|
+
5. Your callbacks fire with payment data
|
|
58
|
+
6. Modal closes automatically on success
|
|
59
|
+
|
|
60
|
+
## Callbacks
|
|
61
|
+
|
|
62
|
+
| Callback | When |
|
|
63
|
+
|----------|------|
|
|
64
|
+
| `onReady` | Checkout page finished loading |
|
|
65
|
+
| `onPaymentComplete` | Payment confirmed on-chain |
|
|
66
|
+
| `onPaymentFailed` | Payment failed |
|
|
67
|
+
| `onExpired` | Session expired |
|
|
68
|
+
| `onClose` | User closed the modal |
|
|
69
|
+
|
|
70
|
+
## Links
|
|
71
|
+
|
|
72
|
+
- [API Reference](https://coincircuit.io/api-reference)
|
|
73
|
+
- [Node.js SDK](https://www.npmjs.com/package/coincircuit)
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coincircuit/checkout",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Embed CoinCircuit checkout in your site via iframe, with vanilla JS and React support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -38,10 +38,6 @@
|
|
|
38
38
|
"sdk"
|
|
39
39
|
],
|
|
40
40
|
"license": "MIT",
|
|
41
|
-
"repository": {
|
|
42
|
-
"type": "git",
|
|
43
|
-
"url": "https://github.com/coincircuit/coincircuit-checkout"
|
|
44
|
-
},
|
|
45
41
|
"peerDependencies": {
|
|
46
42
|
"react": ">=17.0.0",
|
|
47
43
|
"react-dom": ">=17.0.0"
|