@paystack/inline-js 2.11.0-dev.8 → 2.13.0-dev.1

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.
Files changed (2) hide show
  1. package/dist/inline.js +87 -13
  2. package/package.json +1 -1
package/dist/inline.js CHANGED
@@ -162,7 +162,7 @@ var secureByPaystackGrey = "\n<svg id=\"inline-button-wordmark--grey\" width=\"1
162
162
 
163
163
  var applePayMarkLight = "\n <svg width=\"51\" height=\"32\" viewBox=\"0 0 51 32\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" id=\"apple-pay-mark--light\">\n <g>\n <path d=\"M46.0162 0H4.98386C4.81297 0 4.64177 0 4.47118 0.000996555C4.32698 0.00202331 4.18311 0.00362383 4.03925 0.00754966C3.72548 0.0160355 3.40903 0.0345472 3.09919 0.0902335C2.7844 0.146886 2.49148 0.239294 2.20571 0.384791C1.92477 0.52766 1.66757 0.71453 1.44468 0.937516C1.22169 1.1605 1.03482 1.41728 0.891977 1.69852C0.74645 1.98429 0.653982 2.27731 0.597722 2.59234C0.541737 2.90227 0.523101 3.21866 0.514645 3.53209C0.51078 3.67596 0.509122 3.81982 0.508183 3.96366C0.507186 4.13461 0.507519 4.30545 0.507519 4.4767V27.5236C0.507519 27.6949 0.507186 27.8654 0.508183 28.0367C0.509122 28.1805 0.51078 28.3244 0.514645 28.4683C0.523101 28.7814 0.541737 29.0978 0.597722 29.4077C0.653982 29.7228 0.74645 30.0157 0.891977 30.3015C1.03482 30.5827 1.22169 30.8399 1.44468 31.0625C1.66757 31.2859 1.92477 31.4727 2.20571 31.6152C2.49148 31.7611 2.7844 31.8535 3.09919 31.9102C3.40903 31.9655 3.72548 31.9843 4.03925 31.9928C4.18311 31.9961 4.32698 31.998 4.47118 31.9987C4.64177 32 4.81297 32 4.98386 32H46.0162C46.1868 32 46.358 32 46.5286 31.9987C46.6724 31.998 46.8163 31.9961 46.9608 31.9928C47.2739 31.9843 47.5903 31.9655 47.9009 31.9102C48.2153 31.8535 48.5083 31.7611 48.7941 31.6152C49.0753 31.4727 49.3317 31.2859 49.5551 31.0625C49.7777 30.8399 49.9646 30.5827 50.1078 30.3015C50.2537 30.0157 50.346 29.7228 50.402 29.4077C50.458 29.0978 50.4762 28.7814 50.4847 28.4683C50.4886 28.3244 50.4906 28.1805 50.4912 28.0367C50.4925 27.8654 50.4926 27.6949 50.4926 27.5236V4.4767C50.4926 4.30545 50.4925 4.13461 50.4912 3.96366C50.4906 3.81982 50.4886 3.67596 50.4847 3.53209C50.4762 3.21866 50.458 2.90227 50.402 2.59234C50.346 2.27731 50.2537 1.98429 50.1078 1.69852C49.9646 1.41728 49.7777 1.1605 49.5551 0.937516C49.3317 0.71453 49.0753 0.52766 48.7941 0.384791C48.5083 0.239294 48.2153 0.146886 47.9009 0.0902335C47.5903 0.0345472 47.2739 0.0160355 46.9608 0.00754966C46.8163 0.00362383 46.6724 0.00202331 46.5286 0.000996555C46.358 0 46.1868 0 46.0162 0Z\" fill=\"black\"/>\n <path d=\"M46.0162 1.06662L46.521 1.06759C46.6577 1.06855 46.7945 1.07003 46.932 1.07378C47.1711 1.08024 47.4509 1.09319 47.7117 1.13994C47.9384 1.18077 48.1285 1.24286 48.311 1.33575C48.4911 1.42728 48.6562 1.54723 48.8003 1.69113C48.9449 1.83599 49.065 2.0013 49.1578 2.18343C49.2501 2.36447 49.3118 2.55369 49.3524 2.78205C49.3991 3.04001 49.412 3.32055 49.4185 3.56121C49.4222 3.69704 49.424 3.83287 49.4247 3.97194C49.426 4.14012 49.4259 4.3082 49.4259 4.47671V27.5236C49.4259 27.6921 49.426 27.8599 49.4246 28.0317C49.424 28.1675 49.4222 28.3033 49.4185 28.4394C49.4119 28.6797 49.3991 28.9601 49.3519 29.2211C49.3118 29.4463 49.2502 29.6356 49.1573 29.8175C49.0648 29.9992 48.9449 30.1643 48.8009 30.3083C48.656 30.4532 48.4915 30.5728 48.3092 30.6652C48.1281 30.7576 47.9383 30.8197 47.7138 30.8601C47.4477 30.9075 47.1562 30.9205 46.9367 30.9265C46.7986 30.9296 46.6611 30.9315 46.5203 30.9321C46.3525 30.9334 46.1841 30.9334 46.0162 30.9334H4.98386C4.98162 30.9334 4.97945 30.9334 4.97718 30.9334C4.81127 30.9334 4.64503 30.9334 4.4761 30.9321C4.33836 30.9315 4.20093 30.9296 4.06805 30.9266C3.8435 30.9205 3.55181 30.9075 3.2879 30.8604C3.06151 30.8197 2.87171 30.7576 2.68822 30.664C2.50766 30.5724 2.34329 30.453 2.19831 30.3077C2.05444 30.1641 1.93488 29.9995 1.84245 29.8176C1.74992 29.6358 1.68801 29.446 1.64731 29.218C1.60025 28.9576 1.58733 28.6783 1.58087 28.4396C1.57718 28.303 1.57564 28.1664 1.57476 28.0305L1.5741 27.6295L1.57413 27.5236V4.47671L1.5741 4.37083L1.57473 3.97067C1.57564 3.83402 1.57718 3.6974 1.58087 3.56088C1.58733 3.32197 1.60025 3.04258 1.64769 2.77991C1.68804 2.55405 1.74992 2.36422 1.84293 2.18155C1.93464 2.001 2.05441 1.83617 2.19903 1.69158C2.34308 1.54747 2.50799 1.42767 2.6897 1.33527C2.87122 1.24283 3.06138 1.18077 3.28778 1.14003C3.54864 1.09316 3.82861 1.08024 4.06839 1.07375C4.20507 1.07003 4.34174 1.06855 4.4774 1.06762L4.98386 1.06662H46.0162Z\" fill=\"white\"/>\n <path d=\"M14.1531 10.7629C14.5811 10.2276 14.8715 9.50886 14.7949 8.77435C14.1684 8.80551 13.4038 9.18768 12.9612 9.72342C12.5638 10.1822 12.212 10.9311 12.3037 11.6348C13.007 11.6958 13.7097 11.2832 14.1531 10.7629Z\" fill=\"black\"/>\n <path d=\"M14.7869 11.7722C13.7655 11.7114 12.8972 12.3519 12.4094 12.3519C11.9214 12.3519 11.1745 11.8029 10.3667 11.8177C9.31521 11.8331 8.33959 12.4276 7.80602 13.3731C6.70857 15.2646 7.51641 18.0704 8.58362 19.611C9.10188 20.3731 9.72648 21.2123 10.5495 21.1822C11.3271 21.1517 11.6319 20.6787 12.5771 20.6787C13.5216 20.6787 13.7961 21.1822 14.6192 21.1669C15.4729 21.1516 16.0065 20.4044 16.5248 19.6415C17.1193 18.7727 17.3627 17.9338 17.378 17.8877C17.3627 17.8725 15.732 17.2469 15.7169 15.3711C15.7015 13.8004 16.9972 13.0534 17.0581 13.007C16.3265 11.9249 15.1832 11.8029 14.7869 11.7722Z\" fill=\"black\"/>\n <path d=\"M23.68 9.64661C25.8999 9.64661 27.4457 11.1768 27.4457 13.4046C27.4457 15.6404 25.8681 17.1786 23.6244 17.1786H21.1665V21.0872H19.3907V9.64661H23.68V9.64661ZM21.1665 15.688H23.2041C24.7502 15.688 25.6302 14.8556 25.6302 13.4126C25.6302 11.9697 24.7502 11.1451 23.2121 11.1451H21.1665V15.688Z\" fill=\"black\"/>\n <path d=\"M27.9097 18.7167C27.9097 17.2578 29.0276 16.3619 31.0098 16.2509L33.293 16.1162V15.474C33.293 14.5464 32.6666 13.9914 31.6203 13.9914C30.629 13.9914 30.0106 14.467 29.8601 15.2124H28.2428C28.3379 13.7059 29.6222 12.5959 31.6836 12.5959C33.7053 12.5959 34.9976 13.6663 34.9976 15.3392V21.0872H33.3563V19.7156H33.3169C32.8333 20.6433 31.7787 21.2299 30.6847 21.2299C29.0514 21.2299 27.9097 20.2151 27.9097 18.7167ZM33.293 17.9635V17.3055L31.2395 17.4323C30.2167 17.5037 29.6381 17.9556 29.6381 18.6691C29.6381 19.3985 30.2406 19.8742 31.1603 19.8742C32.3574 19.8742 33.293 19.0496 33.293 17.9635Z\" fill=\"black\"/>\n <path d=\"M36.547 24.1556V22.768C36.6736 22.7997 36.959 22.7997 37.1018 22.7997C37.8946 22.7997 38.3228 22.4668 38.5843 21.6105C38.5843 21.5946 38.7351 21.1031 38.7351 21.0952L35.7224 12.7466H37.5774L39.6866 19.5333H39.7181L41.8273 12.7466H43.6349L40.5109 21.5232C39.7976 23.5451 38.973 24.1952 37.2447 24.1952C37.1018 24.1952 36.6736 24.1793 36.547 24.1556Z\" fill=\"black\"/>\n </g>\n <defs>\n <clipPath id=\"clip0\">\n <rect width=\"49.9851\" height=\"32\" fill=\"white\" transform=\"translate(0.507462)\"/>\n </clipPath>\n </defs>\n </svg>\n";
