@paystack/inline-js 2.25.0-dev.3 → 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 +46 -26
- package/es/inline.js +46 -26
- package/lib/inline.js +46 -26
- 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
|
}));
|
|
@@ -943,13 +953,16 @@ var PaystackPop = (function () {
|
|
|
943
953
|
var button = client.createButton(_objectSpread2(_objectSpread2({
|
|
944
954
|
buttonColor: styles.theme === PAYMENT_REQUEST_BUTTON_THEME.LIGHT ? 'white' : 'black',
|
|
945
955
|
buttonType: 'pay',
|
|
946
|
-
|
|
947
|
-
|
|
956
|
+
buttonRadius: GOOGLE_PAY_BUTTON_RADIUS,
|
|
957
|
+
buttonSizeMode: 'fill'
|
|
948
958
|
}, googlePayStyles), {}, {
|
|
949
959
|
onClick: onClick,
|
|
950
960
|
allowedPaymentMethods: [buildCardPaymentMethod(googlePayConfig, getSupportedAuthMethods(googlePayConfig))]
|
|
951
961
|
}));
|
|
952
|
-
|
|
962
|
+
var buttonWrapper = document.createElement('div');
|
|
963
|
+
buttonWrapper.id = 'google-pay-button';
|
|
964
|
+
buttonWrapper.appendChild(button);
|
|
965
|
+
buttonContainer.appendChild(buttonWrapper);
|
|
953
966
|
var loadingButton = document.createElement('button');
|
|
954
967
|
loadingButton.id = 'google-pay-loading-button';
|
|
955
968
|
loadingButton.type = 'button';
|
|
@@ -959,7 +972,7 @@ var PaystackPop = (function () {
|
|
|
959
972
|
var spinner = document.createElement('span');
|
|
960
973
|
spinner.id = 'google-pay-loading-button__spinner';
|
|
961
974
|
loadingButton.appendChild(spinner);
|
|
962
|
-
|
|
975
|
+
buttonContainer.appendChild(loadingButton);
|
|
963
976
|
return buttonContainer;
|
|
964
977
|
}
|
|
965
978
|
function getMountedPaymentRequestButtons(container) {
|
|
@@ -968,12 +981,12 @@ var PaystackPop = (function () {
|
|
|
968
981
|
}
|
|
969
982
|
return [getApplePayButton(container), getGooglePayButton(container)].filter(Boolean);
|
|
970
983
|
}
|
|
971
|
-
function mountPaymentRequestButtons(container,
|
|
972
|
-
var transaction =
|
|
973
|
-
|
|
974
|
-
styles =
|
|
975
|
-
onClickApplePayButton =
|
|
976
|
-
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;
|
|
977
990
|
if (!container) {
|
|
978
991
|
return Promise.reject('Container to mount elements was not provided');
|
|
979
992
|
}
|
|
@@ -981,7 +994,14 @@ var PaystackPop = (function () {
|
|
|
981
994
|
appendCSS(container, generatePaymentRequestInnerWrapperCSS(styles.orientation));
|
|
982
995
|
var innerWrapper = document.createElement('div');
|
|
983
996
|
innerWrapper.id = 'paystack-payment-request-inner-wrapper';
|
|
997
|
+
innerWrapper.style.display = 'none';
|
|
984
998
|
container.appendChild(innerWrapper);
|
|
999
|
+
var revealWrapper = function revealWrapper(button) {
|
|
1000
|
+
if (button) {
|
|
1001
|
+
innerWrapper.style.display = '';
|
|
1002
|
+
}
|
|
1003
|
+
return button;
|
|
1004
|
+
};
|
|
985
1005
|
var applePayOptions = {
|
|
986
1006
|
styles: parseApplePayCustomStyles(styles.applePay),
|
|
987
1007
|
theme: styles.theme,
|
|
@@ -994,7 +1014,7 @@ var PaystackPop = (function () {
|
|
|
994
1014
|
return mountApplePayButton(innerWrapper, applePayOptions);
|
|
995
1015
|
}).catch(function () {
|
|
996
1016
|
return mountApplePayFallbackButton(innerWrapper, applePayOptions);
|
|
997
|
-
}).catch(function () {
|
|
1017
|
+
}).then(revealWrapper).catch(function () {
|
|
998
1018
|
return null;
|
|
999
1019
|
});
|
|
1000
1020
|
} else if (channels.includes(CHANNELS.APPLE_PAY)) {
|
|
@@ -1009,13 +1029,13 @@ var PaystackPop = (function () {
|
|
|
1009
1029
|
styles: styles,
|
|
1010
1030
|
onClick: onClickGooglePayButton
|
|
1011
1031
|
});
|
|
1012
|
-
}).catch(function () {
|
|
1032
|
+
}).then(revealWrapper).catch(function () {
|
|
1013
1033
|
return null;
|
|
1014
1034
|
});
|
|
1015
|
-
return Promise.all([applePayButton, googlePayButton]).then(function (
|
|
1016
|
-
var
|
|
1017
|
-
applePay =
|
|
1018
|
-
googlePay =
|
|
1035
|
+
return Promise.all([applePayButton, googlePayButton]).then(function (_ref6) {
|
|
1036
|
+
var _ref7 = _slicedToArray(_ref6, 2),
|
|
1037
|
+
applePay = _ref7[0],
|
|
1038
|
+
googlePay = _ref7[1];
|
|
1019
1039
|
return {
|
|
1020
1040
|
applePay: !!applePay,
|
|
1021
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
|
}));
|
|
@@ -940,13 +950,16 @@ function mountGooglePayButton(container, _ref3) {
|
|
|
940
950
|
var button = client.createButton(_objectSpread2(_objectSpread2({
|
|
941
951
|
buttonColor: styles.theme === PAYMENT_REQUEST_BUTTON_THEME.LIGHT ? 'white' : 'black',
|
|
942
952
|
buttonType: 'pay',
|
|
943
|
-
|
|
944
|
-
|
|
953
|
+
buttonRadius: GOOGLE_PAY_BUTTON_RADIUS,
|
|
954
|
+
buttonSizeMode: 'fill'
|
|
945
955
|
}, googlePayStyles), {}, {
|
|
946
956
|
onClick: onClick,
|
|
947
957
|
allowedPaymentMethods: [buildCardPaymentMethod(googlePayConfig, getSupportedAuthMethods(googlePayConfig))]
|
|
948
958
|
}));
|
|
949
|
-
|
|
959
|
+
var buttonWrapper = document.createElement('div');
|
|
960
|
+
buttonWrapper.id = 'google-pay-button';
|
|
961
|
+
buttonWrapper.appendChild(button);
|
|
962
|
+
buttonContainer.appendChild(buttonWrapper);
|
|
950
963
|
var loadingButton = document.createElement('button');
|
|
951
964
|
loadingButton.id = 'google-pay-loading-button';
|
|
952
965
|
loadingButton.type = 'button';
|
|
@@ -956,7 +969,7 @@ function mountGooglePayButton(container, _ref3) {
|
|
|
956
969
|
var spinner = document.createElement('span');
|
|
957
970
|
spinner.id = 'google-pay-loading-button__spinner';
|
|
958
971
|
loadingButton.appendChild(spinner);
|
|
959
|
-
|
|
972
|
+
buttonContainer.appendChild(loadingButton);
|
|
960
973
|
return buttonContainer;
|
|
961
974
|
}
|
|
962
975
|
function getMountedPaymentRequestButtons(container) {
|
|
@@ -965,12 +978,12 @@ function getMountedPaymentRequestButtons(container) {
|
|
|
965
978
|
}
|
|
966
979
|
return [getApplePayButton(container), getGooglePayButton(container)].filter(Boolean);
|
|
967
980
|
}
|
|
968
|
-
function mountPaymentRequestButtons(container,
|
|
969
|
-
var transaction =
|
|
970
|
-
|
|
971
|
-
styles =
|
|
972
|
-
onClickApplePayButton =
|
|
973
|
-
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;
|
|
974
987
|
if (!container) {
|
|
975
988
|
return Promise.reject('Container to mount elements was not provided');
|
|
976
989
|
}
|
|
@@ -978,7 +991,14 @@ function mountPaymentRequestButtons(container, _ref4) {
|
|
|
978
991
|
appendCSS(container, generatePaymentRequestInnerWrapperCSS(styles.orientation));
|
|
979
992
|
var innerWrapper = document.createElement('div');
|
|
980
993
|
innerWrapper.id = 'paystack-payment-request-inner-wrapper';
|
|
994
|
+
innerWrapper.style.display = 'none';
|
|
981
995
|
container.appendChild(innerWrapper);
|
|
996
|
+
var revealWrapper = function revealWrapper(button) {
|
|
997
|
+
if (button) {
|
|
998
|
+
innerWrapper.style.display = '';
|
|
999
|
+
}
|
|
1000
|
+
return button;
|
|
1001
|
+
};
|
|
982
1002
|
var applePayOptions = {
|
|
983
1003
|
styles: parseApplePayCustomStyles(styles.applePay),
|
|
984
1004
|
theme: styles.theme,
|
|
@@ -991,7 +1011,7 @@ function mountPaymentRequestButtons(container, _ref4) {
|
|
|
991
1011
|
return mountApplePayButton(innerWrapper, applePayOptions);
|
|
992
1012
|
}).catch(function () {
|
|
993
1013
|
return mountApplePayFallbackButton(innerWrapper, applePayOptions);
|
|
994
|
-
}).catch(function () {
|
|
1014
|
+
}).then(revealWrapper).catch(function () {
|
|
995
1015
|
return null;
|
|
996
1016
|
});
|
|
997
1017
|
} else if (channels.includes(CHANNELS.APPLE_PAY)) {
|
|
@@ -1006,13 +1026,13 @@ function mountPaymentRequestButtons(container, _ref4) {
|
|
|
1006
1026
|
styles: styles,
|
|
1007
1027
|
onClick: onClickGooglePayButton
|
|
1008
1028
|
});
|
|
1009
|
-
}).catch(function () {
|
|
1029
|
+
}).then(revealWrapper).catch(function () {
|
|
1010
1030
|
return null;
|
|
1011
1031
|
});
|
|
1012
|
-
return Promise.all([applePayButton, googlePayButton]).then(function (
|
|
1013
|
-
var
|
|
1014
|
-
applePay =
|
|
1015
|
-
googlePay =
|
|
1032
|
+
return Promise.all([applePayButton, googlePayButton]).then(function (_ref6) {
|
|
1033
|
+
var _ref7 = _slicedToArray(_ref6, 2),
|
|
1034
|
+
applePay = _ref7[0],
|
|
1035
|
+
googlePay = _ref7[1];
|
|
1016
1036
|
return {
|
|
1017
1037
|
applePay: !!applePay,
|
|
1018
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
|
}));
|
|
@@ -942,13 +952,16 @@ function mountGooglePayButton(container, _ref3) {
|
|
|
942
952
|
var button = client.createButton(_objectSpread2(_objectSpread2({
|
|
943
953
|
buttonColor: styles.theme === PAYMENT_REQUEST_BUTTON_THEME.LIGHT ? 'white' : 'black',
|
|
944
954
|
buttonType: 'pay',
|
|
945
|
-
|
|
946
|
-
|
|
955
|
+
buttonRadius: GOOGLE_PAY_BUTTON_RADIUS,
|
|
956
|
+
buttonSizeMode: 'fill'
|
|
947
957
|
}, googlePayStyles), {}, {
|
|
948
958
|
onClick: onClick,
|
|
949
959
|
allowedPaymentMethods: [buildCardPaymentMethod(googlePayConfig, getSupportedAuthMethods(googlePayConfig))]
|
|
950
960
|
}));
|
|
951
|
-
|
|
961
|
+
var buttonWrapper = document.createElement('div');
|
|
962
|
+
buttonWrapper.id = 'google-pay-button';
|
|
963
|
+
buttonWrapper.appendChild(button);
|
|
964
|
+
buttonContainer.appendChild(buttonWrapper);
|
|
952
965
|
var loadingButton = document.createElement('button');
|
|
953
966
|
loadingButton.id = 'google-pay-loading-button';
|
|
954
967
|
loadingButton.type = 'button';
|
|
@@ -958,7 +971,7 @@ function mountGooglePayButton(container, _ref3) {
|
|
|
958
971
|
var spinner = document.createElement('span');
|
|
959
972
|
spinner.id = 'google-pay-loading-button__spinner';
|
|
960
973
|
loadingButton.appendChild(spinner);
|
|
961
|
-
|
|
974
|
+
buttonContainer.appendChild(loadingButton);
|
|
962
975
|
return buttonContainer;
|
|
963
976
|
}
|
|
964
977
|
function getMountedPaymentRequestButtons(container) {
|
|
@@ -967,12 +980,12 @@ function getMountedPaymentRequestButtons(container) {
|
|
|
967
980
|
}
|
|
968
981
|
return [getApplePayButton(container), getGooglePayButton(container)].filter(Boolean);
|
|
969
982
|
}
|
|
970
|
-
function mountPaymentRequestButtons(container,
|
|
971
|
-
var transaction =
|
|
972
|
-
|
|
973
|
-
styles =
|
|
974
|
-
onClickApplePayButton =
|
|
975
|
-
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;
|
|
976
989
|
if (!container) {
|
|
977
990
|
return Promise.reject('Container to mount elements was not provided');
|
|
978
991
|
}
|
|
@@ -980,7 +993,14 @@ function mountPaymentRequestButtons(container, _ref4) {
|
|
|
980
993
|
appendCSS(container, generatePaymentRequestInnerWrapperCSS(styles.orientation));
|
|
981
994
|
var innerWrapper = document.createElement('div');
|
|
982
995
|
innerWrapper.id = 'paystack-payment-request-inner-wrapper';
|
|
996
|
+
innerWrapper.style.display = 'none';
|
|
983
997
|
container.appendChild(innerWrapper);
|
|
998
|
+
var revealWrapper = function revealWrapper(button) {
|
|
999
|
+
if (button) {
|
|
1000
|
+
innerWrapper.style.display = '';
|
|
1001
|
+
}
|
|
1002
|
+
return button;
|
|
1003
|
+
};
|
|
984
1004
|
var applePayOptions = {
|
|
985
1005
|
styles: parseApplePayCustomStyles(styles.applePay),
|
|
986
1006
|
theme: styles.theme,
|
|
@@ -993,7 +1013,7 @@ function mountPaymentRequestButtons(container, _ref4) {
|
|
|
993
1013
|
return mountApplePayButton(innerWrapper, applePayOptions);
|
|
994
1014
|
}).catch(function () {
|
|
995
1015
|
return mountApplePayFallbackButton(innerWrapper, applePayOptions);
|
|
996
|
-
}).catch(function () {
|
|
1016
|
+
}).then(revealWrapper).catch(function () {
|
|
997
1017
|
return null;
|
|
998
1018
|
});
|
|
999
1019
|
} else if (channels.includes(CHANNELS.APPLE_PAY)) {
|
|
@@ -1008,13 +1028,13 @@ function mountPaymentRequestButtons(container, _ref4) {
|
|
|
1008
1028
|
styles: styles,
|
|
1009
1029
|
onClick: onClickGooglePayButton
|
|
1010
1030
|
});
|
|
1011
|
-
}).catch(function () {
|
|
1031
|
+
}).then(revealWrapper).catch(function () {
|
|
1012
1032
|
return null;
|
|
1013
1033
|
});
|
|
1014
|
-
return Promise.all([applePayButton, googlePayButton]).then(function (
|
|
1015
|
-
var
|
|
1016
|
-
applePay =
|
|
1017
|
-
googlePay =
|
|
1034
|
+
return Promise.all([applePayButton, googlePayButton]).then(function (_ref6) {
|
|
1035
|
+
var _ref7 = _slicedToArray(_ref6, 2),
|
|
1036
|
+
applePay = _ref7[0],
|
|
1037
|
+
googlePay = _ref7[1];
|
|
1018
1038
|
return {
|
|
1019
1039
|
applePay: !!applePay,
|
|
1020
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",
|