@paynext/sdk 0.0.33 → 0.0.35

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 CHANGED
@@ -13,7 +13,7 @@ npm install @paynext/sdk
13
13
  ```typescript
14
14
  import { PayNextCheckout, type PaymentResult } from '@paynext/sdk'
15
15
 
16
- const checkout = new PayNextCheckout(document.getElementById('checkout'))
16
+ const checkout = new PayNextCheckout(document.getElementById('checkout-form'))
17
17
 
18
18
  await checkout.mount({
19
19
  clientToken: 'your-client-token',
@@ -30,7 +30,7 @@ await checkout.mount({
30
30
 
31
31
  ```tsx
32
32
  import { useEffect, useRef } from 'react'
33
- import { PayNextCheckout, PaymentResult } from '@paynext/sdk'
33
+ import { PayNextCheckout, type PaymentResult } from '@paynext/sdk'
34
34
 
35
35
  // interface
36
36
  interface IProps {
@@ -44,6 +44,10 @@ export const CheckoutComponent: FC<Readonly<IProps> = (props) => {
44
44
  const checkoutRef = useRef<HTMLDivElement>(null)
45
45
 
46
46
  useEffect(() => {
47
+ if (!clientToken) {
48
+ return
49
+ }
50
+
47
51
  const checkout = new PayNextCheckout(checkoutRef.current)
48
52
 
49
53
  checkout.mount({
@@ -69,55 +73,17 @@ export const CheckoutComponent: FC<Readonly<IProps> = (props) => {
69
73
 
70
74
  ```typescript
71
75
  interface PayNextConfig {
72
- clientToken: string // Required
73
- supportedCardTypes?: CardType[] // Optional: restrict card types
74
- variant?: 'default' | 'compact' // Optional: UI variant
75
- locale?: string // Optional: language (en, de, fr, etc.)
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
+ styles?: StylesConfig // Optional: custom styles
76
82
  onCheckoutComplete?: (result: PaymentResult) => void
77
83
  onCheckoutFail?: (error: Error) => void
78
84
  }
79
85
  ```
80
86
 
81
- ## Payment Result
82
-
83
- The `onCheckoutComplete` callback receives detailed payment information:
84
-
85
- ```typescript
86
- interface PaymentResult {
87
- paymentMethod: 'card' | 'apple_pay' | 'google_pay' | 'paypal'
88
- transactionId?: string
89
- clientSession: string
90
-
91
- paymentDetails?: {
92
- card?: {
93
- brand: string
94
- lastFour: string
95
- expMonth?: number
96
- expYear?: number
97
- }
98
- // ... other payment method details
99
- }
100
-
101
- billingAddress?: {
102
- name?: string
103
- line1?: string
104
- city?: string
105
- country?: string
106
- // ... other address fields
107
- }
108
-
109
- amount?: {
110
- value: number // Amount in cents
111
- currency: string
112
- }
113
-
114
- metadata?: {
115
- timestamp: string
116
- locale?: string
117
- }
118
- }
119
- ```
120
-
121
87
  ## Supported Payment Methods
122
88
 
123
89
  - **Cards**: Visa, Mastercard, American Express, Discover, JCB, Diners Club, UnionPay, Maestro
@@ -128,52 +94,19 @@ interface PaymentResult {
128
94
 
129
95
  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.
130
96
 
131
- ## Custom Styling
132
-
133
- ```typescript
134
- await checkout.mount({
135
- clientToken: 'your-token',
136
- styles: {
137
- card: {
138
- input: {
139
- field: {
140
- styles: { fontSize: '16px', color: '#333' },
141
- className: 'custom-input'
142
- }
143
- }
144
- }
145
- }
146
- })
147
- ```
148
-
149
- ## Error Handling
150
-
151
- ```typescript
152
- await checkout.mount({
153
- clientToken: 'your-token',
154
- onCheckoutFail: (error: Error) => {
155
- // Handle payment errors
156
- switch (error.message) {
157
- case 'invalid_card':
158
- showMessage('Please check your card details')
159
- break
160
- case 'insufficient_funds':
161
- showMessage('Insufficient funds')
162
- break
163
- default:
164
- showMessage('Payment failed. Please try again.')
165
- }
166
- }
167
- })
168
- ```
169
-
170
97
  ## TypeScript Support
171
98
 
172
99
  Full TypeScript support with comprehensive type definitions for all interfaces, payment methods, and configuration options.
173
100
 
174
101
  ## Browser Support
175
102
 
176
- Modern browsers including Chrome 90+, Firefox 88+, Safari 14+, Edge 90+.
103
+ The SDK supports recent versions of all major browsers:
104
+
105
+ - Chrome (v90+)
106
+ - Safari (v14+)
107
+ - Firefox (v88+)
108
+ - Edge (v90+)
109
+ - Android WebView / WKWebView (for in-app flows)
177
110
 
178
111
  ## Security
179
112
 
package/dist/index.d.ts CHANGED
@@ -249,8 +249,8 @@ export declare type Locale = 'ar' | 'en' | 'bg' | 'cs' | 'da' | 'de' | 'el' | 'e
249
249
 
250
250
  export declare interface PaymentResult {
251
251
  paymentMethod: 'card' | 'apple_pay' | 'google_pay' | 'paypal';
252
- transactionId?: string;
253
252
  clientSession: string;
253
+ status?: string;
254
254
  paymentDetails?: {
255
255
  card?: {
256
256
  brand: string;