@simplipayng/checkout 0.0.1-security → 1.4.3

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.

Potentially problematic release.


This version of @simplipayng/checkout might be problematic. Click here for more details.

package/README.md CHANGED
@@ -1,5 +1,149 @@
1
- # Security holding package
1
+ # @simplipayng/checkout
2
2
 
3
- This package contained malicious code and was removed from the registry by the npm security team. A placeholder was published to ensure users are not affected in the future.
3
+ A React component for accepting card payments via SimpliPay.
4
4
 
5
- Please refer to www.npmjs.com/advisories?search=%40simplipayng%2Fcheckout for more information.
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @simplipayng/checkout
9
+ # or
10
+ yarn add @simplipayng/checkout
11
+ ```
12
+
13
+ ## Quick Start
14
+
15
+ ```tsx
16
+ import { SimpliPayCheckout } from '@simplipayng/checkout';
17
+
18
+ function App() {
19
+ const [isOpen, setIsOpen] = useState(false);
20
+
21
+ return (
22
+ <>
23
+ <button onClick={() => setIsOpen(true)}>Pay Now</button>
24
+
25
+ <SimpliPayCheckout
26
+ isOpen={isOpen}
27
+ config={{
28
+ publicKey: 'pk_test_your_public_key',
29
+ environment: 'development' // or 'production'
30
+ }}
31
+ paymentData={{
32
+ organizationId: 'your-organization-id',
33
+ email: 'customer@example.com',
34
+ phone: '+2348012345678',
35
+ amount: 5000,
36
+ currency: 'NGN',
37
+ transactionRef: 'TXN-' + Date.now(),
38
+ customerId: 'CUST-123',
39
+ serviceId: 'payment-service', // optional
40
+ narration: 'Payment for order', // optional
41
+ merchantName: 'Your Store'
42
+ }}
43
+ callbacks={{
44
+ onSuccess: (result) => {
45
+ console.log('Payment successful:', result);
46
+ setIsOpen(false);
47
+ },
48
+ onError: (error) => {
49
+ console.error('Payment failed:', error);
50
+ },
51
+ onClose: () => setIsOpen(false)
52
+ }}
53
+ />
54
+ </>
55
+ );
56
+ }
57
+ ```
58
+
59
+ ## Using the Hook
60
+
61
+ ```tsx
62
+ import { SimpliPayCheckout, useSimplipay } from '@simplipayng/checkout';
63
+
64
+ function App() {
65
+ const { isOpen, openCheckout, closeCheckout, paymentData } = useSimplipay({
66
+ publicKey: 'pk_test_your_public_key',
67
+ environment: 'development'
68
+ });
69
+
70
+ const handlePay = () => {
71
+ openCheckout({
72
+ organizationId: 'your-organization-id',
73
+ email: 'customer@example.com',
74
+ phone: '+2348012345678',
75
+ amount: 5000,
76
+ currency: 'NGN',
77
+ transactionRef: 'TXN-' + Date.now(),
78
+ customerId: 'CUST-123',
79
+ narration: 'Payment for order'
80
+ });
81
+ };
82
+
83
+ return (
84
+ <>
85
+ <button onClick={handlePay}>Pay Now</button>
86
+
87
+ {paymentData && (
88
+ <SimpliPayCheckout
89
+ isOpen={isOpen}
90
+ config={{ publicKey: 'pk_test_xxx', environment: 'development' }}
91
+ paymentData={paymentData}
92
+ callbacks={{
93
+ onSuccess: (result) => closeCheckout(),
94
+ onError: (error) => console.error(error),
95
+ onClose: closeCheckout
96
+ }}
97
+ />
98
+ )}
99
+ </>
100
+ );
101
+ }
102
+ ```
103
+
104
+ ## Props
105
+
106
+ ### SimpliPayCheckout
107
+
108
+ | Prop | Type | Description |
109
+ |------|------|-------------|
110
+ | `isOpen` | `boolean` | Whether to show the checkout modal |
111
+ | `config` | `SimpliPayConfig` | Configuration object |
112
+ | `paymentData` | `PaymentData` | Payment details |
113
+ | `callbacks` | `CheckoutCallbacks` | Callback functions |
114
+
115
+ ### SimpliPayConfig
116
+
117
+ | Property | Type | Description |
118
+ |----------|------|-------------|
119
+ | `publicKey` | `string` | Your SimpliPay public key |
120
+ | `environment` | `'development' \| 'production'` | API environment |
121
+ | `baseUrl` | `string` (optional) | Custom API URL |
122
+
123
+ ### PaymentData
124
+
125
+ | Property | Type | Description |
126
+ |----------|------|-------------|
127
+ | `organizationId` | `string` | Your SimpliPay organization ID |
128
+ | `email` | `string` | Customer email |
129
+ | `phone` | `string` | Customer phone (with country code) |
130
+ | `amount` | `number` | Amount to charge |
131
+ | `currency` | `string` | Currency code (e.g., 'NGN') |
132
+ | `transactionRef` | `string` | Unique transaction reference |
133
+ | `customerId` | `string` | Your customer identifier |
134
+ | `serviceId` | `string` (optional) | Service ID for the payment |
135
+ | `narration` | `string` (optional) | Payment description/narration |
136
+ | `merchantName` | `string` (optional) | Your business name |
137
+ | `metadata` | `object` (optional) | Additional data |
138
+
139
+ ### CheckoutCallbacks
140
+
141
+ | Property | Type | Description |
142
+ |----------|------|-------------|
143
+ | `onSuccess` | `(result: TransactionResult) => void` | Called on successful payment |
144
+ | `onError` | `(error: TransactionError) => void` | Called on payment failure |
145
+ | `onClose` | `() => void` | Called when modal is closed |
146
+
147
+ ## License
148
+
149
+ MIT © SimpliPay
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { PaymentData, SimpliPayConfig, CardDetails } from '../types';
3
+ interface CardFormProps {
4
+ paymentData: PaymentData;
5
+ config: SimpliPayConfig;
6
+ setCardDetails: (details: CardDetails) => void;
7
+ setStep: (step: any) => void;
8
+ onClose: () => void;
9
+ }
10
+ declare const CardForm: React.FC<CardFormProps>;
11
+ export default CardForm;
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { PaymentData, SimpliPayConfig, TransactionResult } from '../types';
3
+ interface OtpEntryProps {
4
+ paymentData: PaymentData;
5
+ config: SimpliPayConfig;
6
+ transactionResponse: any;
7
+ setStep: (step: any) => void;
8
+ goBack: () => void;
9
+ onClose: () => void;
10
+ setError: (error: string) => void;
11
+ onSuccess: (result: TransactionResult) => void;
12
+ }
13
+ declare const OtpEntry: React.FC<OtpEntryProps>;
14
+ export default OtpEntry;
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { PaymentData, SimpliPayConfig, CardDetails, TransactionResult } from '../types';
3
+ interface PinEntryProps {
4
+ paymentData: PaymentData;
5
+ config: SimpliPayConfig;
6
+ cardDetails: CardDetails;
7
+ setStep: (step: any) => void;
8
+ goBack: () => void;
9
+ onClose: () => void;
10
+ setError: (error: string) => void;
11
+ setTransactionResponse: (response: any) => void;
12
+ onSuccess: (result: TransactionResult) => void;
13
+ }
14
+ declare const PinEntry: React.FC<PinEntryProps>;
15
+ export default PinEntry;
@@ -0,0 +1,44 @@
1
+ import React from 'react';
2
+ import 'react-toastify/dist/ReactToastify.css';
3
+ import { SimpliPayCheckoutProps } from '../types';
4
+ import '../styles/checkout.css';
5
+ /**
6
+ * SimpliPay Checkout Component
7
+ *
8
+ * A complete checkout modal for accepting card payments via SimpliPay.
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * import { SimpliPayCheckout } from '@simplipayng/checkout';
13
+ *
14
+ * function App() {
15
+ * const [isOpen, setIsOpen] = useState(false);
16
+ *
17
+ * return (
18
+ * <SimpliPayCheckout
19
+ * isOpen={isOpen}
20
+ * config={{
21
+ * publicKey: 'pk_test_xxxxx',
22
+ * environment: 'development'
23
+ * }}
24
+ * paymentData={{
25
+ * email: 'customer@example.com',
26
+ * phone: '+2348012345678',
27
+ * amount: 5000,
28
+ * currency: 'NGN',
29
+ * transactionRef: 'TXN-123',
30
+ * customerId: 'CUST-456'
31
+ * }}
32
+ * callbacks={{
33
+ * onSuccess: (result) => console.log('Success:', result),
34
+ * onError: (error) => console.error('Error:', error),
35
+ * onClose: () => setIsOpen(false)
36
+ * }}
37
+ * />
38
+ * );
39
+ * }
40
+ * ```
41
+ */
42
+ declare const SimpliPayCheckout: React.FC<SimpliPayCheckoutProps>;
43
+ export default SimpliPayCheckout;
44
+ export { SimpliPayCheckout };
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { PaymentData } from '../types';
3
+ interface SuccessScreenProps {
4
+ paymentData: PaymentData;
5
+ onClose: () => void;
6
+ }
7
+ declare const SuccessScreen: React.FC<SuccessScreenProps>;
8
+ export default SuccessScreen;
@@ -0,0 +1,14 @@
1
+ import React, { ReactNode } from 'react';
2
+ interface CheckoutContextType {
3
+ environment: 'development' | 'production';
4
+ publicKey: string;
5
+ }
6
+ declare const CheckoutContext: React.Context<CheckoutContextType | undefined>;
7
+ interface CheckoutProviderProps {
8
+ children: ReactNode;
9
+ environment: 'development' | 'production';
10
+ publicKey: string;
11
+ }
12
+ export declare const CheckoutProvider: React.FC<CheckoutProviderProps>;
13
+ export declare const useCheckoutContext: () => CheckoutContextType;
14
+ export default CheckoutContext;
@@ -0,0 +1,32 @@
1
+ import { SimpliPayConfig, PaymentData, TransactionResult, TransactionError } from '../types';
2
+ interface UseSimplipayReturn {
3
+ isOpen: boolean;
4
+ openCheckout: (paymentData: PaymentData) => void;
5
+ closeCheckout: () => void;
6
+ paymentData: PaymentData | null;
7
+ result: TransactionResult | null;
8
+ error: TransactionError | null;
9
+ }
10
+ /**
11
+ * Hook for programmatic control of SimpliPay Checkout
12
+ *
13
+ * @example
14
+ * ```tsx
15
+ * const { isOpen, openCheckout, closeCheckout, result, error } = useSimplipay({
16
+ * publicKey: 'pk_test_xxxxx',
17
+ * environment: 'development'
18
+ * });
19
+ *
20
+ * // Open checkout
21
+ * openCheckout({
22
+ * email: 'customer@example.com',
23
+ * phone: '+2348012345678',
24
+ * amount: 5000,
25
+ * currency: 'NGN',
26
+ * transactionRef: 'TXN-123',
27
+ * customerId: 'CUST-456'
28
+ * });
29
+ * ```
30
+ */
31
+ export declare const useSimplipay: (config: SimpliPayConfig) => UseSimplipayReturn;
32
+ export default useSimplipay;
@@ -0,0 +1,160 @@
1
+ import React from 'react';
2
+
3
+ /**
4
+ * Configuration for SimpliPay Checkout
5
+ */
6
+ interface SimpliPayConfig {
7
+ /** Your SimpliPay public key */
8
+ publicKey: string;
9
+ /** Environment: 'development' | 'production' */
10
+ environment?: 'development' | 'production';
11
+ /** Custom API base URL (optional) */
12
+ baseUrl?: string;
13
+ }
14
+ /**
15
+ * Payment data for checkout
16
+ */
17
+ interface PaymentData {
18
+ /** Organization ID from SimpliPay */
19
+ organizationId: string;
20
+ /** Customer email address */
21
+ email: string;
22
+ /** Customer phone number (with country code, e.g., +2348012345678) */
23
+ phone: string;
24
+ /** Payment amount */
25
+ amount: number;
26
+ /** Currency code (e.g., 'NGN') */
27
+ currency: string;
28
+ /** Unique transaction reference */
29
+ transactionRef: string;
30
+ /** Your customer's unique identifier */
31
+ customerId: string;
32
+ /** Service ID for the payment */
33
+ serviceId?: string;
34
+ /** Payment narration/description */
35
+ narration?: string;
36
+ /** Merchant/business name to display */
37
+ merchantName?: string;
38
+ /** Additional metadata */
39
+ metadata?: Record<string, any>;
40
+ }
41
+ /**
42
+ * Callback functions for checkout events
43
+ */
44
+ interface CheckoutCallbacks {
45
+ /** Called when payment is successful */
46
+ onSuccess: (result: TransactionResult) => void;
47
+ /** Called when payment fails */
48
+ onError: (error: TransactionError) => void;
49
+ /** Called when user closes the checkout */
50
+ onClose: () => void;
51
+ /** Called before payment initiation (optional) */
52
+ onBeforePayment?: () => void | Promise<void>;
53
+ }
54
+ /**
55
+ * Transaction result on successful payment
56
+ */
57
+ interface TransactionResult {
58
+ success: true;
59
+ transactionRef: string;
60
+ message: string;
61
+ amount: number;
62
+ currency: string;
63
+ paymentMethod: string;
64
+ responseCode?: string;
65
+ }
66
+ /**
67
+ * Transaction error
68
+ */
69
+ interface TransactionError {
70
+ success: false;
71
+ message: string;
72
+ code?: string;
73
+ transactionRef?: string;
74
+ }
75
+ /**
76
+ * Props for SimpliPayCheckout component
77
+ */
78
+ interface SimpliPayCheckoutProps {
79
+ /** Whether to show the checkout modal */
80
+ isOpen: boolean;
81
+ /** Payment data */
82
+ paymentData: PaymentData;
83
+ /** SimpliPay configuration */
84
+ config: SimpliPayConfig;
85
+ /** Callback functions */
86
+ callbacks: CheckoutCallbacks;
87
+ }
88
+
89
+ /**
90
+ * SimpliPay Checkout Component
91
+ *
92
+ * A complete checkout modal for accepting card payments via SimpliPay.
93
+ *
94
+ * @example
95
+ * ```tsx
96
+ * import { SimpliPayCheckout } from '@simplipayng/checkout';
97
+ *
98
+ * function App() {
99
+ * const [isOpen, setIsOpen] = useState(false);
100
+ *
101
+ * return (
102
+ * <SimpliPayCheckout
103
+ * isOpen={isOpen}
104
+ * config={{
105
+ * publicKey: 'pk_test_xxxxx',
106
+ * environment: 'development'
107
+ * }}
108
+ * paymentData={{
109
+ * email: 'customer@example.com',
110
+ * phone: '+2348012345678',
111
+ * amount: 5000,
112
+ * currency: 'NGN',
113
+ * transactionRef: 'TXN-123',
114
+ * customerId: 'CUST-456'
115
+ * }}
116
+ * callbacks={{
117
+ * onSuccess: (result) => console.log('Success:', result),
118
+ * onError: (error) => console.error('Error:', error),
119
+ * onClose: () => setIsOpen(false)
120
+ * }}
121
+ * />
122
+ * );
123
+ * }
124
+ * ```
125
+ */
126
+ declare const SimpliPayCheckout: React.FC<SimpliPayCheckoutProps>;
127
+
128
+ interface UseSimplipayReturn {
129
+ isOpen: boolean;
130
+ openCheckout: (paymentData: PaymentData) => void;
131
+ closeCheckout: () => void;
132
+ paymentData: PaymentData | null;
133
+ result: TransactionResult | null;
134
+ error: TransactionError | null;
135
+ }
136
+ /**
137
+ * Hook for programmatic control of SimpliPay Checkout
138
+ *
139
+ * @example
140
+ * ```tsx
141
+ * const { isOpen, openCheckout, closeCheckout, result, error } = useSimplipay({
142
+ * publicKey: 'pk_test_xxxxx',
143
+ * environment: 'development'
144
+ * });
145
+ *
146
+ * // Open checkout
147
+ * openCheckout({
148
+ * email: 'customer@example.com',
149
+ * phone: '+2348012345678',
150
+ * amount: 5000,
151
+ * currency: 'NGN',
152
+ * transactionRef: 'TXN-123',
153
+ * customerId: 'CUST-456'
154
+ * });
155
+ * ```
156
+ */
157
+ declare const useSimplipay: (config: SimpliPayConfig) => UseSimplipayReturn;
158
+
159
+ export { SimpliPayCheckout as Checkout, SimpliPayCheckout, useSimplipay };
160
+ export type { CheckoutCallbacks, PaymentData, SimpliPayConfig, TransactionResult };