164
164
 
165
- var applePayCloseIcon = "<svg id=\"apple-pay-close-button\" width=\"18\" height=\"18\" viewBox=\"0 0 18 18\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M13.5 4.5L4.5 13.5\" stroke=\"white\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path d=\"M4.5 4.5L13.5 13.5\" stroke=\"white\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>\n";
165
+ var applePayCloseButton = "\n <button type=\"button\" id=\"apple-pay-close-button\">\n <svg width=\"10\" height=\"9\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n d=\"M5.572 4.033L8.89.71a.4.4 0 0 0-.566-.566L5.003 3.459 1.681.145a.4.4 0 0 0-.566.566L4.44 4.033\n 1.115 7.354a.398.398 0 0 0 0 .566.4.4 0 0 0 .566 0l3.322-3.33 3.322 3.33a.4.4 0 0 0 .566-.566L5.57 4.033z\"\n fill=\"white\"\n />\n </svg>\n </button>\n";
166
166
 
167
167
  var _extends$2 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
168
168
 
@@ -230,7 +230,7 @@ var generateApplePayFallbackCSS = function generateApplePayFallbackCSS(_ref2) {
230
230
  return '\n @supports (-webkit-appearance: -apple-pay-button) { \n .apple-pay-button {\n display: inline-block;\n -webkit-appearance: -apple-pay-button;\n width: ' + width + ';\n height: ' + height + ';\n border-radius: ' + borderRadius + ';\n padding: ' + padding + ';\n -apple-pay-button-type: ' + type + ';\n -webkit-locale: ' + locale + '; \n }\n .apple-pay-button-black {\n -apple-pay-button-style: black;\n }\n .apple-pay-button-white {\n -apple-pay-button-style: white;\n }\n .apple-pay-button-white-with-line {\n -apple-pay-button-style: white-outline;\n }\n }\n\n @supports not (-webkit-appearance: -apple-pay-button) {\n .apple-pay-button {\n display: inline-block;\n background-size: 100% 60%;\n background-repeat: no-repeat;\n background-position: 50% 50%;\n border-radius: 5px;\n padding: 0px;\n box-sizing: border-box;\n min-width: 200px;\n min-height: 32px;\n max-height: 64px;\n }\n .apple-pay-button-black {\n background-image: -webkit-named-image(apple-pay-logo-white);\n background-color: black;\n }\n .apple-pay-button-white {\n background-image: -webkit-named-image(apple-pay-logo-black);\n background-color: white;\n }\n .apple-pay-button-white-with-line {\n background-image: -webkit-named-image(apple-pay-logo-black);\n background-color: white;\n border: .5px solid black;\n } \n }\n';
231
231
  };
