@paystack/inline-js 2.29.0-dev.1 → 2.29.0-dev.2
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/dist/inline.js +20 -12
- package/es/inline.js +20 -12
- package/lib/inline.js +20 -12
- package/package.json +1 -1
package/dist/inline.js
CHANGED
|
@@ -1978,6 +1978,11 @@ var PaystackPop = (function () {
|
|
|
1978
1978
|
_excluded2 = ["container", "styles", "onElementsMount"],
|
|
1979
1979
|
_excluded3 = ["data"];
|
|
1980
1980
|
var inlineInstance;
|
|
1981
|
+
var CHECKOUT_ORIGIN = new URL(config.checkoutUrl).origin;
|
|
1982
|
+
var SITE_ORIGIN = new URL(config.siteUrl).origin;
|
|
1983
|
+
function postToCheckout(checkoutIframe, message) {
|
|
1984
|
+
checkoutIframe.contentWindow.postMessage(message, CHECKOUT_ORIGIN);
|
|
1985
|
+
}
|
|
1981
1986
|
function findResumableTransaction(transactions, parameters) {
|
|
1982
1987
|
if (!transactions.length) {
|
|
1983
1988
|
return null;
|
|
@@ -1996,11 +2001,11 @@ var PaystackPop = (function () {
|
|
|
1996
2001
|
if (!checkoutIframe || !urlParameters) {
|
|
1997
2002
|
return;
|
|
1998
2003
|
}
|
|
1999
|
-
checkoutIframe
|
|
2004
|
+
postToCheckout(checkoutIframe, {
|
|
2000
2005
|
type: 'inline:url',
|
|
2001
2006
|
path: 'newTransaction',
|
|
2002
2007
|
params: urlParameters
|
|
2003
|
-
}
|
|
2008
|
+
});
|
|
2004
2009
|
}
|
|
2005
2010
|
var analyticsActions = {
|
|
2006
2011
|
TRACK_PAYMENT_ERROR: 'trackPaymentError',
|
|
@@ -2020,6 +2025,7 @@ var PaystackPop = (function () {
|
|
|
2020
2025
|
this.isLoaded = false;
|
|
2021
2026
|
this.isCharging = false;
|
|
2022
2027
|
this.isDeprecatedApi = params && params.isDeprecatedApi; // track deprecatedApi
|
|
2028
|
+
this.embedIframes = [];
|
|
2023
2029
|
if (params && params.isEmbed) {
|
|
2024
2030
|
this.isEmbed = true;
|
|
2025
2031
|
} else if (params && params.isPaymentRequest) {
|
|
@@ -2038,12 +2044,13 @@ var PaystackPop = (function () {
|
|
|
2038
2044
|
value: function registerListeners() {
|
|
2039
2045
|
var _this = this;
|
|
2040
2046
|
window.addEventListener('message', function (event) {
|
|
2041
|
-
var
|
|
2042
|
-
var
|
|
2043
|
-
|
|
2044
|
-
|
|
2047
|
+
var isFromThisCheckout = event.origin === CHECKOUT_ORIGIN && _this.checkoutIframe && _this.checkoutIframe.contentWindow === event.source;
|
|
2048
|
+
var isFromThisEmbed = event.origin === SITE_ORIGIN && _this.embedIframes.some(function (iframe) {
|
|
2049
|
+
return iframe.contentWindow === event.source;
|
|
2050
|
+
});
|
|
2051
|
+
if (isFromThisCheckout) {
|
|
2045
2052
|
_this.respondToEvent(event);
|
|
2046
|
-
} else if (
|
|
2053
|
+
} else if (isFromThisEmbed) {
|
|
2047
2054
|
_this.respondToEmbedEvents(event);
|
|
2048
2055
|
}
|
|
2049
2056
|
});
|
|
@@ -2051,11 +2058,11 @@ var PaystackPop = (function () {
|
|
|
2051
2058
|
}, {
|
|
2052
2059
|
key: "sendAnalyticsEventToCheckout",
|
|
2053
2060
|
value: function sendAnalyticsEventToCheckout(action, params) {
|
|
2054
|
-
this.checkoutIframe
|
|
2061
|
+
postToCheckout(this.checkoutIframe, {
|
|
2055
2062
|
type: 'analytics',
|
|
2056
2063
|
action: action,
|
|
2057
2064
|
params: params
|
|
2058
|
-
}
|
|
2065
|
+
});
|
|
2059
2066
|
}
|
|
2060
2067
|
}, {
|
|
2061
2068
|
key: "checkout",
|
|
@@ -2585,7 +2592,7 @@ var PaystackPop = (function () {
|
|
|
2585
2592
|
checkoutIframe: checkoutIframe,
|
|
2586
2593
|
backgroundIframe: backgroundIframe
|
|
2587
2594
|
}).then(function () {
|
|
2588
|
-
_this6.checkoutIframe
|
|
2595
|
+
postToCheckout(_this6.checkoutIframe, 'render');
|
|
2589
2596
|
});
|
|
2590
2597
|
this.isOpen = true;
|
|
2591
2598
|
}
|
|
@@ -2618,7 +2625,7 @@ var PaystackPop = (function () {
|
|
|
2618
2625
|
checkoutIframe: checkoutIframe,
|
|
2619
2626
|
backgroundIframe: backgroundIframe
|
|
2620
2627
|
}).then(function () {
|
|
2621
|
-
_this7.checkoutIframe
|
|
2628
|
+
postToCheckout(_this7.checkoutIframe, 'close');
|
|
2622
2629
|
});
|
|
2623
2630
|
this.isOpen = false;
|
|
2624
2631
|
}
|
|
@@ -2644,9 +2651,10 @@ var PaystackPop = (function () {
|
|
|
2644
2651
|
if (isEmbed) {
|
|
2645
2652
|
var inlineUrl = "".concat(config.siteUrl, "/assets/payment/production/inline.html?").concat(serialize(urlParameters));
|
|
2646
2653
|
var iframe = mountEmbedCheckoutIframe(inlineInstance.id, inlineUrl);
|
|
2654
|
+
inlineInstance.embedIframes.push(iframe);
|
|
2647
2655
|
appendIframeToContainer(parameters.container, iframe);
|
|
2648
2656
|
iframe.onload = function onLoad() {
|
|
2649
|
-
iframe.contentWindow.postMessage("PaystackOpen ".concat(inlineInstance.id),
|
|
2657
|
+
iframe.contentWindow.postMessage("PaystackOpen ".concat(inlineInstance.id), SITE_ORIGIN);
|
|
2650
2658
|
animateEmbedCheckoutIn(iframe);
|
|
2651
2659
|
};
|
|
2652
2660
|
} else {
|
package/es/inline.js
CHANGED
|
@@ -1975,6 +1975,11 @@ var _excluded = ["preload", "inlineTransaction", "transactionData"],
|
|
|
1975
1975
|
_excluded2 = ["container", "styles", "onElementsMount"],
|
|
1976
1976
|
_excluded3 = ["data"];
|
|
1977
1977
|
var inlineInstance;
|
|
1978
|
+
var CHECKOUT_ORIGIN = new URL(config.checkoutUrl).origin;
|
|
1979
|
+
var SITE_ORIGIN = new URL(config.siteUrl).origin;
|
|
1980
|
+
function postToCheckout(checkoutIframe, message) {
|
|
1981
|
+
checkoutIframe.contentWindow.postMessage(message, CHECKOUT_ORIGIN);
|
|
1982
|
+
}
|
|
1978
1983
|
function findResumableTransaction(transactions, parameters) {
|
|
1979
1984
|
if (!transactions.length) {
|
|
1980
1985
|
return null;
|
|
@@ -1993,11 +1998,11 @@ function notifyIframeToUpdateURL(options) {
|
|
|
1993
1998
|
if (!checkoutIframe || !urlParameters) {
|
|
1994
1999
|
return;
|
|
1995
2000
|
}
|
|
1996
|
-
checkoutIframe
|
|
2001
|
+
postToCheckout(checkoutIframe, {
|
|
1997
2002
|
type: 'inline:url',
|
|
1998
2003
|
path: 'newTransaction',
|
|
1999
2004
|
params: urlParameters
|
|
2000
|
-
}
|
|
2005
|
+
});
|
|
2001
2006
|
}
|
|
2002
2007
|
var analyticsActions = {
|
|
2003
2008
|
TRACK_PAYMENT_ERROR: 'trackPaymentError',
|
|
@@ -2017,6 +2022,7 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2017
2022
|
this.isLoaded = false;
|
|
2018
2023
|
this.isCharging = false;
|
|
2019
2024
|
this.isDeprecatedApi = params && params.isDeprecatedApi; // track deprecatedApi
|
|
2025
|
+
this.embedIframes = [];
|
|
2020
2026
|
if (params && params.isEmbed) {
|
|
2021
2027
|
this.isEmbed = true;
|
|
2022
2028
|
} else if (params && params.isPaymentRequest) {
|
|
@@ -2035,12 +2041,13 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2035
2041
|
value: function registerListeners() {
|
|
2036
2042
|
var _this = this;
|
|
2037
2043
|
window.addEventListener('message', function (event) {
|
|
2038
|
-
var
|
|
2039
|
-
var
|
|
2040
|
-
|
|
2041
|
-
|
|
2044
|
+
var isFromThisCheckout = event.origin === CHECKOUT_ORIGIN && _this.checkoutIframe && _this.checkoutIframe.contentWindow === event.source;
|
|
2045
|
+
var isFromThisEmbed = event.origin === SITE_ORIGIN && _this.embedIframes.some(function (iframe) {
|
|
2046
|
+
return iframe.contentWindow === event.source;
|
|
2047
|
+
});
|
|
2048
|
+
if (isFromThisCheckout) {
|
|
2042
2049
|
_this.respondToEvent(event);
|
|
2043
|
-
} else if (
|
|
2050
|
+
} else if (isFromThisEmbed) {
|
|
2044
2051
|
_this.respondToEmbedEvents(event);
|
|
2045
2052
|
}
|
|
2046
2053
|
});
|
|
@@ -2048,11 +2055,11 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2048
2055
|
}, {
|
|
2049
2056
|
key: "sendAnalyticsEventToCheckout",
|
|
2050
2057
|
value: function sendAnalyticsEventToCheckout(action, params) {
|
|
2051
|
-
this.checkoutIframe
|
|
2058
|
+
postToCheckout(this.checkoutIframe, {
|
|
2052
2059
|
type: 'analytics',
|
|
2053
2060
|
action: action,
|
|
2054
2061
|
params: params
|
|
2055
|
-
}
|
|
2062
|
+
});
|
|
2056
2063
|
}
|
|
2057
2064
|
}, {
|
|
2058
2065
|
key: "checkout",
|
|
@@ -2582,7 +2589,7 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2582
2589
|
checkoutIframe: checkoutIframe,
|
|
2583
2590
|
backgroundIframe: backgroundIframe
|
|
2584
2591
|
}).then(function () {
|
|
2585
|
-
_this6.checkoutIframe
|
|
2592
|
+
postToCheckout(_this6.checkoutIframe, 'render');
|
|
2586
2593
|
});
|
|
2587
2594
|
this.isOpen = true;
|
|
2588
2595
|
}
|
|
@@ -2615,7 +2622,7 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2615
2622
|
checkoutIframe: checkoutIframe,
|
|
2616
2623
|
backgroundIframe: backgroundIframe
|
|
2617
2624
|
}).then(function () {
|
|
2618
|
-
_this7.checkoutIframe
|
|
2625
|
+
postToCheckout(_this7.checkoutIframe, 'close');
|
|
2619
2626
|
});
|
|
2620
2627
|
this.isOpen = false;
|
|
2621
2628
|
}
|
|
@@ -2641,9 +2648,10 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2641
2648
|
if (isEmbed) {
|
|
2642
2649
|
var inlineUrl = "".concat(config.siteUrl, "/assets/payment/production/inline.html?").concat(serialize(urlParameters));
|
|
2643
2650
|
var iframe = mountEmbedCheckoutIframe(inlineInstance.id, inlineUrl);
|
|
2651
|
+
inlineInstance.embedIframes.push(iframe);
|
|
2644
2652
|
appendIframeToContainer(parameters.container, iframe);
|
|
2645
2653
|
iframe.onload = function onLoad() {
|
|
2646
|
-
iframe.contentWindow.postMessage("PaystackOpen ".concat(inlineInstance.id),
|
|
2654
|
+
iframe.contentWindow.postMessage("PaystackOpen ".concat(inlineInstance.id), SITE_ORIGIN);
|
|
2647
2655
|
animateEmbedCheckoutIn(iframe);
|
|
2648
2656
|
};
|
|
2649
2657
|
} else {
|
package/lib/inline.js
CHANGED
|
@@ -1977,6 +1977,11 @@ var _excluded = ["preload", "inlineTransaction", "transactionData"],
|
|
|
1977
1977
|
_excluded2 = ["container", "styles", "onElementsMount"],
|
|
1978
1978
|
_excluded3 = ["data"];
|
|
1979
1979
|
var inlineInstance;
|
|
1980
|
+
var CHECKOUT_ORIGIN = new URL(config.checkoutUrl).origin;
|
|
1981
|
+
var SITE_ORIGIN = new URL(config.siteUrl).origin;
|
|
1982
|
+
function postToCheckout(checkoutIframe, message) {
|
|
1983
|
+
checkoutIframe.contentWindow.postMessage(message, CHECKOUT_ORIGIN);
|
|
1984
|
+
}
|
|
1980
1985
|
function findResumableTransaction(transactions, parameters) {
|
|
1981
1986
|
if (!transactions.length) {
|
|
1982
1987
|
return null;
|
|
@@ -1995,11 +2000,11 @@ function notifyIframeToUpdateURL(options) {
|
|
|
1995
2000
|
if (!checkoutIframe || !urlParameters) {
|
|
1996
2001
|
return;
|
|
1997
2002
|
}
|
|
1998
|
-
checkoutIframe
|
|
2003
|
+
postToCheckout(checkoutIframe, {
|
|
1999
2004
|
type: 'inline:url',
|
|
2000
2005
|
path: 'newTransaction',
|
|
2001
2006
|
params: urlParameters
|
|
2002
|
-
}
|
|
2007
|
+
});
|
|
2003
2008
|
}
|
|
2004
2009
|
var analyticsActions = {
|
|
2005
2010
|
TRACK_PAYMENT_ERROR: 'trackPaymentError',
|
|
@@ -2019,6 +2024,7 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2019
2024
|
this.isLoaded = false;
|
|
2020
2025
|
this.isCharging = false;
|
|
2021
2026
|
this.isDeprecatedApi = params && params.isDeprecatedApi; // track deprecatedApi
|
|
2027
|
+
this.embedIframes = [];
|
|
2022
2028
|
if (params && params.isEmbed) {
|
|
2023
2029
|
this.isEmbed = true;
|
|
2024
2030
|
} else if (params && params.isPaymentRequest) {
|
|
@@ -2037,12 +2043,13 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2037
2043
|
value: function registerListeners() {
|
|
2038
2044
|
var _this = this;
|
|
2039
2045
|
window.addEventListener('message', function (event) {
|
|
2040
|
-
var
|
|
2041
|
-
var
|
|
2042
|
-
|
|
2043
|
-
|
|
2046
|
+
var isFromThisCheckout = event.origin === CHECKOUT_ORIGIN && _this.checkoutIframe && _this.checkoutIframe.contentWindow === event.source;
|
|
2047
|
+
var isFromThisEmbed = event.origin === SITE_ORIGIN && _this.embedIframes.some(function (iframe) {
|
|
2048
|
+
return iframe.contentWindow === event.source;
|
|
2049
|
+
});
|
|
2050
|
+
if (isFromThisCheckout) {
|
|
2044
2051
|
_this.respondToEvent(event);
|
|
2045
|
-
} else if (
|
|
2052
|
+
} else if (isFromThisEmbed) {
|
|
2046
2053
|
_this.respondToEmbedEvents(event);
|
|
2047
2054
|
}
|
|
2048
2055
|
});
|
|
@@ -2050,11 +2057,11 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2050
2057
|
}, {
|
|
2051
2058
|
key: "sendAnalyticsEventToCheckout",
|
|
2052
2059
|
value: function sendAnalyticsEventToCheckout(action, params) {
|
|
2053
|
-
this.checkoutIframe
|
|
2060
|
+
postToCheckout(this.checkoutIframe, {
|
|
2054
2061
|
type: 'analytics',
|
|
2055
2062
|
action: action,
|
|
2056
2063
|
params: params
|
|
2057
|
-
}
|
|
2064
|
+
});
|
|
2058
2065
|
}
|
|
2059
2066
|
}, {
|
|
2060
2067
|
key: "checkout",
|
|
@@ -2584,7 +2591,7 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2584
2591
|
checkoutIframe: checkoutIframe,
|
|
2585
2592
|
backgroundIframe: backgroundIframe
|
|
2586
2593
|
}).then(function () {
|
|
2587
|
-
_this6.checkoutIframe
|
|
2594
|
+
postToCheckout(_this6.checkoutIframe, 'render');
|
|
2588
2595
|
});
|
|
2589
2596
|
this.isOpen = true;
|
|
2590
2597
|
}
|
|
@@ -2617,7 +2624,7 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2617
2624
|
checkoutIframe: checkoutIframe,
|
|
2618
2625
|
backgroundIframe: backgroundIframe
|
|
2619
2626
|
}).then(function () {
|
|
2620
|
-
_this7.checkoutIframe
|
|
2627
|
+
postToCheckout(_this7.checkoutIframe, 'close');
|
|
2621
2628
|
});
|
|
2622
2629
|
this.isOpen = false;
|
|
2623
2630
|
}
|
|
@@ -2643,9 +2650,10 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2643
2650
|
if (isEmbed) {
|
|
2644
2651
|
var inlineUrl = "".concat(config.siteUrl, "/assets/payment/production/inline.html?").concat(serialize(urlParameters));
|
|
2645
2652
|
var iframe = mountEmbedCheckoutIframe(inlineInstance.id, inlineUrl);
|
|
2653
|
+
inlineInstance.embedIframes.push(iframe);
|
|
2646
2654
|
appendIframeToContainer(parameters.container, iframe);
|
|
2647
2655
|
iframe.onload = function onLoad() {
|
|
2648
|
-
iframe.contentWindow.postMessage("PaystackOpen ".concat(inlineInstance.id),
|
|
2656
|
+
iframe.contentWindow.postMessage("PaystackOpen ".concat(inlineInstance.id), SITE_ORIGIN);
|
|
2649
2657
|
animateEmbedCheckoutIn(iframe);
|
|
2650
2658
|
};
|
|
2651
2659
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paystack/inline-js",
|
|
3
|
-
"version": "2.29.0-dev.
|
|
3
|
+
"version": "2.29.0-dev.2",
|
|
4
4
|
"description": "Client-side library to load the Paystack checkout form",
|
|
5
5
|
"packageManager": "pnpm@10.33.4+sha512.1c67b3b359b2d408119ba1ed289f34b8fc3c6873412bec6fd264fbdc82489e510fcbecb9ce9d22dae7f3b76269d8441046014bdca53b9979cd7a561ad631b800",
|
|
6
6
|
"main": "lib/inline.js",
|