@tender-cash/agent-sdk-react 1.0.0 → 1.0.1-beta
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/dist/tender-cash-agent-sdk-react.cjs.js +84 -59
- package/dist/tender-cash-agent-sdk-react.cjs.js.map +1 -1
- package/dist/tender-cash-agent-sdk-react.es.js +11074 -5610
- package/dist/tender-cash-agent-sdk-react.es.js.map +1 -1
- package/dist/types/module/types.d.ts +4 -0
- package/package.json +1 -1
- package/readme.md +39 -81
|
@@ -174,6 +174,10 @@ interface TenderAgentProps {
|
|
|
174
174
|
accessId: string;
|
|
175
175
|
env: TenderEnvironments;
|
|
176
176
|
onEventResponse?: (data: onFinishResponse) => void;
|
|
177
|
+
referenceId?: string;
|
|
178
|
+
amount?: number;
|
|
179
|
+
paymentExpirySeconds?: number;
|
|
180
|
+
theme?: "light" | "dark";
|
|
177
181
|
}
|
|
178
182
|
interface StartPaymentParams {
|
|
179
183
|
referenceId: string;
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -19,7 +19,7 @@ npm install @tender-cash/agent-sdk-react
|
|
|
19
19
|
|
|
20
20
|
## Styling
|
|
21
21
|
|
|
22
|
-
The component
|
|
22
|
+
The component uses Shadow DOM to prevent CSS leaks into your application. The styles are automatically injected into the shadow root, so you don't need to import the CSS file manually. However, if you're using the component in a build that doesn't bundle CSS automatically, you can still import it:
|
|
23
23
|
|
|
24
24
|
```javascript
|
|
25
25
|
import '@tender-cash/agent-sdk-react/dist/style.css';
|
|
@@ -27,110 +27,61 @@ import '@tender-cash/agent-sdk-react/dist/style.css';
|
|
|
27
27
|
|
|
28
28
|
## Usage
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
Pass all payment parameters directly as props. The modal will automatically open when the component mounts with the required payment parameters.
|
|
31
31
|
|
|
32
32
|
```jsx
|
|
33
|
-
import
|
|
34
|
-
import '@tender-cash/agent-sdk-react
|
|
35
|
-
import { TenderAgentSdk, TenderAgentRef, onFinishResponse } from '@tender-cash/agent-sdk-react';
|
|
33
|
+
import '@tender-cash/agent-sdk-react/dist/style.css';
|
|
34
|
+
import { TenderAgentSdk, onFinishResponse } from '@tender-cash/agent-sdk-react';
|
|
36
35
|
|
|
37
36
|
function PaymentComponent() {
|
|
38
|
-
const tenderRef = useRef<TenderAgentRef>(null);
|
|
39
|
-
|
|
40
|
-
// --- Static Configuration ---
|
|
41
|
-
const accessId = 'YOUR_ACCESS_ID'; // Replace with your actual Access ID
|
|
42
|
-
const fiatCurrency = 'USD'; // Currency code
|
|
43
|
-
const environment = 'test'; // 'test' or 'live'
|
|
44
|
-
|
|
45
37
|
const handleEventResponse = (response: onFinishResponse) => {
|
|
46
38
|
console.log('SDK Response:', response);
|
|
47
39
|
// Handle success, partial payment, overpayment, error based on response.status
|
|
48
40
|
};
|
|
49
41
|
|
|
50
|
-
const handleOpenModal = () => {
|
|
51
|
-
tenderRef.current?.initiatePayment({
|
|
52
|
-
amount: 150.00,
|
|
53
|
-
referenceId: 'unique-payment-reference-123',
|
|
54
|
-
paymentExpirySeconds: 1800,
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const handleDismissModal = () => {
|
|
59
|
-
tenderRef.current?.dismiss();
|
|
60
|
-
};
|
|
61
|
-
|
|
62
42
|
return (
|
|
63
|
-
<
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
ref={tenderRef}
|
|
73
|
-
accessId={accessId}
|
|
74
|
-
fiatCurrency={fiatCurrency}
|
|
75
|
-
env={environment}
|
|
76
|
-
onEventResponse={handleEventResponse}
|
|
77
|
-
/>
|
|
78
|
-
</div>
|
|
43
|
+
<TenderAgentSdk
|
|
44
|
+
accessId="YOUR_ACCESS_ID"
|
|
45
|
+
fiatCurrency="USD"
|
|
46
|
+
env="test"
|
|
47
|
+
onEventResponse={handleEventResponse}
|
|
48
|
+
amount={150.00}
|
|
49
|
+
referenceId="unique-payment-reference-123"
|
|
50
|
+
paymentExpirySeconds={1800}
|
|
51
|
+
/>
|
|
79
52
|
);
|
|
80
53
|
}
|
|
81
54
|
|
|
82
55
|
export default PaymentComponent;
|
|
83
56
|
```
|
|
84
57
|
|
|
85
|
-
|
|
58
|
+
**Note:** The modal opens automatically on component mount when `referenceId` and `amount` are provided as props.
|
|
86
59
|
|
|
87
|
-
|
|
60
|
+
## API Reference
|
|
88
61
|
|
|
89
|
-
|
|
62
|
+
### Component Props (`TenderAgentProps`)
|
|
90
63
|
|
|
91
|
-
|
|
64
|
+
The `TenderAgentSdk` component accepts the following props:
|
|
92
65
|
|
|
93
|
-
|
|
94
|
-
|---------------------|----------------------------------------------------------|
|
|
95
|
-
| `initiatePayment()` | Initiates a payment and opens the payment modal |
|
|
96
|
-
| `dismiss()` | Closes/dismisses the payment modal |
|
|
66
|
+
#### Required Props
|
|
97
67
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
const tenderRef = useRef<TenderAgentRef>(null);
|
|
104
|
-
|
|
105
|
-
// Open modal
|
|
106
|
-
tenderRef.current?.initiatePayment({
|
|
107
|
-
amount: 150.00,
|
|
108
|
-
referenceId: 'unique-payment-reference-123',
|
|
109
|
-
paymentExpirySeconds: 1800,
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
// Close modal
|
|
113
|
-
tenderRef.current?.dismiss();
|
|
114
|
-
|
|
115
|
-
// Render component
|
|
116
|
-
<TenderAgentSdk
|
|
117
|
-
ref={tenderRef}
|
|
118
|
-
accessId="YOUR_ACCESS_ID"
|
|
119
|
-
fiatCurrency="USD"
|
|
120
|
-
env="test"
|
|
121
|
-
/>;
|
|
122
|
-
```
|
|
68
|
+
| Prop | Type | Description |
|
|
69
|
+
|------------------|---------------------------------------------|-----------------------------------------------------------------------------|
|
|
70
|
+
| `fiatCurrency` | `string` | The fiat currency code (e.g., "USD", "EUR"). |
|
|
71
|
+
| `accessId` | `string` | Your Tender Cash merchant Access ID. |
|
|
72
|
+
| `env` | `"test"` \| `"live"` \| `"local"` | The environment to use (`"test"` for testing, `"live"` for production, `"local"` for local development). |
|
|
123
73
|
|
|
124
|
-
|
|
74
|
+
#### Optional Props
|
|
125
75
|
|
|
126
|
-
|
|
76
|
+
| Prop | Type | Description |
|
|
77
|
+
|-------------------------|---------------------------------------------|-----------------------------------------------------------------------------|
|
|
78
|
+
| `onEventResponse` | `(data: onFinishResponse) => void` | Callback function triggered on payment completion or status change. |
|
|
79
|
+
| `referenceId` | `string` | Payment reference ID. Required to auto-open the modal. |
|
|
80
|
+
| `amount` | `number` | Payment amount in fiat currency. Required to auto-open the modal. |
|
|
81
|
+
| `paymentExpirySeconds` | `number` | Payment expiry time in seconds. Optional, defaults to 30 minutes. |
|
|
82
|
+
| `theme` | `"light"` \| `"dark"` | Theme for the payment modal. Optional, defaults to "light". |
|
|
127
83
|
|
|
128
|
-
|
|
129
|
-
|------------------|---------------------------------------------|----------|-----------------------------------------------------------------------------|
|
|
130
|
-
| `fiatCurrency` | `string` | Yes | The fiat currency code (e.g., "USD", "EUR"). |
|
|
131
|
-
| `accessId` | `string` | Yes | Your Tender Cash merchant Access ID. |
|
|
132
|
-
| `env` | `"test"` \| `"live"` \| `"local"` | Yes | The environment to use (`"test"` for testing, `"live"` for production, `"local"` for local development). |
|
|
133
|
-
| `onEventResponse`| `(data: onFinishResponse) => void` | No | Optional callback function triggered on payment completion or status change. |
|
|
84
|
+
**Note:** When `referenceId` and `amount` are provided as props, the modal will automatically open on component mount.
|
|
134
85
|
|
|
135
86
|
## Callback Data (`onFinishResponse`)
|
|
136
87
|
|
|
@@ -156,6 +107,13 @@ interface IPaymentData {
|
|
|
156
107
|
}
|
|
157
108
|
```
|
|
158
109
|
|
|
110
|
+
## Features
|
|
111
|
+
|
|
112
|
+
- **Shadow DOM Isolation**: The component uses Shadow DOM to prevent CSS leaks and conflicts with your application styles.
|
|
113
|
+
- **Auto-Open**: The modal automatically opens when payment parameters are provided.
|
|
114
|
+
- **TypeScript Support**: Full TypeScript definitions included.
|
|
115
|
+
- **Responsive Design**: Works seamlessly on desktop and mobile devices.
|
|
116
|
+
|
|
159
117
|
## License
|
|
160
118
|
|
|
161
119
|
[MIT](./LICENSE)
|