broxpay 1.0.1 → 1.1.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 +33 -4
- package/dist/index.d.ts +26 -2
- package/package.json +1 -1
- package/src/index.tsx +26 -2
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ npm install broxpay
|
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
1. **Install:** `npm install broxpay`
|
|
12
|
-
2. **Use:** Import `BroxPayButton` and pass your `
|
|
12
|
+
2. **Use:** Import `BroxPayButton` and pass your `publicKey`.
|
|
13
13
|
|
|
14
14
|
## Usage
|
|
15
15
|
|
|
@@ -20,7 +20,7 @@ import { BroxPayButton } from 'broxpay';
|
|
|
20
20
|
|
|
21
21
|
function App() {
|
|
22
22
|
const config = {
|
|
23
|
-
|
|
23
|
+
publicKey: 'pk_test_123',
|
|
24
24
|
amount: 50,
|
|
25
25
|
email: 'user@example.com'
|
|
26
26
|
};
|
|
@@ -46,7 +46,7 @@ function App() {
|
|
|
46
46
|
|
|
47
47
|
const handlePay = () => {
|
|
48
48
|
checkout({
|
|
49
|
-
|
|
49
|
+
publicKey: 'pk_live_...', // Your Public Key
|
|
50
50
|
amount: 50,
|
|
51
51
|
email: 'user@example.com',
|
|
52
52
|
onSuccess: (data) => console.log('Paid!', data),
|
|
@@ -58,13 +58,42 @@ 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
|
+
|
|
61
90
|
## Props
|
|
62
91
|
|
|
63
92
|
### BroxPayButton
|
|
64
93
|
|
|
65
94
|
| Prop | Type | Required | Description |
|
|
66
95
|
|------|------|----------|-------------|
|
|
67
|
-
| `config` | object | No* | Configuration object (
|
|
96
|
+
| `config` | object | No* | Configuration object (publicKey, amount, etc.) |
|
|
68
97
|
| `token` | string | No* | Checkout token from backend |
|
|
69
98
|
| `onSuccess` | function | No | Called on success |
|
|
70
99
|
| `onError` | function | No | Called on error |
|
package/dist/index.d.ts
CHANGED
|
@@ -8,9 +8,33 @@ interface BroxPayCallbacks {
|
|
|
8
8
|
onClose?: () => void;
|
|
9
9
|
}
|
|
10
10
|
interface CheckoutConfig {
|
|
11
|
-
|
|
11
|
+
/** Your BroxPay public key (pk_live_... or pk_test_...). Never use your secret key here. */
|
|
12
|
+
publicKey: string;
|
|
13
|
+
/** Payment amount in GHS */
|
|
12
14
|
amount: number;
|
|
13
|
-
email
|
|
15
|
+
/** Customer email address (required for standard checkout) */
|
|
16
|
+
email?: string;
|
|
17
|
+
/** Your unique reference for this transaction */
|
|
18
|
+
transactionId?: string;
|
|
19
|
+
/** Payment description */
|
|
20
|
+
description?: string;
|
|
21
|
+
/** Customer's full name */
|
|
22
|
+
customerName?: string;
|
|
23
|
+
/** Customer's phone number (e.g., "0241234567") */
|
|
24
|
+
customerPhone?: string;
|
|
25
|
+
/** Customer's email (alternative to email field) */
|
|
26
|
+
customerEmail?: string;
|
|
27
|
+
/** URL to redirect after payment completion */
|
|
28
|
+
redirectUrl?: string;
|
|
29
|
+
/** URL to receive webhook notifications */
|
|
30
|
+
callbackUrl?: string;
|
|
31
|
+
/** Mobile money network */
|
|
32
|
+
network?: 'MTN' | 'VODAFONE' | 'AIRTELTIGO';
|
|
33
|
+
/** Service type for the payment */
|
|
34
|
+
serviceType?: string;
|
|
35
|
+
/** Custom metadata object for your reference */
|
|
36
|
+
metadata?: Record<string, any>;
|
|
37
|
+
/** Additional custom fields */
|
|
14
38
|
[key: string]: any;
|
|
15
39
|
}
|
|
16
40
|
declare global {
|
package/package.json
CHANGED
package/src/index.tsx
CHANGED
|
@@ -11,9 +11,33 @@ interface BroxPayCallbacks {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
interface CheckoutConfig {
|
|
14
|
-
|
|
14
|
+
/** Your BroxPay public key (pk_live_... or pk_test_...). Never use your secret key here. */
|
|
15
|
+
publicKey: string;
|
|
16
|
+
/** Payment amount in GHS */
|
|
15
17
|
amount: number;
|
|
16
|
-
email
|
|
18
|
+
/** Customer email address (required for standard checkout) */
|
|
19
|
+
email?: string;
|
|
20
|
+
/** Your unique reference for this transaction */
|
|
21
|
+
transactionId?: string;
|
|
22
|
+
/** Payment description */
|
|
23
|
+
description?: string;
|
|
24
|
+
/** Customer's full name */
|
|
25
|
+
customerName?: string;
|
|
26
|
+
/** Customer's phone number (e.g., "0241234567") */
|
|
27
|
+
customerPhone?: string;
|
|
28
|
+
/** Customer's email (alternative to email field) */
|
|
29
|
+
customerEmail?: string;
|
|
30
|
+
/** URL to redirect after payment completion */
|
|
31
|
+
redirectUrl?: string;
|
|
32
|
+
/** URL to receive webhook notifications */
|
|
33
|
+
callbackUrl?: string;
|
|
34
|
+
/** Mobile money network */
|
|
35
|
+
network?: 'MTN' | 'VODAFONE' | 'AIRTELTIGO';
|
|
36
|
+
/** Service type for the payment */
|
|
37
|
+
serviceType?: string;
|
|
38
|
+
/** Custom metadata object for your reference */
|
|
39
|
+
metadata?: Record<string, any>;
|
|
40
|
+
/** Additional custom fields */
|
|
17
41
|
[key: string]: any;
|
|
18
42
|
}
|
|
19
43
|
|