232
232
 
233
- var preCheckoutModalCSS = '\n\n .pre-checkout-modal {\n display: none;\n position: fixed;\n z-index: 1;\n left: 0;\n top: 0;\n width: 100vw;\n height: 100%;\n overflow: auto;\n background-color: rgba(0, 0, 0, 0.75);\n transition: all 0.2s ease;\n }\n\n .pre-checkout-modal.show {\n display: block;\n }\n\n .pre-checkout-modal__content {\n position: absolute;\n bottom: 0;\n left: 0;\n right: 0;\n margin-left: auto;\n margin-right: auto;\n background-color: #fefefe;\n padding: 30px 24px;\n padding-bottom: max(30px, env(safe-area-inset-bottom));\n width: 100%;\n border-radius: 6px 6px 0 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n max-width: 450px;\n\n box-sizing: border-box;\n transform: translateY(238px);\n transition: transform 0.3s cubic-bezier(.16,.81,.32,1);\n }\n\n .modal-wrapper {\n padding: 0 16px;\n }\n\n .payment-info {\n position: relative;\n padding-bottom: 15px;\n border-bottom: solid 1px whitesmoke;\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n width: 100%;\n }\n\n .customer-email {\n color: #737373;\n font-size: 13px;\n line-height: 16px;\n }\n\n .customer-info {\n flex: 1;\n text-align: right;\n }\n\n .merchant-logo {\n display: flex;\n align-items: center;\n height: 22px;\n width: 22px;\n }\n .transaction-amount {\n margin-top: 5px;\n font-size: 13px;\n line-height: 16px;\n color: #737373;\n }\n\n .amount {\n color: #29b263;\n font-weight: bold;\n }\n\n @media only screen and (min-width: 500px) {\n .pre-checkout-modal__content {\n bottom: 0;\n top: 0;\n margin: auto;\n border-radius: 6px;\n height: fit-content;\n }\n }\n\n .pre-checkout-modal__content.show {\n transform: translateY(0);\n padding-bottom: 0;\n }\n\n .pre-checkout-modal__content > * {\n margin-top: 0;\n margin-bottom: 40px;\n }\n .pre-checkout-modal__content > *:last-child {\n margin-bottom: 0;\n }\n\n .pre-checkout-modal__content svg {\n margin: auto;\n width: 100%;\n }\n\n #inline-button-wordmark--white {\n position: absolute;\n bottom: -50px;\n margin: auto;\n right: 0;\n width: fit-content;\n }\n\n #inline-button-wordmark--grey {\n display: none;\n }\n\n .pre-checkout-modal__content #apple-pay-mark--light {\n margin-bottom: 16px;\n }\n\n .pre-checkout-modal p {\n -webkit-text-size-adjust: 100%;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n text-rendering: optimizeLegibility;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu",\n "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;\n color: #4E4E4E;\n line-height: 28px;\n font-size: 14px;\n font-weight: 500;\n text-align: center;\n letter-spacing: -0.3px;\n }\n\n .pre-checkout-modal button {\n height: 42px;\n width: 100%;\n background: linear-gradient(180deg, #40ad57 21.43%, #44b669 88.1%), #44b669;\n border: 1px solid #49a861;\n box-sizing: border-box;\n box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.1);\n border-radius: 5px;\n text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1);\n color: #ffffff;\n font-weight: 600;\n font-size: 14px;\n line-height: 14px;\n\n -webkit-text-size-adjust: 100%;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n text-rendering: optimizeLegibility;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu",\n "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;\n }\n\n #payment-request-button {\n width: 100%;\n height: fit-content;\n margin-bottom: 16px;\n }\n\n #paystackpop-button {\n padding: 0 16px;\n }\n\n #apple-pay-close-button {\n width: 18px;\n height: 18px;\n position: absolute;\n top: 0;\n right: -26px;\n cursor: pointer;\n }\n\n @media only screen and (max-width: 500px) {\n .pre-checkout-modal__content {\n max-width: 500px;\n border-radius: 0;\n }\n\n .modal-wrapper {\n padding: 0;\n }\n\n #inline-button-wordmark--white {\n display: none\n }\n \n #inline-button-wordmark--grey {\n display: block;\n width: 100%;\n margin: 16px 0;\n height: 13px;\n }\n\n #apple-pay-close-button {\n display: none;\n }\n }\n';
233
+ var preCheckoutModalCSS = '\n\n .pre-checkout-modal {\n display: none;\n position: fixed;\n z-index: 1;\n left: 0;\n top: 0;\n width: 100vw;\n height: 100%;\n overflow: auto;\n background-color: rgba(0, 0, 0, 0.75);\n transition: all 0.2s ease;\n }\n\n .pre-checkout-modal.show {\n display: block;\n }\n\n .pre-checkout-modal__content {\n position: absolute;\n bottom: 0;\n left: 0;\n right: 0;\n margin-left: auto;\n margin-right: auto;\n background-color: #fefefe;\n padding: 30px 24px;\n padding-bottom: max(30px, env(safe-area-inset-bottom));\n width: 100%;\n border-radius: 6px 6px 0 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n max-width: 450px;\n\n box-sizing: border-box;\n transform: translateY(238px);\n transition: transform 0.3s cubic-bezier(.16,.81,.32,1);\n }\n\n .modal-wrapper {\n padding: 0 16px;\n }\n\n .payment-info {\n position: relative;\n padding-bottom: 15px;\n border-bottom: solid 1px whitesmoke;\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n width: 100%;\n }\n\n .customer-email {\n color: #737373;\n font-size: 13px;\n line-height: 16px;\n }\n\n .customer-info {\n flex: 1;\n text-align: right;\n }\n\n .merchant-logo {\n display: flex;\n align-items: center;\n height: 30px;\n }\n .transaction-amount {\n margin-top: 5px;\n font-size: 13px;\n line-height: 16px;\n color: #737373;\n }\n\n .amount {\n color: #29b263;\n font-weight: bold;\n }\n\n @media only screen and (min-width: 500px) {\n .pre-checkout-modal__content {\n bottom: 0;\n top: 0;\n margin: auto;\n border-radius: 6px;\n height: fit-content;\n }\n }\n\n .pre-checkout-modal__content.show {\n transform: translateY(0);\n padding-bottom: 0;\n margin: 0 auto;\n margin-top: 100px;\n }\n\n .pre-checkout-modal__content > * {\n margin-top: 0;\n margin-bottom: 40px;\n }\n .pre-checkout-modal__content > *:last-child {\n margin-bottom: 0;\n }\n\n .pre-checkout-modal__content svg {\n margin: auto;\n width: 100%;\n }\n\n #inline-button-wordmark--white {\n position: absolute;\n bottom: -50px;\n margin: auto;\n right: 0;\n width: fit-content;\n }\n\n #inline-button-wordmark--grey {\n display: none;\n }\n\n .pre-checkout-modal__content #apple-pay-mark--light {\n margin-bottom: 16px;\n }\n\n .pre-checkout-modal p {\n -webkit-text-size-adjust: 100%;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n text-rendering: optimizeLegibility;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu",\n "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;\n color: #4E4E4E;\n line-height: 28px;\n font-size: 14px;\n font-weight: 500;\n margin: 0;\n padding: 0 20px;\n text-align: center;\n letter-spacing: -0.3px;\n }\n\n .pre-checkout-modal button {\n height: 42px;\n width: 100%;\n background: linear-gradient(180deg, #40ad57 21.43%, #44b669 88.1%), #44b669;\n border: 1px solid #49a861;\n box-sizing: border-box;\n box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.1);\n border-radius: 5px;\n text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1);\n color: #ffffff;\n font-weight: 600;\n font-size: 14px;\n line-height: 14px;\n\n -webkit-text-size-adjust: 100%;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n text-rendering: optimizeLegibility;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu",\n "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;\n }\n\n #payment-request-button {\n width: 100%;\n height: fit-content;\n margin: 24px 0 16px 0;\n }\n\n #paystackpop-button {\n padding: 0 16px;\n }\n\n #apple-pay-close-button {\n position: absolute;\n text-align: center;\n top: 0;\n right: -26px;\n height: 16px;\n width: 16px;\n padding: 0;\n display: inline-block;\n z-index: 3;\n border-radius: 50%;\n background: transparent;\n transition: all 300ms;\n outline: none;\n cursor: pointer;\n border: none;\n }\n\n #apple-pay-close-button svg {\n width: initial;\n }\n \n #apple-pay-close-button:hover {\n background-color: #e22b28;\n }\n\n @media only screen and (max-width: 500px) {\n .pre-checkout-modal__content {\n max-width: 500px;\n border-radius: 0;\n }\n\n .modal-wrapper {\n padding: 0;\n }\n\n #inline-button-wordmark--white {\n display: none\n }\n \n #inline-button-wordmark--grey {\n display: block;\n width: 100%;\n margin: 16px 0;\n height: 13px;\n }\n\n #apple-pay-close-button {\n display: none;\n }\n }\n';
234
234
 
