@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.

@@ -0,0 +1,117 @@
1
+ /**
2
+ * Configuration for SimpliPay Checkout
3
+ */
4
+ export interface SimpliPayConfig {
5
+ /** Your SimpliPay public key */
6
+ publicKey: string;
7
+ /** Environment: 'development' | 'production' */
8
+ environment?: 'development' | 'production';
9
+ /** Custom API base URL (optional) */
10
+ baseUrl?: string;
11
+ }
12
+ /**
13
+ * Payment data for checkout
14
+ */
15
+ export interface PaymentData {
16
+ /** Organization ID from SimpliPay */
17
+ organizationId: string;
18
+ /** Customer email address */
19
+ email: string;
20
+ /** Customer phone number (with country code, e.g., +2348012345678) */
21
+ phone: string;
22
+ /** Payment amount */
23
+ amount: number;
24
+ /** Currency code (e.g., 'NGN') */
25
+ currency: string;
26
+ /** Unique transaction reference */
27
+ transactionRef: string;
28
+ /** Your customer's unique identifier */
29
+ customerId: string;
30
+ /** Service ID for the payment */
31
+ serviceId?: string;
32
+ /** Payment narration/description */
33
+ narration?: string;
34
+ /** Merchant/business name to display */
35
+ merchantName?: string;
36
+ /** Additional metadata */
37
+ metadata?: Record<string, any>;
38
+ }
39
+ /**
40
+ * Callback functions for checkout events
41
+ */
42
+ export interface CheckoutCallbacks {
43
+ /** Called when payment is successful */
44
+ onSuccess: (result: TransactionResult) => void;
45
+ /** Called when payment fails */
46
+ onError: (error: TransactionError) => void;
47
+ /** Called when user closes the checkout */
48
+ onClose: () => void;
49
+ /** Called before payment initiation (optional) */
50
+ onBeforePayment?: () => void | Promise<void>;
51
+ }
52
+ /**
53
+ * Transaction result on successful payment
54
+ */
55
+ export interface TransactionResult {
56
+ success: true;
57
+ transactionRef: string;
58
+ message: string;
59
+ amount: number;
60
+ currency: string;
61
+ paymentMethod: string;
62
+ responseCode?: string;
63
+ }
64
+ /**
65
+ * Transaction error
66
+ */
67
+ export interface TransactionError {
68
+ success: false;
69
+ message: string;
70
+ code?: string;
71
+ transactionRef?: string;
72
+ }
73
+ /**
74
+ * Props for SimpliPayCheckout component
75
+ */
76
+ export interface SimpliPayCheckoutProps {
77
+ /** Whether to show the checkout modal */
78
+ isOpen: boolean;
79
+ /** Payment data */
80
+ paymentData: PaymentData;
81
+ /** SimpliPay configuration */
82
+ config: SimpliPayConfig;
83
+ /** Callback functions */
84
+ callbacks: CheckoutCallbacks;
85
+ }
86
+ /**
87
+ * Internal checkout state
88
+ */
89
+ export type CheckoutStep = 'card' | 'pin' | 'otp' | 'success' | 'error';
90
+ export interface CardDetails {
91
+ pan: string;
92
+ expiryDate: string;
93
+ cvv: string;
94
+ }
95
+ export interface TransactionRequest {
96
+ organizationId: string;
97
+ transactionRef: string;
98
+ customerId: string;
99
+ customerEmail: string;
100
+ customerPhone: string;
101
+ amount: number;
102
+ currency: string;
103
+ paymentMethod: 'CARD' | 'BANK' | 'USSD';
104
+ serviceId?: string;
105
+ authData: string;
106
+ narration?: string;
107
+ }
108
+ export interface OtpAuthRequest {
109
+ transactionRef: string;
110
+ otp: string;
111
+ }
112
+ export interface ApiResponse {
113
+ success: boolean;
114
+ message: string;
115
+ data?: any;
116
+ responseCode?: string;
117
+ }
@@ -0,0 +1,6 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { SimpliPayConfig, TransactionRequest, OtpAuthRequest, ApiResponse } from '../types';
3
+ export declare const createApiClient: (config: SimpliPayConfig) => AxiosInstance;
4
+ export declare const initiatePayment: (client: AxiosInstance, payload: TransactionRequest) => Promise<ApiResponse>;
5
+ export declare const verifyOtp: (client: AxiosInstance, payload: OtpAuthRequest) => Promise<ApiResponse>;
6
+ export declare const resendOtp: (client: AxiosInstance, transactionRef: string) => Promise<ApiResponse>;
@@ -0,0 +1,10 @@
1
+ export interface AuthDataParams {
2
+ version: string;
3
+ pan: string;
4
+ pin: string;
5
+ expiryDate: string;
6
+ cvv: string;
7
+ }
8
+ export declare const generateAuthData: ({ version, pan, pin, expiryDate, cvv, }: AuthDataParams) => Promise<string>;
9
+ export declare const formatExpiryForApi: (expiry: string) => string;
10
+ export declare const cleanPan: (pan: string) => string;
@@ -0,0 +1,14 @@
1
+ import * as Yup from 'yup';
2
+ export declare const cardFormSchema: Yup.ObjectSchema<{
3
+ pan: string;
4
+ expiryDate: string;
5
+ cvv: string;
6
+ }, Yup.AnyObject, {
7
+ pan: undefined;
8
+ expiryDate: undefined;
9
+ cvv: undefined;
10
+ }, "">;
11
+ export type CardType = 'visa' | 'mastercard' | 'verve' | 'unknown';
12
+ export declare const detectCardType: (cardNumber: string) => CardType;
13
+ export declare const formatCardNumber: (value: string) => string;
14
+ export declare const formatExpiryDate: (value: string) => string;
package/package.json CHANGED
@@ -1,6 +1,94 @@
1
1
  {
2
2
  "name": "@simplipayng/checkout",
3
- "version": "0.0.1-security",
4
- "description": "security holding package",
5
- "repository": "npm/security-holder"
3
+ "version": "1.4.3",
4
+ "type": "module",
5
+ "description": "SimpliPay Checkout - A React component for accepting card payments",
6
+ "main": "dist/index.js",
7
+ "module": "dist/index.esm.js",
8
+ "types": "dist/index.d.ts",
9
+ "files": [
10
+ "dist",
11
+ "README.md"
12
+ ],
13
+ "keywords": [
14
+ "simplipay",
15
+ "checkout",
16
+ "payment",
17
+ "react",
18
+ "card-payment",
19
+ "nigeria",
20
+ "fintech"
21
+ ],
22
+ "author": "SimpliPay",
23
+ "license": "MIT",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "https://github.com/simplipayng/checkout.git"
27
+ },
28
+ "homepage": "https://simplipay.ng",
29
+ "peerDependencies": {
30
+ "react": ">=17.0.0",
31
+ "react-dom": ">=17.0.0"
32
+ },
33
+ "dependencies": {
34
+ "axios": "^1.6.2",
35
+ "formik": "^2.4.5",
36
+ "node-forge": "^1.3.1",
37
+ "react-bootstrap": "^2.10.10",
38
+ "react-otp-input": "^3.1.0",
39
+ "react-query": "^3.39.3",
40
+ "react-router-dom": "^7.10.1",
41
+ "react-spinners-kit": "^1.9.1",
42
+ "react-toastify": "^9.1.3",
43
+ "web-vitals": "^5.1.0",
44
+ "yup": "^1.4.0"
45
+ },
46
+ "devDependencies": {
47
+ "@rollup/plugin-commonjs": "^25.0.8",
48
+ "@rollup/plugin-json": "^6.1.0",
49
+ "@rollup/plugin-node-resolve": "^15.3.1",
50
+ "@rollup/plugin-typescript": "^11.1.6",
51
+ "@testing-library/jest-dom": "^5.17.0",
52
+ "@testing-library/react": "^13.4.0",
53
+ "@testing-library/user-event": "^13.5.0",
54
+ "@types/jest": "^27.5.2",
55
+ "@types/node": "^16.18.65",
56
+ "@types/react": "^18.2.39",
57
+ "@types/react-dom": "^18.2.17",
58
+ "react": "^18.2.0",
59
+ "react-dom": "^18.2.0",
60
+ "react-scripts": "5.0.1",
61
+ "rollup": "^4.53.3",
62
+ "rollup-plugin-dts": "^6.3.0",
63
+ "rollup-plugin-peer-deps-external": "^2.2.4",
64
+ "rollup-plugin-postcss": "^4.0.2",
65
+ "sass": "^1.69.5",
66
+ "typescript": "^4.9.5"
67
+ },
68
+ "scripts": {
69
+ "start": "react-scripts start",
70
+ "build": "rollup -c",
71
+ "build:demo": "react-scripts build",
72
+ "test": "react-scripts test",
73
+ "prepublishOnly": "npm run build",
74
+ "lint": "eslint src --ext .ts,.tsx"
75
+ },
76
+ "eslintConfig": {
77
+ "extends": [
78
+ "react-app",
79
+ "react-app/jest"
80
+ ]
81
+ },
82
+ "browserslist": {
83
+ "production": [
84
+ ">0.2%",
85
+ "not dead",
86
+ "not op_mini all"
87
+ ],
88
+ "development": [
89
+ "last 1 chrome version",
90
+ "last 1 firefox version",
91
+ "last 1 safari version"
92
+ ]
93
+ }
6
94
  }