broxpay 1.1.0 → 1.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 +1 -33
- package/dist/index.d.ts +2 -3
- package/dist/index.js +6 -10
- package/package.json +1 -1
- package/src/index.tsx +6 -10
package/README.md
CHANGED
|
@@ -58,43 +58,13 @@ function App() {
|
|
|
58
58
|
}
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
-
### Option 3: Backend Token (Recommended for Production)
|
|
62
|
-
|
|
63
|
-
For secure server-side initialized transactions, generate a checkout token from your backend and pass it to the component:
|
|
64
|
-
|
|
65
|
-
```jsx
|
|
66
|
-
import { BroxPayButton } from 'broxpay';
|
|
67
|
-
|
|
68
|
-
function SecureCheckout({ checkoutToken }) {
|
|
69
|
-
// checkoutToken is generated from your backend via BroxPay API
|
|
70
|
-
return (
|
|
71
|
-
<BroxPayButton
|
|
72
|
-
token={checkoutToken}
|
|
73
|
-
onSuccess={(data) => {
|
|
74
|
-
// Verify payment on your server
|
|
75
|
-
fetch('/api/verify-payment', {
|
|
76
|
-
method: 'POST',
|
|
77
|
-
body: JSON.stringify(data)
|
|
78
|
-
});
|
|
79
|
-
}}
|
|
80
|
-
onError={(error) => console.log('Payment failed', error)}
|
|
81
|
-
>
|
|
82
|
-
Complete Payment
|
|
83
|
-
</BroxPayButton>
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
This approach keeps your secret key on the server and allows you to attach metadata to the transaction.
|
|
89
|
-
|
|
90
61
|
## Props
|
|
91
62
|
|
|
92
63
|
### BroxPayButton
|
|
93
64
|
|
|
94
65
|
| Prop | Type | Required | Description |
|
|
95
66
|
|------|------|----------|-------------|
|
|
96
|
-
| `config` | object |
|
|
97
|
-
| `token` | string | No* | Checkout token from backend |
|
|
67
|
+
| `config` | object | Yes | Configuration object (publicKey, amount, etc.) |
|
|
98
68
|
| `onSuccess` | function | No | Called on success |
|
|
99
69
|
| `onError` | function | No | Called on error |
|
|
100
70
|
| `onClose` | function | No | Called on close |
|
|
@@ -102,8 +72,6 @@ This approach keeps your secret key on the server and allows you to attach metad
|
|
|
102
72
|
| `className` | string | No | CSS class |
|
|
103
73
|
| `disabled` | boolean | No | Disable button |
|
|
104
74
|
|
|
105
|
-
*\*Either `config` or `token` is required.*
|
|
106
|
-
|
|
107
75
|
## Support
|
|
108
76
|
|
|
109
77
|
Email: support@broxpay.com
|
package/dist/index.d.ts
CHANGED
|
@@ -50,8 +50,7 @@ export declare function useBroxPay(): {
|
|
|
50
50
|
checkout: (tokenOrConfig: string | CheckoutConfig, callbacks?: BroxPayCallbacks) => void;
|
|
51
51
|
};
|
|
52
52
|
interface BroxPayButtonProps {
|
|
53
|
-
|
|
54
|
-
config?: CheckoutConfig;
|
|
53
|
+
config: CheckoutConfig;
|
|
55
54
|
onSuccess?: (data: any) => void;
|
|
56
55
|
onError?: (error: any) => void;
|
|
57
56
|
onClose?: () => void;
|
|
@@ -59,5 +58,5 @@ interface BroxPayButtonProps {
|
|
|
59
58
|
className?: string;
|
|
60
59
|
disabled?: boolean;
|
|
61
60
|
}
|
|
62
|
-
export declare function BroxPayButton({
|
|
61
|
+
export declare function BroxPayButton({ config, onSuccess, onError, onClose, children, className, disabled }: BroxPayButtonProps): React.JSX.Element;
|
|
63
62
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ function loadBroxPay(callback) {
|
|
|
6
6
|
return;
|
|
7
7
|
}
|
|
8
8
|
const script = document.createElement('script');
|
|
9
|
-
script.src = 'https://pay.
|
|
9
|
+
script.src = 'https://pay.broxghana.com/inline.js';
|
|
10
10
|
script.onload = callback;
|
|
11
11
|
document.head.appendChild(script);
|
|
12
12
|
}
|
|
@@ -27,18 +27,14 @@ export function useBroxPay() {
|
|
|
27
27
|
};
|
|
28
28
|
return { checkout };
|
|
29
29
|
}
|
|
30
|
-
export function BroxPayButton({
|
|
30
|
+
export function BroxPayButton({ config, onSuccess, onError, onClose, children, className, disabled }) {
|
|
31
31
|
const { checkout } = useBroxPay();
|
|
32
32
|
const handleClick = () => {
|
|
33
|
-
if (
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
else if (config) {
|
|
37
|
-
checkout(config, { onSuccess, onError, onClose });
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
console.error('BroxPay: Either token or config must be provided');
|
|
33
|
+
if (!config) {
|
|
34
|
+
console.error('BroxPay: config is required');
|
|
35
|
+
return;
|
|
41
36
|
}
|
|
37
|
+
checkout(config, { onSuccess, onError, onClose });
|
|
42
38
|
};
|
|
43
39
|
return (React.createElement("button", { onClick: handleClick, className: className, disabled: disabled }, children));
|
|
44
40
|
}
|
package/package.json
CHANGED
package/src/index.tsx
CHANGED
|
@@ -60,7 +60,7 @@ function loadBroxPay(callback: () => void) {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
const script = document.createElement('script');
|
|
63
|
-
script.src = 'https://pay.
|
|
63
|
+
script.src = 'https://pay.broxghana.com/inline.js';
|
|
64
64
|
script.onload = callback;
|
|
65
65
|
document.head.appendChild(script);
|
|
66
66
|
}
|
|
@@ -88,8 +88,7 @@ export function useBroxPay() {
|
|
|
88
88
|
|
|
89
89
|
// Button component
|
|
90
90
|
interface BroxPayButtonProps {
|
|
91
|
-
|
|
92
|
-
config?: CheckoutConfig;
|
|
91
|
+
config: CheckoutConfig;
|
|
93
92
|
onSuccess?: (data: any) => void;
|
|
94
93
|
onError?: (error: any) => void;
|
|
95
94
|
onClose?: () => void;
|
|
@@ -99,7 +98,6 @@ interface BroxPayButtonProps {
|
|
|
99
98
|
}
|
|
100
99
|
|
|
101
100
|
export function BroxPayButton({
|
|
102
|
-
token,
|
|
103
101
|
config,
|
|
104
102
|
onSuccess,
|
|
105
103
|
onError,
|
|
@@ -111,13 +109,11 @@ export function BroxPayButton({
|
|
|
111
109
|
const { checkout } = useBroxPay();
|
|
112
110
|
|
|
113
111
|
const handleClick = () => {
|
|
114
|
-
if (
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
checkout(config, { onSuccess, onError, onClose });
|
|
118
|
-
} else {
|
|
119
|
-
console.error('BroxPay: Either token or config must be provided');
|
|
112
|
+
if (!config) {
|
|
113
|
+
console.error('BroxPay: config is required');
|
|
114
|
+
return;
|
|
120
115
|
}
|
|
116
|
+
checkout(config, { onSuccess, onError, onClose });
|
|
121
117
|
};
|
|
122
118
|
|
|
123
119
|
return (
|