@dintero/checkout-web-sdk 0.2.0 → 0.4.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/.github/workflows/release.yml +1 -2
- package/CHANGELOG.md +25 -1
- package/README.md +26 -4
- package/coverage/{Chrome Headless 80.0.3987.0 (Linux x86_64) → Chrome Headless 99.0.4844.0 (Linux x86_64)}/html/base.css +0 -0
- package/coverage/{Chrome Headless 80.0.3987.0 (Linux x86_64) → Chrome Headless 99.0.4844.0 (Linux x86_64)}/html/block-navigation.js +0 -0
- package/coverage/{Chrome Headless 80.0.3987.0 (Linux x86_64) → Chrome Headless 99.0.4844.0 (Linux x86_64)}/html/checkout.ts.html +9 -3
- package/coverage/{Chrome Headless 80.0.3987.0 (Linux x86_64) → Chrome Headless 99.0.4844.0 (Linux x86_64)}/html/createIframeAsync.ts.html +15 -15
- package/coverage/{Chrome Headless 80.0.3987.0 (Linux x86_64) → Chrome Headless 99.0.4844.0 (Linux x86_64)}/html/favicon.png +0 -0
- package/coverage/{Chrome Headless 80.0.3987.0 (Linux x86_64) → Chrome Headless 99.0.4844.0 (Linux x86_64)}/html/index.html +30 -30
- package/coverage/{Chrome Headless 80.0.3987.0 (Linux x86_64) → Chrome Headless 99.0.4844.0 (Linux x86_64)}/html/index.ts.html +203 -38
- package/coverage/{Chrome Headless 80.0.3987.0 (Linux x86_64) → Chrome Headless 99.0.4844.0 (Linux x86_64)}/html/prettify.css +0 -0
- package/coverage/{Chrome Headless 80.0.3987.0 (Linux x86_64) → Chrome Headless 99.0.4844.0 (Linux x86_64)}/html/prettify.js +0 -0
- package/coverage/{Chrome Headless 80.0.3987.0 (Linux x86_64) → Chrome Headless 99.0.4844.0 (Linux x86_64)}/html/sort-arrow-sprite.png +0 -0
- package/coverage/{Chrome Headless 80.0.3987.0 (Linux x86_64) → Chrome Headless 99.0.4844.0 (Linux x86_64)}/html/sorter.js +0 -0
- package/coverage/{Chrome Headless 80.0.3987.0 (Linux x86_64) → Chrome Headless 99.0.4844.0 (Linux x86_64)}/html/subscribe.ts.html +34 -34
- package/coverage/{Chrome Headless 80.0.3987.0 (Linux x86_64) → Chrome Headless 99.0.4844.0 (Linux x86_64)}/html/url.ts.html +1 -1
- package/dist/declarations/src/checkout.d.ts +75 -73
- package/dist/declarations/src/createIframeAsync.d.ts +10 -10
- package/dist/declarations/src/index.d.ts +43 -43
- package/dist/declarations/src/subscribe.d.ts +41 -41
- package/dist/declarations/src/url.d.ts +16 -16
- package/dist/dintero-checkout-web-sdk.cjs.dev.js +57 -10
- package/dist/dintero-checkout-web-sdk.cjs.prod.js +57 -10
- package/dist/dintero-checkout-web-sdk.esm.js +57 -10
- package/dist/dintero-checkout-web-sdk.umd.min.js +1 -1
- package/dist/dintero-checkout-web-sdk.umd.min.js.map +1 -1
- package/package.json +6 -6
- package/dist/declarations/package.d.ts +0 -52
|
@@ -1,73 +1,75 @@
|
|
|
1
|
-
import { Session } from "./session";
|
|
2
|
-
export declare enum CheckoutEvents {
|
|
3
|
-
SessionNotFound = "SessionNotFound",
|
|
4
|
-
SessionLoaded = "SessionLoaded",
|
|
5
|
-
SessionUpdated = "SessionUpdated",
|
|
6
|
-
SessionCancel = "SessionCancel",
|
|
7
|
-
SessionPaymentOnHold = "SessionPaymentOnHold",
|
|
8
|
-
SessionPaymentAuthorized = "SessionPaymentAuthorized",
|
|
9
|
-
SessionPaymentError = "SessionPaymentError",
|
|
10
|
-
SessionLocked = "SessionLocked",
|
|
11
|
-
SessionLockFailed = "SessionLockFailed",
|
|
12
|
-
ActivePaymentProductType = "ActivePaymentProductType",
|
|
13
|
-
ValidateSession = "ValidateSession"
|
|
14
|
-
}
|
|
15
|
-
export declare enum InternalCheckoutEvents {
|
|
16
|
-
HeightChanged = "HeightChanged",
|
|
17
|
-
LanguageChanged = "LanguageChanged"
|
|
18
|
-
}
|
|
19
|
-
export declare type SessionNotFound = {
|
|
20
|
-
type: CheckoutEvents.SessionNotFound;
|
|
21
|
-
};
|
|
22
|
-
export declare type SessionLoaded = {
|
|
23
|
-
type: CheckoutEvents.SessionLoaded;
|
|
24
|
-
session: Session;
|
|
25
|
-
};
|
|
26
|
-
export declare type SessionUpdated = {
|
|
27
|
-
type: CheckoutEvents.SessionUpdated;
|
|
28
|
-
session: Session;
|
|
29
|
-
};
|
|
30
|
-
export declare type SessionCancel = {
|
|
31
|
-
type: CheckoutEvents.SessionCancel;
|
|
32
|
-
href: string;
|
|
33
|
-
};
|
|
34
|
-
export declare type SessionPaymentOnHold = {
|
|
35
|
-
type: CheckoutEvents.SessionPaymentOnHold;
|
|
36
|
-
transaction_id: string;
|
|
37
|
-
merchant_reference: string;
|
|
38
|
-
href: string;
|
|
39
|
-
};
|
|
40
|
-
export declare type SessionPaymentAuthorized = {
|
|
41
|
-
type: CheckoutEvents.SessionPaymentAuthorized;
|
|
42
|
-
transaction_id: string;
|
|
43
|
-
merchant_reference: string;
|
|
44
|
-
href: string;
|
|
45
|
-
};
|
|
46
|
-
export declare type SessionLocked = {
|
|
47
|
-
type: CheckoutEvents.SessionLocked;
|
|
48
|
-
pay_lock_id: string;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
export declare type
|
|
68
|
-
export declare type
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
1
|
+
import { Session } from "./session";
|
|
2
|
+
export declare enum CheckoutEvents {
|
|
3
|
+
SessionNotFound = "SessionNotFound",
|
|
4
|
+
SessionLoaded = "SessionLoaded",
|
|
5
|
+
SessionUpdated = "SessionUpdated",
|
|
6
|
+
SessionCancel = "SessionCancel",
|
|
7
|
+
SessionPaymentOnHold = "SessionPaymentOnHold",
|
|
8
|
+
SessionPaymentAuthorized = "SessionPaymentAuthorized",
|
|
9
|
+
SessionPaymentError = "SessionPaymentError",
|
|
10
|
+
SessionLocked = "SessionLocked",
|
|
11
|
+
SessionLockFailed = "SessionLockFailed",
|
|
12
|
+
ActivePaymentProductType = "ActivePaymentProductType",
|
|
13
|
+
ValidateSession = "ValidateSession"
|
|
14
|
+
}
|
|
15
|
+
export declare enum InternalCheckoutEvents {
|
|
16
|
+
HeightChanged = "HeightChanged",
|
|
17
|
+
LanguageChanged = "LanguageChanged"
|
|
18
|
+
}
|
|
19
|
+
export declare type SessionNotFound = {
|
|
20
|
+
type: CheckoutEvents.SessionNotFound;
|
|
21
|
+
};
|
|
22
|
+
export declare type SessionLoaded = {
|
|
23
|
+
type: CheckoutEvents.SessionLoaded;
|
|
24
|
+
session: Session;
|
|
25
|
+
};
|
|
26
|
+
export declare type SessionUpdated = {
|
|
27
|
+
type: CheckoutEvents.SessionUpdated;
|
|
28
|
+
session: Session;
|
|
29
|
+
};
|
|
30
|
+
export declare type SessionCancel = {
|
|
31
|
+
type: CheckoutEvents.SessionCancel;
|
|
32
|
+
href: string;
|
|
33
|
+
};
|
|
34
|
+
export declare type SessionPaymentOnHold = {
|
|
35
|
+
type: CheckoutEvents.SessionPaymentOnHold;
|
|
36
|
+
transaction_id: string;
|
|
37
|
+
merchant_reference: string;
|
|
38
|
+
href: string;
|
|
39
|
+
};
|
|
40
|
+
export declare type SessionPaymentAuthorized = {
|
|
41
|
+
type: CheckoutEvents.SessionPaymentAuthorized;
|
|
42
|
+
transaction_id: string;
|
|
43
|
+
merchant_reference: string;
|
|
44
|
+
href: string;
|
|
45
|
+
};
|
|
46
|
+
export declare type SessionLocked = {
|
|
47
|
+
type: CheckoutEvents.SessionLocked;
|
|
48
|
+
pay_lock_id: string;
|
|
49
|
+
callback: () => void;
|
|
50
|
+
};
|
|
51
|
+
export declare type SessionLockFailed = {
|
|
52
|
+
type: CheckoutEvents.SessionLockFailed;
|
|
53
|
+
};
|
|
54
|
+
export declare type ActivePaymentProductType = {
|
|
55
|
+
type: CheckoutEvents.ActivePaymentProductType;
|
|
56
|
+
payment_product_type: string | undefined;
|
|
57
|
+
};
|
|
58
|
+
export declare type ValidateSession = {
|
|
59
|
+
type: CheckoutEvents.ValidateSession;
|
|
60
|
+
session: Session;
|
|
61
|
+
callback: (result: SessionValidationCallback) => void;
|
|
62
|
+
};
|
|
63
|
+
export interface SessionValidationCallback {
|
|
64
|
+
success: boolean;
|
|
65
|
+
clientValidationError?: string;
|
|
66
|
+
}
|
|
67
|
+
export declare type WrappedValidateSession = Pick<ValidateSession, "type" | "session">;
|
|
68
|
+
export declare type WrappedSessionLocked = Pick<SessionLocked, "type" | "pay_lock_id">;
|
|
69
|
+
export declare type SessionPayment = SessionPaymentAuthorized | SessionPaymentOnHold;
|
|
70
|
+
export declare type SessionPaymentError = {
|
|
71
|
+
type: CheckoutEvents.SessionPaymentError;
|
|
72
|
+
error: string;
|
|
73
|
+
href: string;
|
|
74
|
+
};
|
|
75
|
+
export declare type SessionEvent = SessionNotFound | SessionLoaded | SessionUpdated | SessionCancel | SessionPaymentOnHold | SessionPaymentAuthorized | SessionPaymentError | WrappedSessionLocked | SessionLockFailed | ActivePaymentProductType | WrappedValidateSession;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates an iframe and adds it to the container.
|
|
3
|
-
*
|
|
4
|
-
* Returns a promise that resolves to the iframe when the iframe has loaded.
|
|
5
|
-
* Rejects the promise if there is a problem loading the iframe.
|
|
6
|
-
*/
|
|
7
|
-
export declare const createIframeAsync: (container: HTMLDivElement, endpoint: string, url: string) => {
|
|
8
|
-
iframe: HTMLIFrameElement;
|
|
9
|
-
initiate: () => void;
|
|
10
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Creates an iframe and adds it to the container.
|
|
3
|
+
*
|
|
4
|
+
* Returns a promise that resolves to the iframe when the iframe has loaded.
|
|
5
|
+
* Rejects the promise if there is a problem loading the iframe.
|
|
6
|
+
*/
|
|
7
|
+
export declare const createIframeAsync: (container: HTMLDivElement, endpoint: string, url: string) => {
|
|
8
|
+
iframe: HTMLIFrameElement;
|
|
9
|
+
initiate: () => void;
|
|
10
|
+
};
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import "native-promise-only";
|
|
2
|
-
import { SessionNotFound, SessionLoaded, SessionUpdated, SessionCancel, SessionPaymentOnHold, SessionPaymentAuthorized, SessionPaymentError, SessionLocked, SessionLockFailed, ActivePaymentProductType, ValidateSession, SessionValidationCallback } from "./checkout";
|
|
3
|
-
export interface DinteroCheckoutInstance {
|
|
4
|
-
/**
|
|
5
|
-
* Remove iframe and all event listeners.
|
|
6
|
-
*/
|
|
7
|
-
destroy: () => void;
|
|
8
|
-
iframe: HTMLIFrameElement;
|
|
9
|
-
language: string;
|
|
10
|
-
lockSession: () =>
|
|
11
|
-
refreshSession: () =>
|
|
12
|
-
setActivePaymentProductType: (paymentProductType: string) => void;
|
|
13
|
-
submitValidationResult: (result: SessionValidationCallback) => void;
|
|
14
|
-
}
|
|
15
|
-
export interface DinteroCheckoutOptions {
|
|
16
|
-
sid: string;
|
|
17
|
-
endpoint?: string;
|
|
18
|
-
language?: string;
|
|
19
|
-
}
|
|
20
|
-
export interface DinteroEmbedCheckoutOptions extends DinteroCheckoutOptions {
|
|
21
|
-
container: HTMLDivElement;
|
|
22
|
-
onPayment?: (event: SessionPaymentAuthorized | SessionPaymentOnHold, checkout: DinteroCheckoutInstance) => void;
|
|
23
|
-
/**
|
|
24
|
-
* @deprecated Since version 0.0.1. Will be deleted in version 1.0.0. Use onPayment instead.
|
|
25
|
-
*/
|
|
26
|
-
onPaymentAuthorized?: (event: SessionPaymentAuthorized, checkout: DinteroCheckoutInstance) => void;
|
|
27
|
-
onSession?: (event: SessionLoaded | SessionUpdated, checkout: DinteroCheckoutInstance) => void;
|
|
28
|
-
onPaymentError?: (event: SessionPaymentError, checkout: DinteroCheckoutInstance) => void;
|
|
29
|
-
onSessionCancel?: (event: SessionCancel, checkout: DinteroCheckoutInstance) => void;
|
|
30
|
-
onSessionNotFound?: (event: SessionNotFound, checkout: DinteroCheckoutInstance) => void;
|
|
31
|
-
onSessionLocked?: (event: SessionLocked, checkout: DinteroCheckoutInstance) => void;
|
|
32
|
-
onSessionLockFailed?: (event: SessionLockFailed, checkout: DinteroCheckoutInstance) => void;
|
|
33
|
-
onActivePaymentType?: (event: ActivePaymentProductType, checkout: DinteroCheckoutInstance) => void;
|
|
34
|
-
onValidateSession?: (event: ValidateSession, checkout: DinteroCheckoutInstance, callback: (result: SessionValidationCallback) => void) => void;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Show a dintero payment session in an embedded iframe.
|
|
38
|
-
*/
|
|
39
|
-
export declare const embed: (options: DinteroEmbedCheckoutOptions) => Promise<DinteroCheckoutInstance>;
|
|
40
|
-
/**
|
|
41
|
-
* Redirect the customer to a payment session in the Dintero Checkout.
|
|
42
|
-
*/
|
|
43
|
-
export declare const redirect: (options: DinteroCheckoutOptions) => void;
|
|
1
|
+
import "native-promise-only";
|
|
2
|
+
import { SessionNotFound, SessionLoaded, SessionUpdated, SessionCancel, SessionPaymentOnHold, SessionPaymentAuthorized, SessionPaymentError, SessionLocked, SessionLockFailed, ActivePaymentProductType, ValidateSession, SessionValidationCallback, SessionEvent } from "./checkout";
|
|
3
|
+
export interface DinteroCheckoutInstance {
|
|
4
|
+
/**
|
|
5
|
+
* Remove iframe and all event listeners.
|
|
6
|
+
*/
|
|
7
|
+
destroy: () => void;
|
|
8
|
+
iframe: HTMLIFrameElement;
|
|
9
|
+
language: string;
|
|
10
|
+
lockSession: () => Promise<SessionEvent>;
|
|
11
|
+
refreshSession: () => Promise<SessionEvent>;
|
|
12
|
+
setActivePaymentProductType: (paymentProductType: string) => void;
|
|
13
|
+
submitValidationResult: (result: SessionValidationCallback) => void;
|
|
14
|
+
}
|
|
15
|
+
export interface DinteroCheckoutOptions {
|
|
16
|
+
sid: string;
|
|
17
|
+
endpoint?: string;
|
|
18
|
+
language?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface DinteroEmbedCheckoutOptions extends DinteroCheckoutOptions {
|
|
21
|
+
container: HTMLDivElement;
|
|
22
|
+
onPayment?: (event: SessionPaymentAuthorized | SessionPaymentOnHold, checkout: DinteroCheckoutInstance) => void;
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated Since version 0.0.1. Will be deleted in version 1.0.0. Use onPayment instead.
|
|
25
|
+
*/
|
|
26
|
+
onPaymentAuthorized?: (event: SessionPaymentAuthorized, checkout: DinteroCheckoutInstance) => void;
|
|
27
|
+
onSession?: (event: SessionLoaded | SessionUpdated, checkout: DinteroCheckoutInstance) => void;
|
|
28
|
+
onPaymentError?: (event: SessionPaymentError, checkout: DinteroCheckoutInstance) => void;
|
|
29
|
+
onSessionCancel?: (event: SessionCancel, checkout: DinteroCheckoutInstance) => void;
|
|
30
|
+
onSessionNotFound?: (event: SessionNotFound, checkout: DinteroCheckoutInstance) => void;
|
|
31
|
+
onSessionLocked?: (event: SessionLocked, checkout: DinteroCheckoutInstance, callback: () => void) => void;
|
|
32
|
+
onSessionLockFailed?: (event: SessionLockFailed, checkout: DinteroCheckoutInstance) => void;
|
|
33
|
+
onActivePaymentType?: (event: ActivePaymentProductType, checkout: DinteroCheckoutInstance) => void;
|
|
34
|
+
onValidateSession?: (event: ValidateSession, checkout: DinteroCheckoutInstance, callback: (result: SessionValidationCallback) => void) => void;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Show a dintero payment session in an embedded iframe.
|
|
38
|
+
*/
|
|
39
|
+
export declare const embed: (options: DinteroEmbedCheckoutOptions) => Promise<DinteroCheckoutInstance>;
|
|
40
|
+
/**
|
|
41
|
+
* Redirect the customer to a payment session in the Dintero Checkout.
|
|
42
|
+
*/
|
|
43
|
+
export declare const redirect: (options: DinteroCheckoutOptions) => void;
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { CheckoutEvents, InternalCheckoutEvents, SessionEvent, SessionValidationCallback } from "./checkout";
|
|
2
|
-
import { DinteroCheckoutInstance } from ".";
|
|
3
|
-
/**
|
|
4
|
-
* Unsubscribe handler from event(s).
|
|
5
|
-
*/
|
|
6
|
-
export declare type SubscriptionHandler = (sessionEvent: SessionEvent, checkout: DinteroCheckoutInstance) => void;
|
|
7
|
-
interface SubscriptionOptions {
|
|
8
|
-
sid: string;
|
|
9
|
-
endpoint: string;
|
|
10
|
-
handler: SubscriptionHandler;
|
|
11
|
-
eventTypes: (CheckoutEvents | InternalCheckoutEvents)[];
|
|
12
|
-
checkout: DinteroCheckoutInstance;
|
|
13
|
-
}
|
|
14
|
-
export declare type Subscription = {
|
|
15
|
-
/**
|
|
16
|
-
* Unsubscribe handler from event(s).
|
|
17
|
-
*/
|
|
18
|
-
unsubscribe: () => void;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Post a SessionLock-event to the checkout iframe.
|
|
22
|
-
*/
|
|
23
|
-
export declare const postSessionLock: (iframe: HTMLIFrameElement, sid: string) => void;
|
|
24
|
-
/**
|
|
25
|
-
* Post the validation result to the checkout iframe
|
|
26
|
-
*/
|
|
27
|
-
export declare const postValidationResult: (iframe: HTMLIFrameElement, sid: string, result: SessionValidationCallback) => void;
|
|
28
|
-
/**
|
|
29
|
-
* Post RefreshSession-event to the checkout iframe.
|
|
30
|
-
*/
|
|
31
|
-
export declare const postSessionRefresh: (iframe: HTMLIFrameElement, sid: string) => void;
|
|
32
|
-
/**
|
|
33
|
-
* Post setActivePaymentProductType-event to the checkout iframe.
|
|
34
|
-
*/
|
|
35
|
-
export declare const postActivePaymentProductType: (iframe: HTMLIFrameElement, sid: string, paymentProductType?: string) => void;
|
|
36
|
-
/**
|
|
37
|
-
* Subscribe to events from an iframe given a handler and a set
|
|
38
|
-
* of event types.
|
|
39
|
-
*/
|
|
40
|
-
export declare const subscribe: (options: SubscriptionOptions) => Subscription;
|
|
41
|
-
export {};
|
|
1
|
+
import { CheckoutEvents, InternalCheckoutEvents, SessionEvent, SessionValidationCallback } from "./checkout";
|
|
2
|
+
import { DinteroCheckoutInstance } from ".";
|
|
3
|
+
/**
|
|
4
|
+
* Unsubscribe handler from event(s).
|
|
5
|
+
*/
|
|
6
|
+
export declare type SubscriptionHandler = (sessionEvent: SessionEvent, checkout: DinteroCheckoutInstance) => void;
|
|
7
|
+
interface SubscriptionOptions {
|
|
8
|
+
sid: string;
|
|
9
|
+
endpoint: string;
|
|
10
|
+
handler: SubscriptionHandler;
|
|
11
|
+
eventTypes: (CheckoutEvents | InternalCheckoutEvents)[];
|
|
12
|
+
checkout: DinteroCheckoutInstance;
|
|
13
|
+
}
|
|
14
|
+
export declare type Subscription = {
|
|
15
|
+
/**
|
|
16
|
+
* Unsubscribe handler from event(s).
|
|
17
|
+
*/
|
|
18
|
+
unsubscribe: () => void;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Post a SessionLock-event to the checkout iframe.
|
|
22
|
+
*/
|
|
23
|
+
export declare const postSessionLock: (iframe: HTMLIFrameElement, sid: string) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Post the validation result to the checkout iframe
|
|
26
|
+
*/
|
|
27
|
+
export declare const postValidationResult: (iframe: HTMLIFrameElement, sid: string, result: SessionValidationCallback) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Post RefreshSession-event to the checkout iframe.
|
|
30
|
+
*/
|
|
31
|
+
export declare const postSessionRefresh: (iframe: HTMLIFrameElement, sid: string) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Post setActivePaymentProductType-event to the checkout iframe.
|
|
34
|
+
*/
|
|
35
|
+
export declare const postActivePaymentProductType: (iframe: HTMLIFrameElement, sid: string, paymentProductType?: string) => void;
|
|
36
|
+
/**
|
|
37
|
+
* Subscribe to events from an iframe given a handler and a set
|
|
38
|
+
* of event types.
|
|
39
|
+
*/
|
|
40
|
+
export declare const subscribe: (options: SubscriptionOptions) => Subscription;
|
|
41
|
+
export {};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Wraps window.location.assign()
|
|
3
|
-
*/
|
|
4
|
-
export declare const windowLocationAssign: (url: string) => void;
|
|
5
|
-
/**
|
|
6
|
-
* Get the url for the session./yarn-error.log
|
|
7
|
-
.DS_Store
|
|
8
|
-
*/
|
|
9
|
-
export interface SessionUrlOptions {
|
|
10
|
-
sid: string;
|
|
11
|
-
endpoint: string;
|
|
12
|
-
language: string | undefined;
|
|
13
|
-
ui?: "fullscreen" | "inline";
|
|
14
|
-
shouldCallValidateSession: boolean;
|
|
15
|
-
}
|
|
16
|
-
export declare const getSessionUrl: (options: SessionUrlOptions) => string;
|
|
1
|
+
/**
|
|
2
|
+
* Wraps window.location.assign()
|
|
3
|
+
*/
|
|
4
|
+
export declare const windowLocationAssign: (url: string) => void;
|
|
5
|
+
/**
|
|
6
|
+
* Get the url for the session./yarn-error.log
|
|
7
|
+
.DS_Store
|
|
8
|
+
*/
|
|
9
|
+
export interface SessionUrlOptions {
|
|
10
|
+
sid: string;
|
|
11
|
+
endpoint: string;
|
|
12
|
+
language: string | undefined;
|
|
13
|
+
ui?: "fullscreen" | "inline";
|
|
14
|
+
shouldCallValidateSession: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare const getSessionUrl: (options: SessionUrlOptions) => string;
|
|
@@ -6,7 +6,7 @@ require('native-promise-only');
|
|
|
6
6
|
|
|
7
7
|
var pkg = {
|
|
8
8
|
name: "@dintero/checkout-web-sdk",
|
|
9
|
-
version: "0.
|
|
9
|
+
version: "0.4.0",
|
|
10
10
|
description: "Dintero Checkout SDK for web frontends",
|
|
11
11
|
main: "dist/dintero-checkout-web-sdk.cjs.js",
|
|
12
12
|
module: "dist/dintero-checkout-web-sdk.esm.js",
|
|
@@ -19,7 +19,8 @@ var pkg = {
|
|
|
19
19
|
scripts: {
|
|
20
20
|
build: "preconstruct build",
|
|
21
21
|
test: "karma start",
|
|
22
|
-
"semantic-release": "semantic-release"
|
|
22
|
+
"semantic-release": "semantic-release",
|
|
23
|
+
prepublishOnly: "npm run build"
|
|
23
24
|
},
|
|
24
25
|
"private": false,
|
|
25
26
|
repository: {
|
|
@@ -35,7 +36,7 @@ var pkg = {
|
|
|
35
36
|
devDependencies: {
|
|
36
37
|
"@babel/preset-env": "^7.14.1",
|
|
37
38
|
"@babel/preset-typescript": "^7.13.0",
|
|
38
|
-
"@preconstruct/cli": "^2.1.
|
|
39
|
+
"@preconstruct/cli": "^2.1.5",
|
|
39
40
|
"@semantic-release/git": "^10.0.1",
|
|
40
41
|
chai: "^4.2.0",
|
|
41
42
|
karma: "^6.3.14",
|
|
@@ -45,10 +46,9 @@ var pkg = {
|
|
|
45
46
|
"karma-typescript": "^5.0.3",
|
|
46
47
|
mocha: "^8.1.1",
|
|
47
48
|
prettier: "^1.19.1",
|
|
48
|
-
puppeteer: "^
|
|
49
|
-
rollup: "^1.30.1",
|
|
49
|
+
puppeteer: "^13.3.2",
|
|
50
50
|
"semantic-release": "^19.0.2",
|
|
51
|
-
sinon: "^
|
|
51
|
+
sinon: "^13.0.1",
|
|
52
52
|
typescript: "^4.2.4"
|
|
53
53
|
},
|
|
54
54
|
dependencies: {
|
|
@@ -329,6 +329,7 @@ const embed = async options => {
|
|
|
329
329
|
onActivePaymentType,
|
|
330
330
|
onValidateSession
|
|
331
331
|
} = options;
|
|
332
|
+
let checkout;
|
|
332
333
|
const subscriptions = []; // Create iframe
|
|
333
334
|
|
|
334
335
|
const {
|
|
@@ -354,13 +355,53 @@ const embed = async options => {
|
|
|
354
355
|
}
|
|
355
356
|
}
|
|
356
357
|
};
|
|
358
|
+
/**
|
|
359
|
+
* Turn an action into a promise by specifying resolve and
|
|
360
|
+
* reject events.
|
|
361
|
+
*/
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
const promisifyAction = (action, resolveEvent, rejectEvent) => {
|
|
365
|
+
if (!checkout) {
|
|
366
|
+
throw new Error("Unable to create action promise: checkout is undefined");
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
return new Promise((resolve, reject) => {
|
|
370
|
+
const eventSubscriptions = [];
|
|
371
|
+
eventSubscriptions.push(subscribe({
|
|
372
|
+
sid,
|
|
373
|
+
endpoint,
|
|
374
|
+
handler: sessionEvent => {
|
|
375
|
+
eventSubscriptions.forEach(sub => sub.unsubscribe());
|
|
376
|
+
resolve(sessionEvent);
|
|
377
|
+
},
|
|
378
|
+
eventTypes: [resolveEvent],
|
|
379
|
+
checkout
|
|
380
|
+
}));
|
|
381
|
+
eventSubscriptions.push(subscribe({
|
|
382
|
+
sid,
|
|
383
|
+
endpoint,
|
|
384
|
+
handler: () => {
|
|
385
|
+
eventSubscriptions.forEach(sub => sub.unsubscribe());
|
|
386
|
+
reject(`Received unexpected event: ${rejectEvent}`);
|
|
387
|
+
},
|
|
388
|
+
eventTypes: [rejectEvent],
|
|
389
|
+
checkout
|
|
390
|
+
}));
|
|
391
|
+
action();
|
|
392
|
+
});
|
|
393
|
+
};
|
|
357
394
|
|
|
358
395
|
const lockSession = () => {
|
|
359
|
-
|
|
396
|
+
return promisifyAction(() => {
|
|
397
|
+
postSessionLock(iframe, sid);
|
|
398
|
+
}, CheckoutEvents.SessionLocked, CheckoutEvents.SessionLockFailed);
|
|
360
399
|
};
|
|
361
400
|
|
|
362
401
|
const refreshSession = () => {
|
|
363
|
-
|
|
402
|
+
return promisifyAction(() => {
|
|
403
|
+
postSessionRefresh(iframe, sid);
|
|
404
|
+
}, CheckoutEvents.SessionUpdated, CheckoutEvents.SessionNotFound);
|
|
364
405
|
};
|
|
365
406
|
|
|
366
407
|
const setActivePaymentProductType = paymentProductType => {
|
|
@@ -375,10 +416,16 @@ const embed = async options => {
|
|
|
375
416
|
if (onValidateSession) {
|
|
376
417
|
onValidateSession(event, checkout, submitValidationResult);
|
|
377
418
|
}
|
|
419
|
+
};
|
|
420
|
+
|
|
421
|
+
const wrappedOnSessionLocked = (event, checkout) => {
|
|
422
|
+
if (onSessionLocked) {
|
|
423
|
+
onSessionLocked(event, checkout, refreshSession);
|
|
424
|
+
}
|
|
378
425
|
}; // Create checkout object that wraps the destroy function.
|
|
379
426
|
|
|
380
427
|
|
|
381
|
-
|
|
428
|
+
checkout = {
|
|
382
429
|
destroy,
|
|
383
430
|
iframe,
|
|
384
431
|
language,
|
|
@@ -413,7 +460,7 @@ const embed = async options => {
|
|
|
413
460
|
handler: onSessionNotFound,
|
|
414
461
|
eventTypes: [CheckoutEvents.SessionNotFound]
|
|
415
462
|
}, {
|
|
416
|
-
handler:
|
|
463
|
+
handler: wrappedOnSessionLocked,
|
|
417
464
|
eventTypes: [CheckoutEvents.SessionLocked]
|
|
418
465
|
}, {
|
|
419
466
|
handler: onSessionLockFailed,
|
|
@@ -6,7 +6,7 @@ require('native-promise-only');
|
|
|
6
6
|
|
|
7
7
|
var pkg = {
|
|
8
8
|
name: "@dintero/checkout-web-sdk",
|
|
9
|
-
version: "0.
|
|
9
|
+
version: "0.4.0",
|
|
10
10
|
description: "Dintero Checkout SDK for web frontends",
|
|
11
11
|
main: "dist/dintero-checkout-web-sdk.cjs.js",
|
|
12
12
|
module: "dist/dintero-checkout-web-sdk.esm.js",
|
|
@@ -19,7 +19,8 @@ var pkg = {
|
|
|
19
19
|
scripts: {
|
|
20
20
|
build: "preconstruct build",
|
|
21
21
|
test: "karma start",
|
|
22
|
-
"semantic-release": "semantic-release"
|
|
22
|
+
"semantic-release": "semantic-release",
|
|
23
|
+
prepublishOnly: "npm run build"
|
|
23
24
|
},
|
|
24
25
|
"private": false,
|
|
25
26
|
repository: {
|
|
@@ -35,7 +36,7 @@ var pkg = {
|
|
|
35
36
|
devDependencies: {
|
|
36
37
|
"@babel/preset-env": "^7.14.1",
|
|
37
38
|
"@babel/preset-typescript": "^7.13.0",
|
|
38
|
-
"@preconstruct/cli": "^2.1.
|
|
39
|
+
"@preconstruct/cli": "^2.1.5",
|
|
39
40
|
"@semantic-release/git": "^10.0.1",
|
|
40
41
|
chai: "^4.2.0",
|
|
41
42
|
karma: "^6.3.14",
|
|
@@ -45,10 +46,9 @@ var pkg = {
|
|
|
45
46
|
"karma-typescript": "^5.0.3",
|
|
46
47
|
mocha: "^8.1.1",
|
|
47
48
|
prettier: "^1.19.1",
|
|
48
|
-
puppeteer: "^
|
|
49
|
-
rollup: "^1.30.1",
|
|
49
|
+
puppeteer: "^13.3.2",
|
|
50
50
|
"semantic-release": "^19.0.2",
|
|
51
|
-
sinon: "^
|
|
51
|
+
sinon: "^13.0.1",
|
|
52
52
|
typescript: "^4.2.4"
|
|
53
53
|
},
|
|
54
54
|
dependencies: {
|
|
@@ -329,6 +329,7 @@ const embed = async options => {
|
|
|
329
329
|
onActivePaymentType,
|
|
330
330
|
onValidateSession
|
|
331
331
|
} = options;
|
|
332
|
+
let checkout;
|
|
332
333
|
const subscriptions = []; // Create iframe
|
|
333
334
|
|
|
334
335
|
const {
|
|
@@ -354,13 +355,53 @@ const embed = async options => {
|
|
|
354
355
|
}
|
|
355
356
|
}
|
|
356
357
|
};
|
|
358
|
+
/**
|
|
359
|
+
* Turn an action into a promise by specifying resolve and
|
|
360
|
+
* reject events.
|
|
361
|
+
*/
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
const promisifyAction = (action, resolveEvent, rejectEvent) => {
|
|
365
|
+
if (!checkout) {
|
|
366
|
+
throw new Error("Unable to create action promise: checkout is undefined");
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
return new Promise((resolve, reject) => {
|
|
370
|
+
const eventSubscriptions = [];
|
|
371
|
+
eventSubscriptions.push(subscribe({
|
|
372
|
+
sid,
|
|
373
|
+
endpoint,
|
|
374
|
+
handler: sessionEvent => {
|
|
375
|
+
eventSubscriptions.forEach(sub => sub.unsubscribe());
|
|
376
|
+
resolve(sessionEvent);
|
|
377
|
+
},
|
|
378
|
+
eventTypes: [resolveEvent],
|
|
379
|
+
checkout
|
|
380
|
+
}));
|
|
381
|
+
eventSubscriptions.push(subscribe({
|
|
382
|
+
sid,
|
|
383
|
+
endpoint,
|
|
384
|
+
handler: () => {
|
|
385
|
+
eventSubscriptions.forEach(sub => sub.unsubscribe());
|
|
386
|
+
reject(`Received unexpected event: ${rejectEvent}`);
|
|
387
|
+
},
|
|
388
|
+
eventTypes: [rejectEvent],
|
|
389
|
+
checkout
|
|
390
|
+
}));
|
|
391
|
+
action();
|
|
392
|
+
});
|
|
393
|
+
};
|
|
357
394
|
|
|
358
395
|
const lockSession = () => {
|
|
359
|
-
|
|
396
|
+
return promisifyAction(() => {
|
|
397
|
+
postSessionLock(iframe, sid);
|
|
398
|
+
}, CheckoutEvents.SessionLocked, CheckoutEvents.SessionLockFailed);
|
|
360
399
|
};
|
|
361
400
|
|
|
362
401
|
const refreshSession = () => {
|
|
363
|
-
|
|
402
|
+
return promisifyAction(() => {
|
|
403
|
+
postSessionRefresh(iframe, sid);
|
|
404
|
+
}, CheckoutEvents.SessionUpdated, CheckoutEvents.SessionNotFound);
|
|
364
405
|
};
|
|
365
406
|
|
|
366
407
|
const setActivePaymentProductType = paymentProductType => {
|
|
@@ -375,10 +416,16 @@ const embed = async options => {
|
|
|
375
416
|
if (onValidateSession) {
|
|
376
417
|
onValidateSession(event, checkout, submitValidationResult);
|
|
377
418
|
}
|
|
419
|
+
};
|
|
420
|
+
|
|
421
|
+
const wrappedOnSessionLocked = (event, checkout) => {
|
|
422
|
+
if (onSessionLocked) {
|
|
423
|
+
onSessionLocked(event, checkout, refreshSession);
|
|
424
|
+
}
|
|
378
425
|
}; // Create checkout object that wraps the destroy function.
|
|
379
426
|
|
|
380
427
|
|
|
381
|
-
|
|
428
|
+
checkout = {
|
|
382
429
|
destroy,
|
|
383
430
|
iframe,
|
|
384
431
|
language,
|
|
@@ -413,7 +460,7 @@ const embed = async options => {
|
|
|
413
460
|
handler: onSessionNotFound,
|
|
414
461
|
eventTypes: [CheckoutEvents.SessionNotFound]
|
|
415
462
|
}, {
|
|
416
|
-
handler:
|
|
463
|
+
handler: wrappedOnSessionLocked,
|
|
417
464
|
eventTypes: [CheckoutEvents.SessionLocked]
|
|
418
465
|
}, {
|
|
419
466
|
handler: onSessionLockFailed,
|