@odus/checkout 0.6.1 → 0.7.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 CHANGED
@@ -82,6 +82,29 @@ function CheckoutPage() {
82
82
 
83
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
84
 
85
+ ### TypeScript Support
86
+
87
+ For TypeScript users, we export type definitions to enhance your development experience with proper type checking and autocompletion:
88
+
89
+ ```typescript
90
+ // Import the main class and TypeScript types
91
+ import { OdusCheckout, CheckoutConfig, CheckoutInstance, Locale } from '@odus/checkout';
92
+
93
+ // Now you can use these types in your code
94
+ const config: CheckoutConfig = {
95
+ apiKey: 'your_api_key',
96
+ profileId: 'your_profile_id',
97
+ paymentId: 'your_payment_id',
98
+ checkoutKey: 'your_unique_checkout_key',
99
+ returnUrl: 'https://your-website.com/payment-complete',
100
+ environment: 'test',
101
+ locale: 'en', // Type-safe locale values
102
+ };
103
+
104
+ // The checkout instance is properly typed
105
+ const checkout: CheckoutInstance = new OdusCheckout(config);
106
+ ```
107
+
85
108
  ## Getting Started
86
109
 
87
110
  ### Basic Implementation
@@ -138,18 +161,18 @@ Make sure you have a container element in your HTML:
138
161
 
139
162
  When initializing the Odus Checkout, you can configure various options:
140
163
 
141
- | Option | Type | Required | Description |
142
- | ---------------------- | ------- | -------- | -------------------------------------------------------------------------------------------------------- |
143
- | `apiKey` | string | ✅ | Your Odus API key obtained from the dashboard |
144
- | `profileId` | string | ✅ | Your Odus checkout profile ID |
145
- | `checkoutKey` | string | ✅ | Unique checkout key for this payment session |
146
- | `paymentId` | string | ✅ | The ID of the payment being processed |
147
- | `environment` | string | ✅ | API environment to use - either 'test' or 'live' |
148
- | `returnUrl` | string | ✅ | The URL where the customer will be redirected after 3DS authentication or other redirect flows |
149
- | `locale` | string | | Language code for checkout localization (defaults to browser language if supported) |
150
- | `disableErrorMessages` | boolean | | Set to `true` to disable built-in error messages (defaults to `false`) |
151
- | `manualActionHandling` | boolean | | Set to `true` to manually handle 3DS redirects via the `onActionRequired` callback (defaults to `false`) |
152
- | `callbacks` | object | | Event callback functions (see [Callbacks](#callbacks-and-event-handling)) |
164
+ | Option | Type | Required | Description |
165
+ | ---------------------- | ------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
166
+ | `apiKey` | string | ✅ | Your Odus API key obtained from the dashboard's API Keys page |
167
+ | `profileId` | string | ✅ | Your Odus checkout profile ID obtained from the dashboard's Checkout Builder page |
168
+ | `checkoutKey` | string | ✅ | Unique checkout key for this payment session |
169
+ | `paymentId` | string | ✅ | The ID of the payment being processed |
170
+ | `environment` | string | ✅ | API environment to use - either 'test' or 'live' |
171
+ | `returnUrl` | string | ✅ | The URL where the customer will be redirected after 3DS authentication or other redirect flows |
172
+ | `locale` | Locale | | Language code for checkout localization. If not set, automatically defaults to the customer's browser language when supported. If browser language is not supported, falls back to English. |
173
+ | `disableErrorMessages` | boolean | | Set to `true` to disable built-in error messages (defaults to `false`) |
174
+ | `manualActionHandling` | boolean | | Set to `true` to manually handle 3DS redirects via the `onActionRequired` callback (defaults to `false`) |
175
+ | `callbacks` | object | | Event callback functions (see [Callbacks](#callbacks-and-event-handling)) |
153
176
 
154
177
  ## Payment Methods
155
178
 
@@ -307,10 +330,23 @@ type CheckoutConfig = {
307
330
  onActionRequired?: (redirectUrl: string) => void;
308
331
  onLoadingStateChange?: (isLoading: boolean) => void;
309
332
  };
310
- locale?: 'en' | 'de' | 'es' | 'fr' | 'pl' | 'pt' | 'it' | 'tr' | null;
333
+ locale?: Locale;
311
334
  disableErrorMessages?: boolean;
312
335
  manualActionHandling?: boolean;
313
336
  };
337
+
338
+ // Where Locale is a type representing supported languages
339
+ type Locale = 'en' | 'de' | 'es' | 'fr' | 'pl' | 'pt' | 'it' | 'tr';
340
+ ```
341
+
342
+ ### CheckoutInstance Type
343
+
344
+ ```typescript
345
+ // This represents the checkout instance returned when you create a new OdusCheckout
346
+ interface CheckoutInstance {
347
+ mount(containerId: string): this;
348
+ unmount(): void;
349
+ }
314
350
  ```
315
351
 
316
352
  ## Troubleshooting
@@ -13,7 +13,7 @@ export declare type CheckoutConfig = {
13
13
  paymentId: string;
14
14
  environment: Environment;
15
15
  callbacks?: CheckoutCallbacks;
16
- locale?: Locale | null;
16
+ locale?: Locale;
17
17
  disableErrorMessages?: boolean;
18
18
  manualActionHandling?: boolean;
19
19
  };
@@ -155,7 +155,7 @@ export declare const itLocale: {
155
155
  }
156
156
  };
157
157
 
158
- declare type Locale = 'en' | 'de' | 'es' | 'fr' | 'pl' | 'pt' | 'it' | 'tr';
158
+ export declare type Locale = 'en' | 'de' | 'es' | 'fr' | 'pl' | 'pt' | 'it' | 'tr';
159
159
 
160
160
  export declare class OdusCheckout {
161
161
  private config;