@odus/checkout 0.19.0 → 0.20.0-beta.1
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 +37 -0
- package/dist/checkout.d.ts +51 -0
- package/dist/checkout.es.js +6892 -3292
- package/dist/index.css +1 -1
- package/dist/package.json +3 -2
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -299,6 +299,32 @@ This approach is useful for:
|
|
|
299
299
|
- Adding custom tracking or analytics before redirecting
|
|
300
300
|
- Implementing custom UI transitions during the authentication flow
|
|
301
301
|
|
|
302
|
+
### Displaying Error Messages Programmatically
|
|
303
|
+
|
|
304
|
+
You can display custom error messages using the checkout's built-in Alert UI. This is particularly useful for showing errors that occur outside the normal payment flow, such as after a failed 3DS redirect:
|
|
305
|
+
|
|
306
|
+
```javascript
|
|
307
|
+
const checkout = new OdusCheckout({
|
|
308
|
+
// ... configuration
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
checkout.mount('#checkout-container');
|
|
312
|
+
|
|
313
|
+
// Display a custom error message (bypasses disableErrorMessages flag)
|
|
314
|
+
checkout.displayError('Payment failed after 3DS authentication. Please try again.');
|
|
315
|
+
|
|
316
|
+
// Clear the error message when needed
|
|
317
|
+
checkout.clearError();
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
**Common use cases:**
|
|
321
|
+
|
|
322
|
+
- Displaying errors after returning from 3DS authentication
|
|
323
|
+
- Showing validation errors from your backend
|
|
324
|
+
- Communicating payment failures that occur outside the checkout flow
|
|
325
|
+
|
|
326
|
+
**Note:** The `displayError` method always displays the message, even when `disableErrorMessages: true` is set in the configuration, since it represents an explicit intent to show a message. Both methods require the checkout to be mounted first.
|
|
327
|
+
|
|
302
328
|
## API Reference
|
|
303
329
|
|
|
304
330
|
### OdusCheckout Class
|
|
@@ -308,9 +334,18 @@ class OdusCheckout {
|
|
|
308
334
|
constructor(config: CheckoutConfig);
|
|
309
335
|
mount(containerId: string): this;
|
|
310
336
|
unmount(): void;
|
|
337
|
+
displayError(message: string): void;
|
|
338
|
+
clearError(): void;
|
|
311
339
|
}
|
|
312
340
|
```
|
|
313
341
|
|
|
342
|
+
#### Methods
|
|
343
|
+
|
|
344
|
+
- **`mount(containerId: string)`** - Mounts the checkout form to the specified container element.
|
|
345
|
+
- **`unmount()`** - Unmounts and cleans up the checkout form.
|
|
346
|
+
- **`displayError(message: string)`** - Displays a custom error message using the checkout's built-in Alert UI. This method bypasses the `disableErrorMessages` configuration flag. Throws an error if called before `mount()`.
|
|
347
|
+
- **`clearError()`** - Removes the currently displayed error message. Throws an error if called before `mount()`.
|
|
348
|
+
|
|
314
349
|
### CheckoutConfig Type
|
|
315
350
|
|
|
316
351
|
```typescript
|
|
@@ -342,6 +377,8 @@ type Locale = 'en' | 'de' | 'es' | 'fr' | 'pl' | 'pt' | 'it' | 'tr';
|
|
|
342
377
|
interface CheckoutInstance {
|
|
343
378
|
mount(containerId: string): this;
|
|
344
379
|
unmount(): void;
|
|
380
|
+
displayError(message: string): void;
|
|
381
|
+
clearError(): void;
|
|
345
382
|
}
|
|
346
383
|
```
|
|
347
384
|
|
package/dist/checkout.d.ts
CHANGED
|
@@ -37,6 +37,12 @@ declare type Appearance = {
|
|
|
37
37
|
actionButton?: {
|
|
38
38
|
translationKey: string;
|
|
39
39
|
};
|
|
40
|
+
phoneNumber?: {
|
|
41
|
+
enabled: boolean;
|
|
42
|
+
label?: string;
|
|
43
|
+
defaultCountry?: string;
|
|
44
|
+
allowedCountries?: string[];
|
|
45
|
+
};
|
|
40
46
|
billingFields?: {
|
|
41
47
|
street?: {
|
|
42
48
|
enabled: boolean;
|
|
@@ -129,10 +135,15 @@ export declare interface CheckoutInstance {
|
|
|
129
135
|
mount: (containerId: string) => CheckoutInstance;
|
|
130
136
|
unmount: () => void;
|
|
131
137
|
associatePayment: (paymentId: string, checkoutKey: string) => Promise<void>;
|
|
138
|
+
displayError: (message: string) => void;
|
|
139
|
+
clearError: () => void;
|
|
132
140
|
}
|
|
133
141
|
|
|
134
142
|
export declare const deLocale: {
|
|
135
143
|
"email": "E-Mail",
|
|
144
|
+
"phoneNumber": "Telefonnummer",
|
|
145
|
+
"countrySearch": "Länder suchen",
|
|
146
|
+
"countryNoResults": "Keine Ergebnisse gefunden",
|
|
136
147
|
"cardholderNameLabel": "Name des/der Karteninhaber/in",
|
|
137
148
|
"cardInformation": "Kartendaten",
|
|
138
149
|
"cardholderNamePlaceholder": "Vollständiger Name",
|
|
@@ -172,6 +183,8 @@ export declare const deLocale: {
|
|
|
172
183
|
"cardSecurityFormat": "Der Sicherheitscode Ihrer Karte ist unvollständig",
|
|
173
184
|
"nameRequired": "Gib deinen Namen genau so ein, wie er auf deiner Karte steht",
|
|
174
185
|
"cardNumberInvalid": "Die Kartennummer ist unvollständig",
|
|
186
|
+
"phoneNumberRequired": "Telefonnummer ist erforderlich",
|
|
187
|
+
"phoneNumberInvalid": "Bitte geben Sie eine gültige Telefonnummer ein",
|
|
175
188
|
"invalid-checkout": "Checkout konnte nicht initialisiert werden",
|
|
176
189
|
"streetRequired": "Straße ist erforderlich",
|
|
177
190
|
"firstNameRequired": "Vorname ist erforderlich",
|
|
@@ -185,6 +198,9 @@ export declare const deLocale: {
|
|
|
185
198
|
|
|
186
199
|
export declare const enLocale: {
|
|
187
200
|
"email": "Email",
|
|
201
|
+
"phoneNumber": "Phone Number",
|
|
202
|
+
"countrySearch": "Search countries",
|
|
203
|
+
"countryNoResults": "No results found",
|
|
188
204
|
"cardholderNameLabel": "Cardholder name",
|
|
189
205
|
"cardInformation": "Card information",
|
|
190
206
|
"cardholderNamePlaceholder": "Full name on card",
|
|
@@ -224,6 +240,8 @@ export declare const enLocale: {
|
|
|
224
240
|
"cardSecurityFormat": "Your card's security code is incomplete",
|
|
225
241
|
"nameRequired": "Please enter the name as it appears on your card",
|
|
226
242
|
"cardNumberInvalid": "Your card number is incomplete",
|
|
243
|
+
"phoneNumberRequired": "Phone number is required",
|
|
244
|
+
"phoneNumberInvalid": "Please enter a valid phone number",
|
|
227
245
|
"invalid-checkout": "Failed to initialize checkout",
|
|
228
246
|
"streetRequired": "Street address is required",
|
|
229
247
|
"firstNameRequired": "First name is required",
|
|
@@ -239,6 +257,9 @@ declare type Environment = 'test' | 'live';
|
|
|
239
257
|
|
|
240
258
|
export declare const esLocale: {
|
|
241
259
|
"email": "Correo electrónico",
|
|
260
|
+
"phoneNumber": "Número de teléfono",
|
|
261
|
+
"countrySearch": "Buscar países",
|
|
262
|
+
"countryNoResults": "No se encontraron resultados",
|
|
242
263
|
"cardholderNameLabel": "Nombre del titular de la tarjeta",
|
|
243
264
|
"cardInformation": "Información de la tarjeta",
|
|
244
265
|
"cardholderNamePlaceholder": "Nombre completo en la tarjeta",
|
|
@@ -278,6 +299,8 @@ export declare const esLocale: {
|
|
|
278
299
|
"cardSecurityFormat": "El código de seguridad de su tarjeta está incompleto",
|
|
279
300
|
"nameRequired": "Por favor, ingrese el nombre tal como aparece en su tarjeta",
|
|
280
301
|
"cardNumberInvalid": "Su número de tarjeta no es válido",
|
|
302
|
+
"phoneNumberRequired": "El número de teléfono es obligatorio",
|
|
303
|
+
"phoneNumberInvalid": "Por favor, ingrese un número de teléfono válido",
|
|
281
304
|
"invalid-checkout": "No se pudo inicializar el checkout",
|
|
282
305
|
"streetRequired": "La dirección es obligatoria",
|
|
283
306
|
"firstNameRequired": "El nombre es obligatorio",
|
|
@@ -291,6 +314,9 @@ export declare const esLocale: {
|
|
|
291
314
|
|
|
292
315
|
export declare const frLocale: {
|
|
293
316
|
"email": "E-mail",
|
|
317
|
+
"phoneNumber": "Numéro de téléphone",
|
|
318
|
+
"countrySearch": "Rechercher des pays",
|
|
319
|
+
"countryNoResults": "Aucun résultat trouvé",
|
|
294
320
|
"cardholderNameLabel": "Nom du titulaire de la carte",
|
|
295
321
|
"cardInformation": "Informations de la carte",
|
|
296
322
|
"cardholderNamePlaceholder": "Nom complet figurant sur la carte",
|
|
@@ -330,6 +356,8 @@ export declare const frLocale: {
|
|
|
330
356
|
"cardSecurityFormat": "Le code de sécurité de votre carte est incomplet",
|
|
331
357
|
"nameRequired": "Veuillez saisir le nom tel qu'il figure sur votre carte",
|
|
332
358
|
"cardNumberInvalid": "Votre numéro de carte est invalide",
|
|
359
|
+
"phoneNumberRequired": "Le numéro de téléphone est requis",
|
|
360
|
+
"phoneNumberInvalid": "Veuillez saisir un numéro de téléphone valide",
|
|
333
361
|
"invalid-checkout": "Échec de l'initialisation du checkout",
|
|
334
362
|
"streetRequired": "L'adresse est requise",
|
|
335
363
|
"firstNameRequired": "Le prénom est requis",
|
|
@@ -344,12 +372,16 @@ export declare const frLocale: {
|
|
|
344
372
|
declare type InitialValues = {
|
|
345
373
|
email?: string;
|
|
346
374
|
name?: string;
|
|
375
|
+
phoneNumber?: string;
|
|
347
376
|
billingAddress?: Partial<AddressData>;
|
|
348
377
|
shippingAddress?: Partial<AddressData>;
|
|
349
378
|
};
|
|
350
379
|
|
|
351
380
|
export declare const itLocale: {
|
|
352
381
|
"email": "Email",
|
|
382
|
+
"phoneNumber": "Numero di telefono",
|
|
383
|
+
"countrySearch": "Cerca paesi",
|
|
384
|
+
"countryNoResults": "Nessun risultato trovato",
|
|
353
385
|
"cardholderNameLabel": "Nome del titolare della carta",
|
|
354
386
|
"cardInformation": "Informazioni sulla carta",
|
|
355
387
|
"cardholderNamePlaceholder": "Nome completo sulla carta",
|
|
@@ -389,6 +421,8 @@ export declare const itLocale: {
|
|
|
389
421
|
"cardSecurityFormat": "Il codice di sicurezza della tua carta è incompleto",
|
|
390
422
|
"nameRequired": "Inserisci il nome come appare sulla tua carta",
|
|
391
423
|
"cardNumberInvalid": "Il numero della tua carta non è valido",
|
|
424
|
+
"phoneNumberRequired": "Il numero di telefono è obbligatorio",
|
|
425
|
+
"phoneNumberInvalid": "Inserisci un numero di telefono valido",
|
|
392
426
|
"invalid-checkout": "Impossibile inizializzare il checkout",
|
|
393
427
|
"streetRequired": "L'indirizzo è obbligatorio",
|
|
394
428
|
"firstNameRequired": "Il nome è obbligatorio",
|
|
@@ -417,6 +451,8 @@ export declare class OdusCheckout {
|
|
|
417
451
|
private handlePaymentResponse;
|
|
418
452
|
private handleAuthorizationError;
|
|
419
453
|
private getPaymentMethod;
|
|
454
|
+
displayError(message: string): void;
|
|
455
|
+
clearError(): void;
|
|
420
456
|
associatePayment(paymentId: string, checkoutKey: string): Promise<void>;
|
|
421
457
|
}
|
|
422
458
|
|
|
@@ -424,6 +460,9 @@ declare type PaymentResult = 'pending' | 'three_ds_requested' | 'authorized' | '
|
|
|
424
460
|
|
|
425
461
|
export declare const plLocale: {
|
|
426
462
|
"email": "Adres e-mail",
|
|
463
|
+
"phoneNumber": "Numer telefonu",
|
|
464
|
+
"countrySearch": "Szukaj krajów",
|
|
465
|
+
"countryNoResults": "Brak wyników",
|
|
427
466
|
"cardholderNameLabel": "Imię i nazwisko posiadacza karty",
|
|
428
467
|
"cardInformation": "Informacje o karcie",
|
|
429
468
|
"cardholderNamePlaceholder": "Imię i nazwisko na karcie",
|
|
@@ -463,6 +502,8 @@ export declare const plLocale: {
|
|
|
463
502
|
"cardSecurityFormat": "Kod zabezpieczający Państwa karty jest niekompletny",
|
|
464
503
|
"nameRequired": "Proszę wpisać imię i nazwisko tak, jak widnieje na karcie",
|
|
465
504
|
"cardNumberInvalid": "Numer Państwa karty jest nieprawidłowy",
|
|
505
|
+
"phoneNumberRequired": "Numer telefonu jest wymagany",
|
|
506
|
+
"phoneNumberInvalid": "Proszę wpisać prawidłowy numer telefonu",
|
|
466
507
|
"invalid-checkout": "Nie udało się zainicjować procesu płatności",
|
|
467
508
|
"streetRequired": "Adres jest wymagany",
|
|
468
509
|
"firstNameRequired": "Imię jest wymagane",
|
|
@@ -476,6 +517,9 @@ export declare const plLocale: {
|
|
|
476
517
|
|
|
477
518
|
export declare const ptLocale: {
|
|
478
519
|
"email": "E-mail",
|
|
520
|
+
"phoneNumber": "Número de telefone",
|
|
521
|
+
"countrySearch": "Pesquisar países",
|
|
522
|
+
"countryNoResults": "Nenhum resultado encontrado",
|
|
479
523
|
"cardholderNameLabel": "Nome do titular do cartão",
|
|
480
524
|
"cardInformation": "Informações do cartão",
|
|
481
525
|
"cardholderNamePlaceholder": "Nome completo no cartão",
|
|
@@ -515,6 +559,8 @@ export declare const ptLocale: {
|
|
|
515
559
|
"cardSecurityFormat": "O código de segurança do seu cartão está incompleto",
|
|
516
560
|
"nameRequired": "Por favor, insira o nome conforme aparece no cartão",
|
|
517
561
|
"cardNumberInvalid": "O número do seu cartão é inválido",
|
|
562
|
+
"phoneNumberRequired": "O número de telefone é obrigatório",
|
|
563
|
+
"phoneNumberInvalid": "Por favor, insira um número de telefone válido",
|
|
518
564
|
"invalid-checkout": "Falha ao inicializar o checkout",
|
|
519
565
|
"streetRequired": "A morada é obrigatória",
|
|
520
566
|
"firstNameRequired": "O nome é obrigatório",
|
|
@@ -536,6 +582,9 @@ export declare const pushMeasurement: (name: string, value: number, unit?: strin
|
|
|
536
582
|
|
|
537
583
|
export declare const trLocale: {
|
|
538
584
|
"email": "E-posta",
|
|
585
|
+
"phoneNumber": "Telefon Numarası",
|
|
586
|
+
"countrySearch": "Ülkeleri ara",
|
|
587
|
+
"countryNoResults": "Sonuç bulunamadı",
|
|
539
588
|
"cardholderNameLabel": "Kart sahibinin adı",
|
|
540
589
|
"cardInformation": "Kart bilgileri",
|
|
541
590
|
"cardholderNamePlaceholder": "Kart üzerindeki tam ad",
|
|
@@ -575,6 +624,8 @@ export declare const trLocale: {
|
|
|
575
624
|
"cardSecurityFormat": "Kartınızın güvenlik kodu eksik",
|
|
576
625
|
"nameRequired": "Lütfen kart üzerindeki ismi girin",
|
|
577
626
|
"cardNumberInvalid": "Kart numaranız geçersiz",
|
|
627
|
+
"phoneNumberRequired": "Telefon numarası gerekli",
|
|
628
|
+
"phoneNumberInvalid": "Lütfen geçerli bir telefon numarası girin",
|
|
578
629
|
"invalid-checkout": "Checkout başlatılamadı",
|
|
579
630
|
"streetRequired": "Sokak adresi gerekli",
|
|
580
631
|
"firstNameRequired": "Ad gerekli",
|