235
235
  var amountSubunitToBase = function amountSubunitToBase() {
236
236
  var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
@@ -357,7 +357,11 @@ var canUseApplePay = function canUseApplePay() {
357
357
  };
358
358
 
359
359
  var deviceSupportsApplePay = function deviceSupportsApplePay() {
360
- return location && location.protocol === "https:" && window.ApplePaySession && window.ApplePaySession.supportsVersion(config.applePayVersion);
360
+ try {
361
+ return location && location.protocol === "https:" && window.ApplePaySession && window.ApplePaySession.supportsVersion(config.applePayVersion);
362
+ } catch (error) {
363
+ return false;
364
+ }
361
365
  };
362
366
 
363
367
  /* eslint-env browser */
@@ -626,10 +630,10 @@ function mountPreCheckoutModal(id, transaction) {
626
630
 
627
631
  var applePayPaymentInfo = document.createElement('div');
628
632
  applePayPaymentInfo.classList.add("payment-info");
629
- applePayPaymentInfo.innerHTML = '<img class="merchant-logo" src="' + merchant_logo + '" alt="' + merchant_name + ' Logo">\n <div class="customer-info">\n <div class="customer-email">' + email + '</div>\n <div class="transaction-amount">Pay <span class="amount">' + amount / 100 + ' ' + currency + '</span></div>\n </div>';
633
+ applePayPaymentInfo.innerHTML = '<img class="merchant-logo" src="' + merchant_logo + '" alt="' + merchant_name + ' Logo">\n <div class="customer-info">\n <div class="customer-email">' + email + '</div>\n <div class="transaction-amount">Pay <span class="amount">' + currency + ' ' + amount / 100 + '</span></div>\n </div>';
630
634
  content.appendChild(applePayPaymentInfo);
631
635
 
632
- content.innerHTML += applePayCloseIcon;
636
+ content.innerHTML += applePayCloseButton;
633
637
 
634
638
  var wrapper = document.createElement("div");
635
639
  wrapper.classList.add('modal-wrapper');
@@ -880,19 +884,38 @@ function serializeRequestParameters(parameters) {
880
884
 
881
885
  var iOSDevices = ["iPad Simulator", "iPhone Simulator", "iPod Simulator", "iPad", "iPhone", "iPod"];
882
886
 
887
+ /**
888
+ * navigator.platform is deprecated and will eventually be removed
889
+ * but the recommended alternative `navigator.userAgentData` has limited browser support
890
+ * so it is used as a fallback here.
891
+ */
892
+ var DEVICE_PLATFORM = window && window.navigator && (window.navigator.platform || window.navigator.userAgentData && window.navigator.userAgentData.platform);
893
+
883
894
  var isIOS = function isIOS() {
884
895
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
885
- _ref$platform = _ref.platform,
886
- platform = _ref$platform === undefined ? window && window.navigator && window.navigator.platform : _ref$platform,
896
+ platform = _ref.platform,
887
897
  _ref$userAgent = _ref.userAgent,
888
898
  userAgent = _ref$userAgent === undefined ? window && window.navigator && window.navigator.userAgent : _ref$userAgent;
889
899
 
890
- var isSafari = window.navigator && !!window.navigator.userAgent.match(/Version\/[\d\.]+.*Safari/);
891
- var isMAC = window.navigator && /(Mac)/i.test(window.navigator.platform);
900
+ var devicePlatform = platform || DEVICE_PLATFORM;
892
901
 
893
- return iOSDevices.includes(platform) ||
902
+ return iOSDevices.includes(devicePlatform) ||
894
903
  // iPAD os safari detection. iPad OS uses the same version of safari as Mac OS
895
- userAgent.includes("Mac") && "ontouchend" in document || isMAC && isSafari;
904
+ userAgent.includes("Mac") && "ontouchend" in document;
905
+ };
906
+
907
+ var isAppleOS = function isAppleOS() {
908
+ var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
909
+ platform = _ref2.platform,
910
+ _ref2$userAgent = _ref2.userAgent,
911
+ userAgent = _ref2$userAgent === undefined ? window && window.navigator && window.navigator.userAgent : _ref2$userAgent;
912
+
913
+ var devicePlatform = platform || DEVICE_PLATFORM;
914
+
915
+ var isSafari = userAgent && !!userAgent.match(/Version\/[\d\.]+.*Safari/);
916
+ var isMAC = devicePlatform && /(Mac)/i.test(devicePlatform);
917
+
918
+ return isIOS() || isMAC && isSafari;
896
919
  };
897
920
 
898
921
  var AnalyticsAPI = {
@@ -1179,6 +1202,13 @@ function notifyIframeToUpdateURL(config$$1) {
1179
1202
  }, '*');
1180
1203
  }
1181
1204
 
1205
+ var analyticsActions = {
1206
+ TRACK_CHECKOUT_CLOSED: "trackCheckoutClosed",
1207
+ TRACK_PAYMENT_ERROR: "trackPaymentError",
1208
+ TRACK_PAYMENT_ATTEMPT: "trackPaymentAttempt",
1209
+ TRACK_PAYMENT_COMPLETION: "trackPaymentCompletion"
1210
+ };
1211
+
1182
1212
  var Inline = function () {
1183
1213
  function Inline(params) {
1184
1214
  _classCallCheck$1(this, Inline);
@@ -1218,10 +1248,19 @@ var Inline = function () {
1218
1248
  }
1219
1249
  });
1220
1250
  }
1251
+ }, {
1252
+ key: 'sendAnalyticsEventToCheckout',
1253
+ value: function sendAnalyticsEventToCheckout(action, params) {
1254
+ this.checkoutIframe.contentWindow.postMessage({
1255
+ type: "analytics",
1256
+ action: action,
1257
+ params: params
1258
+ }, '*');
1259
+ }
1221
1260
  }, {
1222
1261
  key: 'checkout',
1223
1262
  value: function checkout(params) {
1224
- if (!(deviceSupportsApplePay() && isIOS())) {
1263
+ if (!(deviceSupportsApplePay() && isAppleOS())) {
1225
1264
  return Promise.resolve(this.newTransaction(params));
1226
1265
  }
1227
1266
 
@@ -1312,7 +1351,8 @@ var Inline = function () {
1312
1351
 
1313
1352
  var preCheckoutModalCloseButton = getPreCheckoutModalCloseButton(this.preCheckoutModal);
1314
1353
  preCheckoutModalCloseButton.onclick = function () {
1315
- _this2.closePreCheckoutModal();
1354
+ _this2.sendAnalyticsEventToCheckout(analyticsActions.TRACK_CHECKOUT_CLOSED);
1355
+ _this2.closePreCheckoutModalAndCancelTransaction();
1316
1356
  };
1317
1357
  }
1318
1358
  }, {
@@ -1324,6 +1364,17 @@ var Inline = function () {
1324
1364
  this.preCheckoutModal = null;
1325
1365
  }
1326
1366
  }
1367
+ }, {
1368
+ key: 'closePreCheckoutModalAndCancelTransaction',
1369
+ value: function closePreCheckoutModalAndCancelTransaction() {
1370
+ if (this.preCheckoutModal) {
1371
+ this.cancelTransaction();
1372
+ if (this.checkoutIframe && this.checkoutIframe.contentWindow) {
1373
+ this.checkoutIframe.contentWindow.postMessage('close', '*');
1374
+ }
1375
+ this.closePreCheckoutModal();
1376
+ }
1377
+ }
1327
1378
  }, {
1328
1379
  key: 'newTransaction',
1329
1380
  value: function newTransaction(_ref) {
@@ -1469,8 +1520,22 @@ var Inline = function () {
1469
1520
  var transaction = this.activeTransaction();
1470
1521
 
1471
1522
  if (transaction) {
1523
+ var paymentAttemptAnalyticsPayload = {
1524
+ channel: "apple_pay",
1525
+ paymentMethod: paymentMethod,
1526
+ currency: transaction.currency,
1527
+ amount: transaction.amount
1528
+ };
1529
+ var paymentCompleteAnalyticsPayload = {
1530
+ channel: "apple_pay",
1531
+ currency: transaction.currency,
1532
+ amount: transaction.amount,
1533
+ timeSpent: transaction.getTimeSpent()
1534
+ };
1535
+
1472
1536
  try {
1473
1537
  transaction.logAttempt(paymentMethod);
1538
+ this.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ATTEMPT, paymentAttemptAnalyticsPayload);
1474
1539
 
1475
1540
  var applePayPaymentRequest = generateApplePaymentRequestObject({
1476
1541
  currency: transaction.response.currency,
@@ -1523,15 +1588,24 @@ var Inline = function () {
1523
1588
  if (response.status === 'success') {
1524
1589
  applePaySession.completePayment(applePaySession.STATUS_SUCCESS);
1525
1590
  transaction.onSuccess(response);
1591
+ this.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_COMPLETION, paymentCompleteAnalyticsPayload);
1526
1592
  } else {
1527
1593
  applePaySession.completePayment(applePaySession.STATUS_FAILURE);
1528
1594
  transaction.onSetupError(response);
1595
+ this.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
1596
+ channel: "apple_pay",
1597
+ message: response && response.message || "Transaction attempt failed"
1598
+ });
1529
1599
  }
1530
1600
 
1531
1601
  inlineInstance.closePreCheckoutModal();
1532
1602
  }).catch(function (error) {
1533
1603
  applePaySession.completePayment(applePaySession.STATUS_FAILURE);
1534
1604
  transaction.onSetupError(error);
1605
+ this.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
1606
+ channel: "apple_pay",
1607
+ message: error && error.message || "Error occurred"
1608
+ });
1535
1609
 
1536
1610
  inlineInstance.closePreCheckoutModal();
1537
1611
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paystack/inline-js",
3
- "version": "2.11.0-dev.8",
3
+ "version": "2.13.0-dev.1",
4
4
  "description": "Client-side library to load the Paystack checkout form",
5
5
  "main": "lib/inline.js",
6
6
  "module": "es/inline.js",