@dintero/checkout-web-sdk 0.3.1 → 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/CHANGELOG.md +25 -1
- package/README.md +13 -2
- package/coverage/Chrome Headless 99.0.4844.0 (Linux x86_64)/html/checkout.ts.html +1 -1
- package/coverage/Chrome Headless 99.0.4844.0 (Linux x86_64)/html/createIframeAsync.ts.html +15 -15
- package/coverage/Chrome Headless 99.0.4844.0 (Linux x86_64)/html/index.html +30 -30
- package/coverage/Chrome Headless 99.0.4844.0 (Linux x86_64)/html/index.ts.html +173 -38
- package/coverage/Chrome Headless 99.0.4844.0 (Linux x86_64)/html/subscribe.ts.html +34 -34
- package/coverage/Chrome Headless 99.0.4844.0 (Linux x86_64)/html/url.ts.html +1 -1
- package/dist/declarations/src/index.d.ts +3 -3
- package/dist/dintero-checkout-web-sdk.cjs.dev.js +45 -4
- package/dist/dintero-checkout-web-sdk.cjs.prod.js +45 -4
- package/dist/dintero-checkout-web-sdk.esm.js +45 -4
- 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 +1 -1
|
@@ -23,30 +23,30 @@
|
|
|
23
23
|
<div class='clearfix'>
|
|
24
24
|
|
|
25
25
|
<div class='fl pad1y space-right2'>
|
|
26
|
-
<span class="strong">
|
|
26
|
+
<span class="strong">88.24% </span>
|
|
27
27
|
<span class="quiet">Statements</span>
|
|
28
|
-
<span class='fraction'>
|
|
28
|
+
<span class='fraction'>30/34</span>
|
|
29
29
|
</div>
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
<div class='fl pad1y space-right2'>
|
|
33
|
-
<span class="strong">
|
|
33
|
+
<span class="strong">70.83% </span>
|
|
34
34
|
<span class="quiet">Branches</span>
|
|
35
|
-
<span class='fraction'>
|
|
35
|
+
<span class='fraction'>17/24</span>
|
|
36
36
|
</div>
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
<div class='fl pad1y space-right2'>
|
|
40
|
-
<span class="strong">
|
|
40
|
+
<span class="strong">75% </span>
|
|
41
41
|
<span class="quiet">Functions</span>
|
|
42
|
-
<span class='fraction'>
|
|
42
|
+
<span class='fraction'>6/8</span>
|
|
43
43
|
</div>
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
<div class='fl pad1y space-right2'>
|
|
47
|
-
<span class="strong">
|
|
47
|
+
<span class="strong">86.21% </span>
|
|
48
48
|
<span class="quiet">Lines</span>
|
|
49
|
-
<span class='fraction'>
|
|
49
|
+
<span class='fraction'>25/29</span>
|
|
50
50
|
</div>
|
|
51
51
|
|
|
52
52
|
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
|
|
56
56
|
</p>
|
|
57
57
|
</div>
|
|
58
|
-
<div class='status-line
|
|
58
|
+
<div class='status-line high'></div>
|
|
59
59
|
<pre><table class="coverage">
|
|
60
60
|
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
|
|
61
61
|
<a name='L2'></a><a href='#L2'>2</a>
|
|
@@ -213,7 +213,7 @@
|
|
|
213
213
|
<span class="cline-any cline-neutral"> </span>
|
|
214
214
|
<span class="cline-any cline-neutral"> </span>
|
|
215
215
|
<span class="cline-any cline-yes">1x</span>
|
|
216
|
-
<span class="cline-any cline-yes">
|
|
216
|
+
<span class="cline-any cline-yes">27x</span>
|
|
217
217
|
<span class="cline-any cline-yes">1x</span>
|
|
218
218
|
<span class="cline-any cline-neutral"> </span>
|
|
219
219
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -225,8 +225,8 @@
|
|
|
225
225
|
<span class="cline-any cline-neutral"> </span>
|
|
226
226
|
<span class="cline-any cline-neutral"> </span>
|
|
227
227
|
<span class="cline-any cline-yes">1x</span>
|
|
228
|
-
<span class="cline-any cline-
|
|
229
|
-
<span class="cline-any cline-
|
|
228
|
+
<span class="cline-any cline-yes">2x</span>
|
|
229
|
+
<span class="cline-any cline-yes">2x</span>
|
|
230
230
|
<span class="cline-any cline-neutral"> </span>
|
|
231
231
|
<span class="cline-any cline-neutral"> </span>
|
|
232
232
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -243,8 +243,8 @@
|
|
|
243
243
|
<span class="cline-any cline-neutral"> </span>
|
|
244
244
|
<span class="cline-any cline-neutral"> </span>
|
|
245
245
|
<span class="cline-any cline-yes">1x</span>
|
|
246
|
-
<span class="cline-any cline-
|
|
247
|
-
<span class="cline-any cline-
|
|
246
|
+
<span class="cline-any cline-yes">2x</span>
|
|
247
|
+
<span class="cline-any cline-yes">2x</span>
|
|
248
248
|
<span class="cline-any cline-neutral"> </span>
|
|
249
249
|
<span class="cline-any cline-neutral"> </span>
|
|
250
250
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -265,37 +265,37 @@
|
|
|
265
265
|
<span class="cline-any cline-neutral"> </span>
|
|
266
266
|
<span class="cline-any cline-neutral"> </span>
|
|
267
267
|
<span class="cline-any cline-yes">1x</span>
|
|
268
|
-
<span class="cline-any cline-yes">
|
|
268
|
+
<span class="cline-any cline-yes">1295x</span>
|
|
269
269
|
<span class="cline-any cline-neutral"> </span>
|
|
270
270
|
<span class="cline-any cline-neutral"> </span>
|
|
271
271
|
<span class="cline-any cline-neutral"> </span>
|
|
272
|
-
<span class="cline-any cline-yes">
|
|
273
|
-
<span class="cline-any cline-yes">
|
|
274
|
-
<span class="cline-any cline-yes">
|
|
275
|
-
<span class="cline-any cline-yes">
|
|
272
|
+
<span class="cline-any cline-yes">259x</span>
|
|
273
|
+
<span class="cline-any cline-yes">3679x</span>
|
|
274
|
+
<span class="cline-any cline-yes">3679x</span>
|
|
275
|
+
<span class="cline-any cline-yes">3679x</span>
|
|
276
276
|
<span class="cline-any cline-neutral"> </span>
|
|
277
|
-
<span class="cline-any cline-yes">
|
|
278
|
-
<span class="cline-any cline-yes">
|
|
277
|
+
<span class="cline-any cline-yes">3679x</span>
|
|
278
|
+
<span class="cline-any cline-yes">3679x</span>
|
|
279
279
|
<span class="cline-any cline-neutral"> </span>
|
|
280
280
|
<span class="cline-any cline-neutral"> </span>
|
|
281
281
|
<span class="cline-any cline-neutral"> </span>
|
|
282
282
|
<span class="cline-any cline-neutral"> </span>
|
|
283
283
|
<span class="cline-any cline-neutral"> </span>
|
|
284
|
-
<span class="cline-any cline-yes">
|
|
285
|
-
<span class="cline-any cline-yes">
|
|
284
|
+
<span class="cline-any cline-yes">27x</span>
|
|
285
|
+
<span class="cline-any cline-yes">27x</span>
|
|
286
286
|
<span class="cline-any cline-neutral"> </span>
|
|
287
287
|
<span class="cline-any cline-neutral"> </span>
|
|
288
288
|
<span class="cline-any cline-neutral"> </span>
|
|
289
289
|
<span class="cline-any cline-neutral"> </span>
|
|
290
|
-
<span class="cline-any cline-yes">
|
|
290
|
+
<span class="cline-any cline-yes">259x</span>
|
|
291
291
|
<span class="cline-any cline-neutral"> </span>
|
|
292
292
|
<span class="cline-any cline-neutral"> </span>
|
|
293
|
-
<span class="cline-any cline-yes">
|
|
294
|
-
<span class="cline-any cline-yes">
|
|
293
|
+
<span class="cline-any cline-yes">259x</span>
|
|
294
|
+
<span class="cline-any cline-yes">32x</span>
|
|
295
295
|
<span class="cline-any cline-neutral"> </span>
|
|
296
296
|
<span class="cline-any cline-neutral"> </span>
|
|
297
297
|
<span class="cline-any cline-neutral"> </span>
|
|
298
|
-
<span class="cline-any cline-yes">
|
|
298
|
+
<span class="cline-any cline-yes">259x</span>
|
|
299
299
|
<span class="cline-any cline-neutral"> </span>
|
|
300
300
|
<span class="cline-any cline-neutral"> </span>
|
|
301
301
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -345,9 +345,9 @@ const postAck = (iframe: HTMLIFrameElement, event: MessageEvent) => {
|
|
|
345
345
|
/**
|
|
346
346
|
* Post a SessionLock-event to the checkout iframe.
|
|
347
347
|
*/
|
|
348
|
-
export const postSessionLock =
|
|
349
|
-
<span class="
|
|
350
|
-
|
|
348
|
+
export const postSessionLock = (iframe: HTMLIFrameElement, sid: string) => {
|
|
349
|
+
<span class="missing-if-branch" title="else path not taken" >E</span>if (iframe.contentWindow) {
|
|
350
|
+
iframe.contentWindow.postMessage({ type: "LockSession", sid }, "*");
|
|
351
351
|
}
|
|
352
352
|
};
|
|
353
353
|
|
|
@@ -363,9 +363,9 @@ export const postValidationResult = <span class="fstat-no" title="function not c
|
|
|
363
363
|
/**
|
|
364
364
|
* Post RefreshSession-event to the checkout iframe.
|
|
365
365
|
*/
|
|
366
|
-
export const postSessionRefresh =
|
|
367
|
-
<span class="
|
|
368
|
-
|
|
366
|
+
export const postSessionRefresh = (iframe: HTMLIFrameElement, sid: string) => {
|
|
367
|
+
<span class="missing-if-branch" title="else path not taken" >E</span>if (iframe.contentWindow) {
|
|
368
|
+
iframe.contentWindow.postMessage({ type: "RefreshSession", sid }, "*");
|
|
369
369
|
}
|
|
370
370
|
};
|
|
371
371
|
|
|
@@ -427,7 +427,7 @@ export const subscribe = (options: SubscriptionOptions): Subscription => {
|
|
|
427
427
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
428
428
|
Code coverage generated by
|
|
429
429
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
430
|
-
at
|
|
430
|
+
at Mon Mar 21 2022 13:44:46 GMT+0000 (Coordinated Universal Time)
|
|
431
431
|
</div>
|
|
432
432
|
</div>
|
|
433
433
|
<script src="prettify.js"></script>
|
|
@@ -169,7 +169,7 @@ export const getSessionUrl = (options: SessionUrlOptions): string => {
|
|
|
169
169
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
170
170
|
Code coverage generated by
|
|
171
171
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
172
|
-
at
|
|
172
|
+
at Mon Mar 21 2022 13:44:46 GMT+0000 (Coordinated Universal Time)
|
|
173
173
|
</div>
|
|
174
174
|
</div>
|
|
175
175
|
<script src="prettify.js"></script>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "native-promise-only";
|
|
2
|
-
import { SessionNotFound, SessionLoaded, SessionUpdated, SessionCancel, SessionPaymentOnHold, SessionPaymentAuthorized, SessionPaymentError, SessionLocked, SessionLockFailed, ActivePaymentProductType, ValidateSession, SessionValidationCallback } from "./checkout";
|
|
2
|
+
import { SessionNotFound, SessionLoaded, SessionUpdated, SessionCancel, SessionPaymentOnHold, SessionPaymentAuthorized, SessionPaymentError, SessionLocked, SessionLockFailed, ActivePaymentProductType, ValidateSession, SessionValidationCallback, SessionEvent } from "./checkout";
|
|
3
3
|
export interface DinteroCheckoutInstance {
|
|
4
4
|
/**
|
|
5
5
|
* Remove iframe and all event listeners.
|
|
@@ -7,8 +7,8 @@ export interface DinteroCheckoutInstance {
|
|
|
7
7
|
destroy: () => void;
|
|
8
8
|
iframe: HTMLIFrameElement;
|
|
9
9
|
language: string;
|
|
10
|
-
lockSession: () =>
|
|
11
|
-
refreshSession: () =>
|
|
10
|
+
lockSession: () => Promise<SessionEvent>;
|
|
11
|
+
refreshSession: () => Promise<SessionEvent>;
|
|
12
12
|
setActivePaymentProductType: (paymentProductType: string) => void;
|
|
13
13
|
submitValidationResult: (result: SessionValidationCallback) => void;
|
|
14
14
|
}
|
|
@@ -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",
|
|
@@ -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 => {
|
|
@@ -384,7 +425,7 @@ const embed = async options => {
|
|
|
384
425
|
}; // Create checkout object that wraps the destroy function.
|
|
385
426
|
|
|
386
427
|
|
|
387
|
-
|
|
428
|
+
checkout = {
|
|
388
429
|
destroy,
|
|
389
430
|
iframe,
|
|
390
431
|
language,
|
|
@@ -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",
|
|
@@ -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 => {
|
|
@@ -384,7 +425,7 @@ const embed = async options => {
|
|
|
384
425
|
}; // Create checkout object that wraps the destroy function.
|
|
385
426
|
|
|
386
427
|
|
|
387
|
-
|
|
428
|
+
checkout = {
|
|
388
429
|
destroy,
|
|
389
430
|
iframe,
|
|
390
431
|
language,
|
|
@@ -2,7 +2,7 @@ import 'native-promise-only';
|
|
|
2
2
|
|
|
3
3
|
var pkg = {
|
|
4
4
|
name: "@dintero/checkout-web-sdk",
|
|
5
|
-
version: "0.
|
|
5
|
+
version: "0.4.0",
|
|
6
6
|
description: "Dintero Checkout SDK for web frontends",
|
|
7
7
|
main: "dist/dintero-checkout-web-sdk.cjs.js",
|
|
8
8
|
module: "dist/dintero-checkout-web-sdk.esm.js",
|
|
@@ -325,6 +325,7 @@ const embed = async options => {
|
|
|
325
325
|
onActivePaymentType,
|
|
326
326
|
onValidateSession
|
|
327
327
|
} = options;
|
|
328
|
+
let checkout;
|
|
328
329
|
const subscriptions = []; // Create iframe
|
|
329
330
|
|
|
330
331
|
const {
|
|
@@ -350,13 +351,53 @@ const embed = async options => {
|
|
|
350
351
|
}
|
|
351
352
|
}
|
|
352
353
|
};
|
|
354
|
+
/**
|
|
355
|
+
* Turn an action into a promise by specifying resolve and
|
|
356
|
+
* reject events.
|
|
357
|
+
*/
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
const promisifyAction = (action, resolveEvent, rejectEvent) => {
|
|
361
|
+
if (!checkout) {
|
|
362
|
+
throw new Error("Unable to create action promise: checkout is undefined");
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
return new Promise((resolve, reject) => {
|
|
366
|
+
const eventSubscriptions = [];
|
|
367
|
+
eventSubscriptions.push(subscribe({
|
|
368
|
+
sid,
|
|
369
|
+
endpoint,
|
|
370
|
+
handler: sessionEvent => {
|
|
371
|
+
eventSubscriptions.forEach(sub => sub.unsubscribe());
|
|
372
|
+
resolve(sessionEvent);
|
|
373
|
+
},
|
|
374
|
+
eventTypes: [resolveEvent],
|
|
375
|
+
checkout
|
|
376
|
+
}));
|
|
377
|
+
eventSubscriptions.push(subscribe({
|
|
378
|
+
sid,
|
|
379
|
+
endpoint,
|
|
380
|
+
handler: () => {
|
|
381
|
+
eventSubscriptions.forEach(sub => sub.unsubscribe());
|
|
382
|
+
reject(`Received unexpected event: ${rejectEvent}`);
|
|
383
|
+
},
|
|
384
|
+
eventTypes: [rejectEvent],
|
|
385
|
+
checkout
|
|
386
|
+
}));
|
|
387
|
+
action();
|
|
388
|
+
});
|
|
389
|
+
};
|
|
353
390
|
|
|
354
391
|
const lockSession = () => {
|
|
355
|
-
|
|
392
|
+
return promisifyAction(() => {
|
|
393
|
+
postSessionLock(iframe, sid);
|
|
394
|
+
}, CheckoutEvents.SessionLocked, CheckoutEvents.SessionLockFailed);
|
|
356
395
|
};
|
|
357
396
|
|
|
358
397
|
const refreshSession = () => {
|
|
359
|
-
|
|
398
|
+
return promisifyAction(() => {
|
|
399
|
+
postSessionRefresh(iframe, sid);
|
|
400
|
+
}, CheckoutEvents.SessionUpdated, CheckoutEvents.SessionNotFound);
|
|
360
401
|
};
|
|
361
402
|
|
|
362
403
|
const setActivePaymentProductType = paymentProductType => {
|
|
@@ -380,7 +421,7 @@ const embed = async options => {
|
|
|
380
421
|
}; // Create checkout object that wraps the destroy function.
|
|
381
422
|
|
|
382
423
|
|
|
383
|
-
|
|
424
|
+
checkout = {
|
|
384
425
|
destroy,
|
|
385
426
|
iframe,
|
|
386
427
|
language,
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
v0.8.1 (c) Kyle Simpson
|
|
4
4
|
MIT License: http://getify.mit-license.org
|
|
5
5
|
*/
|
|
6
|
-
var t,o,i;i=function(){var e,n,t,o=Object.prototype.toString,i="undefined"!=typeof setImmediate?function(e){return setImmediate(e)}:setTimeout;try{Object.defineProperty({},"x",{}),e=function(e,n,t,o){return Object.defineProperty(e,n,{value:t,writable:!0,configurable:!1!==o})}}catch(n){e=function(e,n,t){return e[n]=t,e}}function r(e,o){t.add(e,o),n||(n=i(t.drain))}function s(e){var n,t=typeof e;return null==e||"object"!=t&&"function"!=t||(n=e.then),"function"==typeof n&&n}function a(){for(var e=0;e<this.chain.length;e++)c(this,1===this.state?this.chain[e].success:this.chain[e].failure,this.chain[e]);this.chain.length=0}function c(e,n,t){var o,i;try{!1===n?t.reject(e.msg):(o=!0===n?e.msg:n.call(void 0,e.msg))===t.promise?t.reject(TypeError("Promise-chain cycle")):(i=s(o))?i.call(o,t.resolve,t.reject):t.resolve(o)}catch(e){t.reject(e)}}function d(e){var n,t=this;if(!t.triggered){t.triggered=!0,t.def&&(t=t.def);try{(n=s(e))?r((function(){var o=new f(t);try{n.call(e,(function(){d.apply(o,arguments)}),(function(){u.apply(o,arguments)}))}catch(e){u.call(o,e)}})):(t.msg=e,t.state=1,t.chain.length>0&&r(a,t))}catch(e){u.call(new f(t),e)}}}function u(e){var n=this;n.triggered||(n.triggered=!0,n.def&&(n=n.def),n.msg=e,n.state=2,n.chain.length>0&&r(a,n))}function l(e,n,t,o){for(var i=0;i<n.length;i++)!function(i){e.resolve(n[i]).then((function(e){t(i,e)}),o)}(i)}function f(e){this.def=e,this.triggered=!1}function h(e){this.promise=e,this.state=0,this.triggered=!1,this.chain=[],this.msg=void 0}function p(e){if("function"!=typeof e)throw TypeError("Not a function");if(0!==this.__NPO__)throw TypeError("Not a promise");this.__NPO__=1;var n=new h(this);this.then=function(e,t){var o={success:"function"!=typeof e||e,failure:"function"==typeof t&&t};return o.promise=new this.constructor((function(e,n){if("function"!=typeof e||"function"!=typeof n)throw TypeError("Not a function");o.resolve=e,o.reject=n})),n.chain.push(o),0!==n.state&&r(a,n),o.promise},this.catch=function(e){return this.then(void 0,e)};try{e.call(void 0,(function(e){d.call(n,e)}),(function(e){u.call(n,e)}))}catch(e){u.call(n,e)}}t=function(){var e,t,o;function i(e,n){this.fn=e,this.self=n,this.next=void 0}return{add:function(n,r){o=new i(n,r),t?t.next=o:e=o,t=o,o=void 0},drain:function(){var o=e;for(e=t=n=void 0;o;)o.fn.call(o.self),o=o.next}}}();var y=e({},"constructor",p,!1);return p.prototype=y,e(y,"__NPO__",0,!1),e(p,"resolve",(function(e){return e&&"object"==typeof e&&1===e.__NPO__?e:new this((function(n,t){if("function"!=typeof n||"function"!=typeof t)throw TypeError("Not a function");n(e)}))})),e(p,"reject",(function(e){return new this((function(n,t){if("function"!=typeof n||"function"!=typeof t)throw TypeError("Not a function");t(e)}))})),e(p,"all",(function(e){var n=this;return"[object Array]"!=o.call(e)?n.reject(TypeError("Not an array")):0===e.length?n.resolve([]):new n((function(t,o){if("function"!=typeof t||"function"!=typeof o)throw TypeError("Not a function");var i=e.length,r=Array(i),s=0;l(n,e,(function(e,n){r[e]=n,++s===i&&t(r)}),o)}))})),e(p,"race",(function(e){var n=this;return"[object Array]"!=o.call(e)?n.reject(TypeError("Not an array")):new n((function(t,o){if("function"!=typeof t||"function"!=typeof o)throw TypeError("Not a function");l(n,e,(function(e,n){t(n)}),o)}))})),p},(o=n)[t="Promise"]=o[t]||i(),e.exports&&(e.exports=o[t])}));var t="0.
|
|
6
|
+
var t,o,i;i=function(){var e,n,t,o=Object.prototype.toString,i="undefined"!=typeof setImmediate?function(e){return setImmediate(e)}:setTimeout;try{Object.defineProperty({},"x",{}),e=function(e,n,t,o){return Object.defineProperty(e,n,{value:t,writable:!0,configurable:!1!==o})}}catch(n){e=function(e,n,t){return e[n]=t,e}}function r(e,o){t.add(e,o),n||(n=i(t.drain))}function s(e){var n,t=typeof e;return null==e||"object"!=t&&"function"!=t||(n=e.then),"function"==typeof n&&n}function a(){for(var e=0;e<this.chain.length;e++)c(this,1===this.state?this.chain[e].success:this.chain[e].failure,this.chain[e]);this.chain.length=0}function c(e,n,t){var o,i;try{!1===n?t.reject(e.msg):(o=!0===n?e.msg:n.call(void 0,e.msg))===t.promise?t.reject(TypeError("Promise-chain cycle")):(i=s(o))?i.call(o,t.resolve,t.reject):t.resolve(o)}catch(e){t.reject(e)}}function d(e){var n,t=this;if(!t.triggered){t.triggered=!0,t.def&&(t=t.def);try{(n=s(e))?r((function(){var o=new f(t);try{n.call(e,(function(){d.apply(o,arguments)}),(function(){u.apply(o,arguments)}))}catch(e){u.call(o,e)}})):(t.msg=e,t.state=1,t.chain.length>0&&r(a,t))}catch(e){u.call(new f(t),e)}}}function u(e){var n=this;n.triggered||(n.triggered=!0,n.def&&(n=n.def),n.msg=e,n.state=2,n.chain.length>0&&r(a,n))}function l(e,n,t,o){for(var i=0;i<n.length;i++)!function(i){e.resolve(n[i]).then((function(e){t(i,e)}),o)}(i)}function f(e){this.def=e,this.triggered=!1}function h(e){this.promise=e,this.state=0,this.triggered=!1,this.chain=[],this.msg=void 0}function p(e){if("function"!=typeof e)throw TypeError("Not a function");if(0!==this.__NPO__)throw TypeError("Not a promise");this.__NPO__=1;var n=new h(this);this.then=function(e,t){var o={success:"function"!=typeof e||e,failure:"function"==typeof t&&t};return o.promise=new this.constructor((function(e,n){if("function"!=typeof e||"function"!=typeof n)throw TypeError("Not a function");o.resolve=e,o.reject=n})),n.chain.push(o),0!==n.state&&r(a,n),o.promise},this.catch=function(e){return this.then(void 0,e)};try{e.call(void 0,(function(e){d.call(n,e)}),(function(e){u.call(n,e)}))}catch(e){u.call(n,e)}}t=function(){var e,t,o;function i(e,n){this.fn=e,this.self=n,this.next=void 0}return{add:function(n,r){o=new i(n,r),t?t.next=o:e=o,t=o,o=void 0},drain:function(){var o=e;for(e=t=n=void 0;o;)o.fn.call(o.self),o=o.next}}}();var y=e({},"constructor",p,!1);return p.prototype=y,e(y,"__NPO__",0,!1),e(p,"resolve",(function(e){return e&&"object"==typeof e&&1===e.__NPO__?e:new this((function(n,t){if("function"!=typeof n||"function"!=typeof t)throw TypeError("Not a function");n(e)}))})),e(p,"reject",(function(e){return new this((function(n,t){if("function"!=typeof n||"function"!=typeof t)throw TypeError("Not a function");t(e)}))})),e(p,"all",(function(e){var n=this;return"[object Array]"!=o.call(e)?n.reject(TypeError("Not an array")):0===e.length?n.resolve([]):new n((function(t,o){if("function"!=typeof t||"function"!=typeof o)throw TypeError("Not a function");var i=e.length,r=Array(i),s=0;l(n,e,(function(e,n){r[e]=n,++s===i&&t(r)}),o)}))})),e(p,"race",(function(e){var n=this;return"[object Array]"!=o.call(e)?n.reject(TypeError("Not an array")):new n((function(t,o){if("function"!=typeof t||"function"!=typeof o)throw TypeError("Not a function");l(n,e,(function(e,n){t(n)}),o)}))})),p},(o=n)[t="Promise"]=o[t]||i(),e.exports&&(e.exports=o[t])}));var t="0.4.0";let o,i;!function(e){e.SessionNotFound="SessionNotFound",e.SessionLoaded="SessionLoaded",e.SessionUpdated="SessionUpdated",e.SessionCancel="SessionCancel",e.SessionPaymentOnHold="SessionPaymentOnHold",e.SessionPaymentAuthorized="SessionPaymentAuthorized",e.SessionPaymentError="SessionPaymentError",e.SessionLocked="SessionLocked",e.SessionLockFailed="SessionLockFailed",e.ActivePaymentProductType="ActivePaymentProductType",e.ValidateSession="ValidateSession"}(o||(o={})),function(e){e.HeightChanged="HeightChanged",e.LanguageChanged="LanguageChanged"}(i||(i={}));const r=e=>{window.location.assign(e)},s=e=>{const{sid:n,endpoint:o,language:i,ui:r,shouldCallValidateSession:s}=e;if(!o)throw new Error("Invalid endpoint");const a=[i?`language=${i}`:"",r?`ui=${r}`:"",`sdk=${t}`,s?"client_side_validation=true":void 0].filter((e=>e)).join("&");return`${o}/v1/view/${n}${a?"?"+a:""}`},a=e=>{const{sid:n,endpoint:t,handler:o,eventTypes:i,checkout:r}=e,s=e=>{const s=e.origin===t,a=e.source===r.iframe.contentWindow,c=e.data&&e.data.sid===n,d=-1!==i.indexOf(e.data&&e.data.type);s&&a&&c&&d&&(((e,n)=>{n.data.mid&&e.contentWindow&&e.contentWindow.postMessage({ack:n.data.mid},n.origin||"*")})(r.iframe,e),o(e.data,r))};window.addEventListener("message",s,!1);return{unsubscribe:()=>{window.removeEventListener("message",s,!1)}}},c=e=>{e.href&&r(e.href)},d=(e,n)=>{(e.height||0===e.height)&&n.iframe.setAttribute("style",`width:100%; height:${e.height}px;`)},u=(e,n)=>{e.language&&(n.language=e.language)},l=(e,n,i)=>(e,r)=>{const s=["sid","merchant_reference","transaction_id","error"].map((n=>[n,e[n]]));e.type!==o.SessionCancel||e.error||s.push(["error","cancelled"]),s.push(["language",r.language]),s.push(["sdk",t]);const a=s.filter((([e,n])=>n)).map((([e,n])=>`${e}=${n}`)).join("&");r.iframe.setAttribute("src",`${n}/embedResult/?${a}`),i(e,r)};e.embed=async e=>{const{container:n,sid:t,language:r,endpoint:f="https://checkout.dintero.com",onSession:h,onSessionCancel:p,onPayment:y,onPaymentAuthorized:g,onPaymentError:m,onSessionNotFound:v,onSessionLocked:w,onSessionLockFailed:S,onActivePaymentType:T,onValidateSession:b}=e;let P;const E=[],{iframe:_,initiate:k}=((e,n,t)=>{if(!e||!e.appendChild)throw new Error("Invalid container");const o=document.createElement("iframe");return o.setAttribute("frameborder","0"),o.setAttribute("allowTransparency","true"),o.setAttribute("style","width:100%; height:0;"),o.setAttribute("sandbox","allow-scripts allow-forms allow-same-origin allow-popups"),o.setAttribute("importance","high"),o.setAttribute("src",t),{iframe:o,initiate:async()=>new Promise(((n,t)=>{o.onload=()=>n(),o.onerror=()=>t(),e.appendChild(o)}))}})(n,0,s({sid:t,endpoint:f,language:r,ui:"inline",shouldCallValidateSession:void 0!==b})),A=(e,n,o)=>{if(!P)throw new Error("Unable to create action promise: checkout is undefined");return new Promise(((i,r)=>{const s=[];s.push(a({sid:t,endpoint:f,handler:e=>{s.forEach((e=>e.unsubscribe())),i(e)},eventTypes:[n],checkout:P})),s.push(a({sid:t,endpoint:f,handler:()=>{s.forEach((e=>e.unsubscribe())),r(`Received unexpected event: ${o}`)},eventTypes:[o],checkout:P})),e()}))},j=()=>A((()=>{((e,n)=>{e.contentWindow&&e.contentWindow.postMessage({type:"RefreshSession",sid:n},"*")})(_,t)}),o.SessionUpdated,o.SessionNotFound),L=e=>{((e,n,t)=>{e.contentWindow&&e.contentWindow.postMessage({type:"ValidationResult",sid:n,...t},"*")})(_,t,e)};return P={destroy:()=>{_&&(E.forEach((e=>e.unsubscribe())),_.parentElement&&n.removeChild(_))},iframe:_,language:r,lockSession:()=>A((()=>{((e,n)=>{e.contentWindow&&e.contentWindow.postMessage({type:"LockSession",sid:n},"*")})(_,t)}),o.SessionLocked,o.SessionLockFailed),refreshSession:j,setActivePaymentProductType:e=>{((e,n,t)=>{e.contentWindow&&e.contentWindow.postMessage({type:"SetActivePaymentProductType",sid:n,payment_product_type:t},"*")})(_,t,e)},submitValidationResult:L},[{handler:u,eventTypes:[i.LanguageChanged]},{handler:d,eventTypes:[i.HeightChanged]},{handler:h,eventTypes:[o.SessionLoaded,o.SessionUpdated]},{eventTypes:[o.SessionPaymentOnHold],handler:y?l(0,f,y):c},{eventTypes:[o.SessionPaymentAuthorized],handler:g||y?l(0,f,g||y):c},{handler:p?l(0,f,p):c,eventTypes:[o.SessionCancel]},{handler:m?l(0,f,m):c,eventTypes:[o.SessionPaymentError]},{handler:v,eventTypes:[o.SessionNotFound]},{handler:(e,n)=>{w&&w(e,n,j)},eventTypes:[o.SessionLocked]},{handler:S,eventTypes:[o.SessionLockFailed]},{handler:T,eventTypes:[o.ActivePaymentProductType]},{handler:T,eventTypes:[o.ActivePaymentProductType]},{handler:(e,n)=>{b&&b(e,n,L)},eventTypes:[o.ValidateSession]}].forEach((({handler:e,eventTypes:n})=>{e&&E.push(a({sid:t,endpoint:f,handler:e,eventTypes:n,checkout:P}))})),await k(),P},e.redirect=e=>{const{sid:n,language:t,endpoint:o="https://checkout.dintero.com"}=e;r(s({sid:n,endpoint:o,language:t,shouldCallValidateSession:!1}))},Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
7
7
|
//# sourceMappingURL=dintero-checkout-web-sdk.umd.min.js.map
|