@odus/checkout 0.1.2 → 0.2.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 +47 -5
- package/dist/checkout.d.ts +1 -0
- package/dist/checkout.es.js +378 -376
- package/dist/checkout.es.js.map +1 -1
- package/dist/checkout.umd.js +3 -3
- package/dist/checkout.umd.js.map +1 -1
- package/dist/index.css +1 -1
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Checkout SDK
|
|
2
2
|
|
|
3
3
|
The Odus Checkout is a flexible, easy-to-implement JavaScript SDK that allows merchants to accept payments on their websites with minimal integration effort. This documentation provides all the necessary information to successfully implement the Odus Checkout on your website.
|
|
4
4
|
|
|
@@ -9,10 +9,11 @@ The Odus Checkout is a flexible, easy-to-implement JavaScript SDK that allows me
|
|
|
9
9
|
- [Configuration Options](#configuration-options)
|
|
10
10
|
- [Payment Methods](#payment-methods)
|
|
11
11
|
- [Callbacks and Event Handling](#callbacks-and-event-handling)
|
|
12
|
-
- [Localization](#localization)
|
|
12
|
+
- [Localization Support](#localization-support)
|
|
13
13
|
- [Advanced Usage](#advanced-usage)
|
|
14
14
|
- [API Reference](#api-reference)
|
|
15
15
|
- [Troubleshooting](#troubleshooting)
|
|
16
|
+
- [Related Guides](#related-guides)
|
|
16
17
|
|
|
17
18
|
## Installation
|
|
18
19
|
|
|
@@ -55,6 +56,8 @@ npm install @odus-js
|
|
|
55
56
|
|
|
56
57
|
```javascript
|
|
57
58
|
import { OdusCheckout } from '@odus/checkout';
|
|
59
|
+
// Import the required styles
|
|
60
|
+
import '@odus/checkout/styles';
|
|
58
61
|
|
|
59
62
|
function CheckoutPage() {
|
|
60
63
|
useEffect(() => {
|
|
@@ -77,6 +80,8 @@ function CheckoutPage() {
|
|
|
77
80
|
}
|
|
78
81
|
```
|
|
79
82
|
|
|
83
|
+
> **Important**: Always import the styles using `import '@odus/checkout/styles'` to ensure the checkout UI renders correctly. Without the styles, the checkout component will not display properly.
|
|
84
|
+
|
|
80
85
|
## Getting Started
|
|
81
86
|
|
|
82
87
|
### Basic Implementation
|
|
@@ -85,6 +90,8 @@ Here's a simple example of how to implement the Odus Checkout in your applicatio
|
|
|
85
90
|
|
|
86
91
|
```javascript
|
|
87
92
|
import { OdusCheckout } from '@odus/checkout';
|
|
93
|
+
// Import the required styles
|
|
94
|
+
import '@odus/checkout/styles';
|
|
88
95
|
|
|
89
96
|
// Initialize the checkout
|
|
90
97
|
const checkout = new OdusCheckout({
|
|
@@ -108,6 +115,10 @@ const checkout = new OdusCheckout({
|
|
|
108
115
|
console.log('3DS authentication required!', redirectUrl);
|
|
109
116
|
// Custom redirect handling (only called when manualActionHandling is true)
|
|
110
117
|
},
|
|
118
|
+
onLoadingStateChange: (isLoading) => {
|
|
119
|
+
console.log('Loading state changed:', isLoading);
|
|
120
|
+
// Toggle loading indicators in your UI
|
|
121
|
+
},
|
|
111
122
|
},
|
|
112
123
|
// Optional: Enable manual handling of 3DS redirects
|
|
113
124
|
// manualActionHandling: true,
|
|
@@ -189,7 +200,30 @@ onActionRequired: (redirectUrl) => {
|
|
|
189
200
|
};
|
|
190
201
|
```
|
|
191
202
|
|
|
192
|
-
|
|
203
|
+
### onLoadingStateChange
|
|
204
|
+
|
|
205
|
+
Called when the loading state of the checkout form changes. This is useful for showing or hiding custom loading indicators in your UI.
|
|
206
|
+
|
|
207
|
+
This callback is optional. If not provided, Odus will automatically render its default spinner during loading states.
|
|
208
|
+
|
|
209
|
+
```javascript
|
|
210
|
+
onLoadingStateChange: (isLoading) => {
|
|
211
|
+
// isLoading is a boolean indicating whether the form is currently loading
|
|
212
|
+
console.log('Loading state changed:', isLoading);
|
|
213
|
+
|
|
214
|
+
// Example: Toggle a custom spinner in your UI
|
|
215
|
+
const spinner = document.getElementById('my-spinner');
|
|
216
|
+
if (isLoading) {
|
|
217
|
+
spinner.style.display = 'block';
|
|
218
|
+
} else {
|
|
219
|
+
spinner.style.display = 'none';
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
**Note:** Implementing this callback will override the default Odus loading indicator, giving you complete control over the loading experience.
|
|
225
|
+
|
|
226
|
+
## Localization Support
|
|
193
227
|
|
|
194
228
|
Odus provides localized payment experiences in 33 languages, helping you better serve your global customer base.
|
|
195
229
|
|
|
@@ -268,9 +302,10 @@ type CheckoutConfig = {
|
|
|
268
302
|
paymentId: string;
|
|
269
303
|
environment: 'test' | 'live';
|
|
270
304
|
callbacks?: {
|
|
271
|
-
onPaymentSucceeded?: (result:
|
|
305
|
+
onPaymentSucceeded?: (result: string) => void;
|
|
272
306
|
onPaymentFailed?: (result: string) => void;
|
|
273
307
|
onActionRequired?: (redirectUrl: string) => void;
|
|
308
|
+
onLoadingStateChange?: (isLoading: boolean) => void;
|
|
274
309
|
};
|
|
275
310
|
locale?: 'en' | 'de' | 'es' | 'fr' | 'pl' | 'pt' | null;
|
|
276
311
|
disableErrorMessages?: boolean;
|
|
@@ -285,6 +320,7 @@ type CheckoutConfig = {
|
|
|
285
320
|
#### Checkout not appearing
|
|
286
321
|
|
|
287
322
|
- Ensure the container element exists before calling `mount()`
|
|
323
|
+
- Check that styles are imported with `import '@odus/checkout/styles'` when using npm/module approach
|
|
288
324
|
- Check browser console for errors
|
|
289
325
|
- Verify your API key and profile ID are correct
|
|
290
326
|
- Confirm that you're using the correct environment ('test' or 'live')
|
|
@@ -301,4 +337,10 @@ type CheckoutConfig = {
|
|
|
301
337
|
- Ensure the callback correctly handles the redirectUrl parameter
|
|
302
338
|
- Verify that any custom redirect implementation maintains all URL parameters
|
|
303
339
|
|
|
304
|
-
|
|
340
|
+
## Related Guides
|
|
341
|
+
|
|
342
|
+
For a complete understanding of how to integrate the Checkout SDK in your application, please refer to these additional guides:
|
|
343
|
+
|
|
344
|
+
- [Payment Flow Overview](./flow-overview) - Understand the different payment flows and how they work
|
|
345
|
+
- [Handling Redirects](./handling-redirects) - Learn how to handle redirects for 3DS authentication and alternative payment methods
|
|
346
|
+
- [Making Payments](./making-payments) - Step-by-step guide on how to process payments
|
package/dist/checkout.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ declare type CheckoutCallbacks = {
|
|
|
2
2
|
onPaymentSucceeded?: (result: PaymentResult) => void;
|
|
3
3
|
onPaymentFailed?: (result: string) => void;
|
|
4
4
|
onActionRequired?: (redirectUrl: string) => void;
|
|
5
|
+
onLoadingStateChange?: (isLoading: boolean) => void;
|
|
5
6
|
};
|
|
6
7
|
|
|
7
8
|
export declare type CheckoutConfig = {
|