@paynext/sdk 0.0.32 → 0.0.34
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 +105 -47
- package/dist/index.d.ts +52 -1
- package/dist/index.es.js +403 -327
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +44 -44
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,54 +1,112 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
## Expanding the ESLint configuration
|
|
11
|
-
|
|
12
|
-
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
|
|
13
|
-
|
|
14
|
-
```js
|
|
15
|
-
export default tseslint.config({
|
|
16
|
-
extends: [
|
|
17
|
-
// Remove ...tseslint.configs.recommended and replace with this
|
|
18
|
-
...tseslint.configs.recommendedTypeChecked,
|
|
19
|
-
// Alternatively, use this for stricter rules
|
|
20
|
-
...tseslint.configs.strictTypeChecked,
|
|
21
|
-
// Optionally, add this for stylistic rules
|
|
22
|
-
...tseslint.configs.stylisticTypeChecked,
|
|
23
|
-
],
|
|
24
|
-
languageOptions: {
|
|
25
|
-
// other options...
|
|
26
|
-
parserOptions: {
|
|
27
|
-
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
28
|
-
tsconfigRootDir: import.meta.dirname,
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
})
|
|
1
|
+
# PayNext TypeScript SDK
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for integrating PayNext payment processing with full type safety and multiple payment methods support.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @paynext/sdk
|
|
32
9
|
```
|
|
33
10
|
|
|
34
|
-
|
|
11
|
+
## Quick Start
|
|
35
12
|
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
import reactX from 'eslint-plugin-react-x'
|
|
39
|
-
import reactDom from 'eslint-plugin-react-dom'
|
|
13
|
+
```typescript
|
|
14
|
+
import { PayNextCheckout, type PaymentResult } from '@paynext/sdk'
|
|
40
15
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
rules: {
|
|
48
|
-
// other rules...
|
|
49
|
-
// Enable its recommended typescript rules
|
|
50
|
-
...reactX.configs['recommended-typescript'].rules,
|
|
51
|
-
...reactDom.configs.recommended.rules,
|
|
16
|
+
const checkout = new PayNextCheckout(document.getElementById('checkout-form'))
|
|
17
|
+
|
|
18
|
+
await checkout.mount({
|
|
19
|
+
clientToken: 'your-client-token',
|
|
20
|
+
onCheckoutComplete: (result: PaymentResult) => {
|
|
21
|
+
console.log('Payment successful!', result)
|
|
52
22
|
},
|
|
23
|
+
onCheckoutFail: (error: Error) => {
|
|
24
|
+
console.error('Payment failed:', error.message)
|
|
25
|
+
}
|
|
53
26
|
})
|
|
54
27
|
```
|
|
28
|
+
|
|
29
|
+
## React Example
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
import { useEffect, useRef } from 'react'
|
|
33
|
+
import { PayNextCheckout, type PaymentResult } from '@paynext/sdk'
|
|
34
|
+
|
|
35
|
+
// interface
|
|
36
|
+
interface IProps {
|
|
37
|
+
clientToken: string
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// component
|
|
41
|
+
export const CheckoutComponent: FC<Readonly<IProps> = (props) => {
|
|
42
|
+
const { clientToken } = props
|
|
43
|
+
|
|
44
|
+
const checkoutRef = useRef<HTMLDivElement>(null)
|
|
45
|
+
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (!clientToken) {
|
|
48
|
+
return
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const checkout = new PayNextCheckout(checkoutRef.current)
|
|
52
|
+
|
|
53
|
+
checkout.mount({
|
|
54
|
+
clientToken,
|
|
55
|
+
locale: 'en',
|
|
56
|
+
onCheckoutComplete: (result: PaymentResult) => {
|
|
57
|
+
// Handle successful payment
|
|
58
|
+
console.log('Payment completed:', result.paymentMethod, result.transactionId)
|
|
59
|
+
},
|
|
60
|
+
onCheckoutFail: (error: Error) => {
|
|
61
|
+
// Handle payment failure
|
|
62
|
+
console.error('Payment failed:', error.message)
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
}, [clientToken])
|
|
66
|
+
|
|
67
|
+
// return
|
|
68
|
+
return <div ref={checkoutRef} />
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Configuration
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
interface PayNextConfig {
|
|
76
|
+
clientToken: string // Required
|
|
77
|
+
supportedCardTypes?: CardType[] // Optional: restrict card types
|
|
78
|
+
variant?: 'default' | 'compact' // Optional: UI variant
|
|
79
|
+
locale?: Locale // Optional: language (en, de, fr, etc.)
|
|
80
|
+
translate?: CheckoutTranslate // Optional: custom translations
|
|
81
|
+
onCheckoutComplete?: (result: PaymentResult) => void
|
|
82
|
+
onCheckoutFail?: (error: Error) => void
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Supported Payment Methods
|
|
87
|
+
|
|
88
|
+
- **Cards**: Visa, Mastercard, American Express, Discover, JCB, Diners Club, UnionPay, Maestro
|
|
89
|
+
- **Digital Wallets**: Apple Pay, Google Pay
|
|
90
|
+
- **Alternative**: PayPal
|
|
91
|
+
|
|
92
|
+
## Supported Languages
|
|
93
|
+
|
|
94
|
+
English, German, French, Spanish, Italian, Portuguese, Dutch, Polish, Czech, Slovak, Hungarian, Romanian, Bulgarian, Croatian, Slovenian, Estonian, Latvian, Lithuanian, Finnish, Swedish, Danish, Norwegian, Russian, Ukrainian, Arabic, Chinese, Japanese, Korean, Thai, Vietnamese, Indonesian, Malay, Filipino, Hindi, Turkish, Greek, Maltese.
|
|
95
|
+
|
|
96
|
+
## TypeScript Support
|
|
97
|
+
|
|
98
|
+
Full TypeScript support with comprehensive type definitions for all interfaces, payment methods, and configuration options.
|
|
99
|
+
|
|
100
|
+
## Browser Support
|
|
101
|
+
|
|
102
|
+
The SDK supports recent versions of all major browsers:
|
|
103
|
+
|
|
104
|
+
- Chrome (v90+)
|
|
105
|
+
- Safari (v14+)
|
|
106
|
+
- Firefox (v88+)
|
|
107
|
+
- Edge (v90+)
|
|
108
|
+
- Android WebView / WKWebView (for in-app flows)
|
|
109
|
+
|
|
110
|
+
## Security
|
|
111
|
+
|
|
112
|
+
PCI DSS compliant with end-to-end encryption. No sensitive payment data is stored locally.
|
package/dist/index.d.ts
CHANGED
|
@@ -247,6 +247,57 @@ declare type Listener<TData> = (data: TData) => void;
|
|
|
247
247
|
|
|
248
248
|
export declare type Locale = 'ar' | 'en' | 'bg' | 'cs' | 'da' | 'de' | 'el' | 'es' | 'et' | 'fi' | 'fil' | 'fr' | 'hr' | 'hu' | 'id' | 'it' | 'ja' | 'ko' | 'lt' | 'lv' | 'ms' | 'ru' | 'mt' | 'nb' | 'nl' | 'pl' | 'pt' | 'ro' | 'sk' | 'sl' | 'sv' | 'th' | 'tr' | 'vi' | 'zh';
|
|
249
249
|
|
|
250
|
+
export declare interface PaymentResult {
|
|
251
|
+
paymentMethod: 'card' | 'apple_pay' | 'google_pay' | 'paypal';
|
|
252
|
+
transactionId?: string;
|
|
253
|
+
clientSession: string;
|
|
254
|
+
paymentDetails?: {
|
|
255
|
+
card?: {
|
|
256
|
+
brand: string;
|
|
257
|
+
lastFour: string;
|
|
258
|
+
expMonth?: number;
|
|
259
|
+
expYear?: number;
|
|
260
|
+
funding?: string;
|
|
261
|
+
country?: string;
|
|
262
|
+
};
|
|
263
|
+
applePay?: {
|
|
264
|
+
network: string;
|
|
265
|
+
lastFour?: string;
|
|
266
|
+
billingContact?: {
|
|
267
|
+
name?: string;
|
|
268
|
+
email?: string;
|
|
269
|
+
phone?: string;
|
|
270
|
+
};
|
|
271
|
+
};
|
|
272
|
+
googlePay?: {
|
|
273
|
+
network: string;
|
|
274
|
+
lastFour?: string;
|
|
275
|
+
};
|
|
276
|
+
paypal?: {
|
|
277
|
+
payerId?: string;
|
|
278
|
+
email?: string;
|
|
279
|
+
};
|
|
280
|
+
};
|
|
281
|
+
billingAddress?: {
|
|
282
|
+
name?: string;
|
|
283
|
+
line1?: string;
|
|
284
|
+
line2?: string;
|
|
285
|
+
city?: string;
|
|
286
|
+
state?: string;
|
|
287
|
+
postalCode?: string;
|
|
288
|
+
country?: string;
|
|
289
|
+
};
|
|
290
|
+
amount?: {
|
|
291
|
+
value: number;
|
|
292
|
+
currency: string;
|
|
293
|
+
};
|
|
294
|
+
metadata?: {
|
|
295
|
+
timestamp: string;
|
|
296
|
+
userAgent?: string;
|
|
297
|
+
locale?: string;
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
|
|
250
301
|
declare enum PaymentType {
|
|
251
302
|
Card = "CARD"
|
|
252
303
|
}
|
|
@@ -266,7 +317,7 @@ export declare interface PayNextConfig {
|
|
|
266
317
|
styles?: StylesConfig;
|
|
267
318
|
translate?: DeepPartial<CheckoutTranslate>;
|
|
268
319
|
locale?: Locale;
|
|
269
|
-
onCheckoutComplete?: () => void;
|
|
320
|
+
onCheckoutComplete?: (result: PaymentResult) => void;
|
|
270
321
|
onCheckoutFail?: (error: Error) => void;
|
|
271
322
|
}
|
|
272
323
|
|