Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@dintero/checkout-web-sdk

Package Overview
Dependencies
Maintainers
4
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dintero/checkout-web-sdk - npm Package Compare versions

Comparing version 0.0.17 to 0.2.0

.github/dependabot.yml

3

dist/declarations/package.d.ts

@@ -16,2 +16,3 @@ declare const _exports: {

test: string;
"semantic-release": string;
};

@@ -33,2 +34,3 @@ private: boolean;

"@preconstruct/cli": string;
"@semantic-release/git": string;
chai: string;

@@ -44,2 +46,3 @@ karma: string;

rollup: string;
"semantic-release": string;
sinon: string;

@@ -46,0 +49,0 @@ typescript: string;

@@ -12,3 +12,4 @@ import { Session } from "./session";

SessionLockFailed = "SessionLockFailed",
ActivePaymentProductType = "ActivePaymentProductType"
ActivePaymentProductType = "ActivePaymentProductType",
ValidateSession = "ValidateSession"
}

@@ -57,2 +58,12 @@ export declare enum InternalCheckoutEvents {

};
export declare type ValidateSession = {
type: CheckoutEvents.ValidateSession;
session: Session;
callback: (result: SessionValidationCallback) => void;
};
export interface SessionValidationCallback {
success: boolean;
clientValidationError?: string;
}
export declare type WrappedValidateSession = Pick<ValidateSession, "type" | "session">;
export declare type SessionPayment = SessionPaymentAuthorized | SessionPaymentOnHold;

@@ -64,2 +75,2 @@ export declare type SessionPaymentError = {

};
export declare type SessionEvent = SessionNotFound | SessionLoaded | SessionUpdated | SessionCancel | SessionPaymentOnHold | SessionPaymentAuthorized | SessionPaymentError | SessionLocked | SessionLockFailed | ActivePaymentProductType;
export declare type SessionEvent = SessionNotFound | SessionLoaded | SessionUpdated | SessionCancel | SessionPaymentOnHold | SessionPaymentAuthorized | SessionPaymentError | SessionLocked | SessionLockFailed | ActivePaymentProductType | WrappedValidateSession;

4

