@paystack/inline-js 2.25.0-dev.2 → 2.25.0-dev.4
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 +48 -25
- package/es/inline.js +48 -25
- package/lib/inline.js +48 -25
- package/package.json +1 -1
package/dist/inline.js
CHANGED
|
@@ -353,7 +353,7 @@ var PaystackPop = (function () {
|
|
|
353
353
|
return buttonHTML;
|
|
354
354
|
}
|
|
355
355
|
var defaultCustomApplePayStyles = {
|
|
356
|
-
height:
|
|
356
|
+
height: PAYMENT_REQUEST_BUTTON_HEIGHT,
|
|
357
357
|
width: 'auto',
|
|
358
358
|
borderRadius: '3px',
|
|
359
359
|
padding: '10px',
|
|
@@ -387,14 +387,17 @@ var PaystackPop = (function () {
|
|
|
387
387
|
};
|
|
388
388
|
var generatePaymentRequestInnerWrapperCSS = function generatePaymentRequestInnerWrapperCSS(orientation) {
|
|
389
389
|
var isVertical = orientation === PAYMENT_REQUEST_BUTTON_ORIENTATION.VERTICAL;
|
|
390
|
-
return "\n #paystack-payment-request-inner-wrapper {\n display: flex;\n flex-direction: ".concat(isVertical ? 'column' : 'row', ";\n gap: 8px;\n width: 100%;\n max-width: 100%;\n ").concat(isVertical ? '' :
|
|
390
|
+
return "\n #paystack-payment-request-inner-wrapper {\n display: flex;\n flex-direction: ".concat(isVertical ? 'column' : 'row', ";\n gap: 8px;\n width: 100%;\n max-width: 100%;\n ").concat(isVertical ? '' : 'flex: 1 1 0', ";\n }\n\n #paystack-payment-request-inner-wrapper > * {\n min-width: 0;\n }\n\n #paystack-payment-request-inner-wrapper > apple-pay-button,\n #paystack-payment-request-inner-wrapper > #apple-pay-button {\n order: 1;\n }\n #paystack-payment-request-inner-wrapper > #google-pay-button-container {\n order: 2;\n }\n");
|
|
391
391
|
};
|
|
392
392
|
var generateGooglePayCSS = function generateGooglePayCSS() {
|
|
393
|
-
|
|
393
|
+
var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
394
|
+
height = _ref3.height,
|
|
395
|
+
width = _ref3.width;
|
|
396
|
+
return "\n #google-pay-button-container {\n width: ".concat(width || 'auto', ";\n height: ").concat(height || PAYMENT_REQUEST_BUTTON_HEIGHT, ";\n overflow: hidden;\n }\n #google-pay-button-container:empty {\n display: none;\n }\n #google-pay-button-container > div,\n #google-pay-button-container button,\n #google-pay-button-container iframe {\n width: 100%;\n max-width: 100%;\n height: 100%;\n min-width: 100%;\n }\n #google-pay-button-container button {\n outline: none !important;\n }\n");
|
|
394
397
|
};
|
|
395
398
|
var generateGooglePayLoadingCSS = function generateGooglePayLoadingCSS() {
|
|
396
|
-
var
|
|
397
|
-
borderRadius =
|
|
399
|
+
var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
400
|
+
borderRadius = _ref4.borderRadius;
|
|
398
401
|
return "\n #google-pay-loading-button {\n width: 100%;\n height: 100%;\n border: none;\n border-radius: ".concat(borderRadius === undefined ? GOOGLE_PAY_BUTTON_RADIUS : borderRadius, "px;\n background: #000000;\n cursor: default;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n #google-pay-loading-button__spinner {\n width: 18px;\n height: 18px;\n border: 2px solid rgba(255, 255, 255, 0.35);\n border-top-color: #ffffff;\n border-radius: 50%;\n animation: google-pay-spin 0.8s linear infinite;\n }\n @keyframes google-pay-spin {\n to { transform: rotate(360deg); }\n }\n");
|
|
399
402
|
};
|
|
400
403
|
function appendCSS(container, css) {
|
|
@@ -734,6 +737,7 @@ var PaystackPop = (function () {
|
|
|
734
737
|
});
|
|
735
738
|
};
|
|
736
739
|
|
|
740
|
+
var _excluded$2 = ["height", "width"];
|
|
737
741
|
function createIframe(id) {
|
|
738
742
|
var iframe = document.createElement('iframe');
|
|
739
743
|
iframe.setAttribute('frameBorder', '0');
|
|
@@ -917,12 +921,12 @@ var PaystackPop = (function () {
|
|
|
917
921
|
if (!container) {
|
|
918
922
|
return;
|
|
919
923
|
}
|
|
920
|
-
var
|
|
924
|
+
var button = container.querySelector('#google-pay-button');
|
|
921
925
|
var loadingButton = container.querySelector('#google-pay-loading-button');
|
|
922
|
-
if (!
|
|
926
|
+
if (!button || !loadingButton) {
|
|
923
927
|
return;
|
|
924
928
|
}
|
|
925
|
-
|
|
929
|
+
button.style.display = isLoading ? 'none' : '';
|
|
926
930
|
loadingButton.style.display = isLoading ? 'flex' : 'none';
|
|
927
931
|
}
|
|
928
932
|
function mountGooglePayButton(container, _ref3) {
|
|
@@ -930,9 +934,15 @@ var PaystackPop = (function () {
|
|
|
930
934
|
_ref3$styles = _ref3.styles,
|
|
931
935
|
styles = _ref3$styles === void 0 ? {} : _ref3$styles,
|
|
932
936
|
onClick = _ref3.onClick;
|
|
933
|
-
var
|
|
937
|
+
var _ref4 = styles.googlePay || {},
|
|
938
|
+
height = _ref4.height,
|
|
939
|
+
width = _ref4.width,
|
|
940
|
+
googlePayStyles = _objectWithoutProperties(_ref4, _excluded$2);
|
|
934
941
|
var googlePayConfig = getGooglePayConfig(transaction);
|
|
935
|
-
appendCSS(container, generateGooglePayCSS(
|
|
942
|
+
appendCSS(container, generateGooglePayCSS({
|
|
943
|
+
height: height,
|
|
944
|
+
width: width
|
|
945
|
+
}));
|
|
936
946
|
appendCSS(container, generateGooglePayLoadingCSS({
|
|
937
947
|
borderRadius: googlePayStyles.buttonRadius
|
|
938
948
|
}));
|
|
@@ -941,12 +951,18 @@ var PaystackPop = (function () {
|
|
|
941
951
|
container.appendChild(buttonContainer);
|
|
942
952
|
var client = getGooglePayClient(resolveGooglePayEnvironment(transaction.response));
|
|
943
953
|
var button = client.createButton(_objectSpread2(_objectSpread2({
|
|
944
|
-
buttonColor: styles.theme === PAYMENT_REQUEST_BUTTON_THEME.LIGHT ? 'white' : 'black'
|
|
954
|
+
buttonColor: styles.theme === PAYMENT_REQUEST_BUTTON_THEME.LIGHT ? 'white' : 'black',
|
|
955
|
+
buttonType: 'pay',
|
|
956
|
+
buttonRadius: GOOGLE_PAY_BUTTON_RADIUS,
|
|
957
|
+
buttonSizeMode: 'fill'
|
|
945
958
|
}, googlePayStyles), {}, {
|
|
946
959
|
onClick: onClick,
|
|
947
960
|
allowedPaymentMethods: [buildCardPaymentMethod(googlePayConfig, getSupportedAuthMethods(googlePayConfig))]
|
|
948
961
|
}));
|
|
949
|
-
|
|
962
|
+
var buttonWrapper = document.createElement('div');
|
|
963
|
+
buttonWrapper.id = 'google-pay-button';
|
|
964
|
+
buttonWrapper.appendChild(button);
|
|
965
|
+
buttonContainer.appendChild(buttonWrapper);
|
|
950
966
|
var loadingButton = document.createElement('button');
|
|
951
967
|
loadingButton.id = 'google-pay-loading-button';
|
|
952
968
|
loadingButton.type = 'button';
|
|
@@ -956,7 +972,7 @@ var PaystackPop = (function () {
|
|
|
956
972
|
var spinner = document.createElement('span');
|
|
957
973
|
spinner.id = 'google-pay-loading-button__spinner';
|
|
958
974
|
loadingButton.appendChild(spinner);
|
|
959
|
-
|
|
975
|
+
buttonContainer.appendChild(loadingButton);
|
|
960
976
|
return buttonContainer;
|
|
961
977
|
}
|
|
962
978
|
function getMountedPaymentRequestButtons(container) {
|
|
@@ -965,12 +981,12 @@ var PaystackPop = (function () {
|
|
|
965
981
|
}
|
|
966
982
|
return [getApplePayButton(container), getGooglePayButton(container)].filter(Boolean);
|
|
967
983
|
}
|
|
968
|
-
function mountPaymentRequestButtons(container,
|
|
969
|
-
var transaction =
|
|
970
|
-
|
|
971
|
-
styles =
|
|
972
|
-
onClickApplePayButton =
|
|
973
|
-
onClickGooglePayButton =
|
|
984
|
+
function mountPaymentRequestButtons(container, _ref5) {
|
|
985
|
+
var transaction = _ref5.transaction,
|
|
986
|
+
_ref5$styles = _ref5.styles,
|
|
987
|
+
styles = _ref5$styles === void 0 ? {} : _ref5$styles,
|
|
988
|
+
onClickApplePayButton = _ref5.onClickApplePayButton,
|
|
989
|
+
onClickGooglePayButton = _ref5.onClickGooglePayButton;
|
|
974
990
|
if (!container) {
|
|
975
991
|
return Promise.reject('Container to mount elements was not provided');
|
|
976
992
|
}
|
|
@@ -978,7 +994,14 @@ var PaystackPop = (function () {
|
|
|
978
994
|
appendCSS(container, generatePaymentRequestInnerWrapperCSS(styles.orientation));
|
|
979
995
|
var innerWrapper = document.createElement('div');
|
|
980
996
|
innerWrapper.id = 'paystack-payment-request-inner-wrapper';
|
|
997
|
+
innerWrapper.style.display = 'none';
|
|
981
998
|
container.appendChild(innerWrapper);
|
|
999
|
+
var revealWrapper = function revealWrapper(button) {
|
|
1000
|
+
if (button) {
|
|
1001
|
+
innerWrapper.style.display = '';
|
|
1002
|
+
}
|
|
1003
|
+
return button;
|
|
1004
|
+
};
|
|
982
1005
|
var applePayOptions = {
|
|
983
1006
|
styles: parseApplePayCustomStyles(styles.applePay),
|
|
984
1007
|
theme: styles.theme,
|
|
@@ -991,7 +1014,7 @@ var PaystackPop = (function () {
|
|
|
991
1014
|
return mountApplePayButton(innerWrapper, applePayOptions);
|
|
992
1015
|
}).catch(function () {
|
|
993
1016
|
return mountApplePayFallbackButton(innerWrapper, applePayOptions);
|
|
994
|
-
}).catch(function () {
|
|
1017
|
+
}).then(revealWrapper).catch(function () {
|
|
995
1018
|
return null;
|
|
996
1019
|
});
|
|
997
1020
|
} else if (channels.includes(CHANNELS.APPLE_PAY)) {
|
|
@@ -1006,13 +1029,13 @@ var PaystackPop = (function () {
|
|
|
1006
1029
|
styles: styles,
|
|
1007
1030
|
onClick: onClickGooglePayButton
|
|
1008
1031
|
});
|
|
1009
|
-
}).catch(function () {
|
|
1032
|
+
}).then(revealWrapper).catch(function () {
|
|
1010
1033
|
return null;
|
|
1011
1034
|
});
|
|
1012
|
-
return Promise.all([applePayButton, googlePayButton]).then(function (
|
|
1013
|
-
var
|
|
1014
|
-
applePay =
|
|
1015
|
-
googlePay =
|
|
1035
|
+
return Promise.all([applePayButton, googlePayButton]).then(function (_ref6) {
|
|
1036
|
+
var _ref7 = _slicedToArray(_ref6, 2),
|
|
1037
|
+
applePay = _ref7[0],
|
|
1038
|
+
googlePay = _ref7[1];
|
|
1016
1039
|
return {
|
|
1017
1040
|
applePay: !!applePay,
|
|
1018
1041
|
googlePay: !!googlePay
|
package/es/inline.js
CHANGED
|
@@ -350,7 +350,7 @@ function generateInlineButtonHTML(options) {
|
|
|
350
350
|
return buttonHTML;
|
|
351
351
|
}
|
|
352
352
|
var defaultCustomApplePayStyles = {
|
|
353
|
-
height:
|
|
353
|
+
height: PAYMENT_REQUEST_BUTTON_HEIGHT,
|
|
354
354
|
width: 'auto',
|
|
355
355
|
borderRadius: '3px',
|
|
356
356
|
padding: '10px',
|
|
@@ -384,14 +384,17 @@ var generateApplePayFallbackCSS = function generateApplePayFallbackCSS(_ref2) {
|
|
|
384
384
|
};
|
|
385
385
|
var generatePaymentRequestInnerWrapperCSS = function generatePaymentRequestInnerWrapperCSS(orientation) {
|
|
386
386
|
var isVertical = orientation === PAYMENT_REQUEST_BUTTON_ORIENTATION.VERTICAL;
|
|
387
|
-
return "\n #paystack-payment-request-inner-wrapper {\n display: flex;\n flex-direction: ".concat(isVertical ? 'column' : 'row', ";\n gap: 8px;\n width: 100%;\n max-width: 100%;\n ").concat(isVertical ? '' :
|
|
387
|
+
return "\n #paystack-payment-request-inner-wrapper {\n display: flex;\n flex-direction: ".concat(isVertical ? 'column' : 'row', ";\n gap: 8px;\n width: 100%;\n max-width: 100%;\n ").concat(isVertical ? '' : 'flex: 1 1 0', ";\n }\n\n #paystack-payment-request-inner-wrapper > * {\n min-width: 0;\n }\n\n #paystack-payment-request-inner-wrapper > apple-pay-button,\n #paystack-payment-request-inner-wrapper > #apple-pay-button {\n order: 1;\n }\n #paystack-payment-request-inner-wrapper > #google-pay-button-container {\n order: 2;\n }\n");
|
|
388
388
|
};
|
|
389
389
|
var generateGooglePayCSS = function generateGooglePayCSS() {
|
|
390
|
-
|
|
390
|
+
var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
391
|
+
height = _ref3.height,
|
|
392
|
+
width = _ref3.width;
|
|
393
|
+
return "\n #google-pay-button-container {\n width: ".concat(width || 'auto', ";\n height: ").concat(height || PAYMENT_REQUEST_BUTTON_HEIGHT, ";\n overflow: hidden;\n }\n #google-pay-button-container:empty {\n display: none;\n }\n #google-pay-button-container > div,\n #google-pay-button-container button,\n #google-pay-button-container iframe {\n width: 100%;\n max-width: 100%;\n height: 100%;\n min-width: 100%;\n }\n #google-pay-button-container button {\n outline: none !important;\n }\n");
|
|
391
394
|
};
|
|
392
395
|
var generateGooglePayLoadingCSS = function generateGooglePayLoadingCSS() {
|
|
393
|
-
var
|
|
394
|
-
borderRadius =
|
|
396
|
+
var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
397
|
+
borderRadius = _ref4.borderRadius;
|
|
395
398
|
return "\n #google-pay-loading-button {\n width: 100%;\n height: 100%;\n border: none;\n border-radius: ".concat(borderRadius === undefined ? GOOGLE_PAY_BUTTON_RADIUS : borderRadius, "px;\n background: #000000;\n cursor: default;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n #google-pay-loading-button__spinner {\n width: 18px;\n height: 18px;\n border: 2px solid rgba(255, 255, 255, 0.35);\n border-top-color: #ffffff;\n border-radius: 50%;\n animation: google-pay-spin 0.8s linear infinite;\n }\n @keyframes google-pay-spin {\n to { transform: rotate(360deg); }\n }\n");
|
|
396
399
|
};
|
|
397
400
|
function appendCSS(container, css) {
|
|
@@ -731,6 +734,7 @@ var loadGooglePay = function loadGooglePay(transaction) {
|
|
|
731
734
|
});
|
|
732
735
|
};
|
|
733
736
|
|
|
737
|
+
var _excluded$2 = ["height", "width"];
|
|
734
738
|
function createIframe(id) {
|
|
735
739
|
var iframe = document.createElement('iframe');
|
|
736
740
|
iframe.setAttribute('frameBorder', '0');
|
|
@@ -914,12 +918,12 @@ function toggleGooglePayLoadingState(container, isLoading) {
|
|
|
914
918
|
if (!container) {
|
|
915
919
|
return;
|
|
916
920
|
}
|
|
917
|
-
var
|
|
921
|
+
var button = container.querySelector('#google-pay-button');
|
|
918
922
|
var loadingButton = container.querySelector('#google-pay-loading-button');
|
|
919
|
-
if (!
|
|
923
|
+
if (!button || !loadingButton) {
|
|
920
924
|
return;
|
|
921
925
|
}
|
|
922
|
-
|
|
926
|
+
button.style.display = isLoading ? 'none' : '';
|
|
923
927
|
loadingButton.style.display = isLoading ? 'flex' : 'none';
|
|
924
928
|
}
|
|
925
929
|
function mountGooglePayButton(container, _ref3) {
|
|
@@ -927,9 +931,15 @@ function mountGooglePayButton(container, _ref3) {
|
|
|
927
931
|
_ref3$styles = _ref3.styles,
|
|
928
932
|
styles = _ref3$styles === void 0 ? {} : _ref3$styles,
|
|
929
933
|
onClick = _ref3.onClick;
|
|
930
|
-
var
|
|
934
|
+
var _ref4 = styles.googlePay || {},
|
|
935
|
+
height = _ref4.height,
|
|
936
|
+
width = _ref4.width,
|
|
937
|
+
googlePayStyles = _objectWithoutProperties(_ref4, _excluded$2);
|
|
931
938
|
var googlePayConfig = getGooglePayConfig(transaction);
|
|
932
|
-
appendCSS(container, generateGooglePayCSS(
|
|
939
|
+
appendCSS(container, generateGooglePayCSS({
|
|
940
|
+
height: height,
|
|
941
|
+
width: width
|
|
942
|
+
}));
|
|
933
943
|
appendCSS(container, generateGooglePayLoadingCSS({
|
|
934
944
|
borderRadius: googlePayStyles.buttonRadius
|
|
935
945
|
}));
|
|
@@ -938,12 +948,18 @@ function mountGooglePayButton(container, _ref3) {
|
|
|
938
948
|
container.appendChild(buttonContainer);
|
|
939
949
|
var client = getGooglePayClient(resolveGooglePayEnvironment(transaction.response));
|
|
940
950
|
var button = client.createButton(_objectSpread2(_objectSpread2({
|
|
941
|
-
buttonColor: styles.theme === PAYMENT_REQUEST_BUTTON_THEME.LIGHT ? 'white' : 'black'
|
|
951
|
+
buttonColor: styles.theme === PAYMENT_REQUEST_BUTTON_THEME.LIGHT ? 'white' : 'black',
|
|
952
|
+
buttonType: 'pay',
|
|
953
|
+
buttonRadius: GOOGLE_PAY_BUTTON_RADIUS,
|
|
954
|
+
buttonSizeMode: 'fill'
|
|
942
955
|
}, googlePayStyles), {}, {
|
|
943
956
|
onClick: onClick,
|
|
944
957
|
allowedPaymentMethods: [buildCardPaymentMethod(googlePayConfig, getSupportedAuthMethods(googlePayConfig))]
|
|
945
958
|
}));
|
|
946
|
-
|
|
959
|
+
var buttonWrapper = document.createElement('div');
|
|
960
|
+
buttonWrapper.id = 'google-pay-button';
|
|
961
|
+
buttonWrapper.appendChild(button);
|
|
962
|
+
buttonContainer.appendChild(buttonWrapper);
|
|
947
963
|
var loadingButton = document.createElement('button');
|
|
948
964
|
loadingButton.id = 'google-pay-loading-button';
|
|
949
965
|
loadingButton.type = 'button';
|
|
@@ -953,7 +969,7 @@ function mountGooglePayButton(container, _ref3) {
|
|
|
953
969
|
var spinner = document.createElement('span');
|
|
954
970
|
spinner.id = 'google-pay-loading-button__spinner';
|
|
955
971
|
loadingButton.appendChild(spinner);
|
|
956
|
-
|
|
972
|
+
buttonContainer.appendChild(loadingButton);
|
|
957
973
|
return buttonContainer;
|
|
958
974
|
}
|
|
959
975
|
function getMountedPaymentRequestButtons(container) {
|
|
@@ -962,12 +978,12 @@ function getMountedPaymentRequestButtons(container) {
|
|
|
962
978
|
}
|
|
963
979
|
return [getApplePayButton(container), getGooglePayButton(container)].filter(Boolean);
|
|
964
980
|
}
|
|
965
|
-
function mountPaymentRequestButtons(container,
|
|
966
|
-
var transaction =
|
|
967
|
-
|
|
968
|
-
styles =
|
|
969
|
-
onClickApplePayButton =
|
|
970
|
-
onClickGooglePayButton =
|
|
981
|
+
function mountPaymentRequestButtons(container, _ref5) {
|
|
982
|
+
var transaction = _ref5.transaction,
|
|
983
|
+
_ref5$styles = _ref5.styles,
|
|
984
|
+
styles = _ref5$styles === void 0 ? {} : _ref5$styles,
|
|
985
|
+
onClickApplePayButton = _ref5.onClickApplePayButton,
|
|
986
|
+
onClickGooglePayButton = _ref5.onClickGooglePayButton;
|
|
971
987
|
if (!container) {
|
|
972
988
|
return Promise.reject('Container to mount elements was not provided');
|
|
973
989
|
}
|
|
@@ -975,7 +991,14 @@ function mountPaymentRequestButtons(container, _ref4) {
|
|
|
975
991
|
appendCSS(container, generatePaymentRequestInnerWrapperCSS(styles.orientation));
|
|
976
992
|
var innerWrapper = document.createElement('div');
|
|
977
993
|
innerWrapper.id = 'paystack-payment-request-inner-wrapper';
|
|
994
|
+
innerWrapper.style.display = 'none';
|
|
978
995
|
container.appendChild(innerWrapper);
|
|
996
|
+
var revealWrapper = function revealWrapper(button) {
|
|
997
|
+
if (button) {
|
|
998
|
+
innerWrapper.style.display = '';
|
|
999
|
+
}
|
|
1000
|
+
return button;
|
|
1001
|
+
};
|
|
979
1002
|
var applePayOptions = {
|
|
980
1003
|
styles: parseApplePayCustomStyles(styles.applePay),
|
|
981
1004
|
theme: styles.theme,
|
|
@@ -988,7 +1011,7 @@ function mountPaymentRequestButtons(container, _ref4) {
|
|
|
988
1011
|
return mountApplePayButton(innerWrapper, applePayOptions);
|
|
989
1012
|
}).catch(function () {
|
|
990
1013
|
return mountApplePayFallbackButton(innerWrapper, applePayOptions);
|
|
991
|
-
}).catch(function () {
|
|
1014
|
+
}).then(revealWrapper).catch(function () {
|
|
992
1015
|
return null;
|
|
993
1016
|
});
|
|
994
1017
|
} else if (channels.includes(CHANNELS.APPLE_PAY)) {
|
|
@@ -1003,13 +1026,13 @@ function mountPaymentRequestButtons(container, _ref4) {
|
|
|
1003
1026
|
styles: styles,
|
|
1004
1027
|
onClick: onClickGooglePayButton
|
|
1005
1028
|
});
|
|
1006
|
-
}).catch(function () {
|
|
1029
|
+
}).then(revealWrapper).catch(function () {
|
|
1007
1030
|
return null;
|
|
1008
1031
|
});
|
|
1009
|
-
return Promise.all([applePayButton, googlePayButton]).then(function (
|
|
1010
|
-
var
|
|
1011
|
-
applePay =
|
|
1012
|
-
googlePay =
|
|
1032
|
+
return Promise.all([applePayButton, googlePayButton]).then(function (_ref6) {
|
|
1033
|
+
var _ref7 = _slicedToArray(_ref6, 2),
|
|
1034
|
+
applePay = _ref7[0],
|
|
1035
|
+
googlePay = _ref7[1];
|
|
1013
1036
|
return {
|
|
1014
1037
|
applePay: !!applePay,
|
|
1015
1038
|
googlePay: !!googlePay
|
package/lib/inline.js
CHANGED
|
@@ -352,7 +352,7 @@ function generateInlineButtonHTML(options) {
|
|
|
352
352
|
return buttonHTML;
|
|
353
353
|
}
|
|
354
354
|
var defaultCustomApplePayStyles = {
|
|
355
|
-
height:
|
|
355
|
+
height: PAYMENT_REQUEST_BUTTON_HEIGHT,
|
|
356
356
|
width: 'auto',
|
|
357
357
|
borderRadius: '3px',
|
|
358
358
|
padding: '10px',
|
|
@@ -386,14 +386,17 @@ var generateApplePayFallbackCSS = function generateApplePayFallbackCSS(_ref2) {
|
|
|
386
386
|
};
|
|
387
387
|
var generatePaymentRequestInnerWrapperCSS = function generatePaymentRequestInnerWrapperCSS(orientation) {
|
|
388
388
|
var isVertical = orientation === PAYMENT_REQUEST_BUTTON_ORIENTATION.VERTICAL;
|
|
389
|
-
return "\n #paystack-payment-request-inner-wrapper {\n display: flex;\n flex-direction: ".concat(isVertical ? 'column' : 'row', ";\n gap: 8px;\n width: 100%;\n max-width: 100%;\n ").concat(isVertical ? '' :
|
|
389
|
+
return "\n #paystack-payment-request-inner-wrapper {\n display: flex;\n flex-direction: ".concat(isVertical ? 'column' : 'row', ";\n gap: 8px;\n width: 100%;\n max-width: 100%;\n ").concat(isVertical ? '' : 'flex: 1 1 0', ";\n }\n\n #paystack-payment-request-inner-wrapper > * {\n min-width: 0;\n }\n\n #paystack-payment-request-inner-wrapper > apple-pay-button,\n #paystack-payment-request-inner-wrapper > #apple-pay-button {\n order: 1;\n }\n #paystack-payment-request-inner-wrapper > #google-pay-button-container {\n order: 2;\n }\n");
|
|
390
390
|
};
|
|
391
391
|
var generateGooglePayCSS = function generateGooglePayCSS() {
|
|
392
|
-
|
|
392
|
+
var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
393
|
+
height = _ref3.height,
|
|
394
|
+
width = _ref3.width;
|
|
395
|
+
return "\n #google-pay-button-container {\n width: ".concat(width || 'auto', ";\n height: ").concat(height || PAYMENT_REQUEST_BUTTON_HEIGHT, ";\n overflow: hidden;\n }\n #google-pay-button-container:empty {\n display: none;\n }\n #google-pay-button-container > div,\n #google-pay-button-container button,\n #google-pay-button-container iframe {\n width: 100%;\n max-width: 100%;\n height: 100%;\n min-width: 100%;\n }\n #google-pay-button-container button {\n outline: none !important;\n }\n");
|
|
393
396
|
};
|
|
394
397
|
var generateGooglePayLoadingCSS = function generateGooglePayLoadingCSS() {
|
|
395
|
-
var
|
|
396
|
-
borderRadius =
|
|
398
|
+
var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
399
|
+
borderRadius = _ref4.borderRadius;
|
|
397
400
|
return "\n #google-pay-loading-button {\n width: 100%;\n height: 100%;\n border: none;\n border-radius: ".concat(borderRadius === undefined ? GOOGLE_PAY_BUTTON_RADIUS : borderRadius, "px;\n background: #000000;\n cursor: default;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n #google-pay-loading-button__spinner {\n width: 18px;\n height: 18px;\n border: 2px solid rgba(255, 255, 255, 0.35);\n border-top-color: #ffffff;\n border-radius: 50%;\n animation: google-pay-spin 0.8s linear infinite;\n }\n @keyframes google-pay-spin {\n to { transform: rotate(360deg); }\n }\n");
|
|
398
401
|
};
|
|
399
402
|
function appendCSS(container, css) {
|
|
@@ -733,6 +736,7 @@ var loadGooglePay = function loadGooglePay(transaction) {
|
|
|
733
736
|
});
|
|
734
737
|
};
|
|
735
738
|
|
|
739
|
+
var _excluded$2 = ["height", "width"];
|
|
736
740
|
function createIframe(id) {
|
|
737
741
|
var iframe = document.createElement('iframe');
|
|
738
742
|
iframe.setAttribute('frameBorder', '0');
|
|
@@ -916,12 +920,12 @@ function toggleGooglePayLoadingState(container, isLoading) {
|
|
|
916
920
|
if (!container) {
|
|
917
921
|
return;
|
|
918
922
|
}
|
|
919
|
-
var
|
|
923
|
+
var button = container.querySelector('#google-pay-button');
|
|
920
924
|
var loadingButton = container.querySelector('#google-pay-loading-button');
|
|
921
|
-
if (!
|
|
925
|
+
if (!button || !loadingButton) {
|
|
922
926
|
return;
|
|
923
927
|
}
|
|
924
|
-
|
|
928
|
+
button.style.display = isLoading ? 'none' : '';
|
|
925
929
|
loadingButton.style.display = isLoading ? 'flex' : 'none';
|
|
926
930
|
}
|
|
927
931
|
function mountGooglePayButton(container, _ref3) {
|
|
@@ -929,9 +933,15 @@ function mountGooglePayButton(container, _ref3) {
|
|
|
929
933
|
_ref3$styles = _ref3.styles,
|
|
930
934
|
styles = _ref3$styles === void 0 ? {} : _ref3$styles,
|
|
931
935
|
onClick = _ref3.onClick;
|
|
932
|
-
var
|
|
936
|
+
var _ref4 = styles.googlePay || {},
|
|
937
|
+
height = _ref4.height,
|
|
938
|
+
width = _ref4.width,
|
|
939
|
+
googlePayStyles = _objectWithoutProperties(_ref4, _excluded$2);
|
|
933
940
|
var googlePayConfig = getGooglePayConfig(transaction);
|
|
934
|
-
appendCSS(container, generateGooglePayCSS(
|
|
941
|
+
appendCSS(container, generateGooglePayCSS({
|
|
942
|
+
height: height,
|
|
943
|
+
width: width
|
|
944
|
+
}));
|
|
935
945
|
appendCSS(container, generateGooglePayLoadingCSS({
|
|
936
946
|
borderRadius: googlePayStyles.buttonRadius
|
|
937
947
|
}));
|
|
@@ -940,12 +950,18 @@ function mountGooglePayButton(container, _ref3) {
|
|
|
940
950
|
container.appendChild(buttonContainer);
|
|
941
951
|
var client = getGooglePayClient(resolveGooglePayEnvironment(transaction.response));
|
|
942
952
|
var button = client.createButton(_objectSpread2(_objectSpread2({
|
|
943
|
-
buttonColor: styles.theme === PAYMENT_REQUEST_BUTTON_THEME.LIGHT ? 'white' : 'black'
|
|
953
|
+
buttonColor: styles.theme === PAYMENT_REQUEST_BUTTON_THEME.LIGHT ? 'white' : 'black',
|
|
954
|
+
buttonType: 'pay',
|
|
955
|
+
buttonRadius: GOOGLE_PAY_BUTTON_RADIUS,
|
|
956
|
+
buttonSizeMode: 'fill'
|
|
944
957
|
}, googlePayStyles), {}, {
|
|
945
958
|
onClick: onClick,
|
|
946
959
|
allowedPaymentMethods: [buildCardPaymentMethod(googlePayConfig, getSupportedAuthMethods(googlePayConfig))]
|
|
947
960
|
}));
|
|
948
|
-
|
|
961
|
+
var buttonWrapper = document.createElement('div');
|
|
962
|
+
buttonWrapper.id = 'google-pay-button';
|
|
963
|
+
buttonWrapper.appendChild(button);
|
|
964
|
+
buttonContainer.appendChild(buttonWrapper);
|
|
949
965
|
var loadingButton = document.createElement('button');
|
|
950
966
|
loadingButton.id = 'google-pay-loading-button';
|
|
951
967
|
loadingButton.type = 'button';
|
|
@@ -955,7 +971,7 @@ function mountGooglePayButton(container, _ref3) {
|
|
|
955
971
|
var spinner = document.createElement('span');
|
|
956
972
|
spinner.id = 'google-pay-loading-button__spinner';
|
|
957
973
|
loadingButton.appendChild(spinner);
|
|
958
|
-
|
|
974
|
+
buttonContainer.appendChild(loadingButton);
|
|
959
975
|
return buttonContainer;
|
|
960
976
|
}
|
|
961
977
|
function getMountedPaymentRequestButtons(container) {
|
|
@@ -964,12 +980,12 @@ function getMountedPaymentRequestButtons(container) {
|
|
|
964
980
|
}
|
|
965
981
|
return [getApplePayButton(container), getGooglePayButton(container)].filter(Boolean);
|
|
966
982
|
}
|
|
967
|
-
function mountPaymentRequestButtons(container,
|
|
968
|
-
var transaction =
|
|
969
|
-
|
|
970
|
-
styles =
|
|
971
|
-
onClickApplePayButton =
|
|
972
|
-
onClickGooglePayButton =
|
|
983
|
+
function mountPaymentRequestButtons(container, _ref5) {
|
|
984
|
+
var transaction = _ref5.transaction,
|
|
985
|
+
_ref5$styles = _ref5.styles,
|
|
986
|
+
styles = _ref5$styles === void 0 ? {} : _ref5$styles,
|
|
987
|
+
onClickApplePayButton = _ref5.onClickApplePayButton,
|
|
988
|
+
onClickGooglePayButton = _ref5.onClickGooglePayButton;
|
|
973
989
|
if (!container) {
|
|
974
990
|
return Promise.reject('Container to mount elements was not provided');
|
|
975
991
|
}
|
|
@@ -977,7 +993,14 @@ function mountPaymentRequestButtons(container, _ref4) {
|
|
|
977
993
|
appendCSS(container, generatePaymentRequestInnerWrapperCSS(styles.orientation));
|
|
978
994
|
var innerWrapper = document.createElement('div');
|
|
979
995
|
innerWrapper.id = 'paystack-payment-request-inner-wrapper';
|
|
996
|
+
innerWrapper.style.display = 'none';
|
|
980
997
|
container.appendChild(innerWrapper);
|
|
998
|
+
var revealWrapper = function revealWrapper(button) {
|
|
999
|
+
if (button) {
|
|
1000
|
+
innerWrapper.style.display = '';
|
|
1001
|
+
}
|
|
1002
|
+
return button;
|
|
1003
|
+
};
|
|
981
1004
|
var applePayOptions = {
|
|
982
1005
|
styles: parseApplePayCustomStyles(styles.applePay),
|
|
983
1006
|
theme: styles.theme,
|
|
@@ -990,7 +1013,7 @@ function mountPaymentRequestButtons(container, _ref4) {
|
|
|
990
1013
|
return mountApplePayButton(innerWrapper, applePayOptions);
|
|
991
1014
|
}).catch(function () {
|
|
992
1015
|
return mountApplePayFallbackButton(innerWrapper, applePayOptions);
|
|
993
|
-
}).catch(function () {
|
|
1016
|
+
}).then(revealWrapper).catch(function () {
|
|
994
1017
|
return null;
|
|
995
1018
|
});
|
|
996
1019
|
} else if (channels.includes(CHANNELS.APPLE_PAY)) {
|
|
@@ -1005,13 +1028,13 @@ function mountPaymentRequestButtons(container, _ref4) {
|
|
|
1005
1028
|
styles: styles,
|
|
1006
1029
|
onClick: onClickGooglePayButton
|
|
1007
1030
|
});
|
|
1008
|
-
}).catch(function () {
|
|
1031
|
+
}).then(revealWrapper).catch(function () {
|
|
1009
1032
|
return null;
|
|
1010
1033
|
});
|
|
1011
|
-
return Promise.all([applePayButton, googlePayButton]).then(function (
|
|
1012
|
-
var
|
|
1013
|
-
applePay =
|
|
1014
|
-
googlePay =
|
|
1034
|
+
return Promise.all([applePayButton, googlePayButton]).then(function (_ref6) {
|
|
1035
|
+
var _ref7 = _slicedToArray(_ref6, 2),
|
|
1036
|
+
applePay = _ref7[0],
|
|
1037
|
+
googlePay = _ref7[1];
|
|
1015
1038
|
return {
|
|
1016
1039
|
applePay: !!applePay,
|
|
1017
1040
|
googlePay: !!googlePay
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paystack/inline-js",
|
|
3
|
-
"version": "2.25.0-dev.
|
|
3
|
+
"version": "2.25.0-dev.4",
|
|
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",
|