dist/declarations/src/index.d.ts
import "native-promise-only";
import { SessionNotFound, SessionLoaded, SessionUpdated, SessionCancel, SessionPaymentOnHold, SessionPaymentAuthorized, SessionPaymentError, SessionLocked, SessionLockFailed, ActivePaymentProductType } from "./checkout";
import { SessionNotFound, SessionLoaded, SessionUpdated, SessionCancel, SessionPaymentOnHold, SessionPaymentAuthorized, SessionPaymentError, SessionLocked, SessionLockFailed, ActivePaymentProductType, ValidateSession, SessionValidationCallback } from "./checkout";
export interface DinteroCheckoutInstance {

@@ -13,2 +13,3 @@ /**

setActivePaymentProductType: (paymentProductType: string) => void;
submitValidationResult: (result: SessionValidationCallback) => void;
}

@@ -34,2 +35,3 @@ export interface DinteroCheckoutOptions {

onActivePaymentType?: (event: ActivePaymentProductType, checkout: DinteroCheckoutInstance) => void;
onValidateSession?: (event: ValidateSession, checkout: DinteroCheckoutInstance, callback: (result: SessionValidationCallback) => void) => void;
}

@@ -36,0 +38,0 @@ /**

@@ -1,2 +0,2 @@

import { CheckoutEvents, InternalCheckoutEvents, SessionEvent } from "./checkout";
import { CheckoutEvents, InternalCheckoutEvents, SessionEvent, SessionValidationCallback } from "./checkout";
import { DinteroCheckoutInstance } from ".";

@@ -25,2 +25,6 @@ /**

/**
* Post the validation result to the checkout iframe
*/
export declare const postValidationResult: (iframe: HTMLIFrameElement, sid: string, result: SessionValidationCallback) => void;
/**
* Post RefreshSession-event to the checkout iframe.

@@ -27,0 +31,0 @@ */

@@ -14,3 +14,4 @@ /**

ui?: "fullscreen" | "inline";
shouldCallValidateSession: boolean;
}
export declare const getSessionUrl: (options: SessionUrlOptions) => string;

@@ -9,3 +9,3 @@ 'use strict';

name: "@dintero/checkout-web-sdk",
version: "0.0.17",
version: "0.0.0-development",
description: "Dintero Checkout SDK for web frontends",

@@ -22,3 +22,4 @@ main: "dist/dintero-checkout-web-sdk.cjs.js",

build: "preconstruct build",
test: "karma start"
test: "karma start",
"semantic-release": "semantic-release"
},

@@ -28,3 +29,3 @@ "private": false,

type: "git",
url: "git+https://github.com/Dintero/Dintero.Checkout.Web.SDK.git"
url: "https://github.com/Dintero/Dintero.Checkout.Web.SDK.git"
},

@@ -41,4 +42,5 @@ homepage: "https://github.com/Dintero/Dintero.Checkout.Web.SDK#readme",

"@preconstruct/cli": "^2.1.0",
"@semantic-release/git": "^10.0.1",
chai: "^4.2.0",
karma: "^5.1.1",
karma: "^6.3.14",
"karma-chai": "^0.1.0",

@@ -52,2 +54,3 @@ "karma-chrome-launcher": "^3.1.0",

rollup: "^1.30.1",
"semantic-release": "^19.0.2",
sinon: "^8.1.1",

@@ -74,2 +77,3 @@ typescript: "^4.2.4"

CheckoutEvents["ActivePaymentProductType"] = "ActivePaymentProductType";
CheckoutEvents["ValidateSession"] = "ValidateSession";
})(CheckoutEvents || (CheckoutEvents = {}));

@@ -101,3 +105,4 @@

language,
ui
ui,
shouldCallValidateSession
} = options;

@@ -113,3 +118,4 @@

let sdk = `sdk=${pkg.version}`;
const params = [languageParam, uiParam, sdk].filter(x => x).join("&");
let validate = shouldCallValidateSession ? `client_side_validation=true` : undefined;
const params = [languageParam, uiParam, sdk, validate].filter(x => x).join("&");
return `${endpoint}/v1/view/${sid}${params ? "?" + params : ""}`;

@@ -194,2 +200,15 @@ };

/**
* Post the validation result to the checkout iframe
*/
const postValidationResult = (iframe, sid, result) => {
if (iframe.contentWindow) {
iframe.contentWindow.postMessage({
type: "ValidationResult",
sid,
...result
}, "*");
}
};
/**
* Post RefreshSession-event to the checkout iframe.

@@ -319,3 +338,4 @@ */

onSessionLockFailed,
onActivePaymentType
onActivePaymentType,
onValidateSession
} = options;

@@ -327,7 +347,8 @@ const subscriptions = []; // Create iframe

initiate
} = await createIframeAsync(container, endpoint, getSessionUrl({
} = createIframeAsync(container, endpoint, getSessionUrl({
sid,
endpoint,
language,
ui: "inline"
ui: "inline",
shouldCallValidateSession: onValidateSession !== undefined
}));

@@ -358,2 +379,12 @@ /**

postActivePaymentProductType(iframe, sid, paymentProductType);
};
const submitValidationResult = result => {
postValidationResult(iframe, sid, result);
};
const wrappedOnValidateSession = (event, checkout) => {
if (onValidateSession) {
onValidateSession(event, checkout, submitValidationResult);
}
}; // Create checkout object that wraps the destroy function.

@@ -368,3 +399,4 @@

refreshSession,
setActivePaymentProductType
setActivePaymentProductType,
submitValidationResult
}; // Add event handlers (or in some cases add a fallback href handler).

@@ -405,2 +437,8 @@

eventTypes: [CheckoutEvents.ActivePaymentProductType]
}, {
handler: onActivePaymentType,
eventTypes: [CheckoutEvents.ActivePaymentProductType]
}, {
handler: wrappedOnValidateSession,
eventTypes: [CheckoutEvents.ValidateSession]
}].forEach(({

@@ -439,3 +477,4 @@ handler,

endpoint,
language
language,
shouldCallValidateSession: false
}));

@@ -442,0 +481,0 @@ };

@@ -9,3 +9,3 @@ 'use strict';

name: "@dintero/checkout-web-sdk",
version: "0.0.17",
version: "0.0.0-development",
description: "Dintero Checkout SDK for web frontends",

@@ -22,3 +22,4 @@ main: "dist/dintero-checkout-web-sdk.cjs.js",

build: "preconstruct build",
test: "karma start"
test: "karma start",
"semantic-release": "semantic-release"
},

@@ -28,3 +29,3 @@ "private": false,

type: "git",
url: "git+https://github.com/Dintero/Dintero.Checkout.Web.SDK.git"
url: "https://github.com/Dintero/Dintero.Checkout.Web.SDK.git"
},

@@ -41,4 +42,5 @@ homepage: "https://github.com/Dintero/Dintero.Checkout.Web.SDK#readme",

"@preconstruct/cli": "^2.1.0",
"@semantic-release/git": "^10.0.1",
chai: "^4.2.0",
karma: "^5.1.1",
karma: "^6.3.14",
"karma-chai": "^0.1.0",

@@ -52,2 +54,3 @@ "karma-chrome-launcher": "^3.1.0",

rollup: "^1.30.1",
"semantic-release": "^19.0.2",
sinon: "^8.1.1",

@@ -74,2 +77,3 @@ typescript: "^4.2.4"

CheckoutEvents["ActivePaymentProductType"] = "ActivePaymentProductType";
CheckoutEvents["ValidateSession"] = "ValidateSession";
})(CheckoutEvents || (CheckoutEvents = {}));

@@ -101,3 +105,4 @@

language,
ui
ui,
shouldCallValidateSession
} = options;

@@ -113,3 +118,4 @@

let sdk = `sdk=${pkg.version}`;
const params = [languageParam, uiParam, sdk].filter(x => x).join("&");
let validate = shouldCallValidateSession ? `client_side_validation=true` : undefined;
const params = [languageParam, uiParam, sdk, validate].filter(x => x).join("&");
return `${endpoint}/v1/view/${sid}${params ? "?" + params : ""}`;

@@ -194,2 +200,15 @@ };

/**
* Post the validation result to the checkout iframe
*/
const postValidationResult = (iframe, sid, result) => {
if (iframe.contentWindow) {
iframe.contentWindow.postMessage({
type: "ValidationResult",
sid,
...result
}, "*");
}
};
/**
* Post RefreshSession-event to the checkout iframe.

@@ -319,3 +338,4 @@ */

onSessionLockFailed,
onActivePaymentType
onActivePaymentType,
onValidateSession
} = options;

@@ -327,7 +347,8 @@ const subscriptions = []; // Create iframe

initiate
} = await createIframeAsync(container, endpoint, getSessionUrl({
} = createIframeAsync(container, endpoint, getSessionUrl({
sid,
endpoint,
language,
ui: "inline"
ui: "inline",
shouldCallValidateSession: onValidateSession !== undefined
}));

@@ -358,2 +379,12 @@ /**

postActivePaymentProductType(iframe, sid, paymentProductType);
};
const submitValidationResult = result => {
postValidationResult(iframe, sid, result);
};
const wrappedOnValidateSession = (event, checkout) => {
if (onValidateSession) {
onValidateSession(event, checkout, submitValidationResult);
}
}; // Create checkout object that wraps the destroy function.

@@ -368,3 +399,4 @@

refreshSession,
setActivePaymentProductType
setActivePaymentProductType,
submitValidationResult
}; // Add event handlers (or in some cases add a fallback href handler).

@@ -405,2 +437,8 @@

eventTypes: [CheckoutEvents.ActivePaymentProductType]
}, {
handler: onActivePaymentType,
eventTypes: [CheckoutEvents.ActivePaymentProductType]
}, {
handler: wrappedOnValidateSession,
eventTypes: [CheckoutEvents.ValidateSession]
}].forEach(({

@@ -439,3 +477,4 @@ handler,

endpoint,
language
language,
shouldCallValidateSession: false
}));

@@ -442,0 +481,0 @@ };

@@ -5,3 +5,3 @@ import 'native-promise-only';

name: "@dintero/checkout-web-sdk",
version: "0.0.17",
version: "0.0.0-development",
description: "Dintero Checkout SDK for web frontends",

@@ -18,3 +18,4 @@ main: "dist/dintero-checkout-web-sdk.cjs.js",

build: "preconstruct build",
test: "karma start"
test: "karma start",
"semantic-release": "semantic-release"
},

@@ -24,3 +25,3 @@ "private": false,

type: "git",
url: "git+https://github.com/Dintero/Dintero.Checkout.Web.SDK.git"
url: "https://github.com/Dintero/Dintero.Checkout.Web.SDK.git"
},

@@ -37,4 +38,5 @@ homepage: "https://github.com/Dintero/Dintero.Checkout.Web.SDK#readme",

"@preconstruct/cli": "^2.1.0",
"@semantic-release/git": "^10.0.1",
chai: "^4.2.0",
karma: "^5.1.1",
karma: "^6.3.14",
"karma-chai": "^0.1.0",

@@ -48,2 +50,3 @@ "karma-chrome-launcher": "^3.1.0",

rollup: "^1.30.1",
"semantic-release": "^19.0.2",
sinon: "^8.1.1",

@@ -70,2 +73,3 @@ typescript: "^4.2.4"

CheckoutEvents["ActivePaymentProductType"] = "ActivePaymentProductType";
CheckoutEvents["ValidateSession"] = "ValidateSession";
})(CheckoutEvents || (CheckoutEvents = {}));

@@ -97,3 +101,4 @@

language,
ui
ui,
shouldCallValidateSession
} = options;

@@ -109,3 +114,4 @@

let sdk = `sdk=${pkg.version}`;
const params = [languageParam, uiParam, sdk].filter(x => x).join("&");
let validate = shouldCallValidateSession ? `client_side_validation=true` : undefined;
const params = [languageParam, uiParam, sdk, validate].filter(x => x).join("&");
return `${endpoint}/v1/view/${sid}${params ? "?" + params : ""}`;

@@ -190,2 +196,15 @@ };

/**
* Post the validation result to the checkout iframe
*/
const postValidationResult = (iframe, sid, result) => {
if (iframe.contentWindow) {
iframe.contentWindow.postMessage({
type: "ValidationResult",
sid,
...result
}, "*");
}
};
/**
* Post RefreshSession-event to the checkout iframe.

@@ -315,3 +334,4 @@ */

onSessionLockFailed,
onActivePaymentType
onActivePaymentType,
onValidateSession
} = options;

@@ -323,7 +343,8 @@ const subscriptions = []; // Create iframe

initiate
} = await createIframeAsync(container, endpoint, getSessionUrl({
} = createIframeAsync(container, endpoint, getSessionUrl({
sid,
endpoint,
language,
ui: "inline"
ui: "inline",
shouldCallValidateSession: onValidateSession !== undefined
}));

@@ -354,2 +375,12 @@ /**

postActivePaymentProductType(iframe, sid, paymentProductType);
};
const submitValidationResult = result => {
postValidationResult(iframe, sid, result);
};
const wrappedOnValidateSession = (event, checkout) => {
if (onValidateSession) {
onValidateSession(event, checkout, submitValidationResult);
}
}; // Create checkout object that wraps the destroy function.

@@ -364,3 +395,4 @@

refreshSession,
setActivePaymentProductType
setActivePaymentProductType,
submitValidationResult
}; // Add event handlers (or in some cases add a fallback href handler).

@@ -401,2 +433,8 @@

eventTypes: [CheckoutEvents.ActivePaymentProductType]
}, {
handler: onActivePaymentType,
eventTypes: [CheckoutEvents.ActivePaymentProductType]
}, {
handler: wrappedOnValidateSession,
eventTypes: [CheckoutEvents.ValidateSession]
}].forEach(({

@@ -435,3 +473,4 @@ handler,

endpoint,
language
language,
shouldCallValidateSession: false
}));

@@ -438,0 +477,0 @@ };

@@ -6,3 +6,3 @@ !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).dintero={})}(this,(function(e){"use strict";var n="undefined"!=typeof globalThis?globalThis:"undefined"!="object"?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};!function(e,n,t){e(t={path:n,exports:{},require:function(e,n){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==n&&t.path)}},t.exports),t.exports}((function(e){

*/
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 l(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 l(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 f(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 l(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;f(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");f(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.0.17";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"}(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}=e;if(!o)throw new Error("Invalid endpoint");const s=[i?`language=${i}`:"",r?`ui=${r}`:"",`sdk=${t}`].filter((e=>e)).join("&");return`${o}/v1/view/${n}${s?"?"+s:""}`},a=e=>{e.href&&r(e.href)},c=(e,n)=>{(e.height||0===e.height)&&n.iframe.setAttribute("style",`width:100%; height:${e.height}px;`)},d=(e,n)=>{e.language&&(n.language=e.language)},u=(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:l,onSessionCancel:h,onPayment:p,onPaymentAuthorized:y,onPaymentError:g,onSessionNotFound:m,onSessionLocked:v,onSessionLockFailed:w,onActivePaymentType:S}=e,T=[],{iframe:b,initiate:P}=await((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"})),E={destroy:()=>{b&&(T.forEach((e=>e.unsubscribe())),b.parentElement&&n.removeChild(b))},iframe:b,language:r,lockSession:()=>{((e,n)=>{e.contentWindow&&e.contentWindow.postMessage({type:"LockSession",sid:n},"*")})(b,t)},refreshSession:()=>{((e,n)=>{e.contentWindow&&e.contentWindow.postMessage({type:"RefreshSession",sid:n},"*")})(b,t)},setActivePaymentProductType:e=>{((e,n,t)=>{e.contentWindow&&e.contentWindow.postMessage({type:"SetActivePaymentProductType",sid:n,payment_product_type:t},"*")})(b,t,e)}};return[{handler:d,eventTypes:[i.LanguageChanged]},{handler:c,eventTypes:[i.HeightChanged]},{handler:l,eventTypes:[o.SessionLoaded,o.SessionUpdated]},{eventTypes:[o.SessionPaymentOnHold],handler:p?u(0,f,p):a},{eventTypes:[o.SessionPaymentAuthorized],handler:y||p?u(0,f,y||p):a},{handler:h?u(0,f,h):a,eventTypes:[o.SessionCancel]},{handler:g?u(0,f,g):a,eventTypes:[o.SessionPaymentError]},{handler:m,eventTypes:[o.SessionNotFound]},{handler:v,eventTypes:[o.SessionLocked]},{handler:w,eventTypes:[o.SessionLockFailed]},{handler:S,eventTypes:[o.ActivePaymentProductType]}].forEach((({handler:e,eventTypes:n})=>{e&&T.push((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))};return window.addEventListener("message",s,!1),{unsubscribe:()=>{window.removeEventListener("message",s,!1)}}})({sid:t,endpoint:f,handler:e,eventTypes:n,checkout:E}))})),await P(),E},e.redirect=e=>{const{sid:n,language:t,endpoint:o="https://checkout.dintero.com"}=e;r(s({sid:n,endpoint:o,language:t}))},Object.defineProperty(e,"__esModule",{value:!0})}));
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.0.0-development";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=>{e.href&&r(e.href)},c=(e,n)=>{(e.height||0===e.height)&&n.iframe.setAttribute("style",`width:100%; height:${e.height}px;`)},d=(e,n)=>{e.language&&(n.language=e.language)},u=(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:l="https://checkout.dintero.com",onSession:f,onSessionCancel:h,onPayment:p,onPaymentAuthorized:y,onPaymentError:g,onSessionNotFound:m,onSessionLocked:v,onSessionLockFailed:w,onActivePaymentType:S,onValidateSession:T}=e,b=[],{iframe:P,initiate:_}=((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:l,language:r,ui:"inline",shouldCallValidateSession:void 0!==T})),E=e=>{((e,n,t)=>{e.contentWindow&&e.contentWindow.postMessage({type:"ValidationResult",sid:n,...t},"*")})(P,t,e)},A={destroy:()=>{P&&(b.forEach((e=>e.unsubscribe())),P.parentElement&&n.removeChild(P))},iframe:P,language:r,lockSession:()=>{((e,n)=>{e.contentWindow&&e.contentWindow.postMessage({type:"LockSession",sid:n},"*")})(P,t)},refreshSession:()=>{((e,n)=>{e.contentWindow&&e.contentWindow.postMessage({type:"RefreshSession",sid:n},"*")})(P,t)},setActivePaymentProductType:e=>{((e,n,t)=>{e.contentWindow&&e.contentWindow.postMessage({type:"SetActivePaymentProductType",sid:n,payment_product_type:t},"*")})(P,t,e)},submitValidationResult:E};return[{handler:d,eventTypes:[i.LanguageChanged]},{handler:c,eventTypes:[i.HeightChanged]},{handler:f,eventTypes:[o.SessionLoaded,o.SessionUpdated]},{eventTypes:[o.SessionPaymentOnHold],handler:p?u(0,l,p):a},{eventTypes:[o.SessionPaymentAuthorized],handler:y||p?u(0,l,y||p):a},{handler:h?u(0,l,h):a,eventTypes:[o.SessionCancel]},{handler:g?u(0,l,g):a,eventTypes:[o.SessionPaymentError]},{handler:m,eventTypes:[o.SessionNotFound]},{handler:v,eventTypes:[o.SessionLocked]},{handler:w,eventTypes:[o.SessionLockFailed]},{handler:S,eventTypes:[o.ActivePaymentProductType]},{handler:S,eventTypes:[o.ActivePaymentProductType]},{handler:(e,n)=>{T&&T(e,n,E)},eventTypes:[o.ValidateSession]}].forEach((({handler:e,eventTypes:n})=>{e&&b.push((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))};return window.addEventListener("message",s,!1),{unsubscribe:()=>{window.removeEventListener("message",s,!1)}}})({sid:t,endpoint:l,handler:e,eventTypes:n,checkout:A}))})),await _(),A},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})}));
//# sourceMappingURL=dintero-checkout-web-sdk.umd.min.js.map
{
"name": "@dintero/checkout-web-sdk",
"version": "0.0.17",
"description": "Dintero Checkout SDK for web frontends",
"main": "dist/dintero-checkout-web-sdk.cjs.js",
"module": "dist/dintero-checkout-web-sdk.esm.js",
"umd:main": "dist/dintero-checkout-web-sdk.umd.min.js",
"unpkg": "dist/dintero-checkout-web-sdk.umd.min.js",
"types": "dist/dintero-checkout-web-sdk.cjs.d.ts",
"preconstruct": {
"umdName": "dintero"
},
"scripts": {
"build": "preconstruct build",
"test": "karma start"
},
"private": false,
"repository": {
"type": "git",
"url": "git+https://github.com/Dintero/Dintero.Checkout.Web.SDK.git"
},
"homepage": "https://github.com/Dintero/Dintero.Checkout.Web.SDK#readme",
"author": "Sven Nicolai Viig <sven@dintero.com> (http://dintero.com)",
"license": "MIT",
"bugs": {
"url": "https://github.com/Dintero/Dintero.Checkout.Web.SDK/issues"
},
"devDependencies": {
"@babel/preset-env": "^7.14.1",
"@babel/preset-typescript": "^7.13.0",
"@preconstruct/cli": "^2.1.0",
"chai": "^4.2.0",
"karma": "^5.1.1",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^3.1.0",
"karma-mocha": "^2.0.1",
"karma-typescript": "^5.0.3",
"mocha": "^8.1.1",
"prettier": "^1.19.1",
"puppeteer": "^2.1.0",
"rollup": "^1.30.1",
"sinon": "^8.1.1",
"typescript": "^4.2.4"
},
"dependencies": {
"native-promise-only": "^0.8.1"
}
"name": "@dintero/checkout-web-sdk",
"version": "0.2.0",
"description": "Dintero Checkout SDK for web frontends",
"main": "dist/dintero-checkout-web-sdk.cjs.js",
"module": "dist/dintero-checkout-web-sdk.esm.js",
"umd:main": "dist/dintero-checkout-web-sdk.umd.min.js",
"unpkg": "dist/dintero-checkout-web-sdk.umd.min.js",
"types": "dist/dintero-checkout-web-sdk.cjs.d.ts",
"preconstruct": {
"umdName": "dintero"
},
"scripts": {
"build": "preconstruct build",
"test": "karma start",
"semantic-release": "semantic-release"
},
"private": false,
"repository": {
"type": "git",
"url": "https://github.com/Dintero/Dintero.Checkout.Web.SDK.git"
},
"homepage": "https://github.com/Dintero/Dintero.Checkout.Web.SDK#readme",
"author": "Sven Nicolai Viig <sven@dintero.com> (http://dintero.com)",
"license": "MIT",
"bugs": {
"url": "https://github.com/Dintero/Dintero.Checkout.Web.SDK/issues"
},
"devDependencies": {
"@babel/preset-env": "^7.14.1",
"@babel/preset-typescript": "^7.13.0",
"@preconstruct/cli": "^2.1.0",
"@semantic-release/git": "^10.0.1",
"chai": "^4.2.0",
"karma": "^6.3.14",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^3.1.0",
"karma-mocha": "^2.0.1",
"karma-typescript": "^5.0.3",
"mocha": "^8.1.1",
"prettier": "^1.19.1",
"puppeteer": "^2.1.0",
"rollup": "^1.30.1",
"semantic-release": "^19.0.2",
"sinon": "^8.1.1",
"typescript": "^4.2.4"
},
"dependencies": {
"native-promise-only": "^0.8.1"
}
}

@@ -28,10 +28,2 @@ # Dintero Checkout JavaScript SDK for frontend applications [![Actions Status](https://github.com/Dintero/Dintero.Checkout.Web.SDK/workflows/CI/badge.svg?branch=master)](https://github.com/Dintero/Dintero.Checkout.Web.SDK/actions?query=branch%3Amaster+workflow%3ACI+)

**unpkg**
Load the Dintero Checkout SDK in a script tag on your site.
```
<script src="https://unpkg.com/@dintero/checkout-web-sdk@0.0.17/dist/dintero-checkout-web-sdk.umd.min.js" integrity="sha384-C+s7429Bxo4cmt8Tt3N5MRR4fZ/OsEBHDJaHwOnhlizydtc7wgCGvH5u5cXnjSSx"></script>
```
## Using the SDK for an embedded checkout

@@ -94,2 +86,9 @@

},
onValidateSession: function(event, checkout, callback) {
console.log("validating session", event.session);
callback({
success: true,
clientValidationError: undefined,
});
},
})

@@ -145,2 +144,9 @@ .then(function(checkout) {

},
onValidateSession: function(event, checkout, callback) {
console.log("validating session", event.session);
callback({
success: true,
clientValidationError: undefined,
});
},
});

@@ -198,2 +204,37 @@ ```

### Validating session before payment
To validate the session and perform actions before the session is paid, use the `onSessionValidation`-handler.
The checkout will be locked and payment will be paused until the provided callback function is called, or `checkout.submitValidationResult` is called with the result.
When validated successfully, return a successful result:
```js
{
success: true
}
```
If the validation is not successful, return the result with an error message:
```js
{
success: false,
clientValidationError: "session is not in sync with cart"
}
```
Example implementation:
```
onValidateSession: function(event, checkout, callback) {
// Call the ecommerce solution to make sure the session is sync with the cart
callback({
success: false,
clientValidationError: "session is not in sync with cart",
});
},
```
## Using the SDK for a redirect checkout

@@ -234,9 +275,5 @@

## Creating a new release checklist
## Creating a new release
1. Bump the package version in `package.json`.
2. Regenerate integrity hash and update the unpgk install instructions in this file `shasum -b -a 384 dist/dintero-checkout-web-sdk.umd.min.js | awk '{ print $1 }' | xxd -r -p | base64 | sed "s/^/sha384-/g"`
3. Update README.md with new version/sha
4. Publish new version to npm with `npm publish --access=public`.
5. Tag and create release in Github
`git tag "v$(jq .version -r < package.json)"`
1. Enforce all commits to the master branch to be formatted according to the [Angular Commit Message Format](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#-commit-message-format)
2. When merged to master, it will automatically be released with [semantic-release](https://github.com/semantic-release/semantic-release)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc