@adyen/adyen-web 6.0.0-alpha.0 → 6.0.0-alpha.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.
Files changed (130) hide show
  1. package/auto/auto.js +2 -0
  2. package/dist/cjs/adyen.css +1 -1
  3. package/dist/cjs/index.cjs +2 -2
  4. package/dist/cjs/index.cjs.map +1 -1
  5. package/dist/cjs/index.d.cts +161 -248
  6. package/dist/es/adyen.css +1 -1
  7. package/dist/es/components/ApplePay/ApplePay.js +1 -1
  8. package/dist/es/components/ApplePay/ApplePay.js.map +1 -1
  9. package/dist/es/components/Dropin/Dropin.js +1 -1
  10. package/dist/es/components/Dropin/Dropin.js.map +1 -1
  11. package/dist/es/components/Dropin/components/DropinComponent.js +1 -1
  12. package/dist/es/components/Dropin/components/DropinComponent.js.map +1 -1
  13. package/dist/es/components/Dropin/defaultProps.js +1 -1
  14. package/dist/es/components/Dropin/defaultProps.js.map +1 -1
  15. package/dist/es/components/GooglePay/GooglePay.js +1 -1
  16. package/dist/es/components/GooglePay/GooglePay.js.map +1 -1
  17. package/dist/es/components/PayPal/Paypal.js +1 -1
  18. package/dist/es/components/PayPal/Paypal.js.map +1 -1
  19. package/dist/es/components/PayPal/components/PaypalButtons.js +1 -1
  20. package/dist/es/components/PayPal/components/PaypalButtons.js.map +1 -1
  21. package/dist/es/components/PayPal/components/PaypalComponent.js +1 -1
  22. package/dist/es/components/PayPal/components/PaypalComponent.js.map +1 -1
  23. package/dist/es/components/PayPal/defaultProps.js +1 -1
  24. package/dist/es/components/PayPal/defaultProps.js.map +1 -1
  25. package/dist/es/components/PayPal/utils/format-paypal-order-contact-to-adyen-format.js +1 -1
  26. package/dist/es/components/PayPal/utils/format-paypal-order-contact-to-adyen-format.js.map +1 -1
  27. package/dist/es/components/PayPal/utils/get-paypal-locale.js +2 -0
  28. package/dist/es/components/PayPal/utils/get-paypal-locale.js.map +1 -0
  29. package/dist/es/components/PayPal/utils/get-paypal-settings.js +2 -0
  30. package/dist/es/components/PayPal/utils/get-paypal-settings.js.map +1 -0
  31. package/dist/es/components/PayPal/utils/get-paypal-styles.js +2 -0
  32. package/dist/es/components/PayPal/utils/get-paypal-styles.js.map +1 -0
  33. package/dist/es/components/PayPal/utils/get-paypal-url.js +2 -0
  34. package/dist/es/components/PayPal/utils/get-paypal-url.js.map +1 -0
  35. package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js +1 -1
  36. package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
  37. package/dist/es/components/internal/BaseElement/BaseElement.js +1 -1
  38. package/dist/es/components/internal/BaseElement/BaseElement.js.map +1 -1
  39. package/dist/es/components/internal/UIElement/UIElement.js +1 -1
  40. package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
  41. package/dist/es/components/internal/UIElement/utils.js.map +1 -1
  42. package/dist/es/core/AdyenCheckout.js +1 -1
  43. package/dist/es/core/AdyenCheckout.js.map +1 -1
  44. package/dist/es/core/Analytics/Analytics.js +1 -1
  45. package/dist/es/core/Analytics/Analytics.js.map +1 -1
  46. package/dist/es/core/Analytics/EventsQueue.js +1 -1
  47. package/dist/es/core/Analytics/EventsQueue.js.map +1 -1
  48. package/dist/es/core/Analytics/utils.js +1 -1
  49. package/dist/es/core/Analytics/utils.js.map +1 -1
  50. package/dist/es/core/Errors/AdyenCheckoutError.js +1 -1
  51. package/dist/es/core/Errors/AdyenCheckoutError.js.map +1 -1
  52. package/dist/es/core/Errors/utils.js +1 -1
  53. package/dist/es/core/Errors/utils.js.map +1 -1
  54. package/dist/es/core/Services/analytics/collect-id.js +1 -1
  55. package/dist/es/core/Services/analytics/collect-id.js.map +1 -1
  56. package/dist/es/core/Services/analytics/log-event.js +1 -1
  57. package/dist/es/core/config.js +1 -1
  58. package/dist/es/core/config.js.map +1 -1
  59. package/dist/es/core/core.js +1 -1
  60. package/dist/es/core/core.js.map +1 -1
  61. package/dist/es/index.d.ts +161 -248
  62. package/dist/es/language/locales/en-US.json.js +1 -1
  63. package/dist/es/utils/Script.js +1 -1
  64. package/dist/es/utils/Script.js.map +1 -1
  65. package/dist/es-legacy/adyen.css +1 -1
  66. package/dist/es-legacy/components/ApplePay/ApplePay.js +1 -1
  67. package/dist/es-legacy/components/ApplePay/ApplePay.js.map +1 -1
  68. package/dist/es-legacy/components/Dropin/Dropin.js +1 -1
  69. package/dist/es-legacy/components/Dropin/Dropin.js.map +1 -1
  70. package/dist/es-legacy/components/Dropin/components/DropinComponent.js +1 -1
  71. package/dist/es-legacy/components/Dropin/components/DropinComponent.js.map +1 -1
  72. package/dist/es-legacy/components/Dropin/defaultProps.js +1 -1
  73. package/dist/es-legacy/components/Dropin/defaultProps.js.map +1 -1
  74. package/dist/es-legacy/components/GooglePay/GooglePay.js +1 -1
  75. package/dist/es-legacy/components/GooglePay/GooglePay.js.map +1 -1
  76. package/dist/es-legacy/components/PayPal/Paypal.js +1 -1
  77. package/dist/es-legacy/components/PayPal/Paypal.js.map +1 -1
  78. package/dist/es-legacy/components/PayPal/components/PaypalButtons.js +1 -1
  79. package/dist/es-legacy/components/PayPal/components/PaypalButtons.js.map +1 -1
  80. package/dist/es-legacy/components/PayPal/components/PaypalComponent.js +1 -1
  81. package/dist/es-legacy/components/PayPal/components/PaypalComponent.js.map +1 -1
  82. package/dist/es-legacy/components/PayPal/defaultProps.js +1 -1
  83. package/dist/es-legacy/components/PayPal/defaultProps.js.map +1 -1
  84. package/dist/es-legacy/components/PayPal/utils/format-paypal-order-contact-to-adyen-format.js +1 -1
  85. package/dist/es-legacy/components/PayPal/utils/format-paypal-order-contact-to-adyen-format.js.map +1 -1
  86. package/dist/es-legacy/components/PayPal/utils/get-paypal-locale.js +2 -0
  87. package/dist/es-legacy/components/PayPal/utils/get-paypal-locale.js.map +1 -0
  88. package/dist/es-legacy/components/PayPal/utils/get-paypal-settings.js +2 -0
  89. package/dist/es-legacy/components/PayPal/utils/get-paypal-settings.js.map +1 -0
  90. package/dist/es-legacy/components/PayPal/utils/get-paypal-styles.js +2 -0
  91. package/dist/es-legacy/components/PayPal/utils/get-paypal-styles.js.map +1 -0
  92. package/dist/es-legacy/components/PayPal/utils/get-paypal-url.js +2 -0
  93. package/dist/es-legacy/components/PayPal/utils/get-paypal-url.js.map +1 -0
  94. package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js +1 -1
  95. package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
  96. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js +1 -1
  97. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js.map +1 -1
  98. package/dist/es-legacy/components/internal/UIElement/UIElement.js +1 -1
  99. package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
  100. package/dist/es-legacy/components/internal/UIElement/utils.js.map +1 -1
  101. package/dist/es-legacy/core/AdyenCheckout.js +1 -1
  102. package/dist/es-legacy/core/AdyenCheckout.js.map +1 -1
  103. package/dist/es-legacy/core/Analytics/Analytics.js +1 -1
  104. package/dist/es-legacy/core/Analytics/Analytics.js.map +1 -1
  105. package/dist/es-legacy/core/Analytics/EventsQueue.js +1 -1
  106. package/dist/es-legacy/core/Analytics/EventsQueue.js.map +1 -1
  107. package/dist/es-legacy/core/Analytics/utils.js +1 -1
  108. package/dist/es-legacy/core/Analytics/utils.js.map +1 -1
  109. package/dist/es-legacy/core/Errors/AdyenCheckoutError.js +1 -1
  110. package/dist/es-legacy/core/Errors/AdyenCheckoutError.js.map +1 -1
  111. package/dist/es-legacy/core/Errors/utils.js +1 -1
  112. package/dist/es-legacy/core/Errors/utils.js.map +1 -1
  113. package/dist/es-legacy/core/Services/analytics/collect-id.js +1 -1
  114. package/dist/es-legacy/core/Services/analytics/collect-id.js.map +1 -1
  115. package/dist/es-legacy/core/Services/analytics/log-event.js +1 -1
  116. package/dist/es-legacy/core/config.js +1 -1
  117. package/dist/es-legacy/core/config.js.map +1 -1
  118. package/dist/es-legacy/core/core.js +1 -1
  119. package/dist/es-legacy/core/core.js.map +1 -1
  120. package/dist/es-legacy/language/locales/en-US.json.js +1 -1
  121. package/dist/es-legacy/utils/Script.js +1 -1
  122. package/dist/es-legacy/utils/Script.js.map +1 -1
  123. package/dist/umd/adyen.css +1 -1
  124. package/dist/umd/adyen.js +2 -2
  125. package/dist/umd/adyen.js.map +1 -1
  126. package/package.json +2 -2
  127. package/dist/es/components/PayPal/utils.js +0 -2
  128. package/dist/es/components/PayPal/utils.js.map +0 -1
  129. package/dist/es-legacy/components/PayPal/utils.js +0 -2
  130. package/dist/es-legacy/components/PayPal/utils.js.map +0 -1
@@ -1,2 +1,2 @@
1
- var e={payButton:"Pay","payButton.redirecting":"Redirecting...","payButton.with":"Pay %{value} with %{maskedData}","payButton.saveDetails":"Save details",close:"Close",storeDetails:"Save for my next payment",readMore:"Read more","creditCard.holderName":"Name on card","creditCard.holderName.invalid":"Enter name as shown on card","creditCard.expiryDateField.month":"Month","creditCard.expiryDateField.year":"Year","creditCard.storeDetailsButton":"Remember for next time",installments:"Number of installments",installmentOption:"%{times}x %{partialValue}",installmentOptionMonths:"%{times} months","installments.oneTime":"One time payment","installments.installments":"Installments payment","installments.revolving":"Revolving payment","sepaDirectDebit.ibanField.invalid":"Invalid account number","sepa.ownerName":"Holder Name","sepa.ibanNumber":"Account Number (IBAN)","error.title":"Error","error.subtitle.redirect":"Redirect failed","error.subtitle.payment":"Payment failed","error.subtitle.refused":"Payment refused","error.message.unknown":"An unknown error occurred","errorPanel.title":"Existing errors","idealIssuer.selectField.title":"Bank","creditCard.success":"Payment Successful",loading:"Loading…",continue:"Continue",continueTo:"Continue to","wechatpay.timetopay":"You have %@ to pay","sr.wechatpay.timetopay":"You have %#minutes%# %#seconds%# to pay","wechatpay.scanqrcode":"Scan QR code",personalDetails:"Personal details",companyDetails:"Company details","companyDetails.name":"Company name","companyDetails.registrationNumber":"Registration number",socialSecurityNumber:"Social security number",firstName:"First name","firstName.invalid":"Enter your first name",infix:"Prefix",lastName:"Last name","lastName.invalid":"Enter your last name",mobileNumber:"Mobile number","mobileNumber.invalid":"Invalid mobile number",city:"City",postalCode:"Postal code","postalCode.optional":"Postal code (optional)",countryCode:"Country Code",telephoneNumber:"Telephone number",telephonePrefix:"Prefix",dateOfBirth:"Date of birth",shopperEmail:"Email address",gender:"Gender","gender.notselected":"Select your gender",male:"Male",female:"Female",billingAddress:"Billing address",street:"Street",stateOrProvince:"State or province",country:"Country",houseNumberOrName:"House number",separateDeliveryAddress:"Specify a separate delivery address",deliveryAddress:"Delivery Address","deliveryAddress.firstName":"Recipient first name","deliveryAddress.lastName":"Recipient last name",zipCode:"Zip code",apartmentSuite:"Apartment / Suite",provinceOrTerritory:"Province or Territory",cityTown:"City / Town",address:"Address","address.search.contextualText":"Type to start searching your address","address.errors.incomplete":"Enter an address to continue","address.enterManually":"Enter address manually",state:"State","field.title.optional":"(optional)","issuerList.selectField.contextualText":"Select your bank to continue","issuerList.selectField.label":"Bank selection",privacyPolicy:"Privacy policy","afterPay.agreement":"I agree with the %@ of Riverty",paymentConditions:"payment conditions",openApp:"Open the app","voucher.readInstructions":"Read instructions","voucher.introduction":"Thank you for your purchase, please use the following coupon to complete your payment.","voucher.expirationDate":"Expiration Date","voucher.alternativeReference":"Alternative Reference","voucher.paymentReferenceLabel":"Payment Reference","voucher.surcharge":"Incl. %@ surcharge","voucher.introduction.doku":"Thank you for your purchase, please use the following information to complete your payment.","voucher.shopperName":"Shopper Name","voucher.merchantName":"Merchant","voucher.introduction.econtext":"Thank you for your purchase, please use the following information to complete your payment.","voucher.telephoneNumber":"Phone Number","voucher.shopperReference":"Shopper Reference","voucher.collectionInstitutionNumber":"Collection Institution Number","voucher.econtext.telephoneNumber.invalid":"Telephone number must be 10 or 11 digits long","boletobancario.btnLabel":"Generate Boleto","boleto.sendCopyToEmail":"Send a copy to my email","button.copy":"Copy","button.download":"Download","boleto.socialSecurityNumber":"CPF/CNPJ","boleto.socialSecurityNumber.invalid":"Field is not valid","creditCard.storedCard.description.ariaLabel":"Stored card ends in %@","voucher.entity":"Entity",donateButton:"Donate",notNowButton:"Not now",thanksForYourSupport:"Thanks for your support!","resultMessages.preauthorized":"Details saved",preauthorizeWith:"Preauthorize with",confirmPreauthorization:"Confirm preauthorization",confirmPurchase:"Confirm purchase",applyGiftcard:"Redeem",giftcardBalance:"Gift card balance",deductedBalance:"Deducted balance","creditCard.taxNumber":"Cardholder birthdate or Corporate registration number","creditCard.taxNumber.label":"Cardholder birthdate (YYMMDD) or Corporate registration number (10 digits)","creditCard.taxNumber.labelAlt":"Corporate registration number (10 digits)","creditCard.taxNumber.invalid":"Invalid Cardholder birthdate or Corporate registration number","storedPaymentMethod.disable.button":"Remove","storedPaymentMethod.disable.confirmation":"Remove stored payment method","storedPaymentMethod.disable.confirmButton":"Yes, remove","storedPaymentMethod.disable.cancelButton":"Cancel","ach.bankAccount":"Bank account","ach.accountHolderNameField.title":"Account holder name","ach.accountHolderNameField.contextualText":"Located on the front of your card","ach.accountHolderNameField.invalid":"Invalid account holder name","ach.accountNumberField.invalid":"Invalid account number","ach.accountLocationField.invalid":"Invalid ABA routing number","ach.savedBankAccount":"Saved bank account","select.state":"Select state","select.stateOrProvince":"Select state or province","select.provinceOrTerritory":"Select province or territory","select.country":"Select country","select.noOptionsFound":"No options found","telephoneNumber.invalid":"Invalid telephone number",qrCodeOrApp:"or","paypal.processingPayment":"Processing payment...",generateQRCode:"Generate QR code","await.waitForConfirmation":"Waiting for confirmation","mbway.confirmPayment":"Confirm your payment on the MB WAY app","shopperEmail.invalid":"Invalid email address","dateOfBirth.format":"DD/MM/YYYY","dateOfBirth.invalid":"Enter a valid date of birth that indicates you are at least 18 years old","blik.confirmPayment":"Open your banking app to confirm the payment.","blik.invalid":"Enter 6 numbers","blik.code":"6-digit code","blik.help":"Get the code from your banking app.","swish.pendingMessage":"After you scan, the status can be pending for up to 10 minutes. Attempting to pay again within this time may result in multiple charges.","field.valid":"Field valid","field.invalid":"Field not valid","field.error.required":"Enter the %{label}","field.error.invalid":"Enter a valid %{label}","error.va.gen.01":"Incomplete field","error.va.gen.02":"Field not valid","error.va.sf-cc-num.01":"Enter a valid card number","error.va.sf-cc-num.02":"Enter the card number","error.va.sf-cc-num.03":"Enter a supported card brand","error.va.sf-cc-num.04":"Enter the complete card number","error.va.sf-cc-dat.01":"Enter a valid expiry date","error.va.sf-cc-dat.02":"Enter a valid expiry date","error.va.sf-cc-dat.03":"Credit card about to expire","error.va.sf-cc-dat.04":"Enter the expiry date","error.va.sf-cc-dat.05":"Enter the complete expiry date","error.va.sf-cc-mth.01":"Enter the expiry month","error.va.sf-cc-yr.01":"Enter the expiry year","error.va.sf-cc-yr.02":"Enter the complete expiry year","error.va.sf-cc-cvc.01":"Enter the security code","error.va.sf-cc-cvc.02":"Enter the complete security code","error.va.sf-ach-num.01":"Bank account number field is empty","error.va.sf-ach-num.02":"Bank account number is the wrong length","error.va.sf-ach-loc.01":"Bank routing number field is empty","error.va.sf-ach-loc.02":"Bank routing number is the wrong length","error.va.sf-kcp-pwd.01":"Password field is empty","error.va.sf-kcp-pwd.02":"Password is the wrong length","error.giftcard.no-balance":"This gift card has zero balance","error.giftcard.card-error":"In our records we have no gift card with this number","error.giftcard.currency-error":"Gift cards are only valid in the currency they were issued in","amazonpay.signout":"Sign out from Amazon","amazonpay.changePaymentDetails":"Change payment details","partialPayment.warning":"Select another payment method to pay the remaining","partialPayment.remainingBalance":"Remaining balance will be %{amount}","bankTransfer.beneficiary":"Beneficiary","bankTransfer.iban":"IBAN","bankTransfer.bic":"BIC","bankTransfer.reference":"Reference","bankTransfer.introduction":"Continue to create a new bank transfer payment. You can use the details in the following screen to finalize this payment.","bankTransfer.instructions":"Thank you for your purchase, please use the following information to complete your payment.","bacs.accountHolderName":"Bank account holder name","bacs.accountHolderName.invalid":"Invalid bank account holder name","bacs.accountNumber":"Bank account number","bacs.accountNumber.invalid":"Invalid bank account number","bacs.bankLocationId":"Sort code","bacs.bankLocationId.invalid":"Invalid sort code","bacs.consent.amount":"I agree that the above amount will be deducted from my bank account.","bacs.consent.account":"I confirm the account is in my name and I am the only signatory required to authorise the Direct Debit on this account.",edit:"Edit","bacs.confirm":"Confirm and pay","bacs.result.introduction":"Download your Direct Debit Instruction (DDI / Mandate)","download.pdf":"Download PDF","creditCard.encryptedCardNumber.aria.iframeTitle":"Iframe for card number","creditCard.encryptedExpiryDate.aria.iframeTitle":"Iframe for expiry date","creditCard.encryptedExpiryMonth.aria.iframeTitle":"Iframe for expiry month","creditCard.encryptedExpiryYear.aria.iframeTitle":"Iframe for expiry year","creditCard.encryptedSecurityCode.aria.iframeTitle":"Iframe for security code","creditCard.encryptedPassword.aria.iframeTitle":"Iframe for password","giftcard.encryptedCardNumber.aria.iframeTitle":"Iframe for card number","giftcard.encryptedSecurityCode.aria.iframeTitle":"Iframe for pin",giftcardTransactionLimit:"Max. %{amount} allowed per transaction on this gift card","ach.encryptedBankAccountNumber.aria.iframeTitle":"Iframe for bank account number","ach.encryptedBankLocationId.aria.iframeTitle":"Iframe for bank routing number","pix.instructions":"Open the app with the PIX registered key, choose Pay with PIX and scan the QR Code or copy and paste the code","twint.saved":"saved",orPayWith:"or pay with",invalidFormatExpects:"Invalid format. Expected format: %{format}","upi.qrCodeWaitingMessage":"Scan the QR code using your preferred UPI app to complete the payment","upi.vpaWaitingMessage":"Open your UPI app to confirm the payment","upi.modeSelection":"Make a selection on how you would like to use UPI.","onlineBanking.termsAndConditions":"By continuing you agree with the %#terms and conditions%#","onlineBankingPL.termsAndConditions":"By continuing you agree with the %#regulations%# and %#information obligation%# of Przelewy24","ctp.loading.poweredByCtp":"Powered by Click to Pay","ctp.loading.intro":"We are checking to see if you have any saved cards with Click to Pay...","ctp.login.title":"Continue to Click to Pay","ctp.login.subtitle":"Enter the email address that is connected to Click to Pay to continue.","ctp.login.inputLabel":"Email","ctp.logout.notYou":"Not you?","ctp.logout.notYourCards":"Not your cards?","ctp.logout.notYourCard":"Not your card?","ctp.logout.notYourProfile":"Not your profile?","ctp.otp.fieldLabel":"One time code","ctp.otp.resendCode":"Resend code","ctp.otp.codeResent":"Code resent","ctp.otp.title":"Access your Click to Pay cards","ctp.otp.subtitle":"Enter the code %@ sent to %@ to verify it‘s you.","ctp.otp.saveCookiesCheckbox.label":"Skip verification next time","ctp.otp.saveCookiesCheckbox.information":"Select to be remembered on your device and browser at participating stores for faster checkout. Not recommended for shared devices.","ctp.otp.saveCookiesCheckbox.shorterInfo":"Select to be remembered on your device and browser","ctp.emptyProfile.message":"No cards registered in this Click to Pay profile","ctp.separatorText":"or use","ctp.cards.title":"Complete payment with Click to Pay","ctp.cards.subtitle":"Select a card to use.","ctp.cards.expiredCard":"Expired","ctp.manualCardEntry":"Manual card entry","ctp.aria.infoModalButton":"What is Click to Pay","ctp.infoPopup.title":"Click to Pay brings the ease of contactless, online","ctp.infoPopup.subtitle":"A fast, secure payment method supported by Mastercard, Visa and other payment cards.","ctp.infoPopup.benefit1":"Click to Pay uses encryption to keep your information safe and secure","ctp.infoPopup.benefit2":"Use it with merchants worldwide","ctp.infoPopup.benefit3":"Set up once for hassle-free payments in the future","ctp.errors.AUTH_INVALID":"Authentication Invalid","ctp.errors.NOT_FOUND":"No account found, enter a valid email or continue using manual card entry","ctp.errors.ID_FORMAT_UNSUPPORTED":"Format not supported","ctp.errors.FRAUD":"The user account was locked or disabled","ctp.errors.CONSUMER_ID_MISSING":"Consumer identity is missing in the request","ctp.errors.ACCT_INACCESSIBLE":"This account is currently not available, e.g it is locked","ctp.errors.CODE_INVALID":"Incorrect verification code","ctp.errors.CODE_EXPIRED":"This code has expired","ctp.errors.RETRIES_EXCEEDED":"The limit for the number of retries for OTP generation was exceeded","ctp.errors.OTP_SEND_FAILED":"The OTP could not be sent to the recipient","ctp.errors.REQUEST_TIMEOUT":"Something went wrong, try again or use the manual card entry","ctp.errors.UNKNOWN_ERROR":"Something went wrong, try again or use the manual card entry","ctp.errors.SERVICE_ERROR":"Something went wrong, try again or use the manual card entry","ctp.errors.SERVER_ERROR":"Something went wrong, try again or use the manual card entry","ctp.errors.INVALID_PARAMETER":"Something went wrong, try again or use the manual card entry","ctp.errors.AUTH_ERROR":"Something went wrong, try again or use the manual card entry","paymentMethodsList.aria.label":"Choose a payment method","paymentMethodsList.storedPayments.label":"Saved payment methods","paymentMethodsList.otherPayments.label":"More payment options","companyDetails.name.invalid":"Enter the company name","companyDetails.registrationNumber.invalid":"Enter the registration number","consent.checkbox.invalid":"You must agree with the terms & conditions","form.instruction":"All fields are required unless marked otherwise.","trustly.descriptor":"Instant Bank Payment","trustly.description1":"Pay directly from any of your bank accounts, backed by bank-level security","trustly.description2":"No cards, no app download, no registration","ancv.input.label":"Your ANCV identification","ancv.confirmPayment":"Use your ANCV application to confirm the payment.","ancv.form.instruction":"The Cheque-Vacances application is necessary to validate this payment.","ancv.beneficiaryId.invalid":"Enter a valid email address or ANCV ID","creditCard.cardNumber.label":"Card number","creditCard.expiryDate.label":"Expiry date","creditCard.expiryDate.contextualText":"Front of card in MM/YY format","creditCard.securityCode.label":"Security code","creditCard.securityCode.label.optional":"Security code (optional)","creditCard.securityCode.contextualText.3digits":"3 digits on back of card","creditCard.securityCode.contextualText.4digits":"4 digits on back of card","creditCard.pin.label":"Pin","creditCard.password.label":"First 2 digits of card password","giftcard.cardNumber.label":"Card Number","giftcard.expiryDate.label":"Expiry date","giftcard.securityCode.label":"Pin","ach.bankAccountNumber.label":"Account number","ach.bankLocationId.label":"ABA routing number","dragonpayVoucher.selectField.contextualText.nonBank":"Select your provider","dragonpayVoucher.selectField.contextualText.bank":"Select your bank","payme.openPayMeApp":"Complete your payment in the PayMe app by authorizing the payment in the app and wait for the confirmation.","payme.redirectButtonLabel":"Open PayMe app","payme.scanQrCode":"Complete your payment by QR code","payme.timeToPay":"This QR code is valid for %@","payme.instructions.steps":"Open the PayMe app.%@Scan the QR code to authorize the payment.%@Complete the payment in the app and wait for confirmation.","payme.instructions.footnote":"Please do not close this page before the payment is completed"};export{e as default};
1
+ var e={payButton:"Pay","payButton.redirecting":"Redirecting...","payButton.with":"Pay %{value} with %{maskedData}","payButton.saveDetails":"Save details",close:"Close",storeDetails:"Save for my next payment",readMore:"Read more","creditCard.holderName":"Name on card","creditCard.holderName.invalid":"Enter name as shown on card","creditCard.expiryDateField.month":"Month","creditCard.expiryDateField.year":"Year","creditCard.storeDetailsButton":"Remember for next time",installments:"Number of installments",installmentOption:"%{times}x %{partialValue}",installmentOptionMonths:"%{times} months","installments.oneTime":"One time payment","installments.installments":"Installments payment","installments.revolving":"Revolving payment","sepaDirectDebit.ibanField.invalid":"Invalid account number","sepa.ownerName":"Holder Name","sepa.ibanNumber":"Account Number (IBAN)","error.title":"Error","error.subtitle.redirect":"Redirect failed","error.subtitle.payment":"Payment failed","error.subtitle.refused":"Payment refused","error.message.unknown":"An unknown error occurred","errorPanel.title":"Existing errors","idealIssuer.selectField.title":"Bank","creditCard.success":"Payment Successful",loading:"Loading…",continue:"Continue",continueTo:"Continue to","wechatpay.timetopay":"You have %@ to pay","sr.wechatpay.timetopay":"You have %#minutes%# %#seconds%# to pay","wechatpay.scanqrcode":"Scan QR code",personalDetails:"Personal details",companyDetails:"Company details","companyDetails.name":"Company name","companyDetails.registrationNumber":"Registration number",socialSecurityNumber:"Social security number",firstName:"First name","firstName.invalid":"Enter your first name",infix:"Prefix",lastName:"Last name","lastName.invalid":"Enter your last name",mobileNumber:"Mobile number","mobileNumber.invalid":"Invalid mobile number",city:"City",postalCode:"Postal code","postalCode.optional":"Postal code (optional)",countryCode:"Country Code",telephoneNumber:"Telephone number",telephonePrefix:"Prefix",dateOfBirth:"Date of birth",shopperEmail:"Email address",gender:"Gender","gender.notselected":"Select your gender",male:"Male",female:"Female",billingAddress:"Billing address",street:"Street",stateOrProvince:"State or province",country:"Country",houseNumberOrName:"House number",separateDeliveryAddress:"Specify a separate delivery address",deliveryAddress:"Delivery Address","deliveryAddress.firstName":"Recipient first name","deliveryAddress.lastName":"Recipient last name",zipCode:"Zip code",apartmentSuite:"Apartment / Suite",provinceOrTerritory:"Province or Territory",cityTown:"City / Town",address:"Address","address.search.contextualText":"Type to start searching your address","address.errors.incomplete":"Enter an address to continue","address.enterManually":"Enter address manually",state:"State","field.title.optional":"(optional)","issuerList.selectField.contextualText":"Select your bank to continue","issuerList.selectField.label":"Bank selection",privacyPolicy:"Privacy policy","afterPay.agreement":"I agree with the %@ of Riverty",paymentConditions:"payment conditions",openApp:"Open the app","voucher.readInstructions":"Read instructions","voucher.introduction":"Thank you for your purchase, please use the following coupon to complete your payment.","voucher.expirationDate":"Expiration Date","voucher.alternativeReference":"Alternative Reference","voucher.paymentReferenceLabel":"Payment Reference","voucher.surcharge":"Incl. %@ surcharge","voucher.introduction.doku":"Thank you for your purchase, please use the following information to complete your payment.","voucher.shopperName":"Shopper Name","voucher.merchantName":"Merchant","voucher.introduction.econtext":"Thank you for your purchase, please use the following information to complete your payment.","voucher.telephoneNumber":"Phone Number","voucher.shopperReference":"Shopper Reference","voucher.collectionInstitutionNumber":"Collection Institution Number","voucher.econtext.telephoneNumber.invalid":"Telephone number must be 10 or 11 digits long","boletobancario.btnLabel":"Generate Boleto","boleto.sendCopyToEmail":"Send a copy to my email","button.copy":"Copy","button.download":"Download","boleto.socialSecurityNumber":"CPF/CNPJ","boleto.socialSecurityNumber.invalid":"Enter a complete CPF/CNPJ number","creditCard.storedCard.description.ariaLabel":"Stored card ends in %@","voucher.entity":"Entity",donateButton:"Donate",notNowButton:"Not now",thanksForYourSupport:"Thanks for your support!","resultMessages.preauthorized":"Details saved",preauthorizeWith:"Preauthorize with",confirmPreauthorization:"Confirm preauthorization",confirmPurchase:"Confirm purchase",applyGiftcard:"Redeem",giftcardBalance:"Gift card balance",deductedBalance:"Deducted balance","creditCard.taxNumber":"Cardholder birthdate or Corporate registration number","creditCard.taxNumber.label":"Cardholder birthdate (YYMMDD) or Corporate registration number (10 digits)","creditCard.taxNumber.labelAlt":"Corporate registration number (10 digits)","creditCard.taxNumber.invalid":"Invalid Cardholder birthdate or Corporate registration number","storedPaymentMethod.disable.button":"Remove","storedPaymentMethod.disable.confirmation":"Remove stored payment method","storedPaymentMethod.disable.confirmButton":"Yes, remove","storedPaymentMethod.disable.cancelButton":"Cancel","ach.bankAccount":"Bank account","ach.accountHolderNameField.title":"Account holder name","ach.accountHolderNameField.contextualText":"Located on the front of your card","ach.accountHolderNameField.invalid":"Invalid account holder name","ach.accountNumberField.invalid":"Invalid account number","ach.accountLocationField.invalid":"Invalid ABA routing number","ach.savedBankAccount":"Saved bank account","select.state":"Select state","select.stateOrProvince":"Select state or province","select.provinceOrTerritory":"Select province or territory","select.country":"Select country","select.noOptionsFound":"No options found","telephoneNumber.invalid":"Invalid telephone number",qrCodeOrApp:"or","paypal.processingPayment":"Processing payment...",generateQRCode:"Generate QR code","await.waitForConfirmation":"Waiting for confirmation","mbway.confirmPayment":"Confirm your payment on the MB WAY app","shopperEmail.invalid":"Invalid email address","dateOfBirth.format":"DD/MM/YYYY","dateOfBirth.invalid":"Enter a valid date of birth that indicates you are at least 18 years old","blik.confirmPayment":"Open your banking app to confirm the payment.","blik.invalid":"Enter 6 numbers","blik.code":"6-digit code","blik.help":"Get the code from your banking app.","swish.pendingMessage":"After you scan, the status can be pending for up to 10 minutes. Attempting to pay again within this time may result in multiple charges.","field.valid":"Field valid","field.invalid":"Field not valid","field.error.required":"Enter the %{label}","field.error.invalid":"Enter a valid %{label}","error.va.gen.01":"Incomplete field","error.va.gen.02":"Field not valid","error.va.sf-cc-num.01":"Enter a valid card number","error.va.sf-cc-num.02":"Enter the card number","error.va.sf-cc-num.03":"Enter a supported card brand","error.va.sf-cc-num.04":"Enter the complete card number","error.va.sf-cc-dat.01":"Enter a valid expiry date","error.va.sf-cc-dat.02":"Enter a valid expiry date","error.va.sf-cc-dat.03":"Credit card about to expire","error.va.sf-cc-dat.04":"Enter the expiry date","error.va.sf-cc-dat.05":"Enter the complete expiry date","error.va.sf-cc-mth.01":"Enter the expiry month","error.va.sf-cc-yr.01":"Enter the expiry year","error.va.sf-cc-yr.02":"Enter the complete expiry year","error.va.sf-cc-cvc.01":"Enter the security code","error.va.sf-cc-cvc.02":"Enter the complete security code","error.va.sf-ach-num.01":"Bank account number field is empty","error.va.sf-ach-num.02":"Bank account number is the wrong length","error.va.sf-ach-loc.01":"Bank routing number field is empty","error.va.sf-ach-loc.02":"Bank routing number is the wrong length","error.va.sf-kcp-pwd.01":"Password field is empty","error.va.sf-kcp-pwd.02":"Password is the wrong length","error.giftcard.no-balance":"This gift card has zero balance","error.giftcard.card-error":"In our records we have no gift card with this number","error.giftcard.currency-error":"Gift cards are only valid in the currency they were issued in","amazonpay.signout":"Sign out from Amazon","amazonpay.changePaymentDetails":"Change payment details","partialPayment.warning":"Select another payment method to pay the remaining","partialPayment.remainingBalance":"Remaining balance will be %{amount}","bankTransfer.beneficiary":"Beneficiary","bankTransfer.iban":"IBAN","bankTransfer.bic":"BIC","bankTransfer.reference":"Reference","bankTransfer.introduction":"Continue to create a new bank transfer payment. You can use the details in the following screen to finalize this payment.","bankTransfer.instructions":"Thank you for your purchase, please use the following information to complete your payment.","bacs.accountHolderName":"Bank account holder name","bacs.accountHolderName.invalid":"Invalid bank account holder name","bacs.accountNumber":"Bank account number","bacs.accountNumber.invalid":"Invalid bank account number","bacs.bankLocationId":"Sort code","bacs.bankLocationId.invalid":"Invalid sort code","bacs.consent.amount":"I agree that the above amount will be deducted from my bank account.","bacs.consent.account":"I confirm the account is in my name and I am the only signatory required to authorise the Direct Debit on this account.",edit:"Edit","bacs.confirm":"Confirm and pay","bacs.result.introduction":"Download your Direct Debit Instruction (DDI / Mandate)","download.pdf":"Download PDF","creditCard.encryptedCardNumber.aria.iframeTitle":"Iframe for card number","creditCard.encryptedExpiryDate.aria.iframeTitle":"Iframe for expiry date","creditCard.encryptedExpiryMonth.aria.iframeTitle":"Iframe for expiry month","creditCard.encryptedExpiryYear.aria.iframeTitle":"Iframe for expiry year","creditCard.encryptedSecurityCode.aria.iframeTitle":"Iframe for security code","creditCard.encryptedPassword.aria.iframeTitle":"Iframe for password","giftcard.encryptedCardNumber.aria.iframeTitle":"Iframe for card number","giftcard.encryptedSecurityCode.aria.iframeTitle":"Iframe for pin",giftcardTransactionLimit:"Max. %{amount} allowed per transaction on this gift card","ach.encryptedBankAccountNumber.aria.iframeTitle":"Iframe for bank account number","ach.encryptedBankLocationId.aria.iframeTitle":"Iframe for bank routing number","pix.instructions":"Open the app with the PIX registered key, choose Pay with PIX and scan the QR Code or copy and paste the code","twint.saved":"saved",orPayWith:"or pay with",invalidFormatExpects:"Invalid format. Expected format: %{format}","upi.qrCodeWaitingMessage":"Scan the QR code using your preferred UPI app to complete the payment","upi.vpaWaitingMessage":"Open your UPI app to confirm the payment","upi.modeSelection":"Make a selection on how you would like to use UPI.","onlineBanking.termsAndConditions":"By continuing you agree with the %#terms and conditions%#","onlineBankingPL.termsAndConditions":"By continuing you agree with the %#regulations%# and %#information obligation%# of Przelewy24","ctp.loading.poweredByCtp":"Powered by Click to Pay","ctp.loading.intro":"We are checking to see if you have any saved cards with Click to Pay...","ctp.login.title":"Continue to Click to Pay","ctp.login.subtitle":"Enter the email address that is connected to Click to Pay to continue.","ctp.login.inputLabel":"Email","ctp.logout.notYou":"Not you?","ctp.logout.notYourCards":"Not your cards?","ctp.logout.notYourCard":"Not your card?","ctp.logout.notYourProfile":"Not your profile?","ctp.otp.fieldLabel":"One time code","ctp.otp.resendCode":"Resend code","ctp.otp.codeResent":"Code resent","ctp.otp.title":"Access your Click to Pay cards","ctp.otp.subtitle":"Enter the code %@ sent to %@ to verify it‘s you.","ctp.otp.saveCookiesCheckbox.label":"Skip verification next time","ctp.otp.saveCookiesCheckbox.information":"Select to be remembered on your device and browser at participating stores for faster checkout. Not recommended for shared devices.","ctp.otp.saveCookiesCheckbox.shorterInfo":"Select to be remembered on your device and browser","ctp.emptyProfile.message":"No cards registered in this Click to Pay profile","ctp.separatorText":"or use","ctp.cards.title":"Complete payment with Click to Pay","ctp.cards.subtitle":"Select a card to use.","ctp.cards.expiredCard":"Expired","ctp.manualCardEntry":"Manual card entry","ctp.aria.infoModalButton":"What is Click to Pay","ctp.infoPopup.title":"Click to Pay brings the ease of contactless, online","ctp.infoPopup.subtitle":"A fast, secure payment method supported by Mastercard, Visa and other payment cards.","ctp.infoPopup.benefit1":"Click to Pay uses encryption to keep your information safe and secure","ctp.infoPopup.benefit2":"Use it with merchants worldwide","ctp.infoPopup.benefit3":"Set up once for hassle-free payments in the future","ctp.errors.AUTH_INVALID":"Authentication Invalid","ctp.errors.NOT_FOUND":"No account found, enter a valid email or continue using manual card entry","ctp.errors.ID_FORMAT_UNSUPPORTED":"Format not supported","ctp.errors.FRAUD":"The user account was locked or disabled","ctp.errors.CONSUMER_ID_MISSING":"Consumer identity is missing in the request","ctp.errors.ACCT_INACCESSIBLE":"This account is currently not available, e.g it is locked","ctp.errors.CODE_INVALID":"Incorrect verification code","ctp.errors.CODE_EXPIRED":"This code has expired","ctp.errors.RETRIES_EXCEEDED":"The limit for the number of retries for OTP generation was exceeded","ctp.errors.OTP_SEND_FAILED":"The OTP could not be sent to the recipient","ctp.errors.REQUEST_TIMEOUT":"Something went wrong, try again or use the manual card entry","ctp.errors.UNKNOWN_ERROR":"Something went wrong, try again or use the manual card entry","ctp.errors.SERVICE_ERROR":"Something went wrong, try again or use the manual card entry","ctp.errors.SERVER_ERROR":"Something went wrong, try again or use the manual card entry","ctp.errors.INVALID_PARAMETER":"Something went wrong, try again or use the manual card entry","ctp.errors.AUTH_ERROR":"Something went wrong, try again or use the manual card entry","paymentMethodsList.aria.label":"Choose a payment method","paymentMethodsList.storedPayments.label":"Saved payment methods","paymentMethodsList.otherPayments.label":"More payment options","companyDetails.name.invalid":"Enter the company name","companyDetails.registrationNumber.invalid":"Enter the registration number","consent.checkbox.invalid":"You must agree with the terms & conditions","form.instruction":"All fields are required unless marked otherwise.","trustly.descriptor":"Instant Bank Payment","trustly.description1":"Pay directly from any of your bank accounts, backed by bank-level security","trustly.description2":"No cards, no app download, no registration","ancv.input.label":"Your ANCV identification","ancv.confirmPayment":"Use your ANCV application to confirm the payment.","ancv.form.instruction":"The Cheque-Vacances application is necessary to validate this payment.","ancv.beneficiaryId.invalid":"Enter a valid email address or ANCV ID","creditCard.cardNumber.label":"Card number","creditCard.expiryDate.label":"Expiry date","creditCard.expiryDate.contextualText":"Front of card in MM/YY format","creditCard.securityCode.label":"Security code","creditCard.securityCode.label.optional":"Security code (optional)","creditCard.securityCode.contextualText.3digits":"3 digits on back of card","creditCard.securityCode.contextualText.4digits":"4 digits on back of card","creditCard.pin.label":"Pin","creditCard.password.label":"First 2 digits of card password","giftcard.cardNumber.label":"Card Number","giftcard.expiryDate.label":"Expiry date","giftcard.securityCode.label":"Pin","ach.bankAccountNumber.label":"Account number","ach.bankLocationId.label":"ABA routing number","dragonpayVoucher.selectField.contextualText.nonBank":"Select your provider","dragonpayVoucher.selectField.contextualText.bank":"Select your bank","payme.openPayMeApp":"Complete your payment in the PayMe app by authorizing the payment in the app and wait for the confirmation.","payme.redirectButtonLabel":"Open PayMe app","payme.scanQrCode":"Complete your payment by QR code","payme.timeToPay":"This QR code is valid for %@","payme.instructions.steps":"Open the PayMe app.%@Scan the QR code to authorize the payment.%@Complete the payment in the app and wait for confirmation.","payme.instructions.footnote":"Please do not close this page before the payment is completed"};export{e as default};
2
2
  //# sourceMappingURL=en-US.json.js.map
@@ -1,2 +1,2 @@
1
- class t{src;node;attributes;dataAttributes;isScriptLoadCalled=!1;script;constructor(t,s="body",i={},r={}){this.src=t,this.node=s,this.attributes=i,this.dataAttributes=r}load=()=>{if(!this.isScriptLoadCalled)return new Promise(((t,s)=>{const i=()=>{this.script.setAttribute("data-script-loaded","true"),t()},r=()=>{this.remove(),s(new Error(`Unable to load script ${this.src}`))};this.isScriptLoadCalled=!0;const e=document.querySelector(this.node);if(this.script=e.querySelector(`script[src="${this.src}"]`),this.script&&this.script.getAttribute("data-script-loaded"))t();else{if(this.script)return this.script.addEventListener("load",i),void this.script.addEventListener("error",r);this.script=document.createElement("script"),Object.assign(this.script,this.attributes),Object.assign(this.script.dataset,this.dataAttributes),this.script.src=this.src,this.script.async=!0,this.script.addEventListener("load",i),this.script.addEventListener("error",r),e.appendChild(this.script)}}))};remove=()=>this.script.parentNode&&this.script.parentNode.removeChild(this.script)}export{t as default};
1
+ import t from"../core/Errors/AdyenCheckoutError.js";class s{src;node;attributes;dataAttributes;isScriptLoadCalled=!1;script;constructor(t,s="body",i={},r={}){this.src=t,this.node=s,this.attributes=i,this.dataAttributes=r}load=()=>{if(!this.isScriptLoadCalled)return new Promise(((s,i)=>{const r=()=>{this.script.setAttribute("data-script-loaded","true"),s()},e=s=>{this.remove(),i(new t("SCRIPT_ERROR",`Unable to load script ${this.src}. Message: ${s.message}`,{cause:s.error}))};this.isScriptLoadCalled=!0;const c=document.querySelector(this.node);if(this.script=c.querySelector(`script[src="${this.src}"]`),this.script&&this.script.getAttribute("data-script-loaded"))s();else{if(this.script)return this.script.addEventListener("load",r),void this.script.addEventListener("error",e);this.script=document.createElement("script"),Object.assign(this.script,this.attributes),Object.assign(this.script.dataset,this.dataAttributes),this.script.src=this.src,this.script.async=!0,this.script.addEventListener("load",r),this.script.addEventListener("error",e),c.appendChild(this.script)}}))};remove=()=>this.script.parentNode&&this.script.parentNode.removeChild(this.script)}export{s as default};
2
2
  //# sourceMappingURL=Script.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Script.js","sources":["../../../src/utils/Script.ts"],"sourcesContent":["interface IScript {\n load(): Promise<any>;\n remove(): HTMLScriptElement;\n}\n\n/**\n * Creates a script element from a certain source in the passed node selector.\n * If no selector is passed it will add the script element in the body.\n *\n * @example\n * ```\n * const script = new Script('https://example.com/script.js', '.container');\n * script.load().then(doSomething);\n *\n * // To clean up just call the remove method\n * script.remove();\n * ```\n */\nclass Script implements IScript {\n private readonly src: string;\n private readonly node: string;\n private readonly attributes: Partial<HTMLScriptElement>;\n private readonly dataAttributes: Record<string, string | undefined>;\n\n private isScriptLoadCalled = false;\n private script: HTMLScriptElement;\n\n constructor(src, node = 'body', attributes: Partial<HTMLScriptElement> = {}, dataAttributes: Record<string, string | undefined> = {}) {\n this.src = src;\n this.node = node;\n this.attributes = attributes;\n this.dataAttributes = dataAttributes;\n }\n\n public load = (): Promise<void> => {\n if (this.isScriptLoadCalled) {\n if (process.env.NODE_ENV === 'development') console.warn(`[Warning] script.load called more than once for ${this.src}`);\n return;\n }\n\n return new Promise((resolve, reject) => {\n const handleOnLoad = () => {\n this.script.setAttribute('data-script-loaded', 'true');\n resolve();\n };\n\n const handleOnError = () => {\n this.remove();\n reject(new Error(`Unable to load script ${this.src}`));\n };\n\n this.isScriptLoadCalled = true;\n\n const scriptContainer: Element = document.querySelector(this.node);\n this.script = scriptContainer.querySelector(`script[src=\"${this.src}\"]`);\n\n // Script element exists in the browser and is already loaded\n if (this.script && this.script.getAttribute('data-script-loaded')) {\n resolve();\n return;\n } else if (this.script) {\n // Script element exists in the browser, but it is not loaded yet\n // Use-case: Multiple PayPal standalone components being loaded in different parts of the screen.\n this.script.addEventListener('load', handleOnLoad);\n this.script.addEventListener('error', handleOnError);\n return;\n }\n\n // Script element doesn't exist in the browser, so we create it and append to the DOM tree\n this.script = document.createElement('script');\n Object.assign(this.script, this.attributes);\n Object.assign(this.script.dataset, this.dataAttributes);\n\n this.script.src = this.src;\n this.script.async = true;\n\n this.script.addEventListener('load', handleOnLoad);\n this.script.addEventListener('error', handleOnError);\n\n scriptContainer.appendChild(this.script);\n });\n };\n\n public remove = (): HTMLScriptElement => {\n return this.script.parentNode && this.script.parentNode.removeChild(this.script);\n };\n}\n\nexport default Script;\n"],"names":["Script","src","node","attributes","dataAttributes","isScriptLoadCalled","script","constructor","this","load","Promise","resolve","reject","handleOnLoad","setAttribute","handleOnError","remove","Error","scriptContainer","document","querySelector","getAttribute","addEventListener","createElement","Object","assign","dataset","async","appendChild","parentNode","removeChild"],"mappings":"AAkBA,MAAMA,EACeC,IACAC,KACAC,WACAC,eAETC,oBAAqB,EACrBC,OAERC,WAAAA,CAAYN,EAAKC,EAAO,OAAQC,EAAyC,CAAE,EAAEC,EAAqD,IAC9HI,KAAKP,IAAMA,EACXO,KAAKN,KAAOA,EACZM,KAAKL,WAAaA,EAClBK,KAAKJ,eAAiBA,CAC1B,CAEOK,KAAO,KACV,IAAID,KAAKH,mBAKT,OAAO,IAAIK,SAAQ,CAACC,EAASC,KACzB,MAAMC,EAAe,KACjBL,KAAKF,OAAOQ,aAAa,qBAAsB,QAC/CH,GAAAA,EAGEI,EAAgB,KAClBP,KAAKQ,SACLJ,EAAO,IAAIK,MAAM,yBAAyBT,KAAKP,OAAK,EAGxDO,KAAKH,oBAAqB,EAE1B,MAAMa,EAA2BC,SAASC,cAAcZ,KAAKN,MAI7D,GAHAM,KAAKF,OAASY,EAAgBE,cAAc,eAAeZ,KAAKP,SAG5DO,KAAKF,QAAUE,KAAKF,OAAOe,aAAa,sBACxCV,QADJ,CAGO,GAAIH,KAAKF,OAKZ,OAFAE,KAAKF,OAAOgB,iBAAiB,OAAQT,QACrCL,KAAKF,OAAOgB,iBAAiB,QAASP,GAK1CP,KAAKF,OAASa,SAASI,cAAc,UACrCC,OAAOC,OAAOjB,KAAKF,OAAQE,KAAKL,YAChCqB,OAAOC,OAAOjB,KAAKF,OAAOoB,QAASlB,KAAKJ,gBAExCI,KAAKF,OAAOL,IAAMO,KAAKP,IACvBO,KAAKF,OAAOqB,OAAQ,EAEpBnB,KAAKF,OAAOgB,iBAAiB,OAAQT,GACrCL,KAAKF,OAAOgB,iBAAiB,QAASP,GAEtCG,EAAgBU,YAAYpB,KAAKF,OAbjC,CAauC,GAC3C,EAGGU,OAAS,IACLR,KAAKF,OAAOuB,YAAcrB,KAAKF,OAAOuB,WAAWC,YAAYtB,KAAKF"}
1
+ {"version":3,"file":"Script.js","sources":["../../../src/utils/Script.ts"],"sourcesContent":["import AdyenCheckoutError from '../core/Errors/AdyenCheckoutError';\n\ninterface IScript {\n load(): Promise<any>;\n remove(): HTMLScriptElement;\n}\n\n/**\n * Creates a script element from a certain source in the passed node selector.\n * If no selector is passed it will add the script element in the body.\n *\n * @example\n * ```\n * const script = new Script('https://example.com/script.js', '.container');\n * script.load().then(doSomething);\n *\n * // To clean up just call the remove method\n * script.remove();\n * ```\n */\nclass Script implements IScript {\n private readonly src: string;\n private readonly node: string;\n private readonly attributes: Partial<HTMLScriptElement>;\n private readonly dataAttributes: Record<string, string | undefined>;\n\n private isScriptLoadCalled = false;\n private script: HTMLScriptElement;\n\n constructor(src, node = 'body', attributes: Partial<HTMLScriptElement> = {}, dataAttributes: Record<string, string | undefined> = {}) {\n this.src = src;\n this.node = node;\n this.attributes = attributes;\n this.dataAttributes = dataAttributes;\n }\n\n public load = (): Promise<void> => {\n if (this.isScriptLoadCalled) {\n if (process.env.NODE_ENV === 'development') console.warn(`[Warning] script.load called more than once for ${this.src}`);\n return;\n }\n\n return new Promise((resolve, reject) => {\n const handleOnLoad = () => {\n this.script.setAttribute('data-script-loaded', 'true');\n resolve();\n };\n\n const handleOnError = (errorEvent: ErrorEvent) => {\n this.remove();\n reject(\n new AdyenCheckoutError('SCRIPT_ERROR', `Unable to load script ${this.src}. Message: ${errorEvent.message}`, {\n cause: errorEvent.error\n })\n );\n };\n\n this.isScriptLoadCalled = true;\n\n const scriptContainer: Element = document.querySelector(this.node);\n this.script = scriptContainer.querySelector(`script[src=\"${this.src}\"]`);\n\n // Script element exists in the browser and is already loaded\n if (this.script && this.script.getAttribute('data-script-loaded')) {\n resolve();\n return;\n } else if (this.script) {\n // Script element exists in the browser, but it is not loaded yet\n // Use-case: Multiple PayPal standalone components being loaded in different parts of the screen.\n this.script.addEventListener('load', handleOnLoad);\n this.script.addEventListener('error', handleOnError);\n return;\n }\n\n // Script element doesn't exist in the browser, so we create it and append to the DOM tree\n this.script = document.createElement('script');\n Object.assign(this.script, this.attributes);\n Object.assign(this.script.dataset, this.dataAttributes);\n\n this.script.src = this.src;\n this.script.async = true;\n\n this.script.addEventListener('load', handleOnLoad);\n this.script.addEventListener('error', handleOnError);\n\n scriptContainer.appendChild(this.script);\n });\n };\n\n public remove = (): HTMLScriptElement => {\n return this.script.parentNode && this.script.parentNode.removeChild(this.script);\n };\n}\n\nexport default Script;\n"],"names":["Script","src","node","attributes","dataAttributes","isScriptLoadCalled","script","constructor","this","load","Promise","resolve","reject","handleOnLoad","setAttribute","handleOnError","errorEvent","remove","AdyenCheckoutError","message","cause","error","scriptContainer","document","querySelector","getAttribute","addEventListener","createElement","Object","assign","dataset","async","appendChild","parentNode","removeChild"],"mappings":"oDAoBA,MAAMA,EACeC,IACAC,KACAC,WACAC,eAETC,oBAAqB,EACrBC,OAERC,WAAAA,CAAYN,EAAKC,EAAO,OAAQC,EAAyC,CAAE,EAAEC,EAAqD,IAC9HI,KAAKP,IAAMA,EACXO,KAAKN,KAAOA,EACZM,KAAKL,WAAaA,EAClBK,KAAKJ,eAAiBA,CAC1B,CAEOK,KAAO,KACV,IAAID,KAAKH,mBAKT,OAAO,IAAIK,SAAQ,CAACC,EAASC,KACzB,MAAMC,EAAe,KACjBL,KAAKF,OAAOQ,aAAa,qBAAsB,QAC/CH,GAAAA,EAGEI,EAAiBC,IACnBR,KAAKS,SACLL,EACI,IAAIM,EAAmB,eAAgB,yBAAyBV,KAAKP,iBAAiBe,EAAWG,UAAW,CACxGC,MAAOJ,EAAWK,QACtB,EAIRb,KAAKH,oBAAqB,EAE1B,MAAMiB,EAA2BC,SAASC,cAAchB,KAAKN,MAI7D,GAHAM,KAAKF,OAASgB,EAAgBE,cAAc,eAAehB,KAAKP,SAG5DO,KAAKF,QAAUE,KAAKF,OAAOmB,aAAa,sBACxCd,QADJ,CAGO,GAAIH,KAAKF,OAKZ,OAFAE,KAAKF,OAAOoB,iBAAiB,OAAQb,QACrCL,KAAKF,OAAOoB,iBAAiB,QAASX,GAK1CP,KAAKF,OAASiB,SAASI,cAAc,UACrCC,OAAOC,OAAOrB,KAAKF,OAAQE,KAAKL,YAChCyB,OAAOC,OAAOrB,KAAKF,OAAOwB,QAAStB,KAAKJ,gBAExCI,KAAKF,OAAOL,IAAMO,KAAKP,IACvBO,KAAKF,OAAOyB,OAAQ,EAEpBvB,KAAKF,OAAOoB,iBAAiB,OAAQb,GACrCL,KAAKF,OAAOoB,iBAAiB,QAASX,GAEtCO,EAAgBU,YAAYxB,KAAKF,OAbjC,CAauC,GAC3C,EAGGW,OAAS,IACLT,KAAKF,OAAO2B,YAAczB,KAAKF,OAAO2B,WAAWC,YAAY1B,KAAKF"}
@@ -1,5 +1,5 @@
1
1
  .js-iframe{border:none;height:100%;overflow:hidden;width:100%}
2
- .adyen-checkout-card-input__wrapper{position:relative}.adyen-checkout-card-input__icon{border-radius:var(--adyen-checkout-border-radius-s);height:18px;margin-right:var(--adyen-checkout-spacer-060);width:27px}.adyen-checkout-card-input__form{opacity:1}.adyen-checkout-card-input__spinner{display:none;height:100%;left:0;position:absolute;top:0;width:100%;z-index:1}.adyen-checkout-card-input__spinner--active{display:block}.adyen-checkout-card-input__form--loading{opacity:0}.adyen-checkout__input{display:block;max-height:100px}.adyen-checkout__field.adyen-checkout__card__cvc__input--hidden,.adyen-checkout__field.adyen-checkout__card__exp-date__input--hidden{display:none}.adyen-checkout__card__exp-cvc__exp-date__input--hidden{justify-content:flex-end}.revolving-plan-installments__disabled{opacity:.4;pointer-events:none}.adyen-checkout__card-input__form{transition:opacity .25s ease-out}.adyen-checkout__card__cardNumber{max-width:400px}.adyen-checkout__card__cardNumber__input{padding-left:var(--adyen-checkout-spacer-060)}.adyen-checkout__card__exp-date__input--oneclick{font-weight:var(--adyen-checkout-text-body-font-weight);line-height:var(--adyen-checkout-text-title-line-height);overflow:hidden;text-align:left;text-overflow:ellipsis;white-space:nowrap}.adyen-checkout__card__holderName,.adyen-checkout__field--expiryDate,.adyen-checkout__field--storedCard{margin-bottom:0}.adyen-checkout__store-details{align-items:center;border:var(--adyen-checkout-border-width-s) solid var(--adyen-checkout-color-outline-primary);border-radius:var(--adyen-checkout-border-radius-m);display:flex;gap:var(--adyen-checkout-spacer-060);padding:var(--adyen-checkout-spacer-060) var(--adyen-checkout-spacer-070)}.adyen-checkout__card-input .adyen-checkout__fieldset--billingAddress,.adyen-checkout__card__holderName,.adyen-checkout__card__kcp-authentication,.adyen-checkout__card__socialSecurityNumber,.adyen-checkout__installments,.adyen-checkout__store-details{margin-top:var(--adyen-checkout-spacer-070)}.adyen-checkout__card-input.adyen-checkout__card-input--loading{pointer-events:none}.adyen-checkout__card__holderName:first-child{margin:0 0 var(--adyen-checkout-input-field-label-margin-bottom)}.adyen-checkout__field--cardNumber .adyen-checkout__input--error+.adyen-checkout__card__cardNumber__brandIcon,.adyen-checkout__field--cardNumber .adyen-checkout__input--valid:not(.adyen-checkout__card__cardNumber__input--noBrand)+.adyen-checkout-input__inline-validation--valid{display:none}.adyen-checkout__field--securityCode.adyen-checkout__field--error .adyen-checkout__card__cvc__hint,.adyen-checkout__field--securityCode.adyen-checkout__field--valid .adyen-checkout__card__cvc__hint{opacity:0}@keyframes cvc-indicate-location{0%{opacity:1}to{opacity:.3}}.adyen-checkout__label--focused .adyen-checkout__field__cvc--back-hint .adyen-checkout__card__cvc__hint--back .adyen-checkout__card__cvc__hint__location,.adyen-checkout__label--focused .adyen-checkout__field__cvc--front-hint .adyen-checkout__card__cvc__hint--front .adyen-checkout__card__cvc__hint__location{animation-direction:alternate;animation-duration:1s;animation-iteration-count:infinite;animation-name:cvc-indicate-location}.adyen-checkout__card__cvc__hint__wrapper{align-items:center;backface-visibility:visible;display:flex;height:100%;margin-right:var(--adyen-checkout-spacer-060);transform:translateZ(0);transform-origin:center;transform-style:preserve-3d;transition:transform .3s cubic-bezier(.455,.03,.515,.955);width:27px;will-change:transform}.adyen-checkout__field__cvc--front-hint.adyen-checkout__card__cvc__hint__wrapper{transform:rotateY(180deg)}.adyen-checkout__card__cvc__hint{backface-visibility:hidden;position:absolute;transition:opacity .1s linear}.adyen-checkout__field__exp-date_hint_wrapper{align-items:center;display:flex;margin-right:var(--adyen-checkout-spacer-060);transition:opacity .1s linear}.adyen-checkout__field__exp-date_hint_wrapper.adyen-checkout__field__exp-date_hint_wrapper--hidden{opacity:0}.adyen-checkout__field__exp-date_hint{height:18px;width:27px}.adyen-checkout__card__cvc__hint--front{transform:rotateY(180deg)}@media (prefers-reduced-motion:reduce){.adyen-checkout__card__cvc__hint__wrapper{transition:none}}.adyen-checkout__fieldset--revolving-plan .adyen-checkout__fieldset__fields{justify-content:left}.adyen-checkout__fieldset--revolving-plan .adyen-checkout__radio_group{display:flex;flex-direction:column}.adyen-checkout__fieldset--revolving-plan .adyen-checkout__radio_group__input-wrapper{margin-top:var(--adyen-checkout-spacer-080)}.adyen-checkout__fieldset--revolving-plan .adyen-checkout__field--revolving-plan-installments{margin-left:var(--adyen-checkout-spacer-070);position:relative;top:42px;width:30%}
2
+ .adyen-checkout-card-input__wrapper{position:relative}.adyen-checkout-card-input__icon{border-radius:var(--adyen-checkout-border-radius-s);height:18px;margin-right:var(--adyen-checkout-spacer-060);width:27px}.adyen-checkout-card-input__form{opacity:1}.adyen-checkout-card-input__spinner{display:none;height:100%;left:0;position:absolute;top:0;width:100%;z-index:1}.adyen-checkout-card-input__spinner--active{display:block}.adyen-checkout-card-input__form--loading{opacity:0}.adyen-checkout__input{display:block;max-height:100px}.adyen-checkout__field.adyen-checkout__card__cvc__input--hidden,.adyen-checkout__field.adyen-checkout__card__exp-date__input--hidden{display:none}.adyen-checkout__card__exp-cvc__exp-date__input--hidden{justify-content:flex-end}.revolving-plan-installments__disabled{opacity:.4;pointer-events:none}.adyen-checkout__card-input__form{transition:opacity .25s ease-out}.adyen-checkout__card__cardNumber{max-width:400px}.adyen-checkout__card__cardNumber__input{padding-left:var(--adyen-checkout-spacer-060)}.adyen-checkout__card__exp-date__input--oneclick{font-weight:var(--adyen-checkout-text-body-font-weight);line-height:var(--adyen-checkout-text-title-line-height);overflow:hidden;text-align:left;text-overflow:ellipsis;white-space:nowrap}.adyen-checkout__card__holderName,.adyen-checkout__field--expiryDate,.adyen-checkout__field--storedCard{margin-bottom:0}.adyen-checkout__store-details{align-items:center;background:var(--adyen-checkout-color-background-primary);border:var(--adyen-checkout-border-width-s) solid var(--adyen-checkout-color-outline-primary);border-radius:var(--adyen-checkout-border-radius-m);display:flex;gap:var(--adyen-checkout-spacer-060);padding:var(--adyen-checkout-spacer-060) var(--adyen-checkout-spacer-070)}.adyen-checkout__card-input .adyen-checkout__fieldset--billingAddress,.adyen-checkout__card__holderName,.adyen-checkout__card__kcp-authentication,.adyen-checkout__card__socialSecurityNumber,.adyen-checkout__installments,.adyen-checkout__store-details{margin-top:var(--adyen-checkout-spacer-070)}.adyen-checkout__card-input.adyen-checkout__card-input--loading{pointer-events:none}.adyen-checkout__card__holderName:first-child{margin:0 0 var(--adyen-checkout-input-field-label-margin-bottom)}.adyen-checkout__field--cardNumber .adyen-checkout__input--error+.adyen-checkout__card__cardNumber__brandIcon,.adyen-checkout__field--cardNumber .adyen-checkout__input--valid:not(.adyen-checkout__card__cardNumber__input--noBrand)+.adyen-checkout-input__inline-validation--valid{display:none}.adyen-checkout__field--securityCode.adyen-checkout__field--error .adyen-checkout__card__cvc__hint,.adyen-checkout__field--securityCode.adyen-checkout__field--valid .adyen-checkout__card__cvc__hint{opacity:0}@keyframes cvc-indicate-location{0%{opacity:1}to{opacity:.3}}.adyen-checkout__label--focused .adyen-checkout__field__cvc--back-hint .adyen-checkout__card__cvc__hint--back .adyen-checkout__card__cvc__hint__location,.adyen-checkout__label--focused .adyen-checkout__field__cvc--front-hint .adyen-checkout__card__cvc__hint--front .adyen-checkout__card__cvc__hint__location{animation-direction:alternate;animation-duration:1s;animation-iteration-count:infinite;animation-name:cvc-indicate-location}.adyen-checkout__card__cvc__hint__wrapper{align-items:center;backface-visibility:visible;display:flex;height:100%;margin-right:var(--adyen-checkout-spacer-060);transform:translateZ(0);transform-origin:center;transform-style:preserve-3d;transition:transform .3s cubic-bezier(.455,.03,.515,.955);width:27px;will-change:transform}.adyen-checkout__field__cvc--front-hint.adyen-checkout__card__cvc__hint__wrapper{transform:rotateY(180deg)}.adyen-checkout__card__cvc__hint{backface-visibility:hidden;position:absolute;transition:opacity .1s linear}.adyen-checkout__field__exp-date_hint_wrapper{align-items:center;display:flex;margin-right:var(--adyen-checkout-spacer-060);transition:opacity .1s linear}.adyen-checkout__field__exp-date_hint_wrapper.adyen-checkout__field__exp-date_hint_wrapper--hidden{opacity:0}.adyen-checkout__field__exp-date_hint{height:18px;width:27px}.adyen-checkout__card__cvc__hint--front{transform:rotateY(180deg)}@media (prefers-reduced-motion:reduce){.adyen-checkout__card__cvc__hint__wrapper{transition:none}}.adyen-checkout__fieldset--revolving-plan .adyen-checkout__fieldset__fields{justify-content:left}.adyen-checkout__fieldset--revolving-plan .adyen-checkout__radio_group{display:flex;flex-direction:column}.adyen-checkout__fieldset--revolving-plan .adyen-checkout__radio_group__input-wrapper{margin-top:var(--adyen-checkout-spacer-080)}.adyen-checkout__fieldset--revolving-plan .adyen-checkout__field--revolving-plan-installments{margin-left:var(--adyen-checkout-spacer-070);position:relative;top:42px;width:30%}
3
3
  .adyen-checkout__spinner__wrapper{--adyen-checkout-loading-indicator-large-width:var(--adyen-checkout-spacer-120);--adyen-checkout-loading-indicator-large-height:var(--adyen-checkout-spacer-120);--adyen-checkout-loading-indicator-large-border-width:var(--adyen-checkout-spacer-020);--adyen-checkout-loading-indicator-medium-width:28px;--adyen-checkout-loading-indicator-medium-height:28px;--adyen-checkout-loading-indicator-small-width:var(--adyen-checkout-spacer-070);--adyen-checkout-loading-indicator-small-height:var(--adyen-checkout-spacer-070);--adyen-checkout-loading-indicator-small-border-width:var(--adyen-checkout-spacer-010);--adyen-checkout-loading-indicator-width:var(--adyen-checkout-spacer-090);--adyen-checkout-loading-indicator-height:var(--adyen-checkout-spacer-090);align-items:center;display:flex;height:100%;justify-content:center}.adyen-checkout__spinner__wrapper--inline{display:inline-block;height:auto;margin-right:var(--adyen-checkout-spacer-040)}[dir=rtl] .adyen-checkout__spinner__wrapper--inline{margin-left:var(--adyen-checkout-spacer-040);margin-right:0}.adyen-checkout__spinner{height:var(--adyen-checkout-loading-indicator-height);position:relative;width:var(--adyen-checkout-loading-indicator-width)}.adyen-checkout__spinner:after,.adyen-checkout__spinner:before{animation:bento-progress-circular-rotate 1s cubic-bezier(.785,.135,.15,.86) infinite;border:var(--adyen-checkout-border-width-l) solid transparent;border-radius:50%;box-sizing:border-box;content:"";display:block;height:100%;left:0;position:absolute;top:0;width:100%}.adyen-checkout__spinner:before{border-color:var(--adyen-checkout-loading-indicator-background-color);border-top-color:transparent;opacity:.1}.adyen-checkout__spinner:after{border-color:transparent;border-top-color:var(--adyen-checkout-loading-indicator-color)}.adyen-checkout__spinner--small{height:var(--adyen-checkout-loading-indicator-small-height);width:var(--adyen-checkout-loading-indicator-small-width)}.adyen-checkout__spinner--small:after,.adyen-checkout__spinner--small:before{border-width:var(--adyen-checkout-loading-indicator-small-border-width)}.adyen-checkout__spinner--medium{height:var(--adyen-checkout-loading-indicator-medium-height);width:var(--adyen-checkout-loading-indicator-medium-width)}.adyen-checkout__spinner--large{height:var(--adyen-checkout-loading-indicator-large-height);width:var(--adyen-checkout-loading-indicator-large-width)}.adyen-checkout__spinner--large:after,.adyen-checkout__spinner--large:before{border-width:var(--adyen-checkout-loading-indicator-large-border-width)}@keyframes bento-progress-circular-rotate{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}
4
4
  .loading-input__form{opacity:1}.loading-input__form--loading{opacity:0}.loading-input__spinner{display:none;height:100%;left:0;position:absolute;top:0;width:100%;z-index:1}.loading-input__spinner--active{display:block}
5
5
  .adyen-checkout__field{display:block;margin-bottom:var(--adyen-checkout-spacer-070);width:100%}.adyen-checkout__input-wrapper{align-items:center;background:var(--adyen-checkout-input-wrapper-background);border:var(--adyen-checkout-input-wrapper-border-width) solid var(--adyen-checkout-input-wrapper-border-color);border-radius:var(--adyen-checkout-input-wrapper-border-radius);display:flex;position:relative}.adyen-checkout__input-wrapper div,.adyen-checkout__input-wrapper input,.adyen-checkout__input-wrapper span{border-radius:inherit}.adyen-checkout__input-wrapper button,.adyen-checkout__input-wrapper div,.adyen-checkout__input-wrapper input{border:none}.adyen-checkout__input-wrapper:active,.adyen-checkout__input-wrapper:active:hover,.adyen-checkout__input-wrapper:focus-within,.adyen-checkout__input-wrapper:focus-within:hover{border-color:var(--adyen-checkout-input-wrapper-focus-border-color);box-shadow:0 0 0 .5px var(--adyen-checkout-input-wrapper-focus-border-color)}.adyen-checkout__input-wrapper:hover{border-color:var(--adyen-checkout-input-wrapper-hover-border-color)}.adyen-checkout__field--inactive>.adyen-checkout__input-wrapper{background:var(--adyen-checkout-input-wrapper-inactive-background);border-color:transparent}.adyen-checkout__field--valid:not(.adyen-checkout__field--inactive)>:not(.adyen-checkout__label--focused)+.adyen-checkout__input-wrapper:not(:focus-within,:active){border-bottom-color:var(--adyen-checkout-color-label-success)}.adyen-checkout__field--error>:not(.adyen-checkout__label--focused)+.adyen-checkout__input-wrapper:not(:focus-within,:active){border-color:var(--adyen-checkout-color-label-critical)}.adyen-checkout__label{display:block;position:relative}.adyen-checkout__label--focused+.adyen-checkout__input-wrapper{border-color:var(--adyen-checkout-input-wrapper-focus-border-color);box-shadow:0 0 0 .5px var(--adyen-checkout-input-wrapper-focus-border-color)}.adyen-checkout__label--disabled+.adyen-checkout__input-wrapper{background:var(--adyen-checkout-input-wrapper-inactive-background);border-color:transparent}.adyen-checkout__helper-text,.adyen-checkout__label__text{display:block;font-size:var(--adyen-checkout-font-size-small);margin-bottom:var(--adyen-checkout-input-field-label-margin-bottom)}.adyen-checkout__label-adornment--end{position:absolute;right:0;top:0}.adyen-checkout__helper-text{color:var(--adyen-checkout-input-field-context-color);font-weight:400;line-height:var(--adyen-checkout-line-height-100)}.adyen-checkout__label__text{color:var(--adyen-checkout-input-field-label-color);display:block;font-weight:var(--adyen-checkout-text-body-stronger-font-weight);line-height:var(--adyen-checkout-line-height-200);overflow:hidden;text-overflow:ellipsis;transition:color .1s ease-out;white-space:nowrap}.adyen-checkout__label__text--error{color:var(--adyen-checkout-color-label-critical)}.adyen-checkout__label--focused .adyen-checkout__label__text{color:var(--adyen-checkout-color-label-primary)}.adyen-checkout-contextual-text,.adyen-checkout-contextual-text--error{align-items:center;color:var(--adyen-checkout-input-field-context-color);display:flex;font-size:var(--adyen-checkout-font-size-xsmall);font-weight:400;line-height:var(--adyen-checkout-line-height-100);margin-top:var(--adyen-checkout-input-field-context-margin-top)}.adyen-checkout-contextual-text--error{color:var(--adyen-checkout-color-label-critical)}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../external/preact/dist/preact.js";import{UIElement as t}from"../internal/UIElement/UIElement.js";import r from"./components/ApplePayButton.js";import n from"./ApplePayService.js";import o from"../../utils/base64.js";import i from"./defaultProps.js";import{httpPost as s}from"../../core/Services/http.js";import{APPLEPAY_SESSION_ENDPOINT as a}from"./config.js";import{preparePaymentRequest as p}from"./payment-request.js";import{resolveSupportedVersion as l,mapBrands as c,formatApplePayContactToAdyenAddressFormat as d}from"./utils.js";import h from"../../core/Errors/AdyenCheckoutError.js";import{TxVariants as u}from"../tx-variants.js";import{sanitizeResponse as m,verifyPaymentDidNotFail as y}from"../internal/UIElement/utils.js";import{ANALYTICS_SELECTED_STR as f,ANALYTICS_INSTANT_PAYMENT_BUTTON as b}from"../../core/Analytics/constants.js";function P(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function g(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),n.forEach((function(t){P(e,t,r[t])}))}return e}function v(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})),e}class A extends t{formatProps(e){var t,r;const n=e.version||l(14),o=(null===(t=e.brands)||void 0===t?void 0:t.length)?c(e.brands):e.supportedNetworks;return v(g({},e),{configuration:e.configuration,supportedNetworks:o,version:n,totalPriceLabel:e.totalPriceLabel||(null===(r=e.configuration)||void 0===r?void 0:r.merchantName)})}formatData(){const{applePayToken:e,billingAddress:t,deliveryAddress:r}=this.state;return g({paymentMethod:{type:A.type,applePayToken:e}},t&&{billingAddress:t},r&&{deliveryAddress:r})}startSession(){const{version:e,onValidateMerchant:t,onPaymentMethodSelected:r,onShippingMethodSelected:o,onShippingContactSelected:i}=this.props,s=p(g({companyName:this.props.configuration.merchantName,countryCode:this.core.options.countryCode},this.props)),a=new n(s,{version:e,onError:e=>{this.handleError(new h("ERROR","ApplePay - Something went wrong on ApplePayService",{cause:e}))},onCancel:e=>{this.handleError(new h("CANCEL","ApplePay UI dismissed",{cause:e}))},onPaymentMethodSelected:r,onShippingMethodSelected:o,onShippingContactSelected:i,onValidateMerchant:t||this.validateMerchant,onPaymentAuthorized:(e,t,r)=>{const n=d(r.payment.billingContact),o=d(r.payment.shippingContact,!0);this.setState(g({applePayToken:btoa(JSON.stringify(r.payment.token.paymentData)),authorizedEvent:r},n&&{billingAddress:n},o&&{deliveryAddress:o})),this.handleAuthorization().then(this.makePaymentsCall).then(m).then(y).then(this.collectOrderTrackingDetailsIfNeeded).then((({paymentResponse:t,orderDetails:r})=>(e(g({status:ApplePaySession.STATUS_SUCCESS},r&&{orderDetails:r})),t))).then((e=>{this.handleResponse(e)})).catch((e=>{var r;const n=null==e||null===(r=e.error)||void 0===r?void 0:r.applePayError;t({status:ApplePaySession.STATUS_FAILURE,errors:n?Array.isArray(n)?n:[n]:void 0}),this.handleFailedResult(e)}))}});return new Promise(((e,t)=>this.props.onClick(e,t))).then((()=>{a.begin()})).catch((()=>({})))}async handleAuthorization(){return new Promise(((e,t)=>{this.props.onAuthorized||e();const{authorizedEvent:r,billingAddress:n,deliveryAddress:o}=this.state;this.props.onAuthorized(g({authorizedEvent:r},n&&{billingAddress:n},o&&{deliveryAddress:o}),{resolve:e,reject:t})})).catch((e=>{const t={error:{applePayError:e}};return Promise.reject(t)}))}async collectOrderTrackingDetailsIfNeeded(e){return new Promise(((e,t)=>{if(!this.props.onOrderTrackingRequest)return e();this.props.onOrderTrackingRequest(e,t)})).then((t=>g({paymentResponse:e},t&&{orderDetails:t}))).catch((()=>({paymentResponse:e})))}async validateMerchant(e,t){const{hostname:r}=window.location,{clientKey:n,configuration:i,loadingContext:p,initiative:l}=this.props,{merchantName:c,merchantId:d}=i,h={loadingContext:p,path:`${a}?clientKey=${n}`},u={displayName:c,domainName:r,initiative:l,merchantIdentifier:d};try{const r=await s(h,u),n=o.decode(r.data);n||t("Could not decode Apple Pay session");e(JSON.parse(n))}catch(e){t("Could not get Apple Pay session")}}get isValid(){return!0}async isAvailable(){if("https:"!==document.location.protocol)return Promise.reject(new h("IMPLEMENTATION_ERROR","Trying to start an Apple Pay session from an insecure document"));if(!this.props.onValidateMerchant&&!this.props.clientKey)return Promise.reject(new h("IMPLEMENTATION_ERROR","clientKey was not provided"));try{if(window.ApplePaySession&&ApplePaySession.canMakePayments()&&ApplePaySession.supportsVersion(this.props.version))return Promise.resolve()}catch(e){console.warn(e)}return Promise.reject(new h("ERROR","Apple Pay is not available on this device"))}render(){return this.props.showPayButton?e(r,{i18n:this.props.i18n,buttonColor:this.props.buttonColor,buttonType:this.props.buttonType,onClick:e=>{e.preventDefault(),this.submit()}}):null}constructor(e,t){super(e,t),P(this,"submit",(()=>{this.props.isInstantPayment&&this.submitAnalytics({type:f,target:b}),this.startSession()})),this.startSession=this.startSession.bind(this),this.submit=this.submit.bind(this),this.validateMerchant=this.validateMerchant.bind(this),this.collectOrderTrackingDetailsIfNeeded=this.collectOrderTrackingDetailsIfNeeded.bind(this),this.handleAuthorization=this.handleAuthorization.bind(this)}}P(A,"type",u.applepay),P(A,"defaultProps",i);export{A as default};
1
+ import{createElement as e}from"../../external/preact/dist/preact.js";import{UIElement as t}from"../internal/UIElement/UIElement.js";import r from"./components/ApplePayButton.js";import n from"./ApplePayService.js";import o from"../../utils/base64.js";import i from"./defaultProps.js";import{httpPost as s}from"../../core/Services/http.js";import{APPLEPAY_SESSION_ENDPOINT as a}from"./config.js";import{preparePaymentRequest as p}from"./payment-request.js";import{resolveSupportedVersion as l,mapBrands as c,formatApplePayContactToAdyenAddressFormat as d}from"./utils.js";import h from"../../core/Errors/AdyenCheckoutError.js";import{TxVariants as u}from"../tx-variants.js";import{sanitizeResponse as m,verifyPaymentDidNotFail as y}from"../internal/UIElement/utils.js";import{ANALYTICS_SELECTED_STR as f,ANALYTICS_INSTANT_PAYMENT_BUTTON as P}from"../../core/Analytics/constants.js";function b(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function g(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),n.forEach((function(t){b(e,t,r[t])}))}return e}function v(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})),e}class A extends t{formatProps(e){var t,r;const n=e.version||l(14),o=(null===(t=e.brands)||void 0===t?void 0:t.length)?c(e.brands):e.supportedNetworks;return v(g({},e),{configuration:e.configuration,supportedNetworks:o,version:n,totalPriceLabel:e.totalPriceLabel||(null===(r=e.configuration)||void 0===r?void 0:r.merchantName)})}formatData(){const{applePayToken:e,billingAddress:t,deliveryAddress:r}=this.state;return g({paymentMethod:{type:A.type,applePayToken:e}},t&&{billingAddress:t},r&&{deliveryAddress:r})}startSession(){const{version:e,onValidateMerchant:t,onPaymentMethodSelected:r,onShippingMethodSelected:o,onShippingContactSelected:i}=this.props,s=p(g({companyName:this.props.configuration.merchantName,countryCode:this.core.options.countryCode},this.props)),a=new n(s,{version:e,onError:e=>{this.handleError(new h("ERROR","ApplePay - Something went wrong on ApplePayService",{cause:e}))},onCancel:e=>{this.handleError(new h("CANCEL","ApplePay UI dismissed",{cause:e}))},onPaymentMethodSelected:r,onShippingMethodSelected:o,onShippingContactSelected:i,onValidateMerchant:t||this.validateMerchant,onPaymentAuthorized:(e,t,r)=>{const n=d(r.payment.billingContact),o=d(r.payment.shippingContact,!0);this.setState(g({applePayToken:btoa(JSON.stringify(r.payment.token.paymentData)),authorizedEvent:r},n&&{billingAddress:n},o&&{deliveryAddress:o})),this.handleAuthorization().then(this.makePaymentsCall).then(m).then(y).then(this.collectOrderTrackingDetailsIfNeeded).then((({paymentResponse:t,orderDetails:r})=>(e(g({status:ApplePaySession.STATUS_SUCCESS},r&&{orderDetails:r})),t))).then((e=>{this.handleResponse(e)})).catch((e=>{var r;const n=null==e||null===(r=e.error)||void 0===r?void 0:r.applePayError;t({status:ApplePaySession.STATUS_FAILURE,errors:n?Array.isArray(n)?n:[n]:void 0});const o=v(g({},e),{error:{applePayError:n}});this.handleFailedResult(o)}))}});return new Promise(((e,t)=>this.props.onClick(e,t))).then((()=>{a.begin()})).catch((()=>({})))}async handleAuthorization(){return new Promise(((e,t)=>{this.props.onAuthorized||e();const{authorizedEvent:r,billingAddress:n,deliveryAddress:o}=this.state;this.props.onAuthorized(g({authorizedEvent:r},n&&{billingAddress:n},o&&{deliveryAddress:o}),{resolve:e,reject:t})})).catch((e=>{const t={error:{applePayError:e}};return Promise.reject(t)}))}async collectOrderTrackingDetailsIfNeeded(e){return new Promise(((e,t)=>{if(!this.props.onOrderTrackingRequest)return e();this.props.onOrderTrackingRequest(e,t)})).then((t=>g({paymentResponse:e},t&&{orderDetails:t}))).catch((()=>({paymentResponse:e})))}async validateMerchant(e,t){const{hostname:r}=window.location,{clientKey:n,configuration:i,loadingContext:p,initiative:l}=this.props,{merchantName:c,merchantId:d}=i,h={loadingContext:p,path:`${a}?clientKey=${n}`},u={displayName:c,domainName:r,initiative:l,merchantIdentifier:d};try{const r=await s(h,u),n=o.decode(r.data);n||t("Could not decode Apple Pay session");e(JSON.parse(n))}catch(e){t("Could not get Apple Pay session")}}get isValid(){return!0}async isAvailable(){if("https:"!==document.location.protocol)return Promise.reject(new h("IMPLEMENTATION_ERROR","Trying to start an Apple Pay session from an insecure document"));if(!this.props.onValidateMerchant&&!this.props.clientKey)return Promise.reject(new h("IMPLEMENTATION_ERROR","clientKey was not provided"));try{if(window.ApplePaySession&&ApplePaySession.canMakePayments()&&ApplePaySession.supportsVersion(this.props.version))return Promise.resolve()}catch(e){console.warn(e)}return Promise.reject(new h("ERROR","Apple Pay is not available on this device"))}render(){return this.props.showPayButton?e(r,{i18n:this.props.i18n,buttonColor:this.props.buttonColor,buttonType:this.props.buttonType,onClick:e=>{e.preventDefault(),this.submit()}}):null}constructor(e,t){super(e,t),b(this,"submit",(()=>{this.props.isInstantPayment&&this.submitAnalytics({type:f,target:P}),this.startSession()})),this.startSession=this.startSession.bind(this),this.submit=this.submit.bind(this),this.validateMerchant=this.validateMerchant.bind(this),this.collectOrderTrackingDetailsIfNeeded=this.collectOrderTrackingDetailsIfNeeded.bind(this),this.handleAuthorization=this.handleAuthorization.bind(this)}}b(A,"type",u.applepay),b(A,"defaultProps",i);export{A as default};
2
2
  //# sourceMappingURL=ApplePay.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ApplePay.js","sources":["../../../../src/components/ApplePay/ApplePay.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport ApplePayButton from './components/ApplePayButton';\nimport ApplePayService from './ApplePayService';\nimport base64 from '../../utils/base64';\nimport defaultProps from './defaultProps';\nimport { httpPost } from '../../core/Services/http';\nimport { APPLEPAY_SESSION_ENDPOINT } from './config';\nimport { preparePaymentRequest } from './payment-request';\nimport { resolveSupportedVersion, mapBrands, formatApplePayContactToAdyenAddressFormat } from './utils';\nimport AdyenCheckoutError from '../../core/Errors/AdyenCheckoutError';\nimport { TxVariants } from '../tx-variants';\nimport { sanitizeResponse, verifyPaymentDidNotFail } from '../internal/UIElement/utils';\nimport type { ApplePayConfiguration, ApplePayElementData, ApplePayPaymentOrderDetails, ApplePaySessionRequest } from './types';\nimport type { ICore } from '../../core/types';\nimport type { PaymentResponseData, RawPaymentResponse } from '../../types/global-types';\nimport { ANALYTICS_INSTANT_PAYMENT_BUTTON, ANALYTICS_SELECTED_STR } from '../../core/Analytics/constants';\n\nconst latestSupportedVersion = 14;\n\nclass ApplePayElement extends UIElement<ApplePayConfiguration> {\n public static type = TxVariants.applepay;\n protected static defaultProps = defaultProps;\n\n constructor(checkout: ICore, props?: ApplePayConfiguration) {\n super(checkout, props);\n this.startSession = this.startSession.bind(this);\n this.submit = this.submit.bind(this);\n this.validateMerchant = this.validateMerchant.bind(this);\n this.collectOrderTrackingDetailsIfNeeded = this.collectOrderTrackingDetailsIfNeeded.bind(this);\n this.handleAuthorization = this.handleAuthorization.bind(this);\n }\n\n /**\n * Formats the component props\n */\n protected formatProps(props) {\n const version = props.version || resolveSupportedVersion(latestSupportedVersion);\n const supportedNetworks = props.brands?.length ? mapBrands(props.brands) : props.supportedNetworks;\n\n return {\n ...props,\n configuration: props.configuration,\n supportedNetworks,\n version,\n totalPriceLabel: props.totalPriceLabel || props.configuration?.merchantName\n };\n }\n\n /**\n * Formats the component data output\n */\n protected formatData(): ApplePayElementData {\n const { applePayToken, billingAddress, deliveryAddress } = this.state;\n\n return {\n paymentMethod: {\n type: ApplePayElement.type,\n applePayToken\n },\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n };\n }\n\n public submit = (): void => {\n // Analytics\n if (this.props.isInstantPayment) {\n this.submitAnalytics({ type: ANALYTICS_SELECTED_STR, target: ANALYTICS_INSTANT_PAYMENT_BUTTON });\n }\n void this.startSession();\n };\n\n private startSession() {\n const { version, onValidateMerchant, onPaymentMethodSelected, onShippingMethodSelected, onShippingContactSelected } = this.props;\n\n const paymentRequest = preparePaymentRequest({\n companyName: this.props.configuration.merchantName,\n countryCode: this.core.options.countryCode,\n ...this.props\n });\n\n const session = new ApplePayService(paymentRequest, {\n version,\n onError: (error: unknown) => {\n this.handleError(\n new AdyenCheckoutError('ERROR', 'ApplePay - Something went wrong on ApplePayService', {\n cause: error\n })\n );\n },\n onCancel: event => {\n this.handleError(new AdyenCheckoutError('CANCEL', 'ApplePay UI dismissed', { cause: event }));\n },\n onPaymentMethodSelected,\n onShippingMethodSelected,\n onShippingContactSelected,\n onValidateMerchant: onValidateMerchant || this.validateMerchant,\n onPaymentAuthorized: (resolve, reject, event) => {\n const billingAddress = formatApplePayContactToAdyenAddressFormat(event.payment.billingContact);\n const deliveryAddress = formatApplePayContactToAdyenAddressFormat(event.payment.shippingContact, true);\n\n this.setState({\n applePayToken: btoa(JSON.stringify(event.payment.token.paymentData)),\n authorizedEvent: event,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n });\n\n this.handleAuthorization()\n .then(this.makePaymentsCall)\n .then(sanitizeResponse)\n .then(verifyPaymentDidNotFail)\n .then(this.collectOrderTrackingDetailsIfNeeded)\n .then(({ paymentResponse, orderDetails }) => {\n resolve({\n status: ApplePaySession.STATUS_SUCCESS,\n ...(orderDetails && { orderDetails })\n });\n return paymentResponse;\n })\n .then(paymentResponse => {\n this.handleResponse(paymentResponse);\n })\n .catch((paymentResponse: RawPaymentResponse) => {\n const errors = paymentResponse?.error?.applePayError;\n\n reject({\n status: ApplePaySession.STATUS_FAILURE,\n errors: errors ? (Array.isArray(errors) ? errors : [errors]) : undefined\n });\n\n this.handleFailedResult(paymentResponse);\n });\n }\n });\n\n return new Promise((resolve, reject) => this.props.onClick(resolve, reject))\n .then(() => {\n session.begin();\n })\n .catch(() => ({\n // Swallow exception triggered by onClick reject\n }));\n }\n\n /**\n * Call the 'onAuthorized' callback if available.\n * Must be resolved/reject for the payment flow to continue\n *\n * @private\n */\n private async handleAuthorization(): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n if (!this.props.onAuthorized) {\n resolve();\n }\n\n const { authorizedEvent, billingAddress, deliveryAddress } = this.state;\n\n this.props.onAuthorized(\n {\n authorizedEvent,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n },\n { resolve, reject }\n );\n }).catch((error?: ApplePayJS.ApplePayError) => {\n // Format error in a way that the 'catch' of the 'onPaymentAuthorize' block accepts it\n const data = { error: { applePayError: error } };\n return Promise.reject(data);\n });\n }\n\n /**\n * Verify if the 'onOrderTrackingRequest' is provided. If so, triggers the callback expecting an\n * Apple Pay order details back\n *\n * @private\n */\n private async collectOrderTrackingDetailsIfNeeded(\n paymentResponse: PaymentResponseData\n ): Promise<{ orderDetails?: ApplePayPaymentOrderDetails; paymentResponse: PaymentResponseData }> {\n return new Promise<ApplePayPaymentOrderDetails | void>((resolve, reject) => {\n if (!this.props.onOrderTrackingRequest) {\n return resolve();\n }\n\n this.props.onOrderTrackingRequest(resolve, reject);\n })\n .then(orderDetails => {\n return {\n paymentResponse,\n ...(orderDetails && { orderDetails })\n };\n })\n .catch(() => {\n return { paymentResponse };\n });\n }\n\n private async validateMerchant(resolve, reject) {\n const { hostname: domainName } = window.location;\n const { clientKey, configuration, loadingContext, initiative } = this.props;\n const { merchantName, merchantId } = configuration;\n const path = `${APPLEPAY_SESSION_ENDPOINT}?clientKey=${clientKey}`;\n const options = { loadingContext, path };\n const request: ApplePaySessionRequest = {\n displayName: merchantName,\n domainName,\n initiative,\n merchantIdentifier: merchantId\n };\n\n try {\n const response = await httpPost(options, request);\n const decodedData = base64.decode(response.data);\n if (!decodedData) reject('Could not decode Apple Pay session');\n const session = JSON.parse(decodedData as string);\n resolve(session);\n } catch (e) {\n reject('Could not get Apple Pay session');\n }\n }\n\n /**\n * Validation\n *\n * @remarks\n * Apple Pay does not require any specific validation\n */\n get isValid(): boolean {\n return true;\n }\n\n /**\n * Determine a shopper's ability to return a form of payment from Apple Pay.\n * @returns Promise Resolve/Reject whether the shopper can use Apple Pay\n */\n public override async isAvailable(): Promise<void> {\n if (document.location.protocol !== 'https:') {\n return Promise.reject(new AdyenCheckoutError('IMPLEMENTATION_ERROR', 'Trying to start an Apple Pay session from an insecure document'));\n }\n\n if (!this.props.onValidateMerchant && !this.props.clientKey) {\n return Promise.reject(new AdyenCheckoutError('IMPLEMENTATION_ERROR', 'clientKey was not provided'));\n }\n\n try {\n if (window.ApplePaySession && ApplePaySession.canMakePayments() && ApplePaySession.supportsVersion(this.props.version)) {\n return Promise.resolve();\n }\n } catch (error) {\n console.warn(error);\n }\n\n return Promise.reject(new AdyenCheckoutError('ERROR', 'Apple Pay is not available on this device'));\n }\n\n /**\n * Renders the Apple Pay button or nothing in the Dropin\n */\n render() {\n if (this.props.showPayButton) {\n return (\n <ApplePayButton\n i18n={this.props.i18n}\n buttonColor={this.props.buttonColor}\n buttonType={this.props.buttonType}\n onClick={e => {\n e.preventDefault();\n this.submit();\n }}\n />\n );\n }\n\n return null;\n }\n}\n\nexport default ApplePayElement;\n"],"names":["ApplePayElement","UIElement","formatProps","props","version","resolveSupportedVersion","supportedNetworks","brands","length","mapBrands","_object_spread_props","configuration","totalPriceLabel","merchantName","formatData","applePayToken","billingAddress","deliveryAddress","this","state","_object_spread","paymentMethod","type","startSession","onValidateMerchant","onPaymentMethodSelected","onShippingMethodSelected","onShippingContactSelected","paymentRequest","preparePaymentRequest","companyName","countryCode","core","options","session","ApplePayService","onError","error","handleError","AdyenCheckoutError","cause","onCancel","event","validateMerchant","onPaymentAuthorized","resolve","reject","formatApplePayContactToAdyenAddressFormat","payment","billingContact","shippingContact","setState","btoa","JSON","stringify","token","paymentData","authorizedEvent","handleAuthorization","then","makePaymentsCall","sanitizeResponse","verifyPaymentDidNotFail","collectOrderTrackingDetailsIfNeeded","paymentResponse","orderDetails","status","ApplePaySession","STATUS_SUCCESS","handleResponse","catch","errors","applePayError","STATUS_FAILURE","Array","isArray","undefined","handleFailedResult","Promise","onClick","begin","onAuthorized","data","onOrderTrackingRequest","hostname","domainName","window","location","clientKey","loadingContext","initiative","merchantId","path","APPLEPAY_SESSION_ENDPOINT","request","displayName","merchantIdentifier","response","httpPost","decodedData","base64","decode","parse","e","isValid","isAvailable","document","protocol","canMakePayments","supportsVersion","console","warn","render","showPayButton","h","ApplePayButton","i18n","buttonColor","buttonType","preventDefault","submit","constructor","checkout","super","_define_property","isInstantPayment","submitAnalytics","ANALYTICS_SELECTED_STR","target","ANALYTICS_INSTANT_PAYMENT_BUTTON","bind","TxVariants","applepay","defaultProps"],"mappings":"yvDAoBA,MAAMA,UAAwBC,EAgBhBC,WAAAA,CAAYC,OAEQA,EAOoBA,EAR9C,MAAMC,EAAUD,EAAMC,SAAWC,EAnBV,IAoBjBC,GAAoBH,QAAAA,EAAAA,EAAMI,cAANJ,IAAAA,OAAAA,EAAAA,EAAcK,QAASC,EAAUN,EAAMI,QAAUJ,EAAMG,kBAEjF,OAAOI,EACAP,EAAAA,CAAAA,EAAAA,GAAAA,CACHQ,cAAeR,EAAMQ,cACrBL,oBACAF,UACAQ,gBAAiBT,EAAMS,kBAAsC,QAAnBT,EAAAA,EAAMQ,qBAANR,IAAAA,OAAAA,EAAAA,EAAqBU,eAEvE,CAKA,UAAAC,GACI,MAAMC,cAAEA,EAAaC,eAAEA,EAAcC,gBAAEA,GAAoBC,KAAKC,MAEhE,OAAOC,EAAA,CACH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KAAKhH,MACnDA,KAAK6C,oCAAsC7C,KAAK6C,oCAAoCmE,KAAKhH,MACzFA,KAAKwC,oBAAsBxC,KAAKwC,oBAAoBwE,KAAKhH,KAC7D,EAVA0G,EADE5H,EACYsB,OAAO6G,EAAWC,UAChCR,EAFE5H,EAEeqI,eAAeA"}
1
+ {"version":3,"file":"ApplePay.js","sources":["../../../../src/components/ApplePay/ApplePay.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport ApplePayButton from './components/ApplePayButton';\nimport ApplePayService from './ApplePayService';\nimport base64 from '../../utils/base64';\nimport defaultProps from './defaultProps';\nimport { httpPost } from '../../core/Services/http';\nimport { APPLEPAY_SESSION_ENDPOINT } from './config';\nimport { preparePaymentRequest } from './payment-request';\nimport { resolveSupportedVersion, mapBrands, formatApplePayContactToAdyenAddressFormat } from './utils';\nimport AdyenCheckoutError from '../../core/Errors/AdyenCheckoutError';\nimport { TxVariants } from '../tx-variants';\nimport { sanitizeResponse, verifyPaymentDidNotFail } from '../internal/UIElement/utils';\nimport { ANALYTICS_INSTANT_PAYMENT_BUTTON, ANALYTICS_SELECTED_STR } from '../../core/Analytics/constants';\nimport type { ApplePayConfiguration, ApplePayElementData, ApplePayPaymentOrderDetails, ApplePaySessionRequest } from './types';\nimport type { ICore } from '../../core/types';\nimport type { PaymentResponseData, RawPaymentResponse } from '../../types/global-types';\n\nconst latestSupportedVersion = 14;\n\nclass ApplePayElement extends UIElement<ApplePayConfiguration> {\n public static type = TxVariants.applepay;\n protected static defaultProps = defaultProps;\n\n constructor(checkout: ICore, props?: ApplePayConfiguration) {\n super(checkout, props);\n this.startSession = this.startSession.bind(this);\n this.submit = this.submit.bind(this);\n this.validateMerchant = this.validateMerchant.bind(this);\n this.collectOrderTrackingDetailsIfNeeded = this.collectOrderTrackingDetailsIfNeeded.bind(this);\n this.handleAuthorization = this.handleAuthorization.bind(this);\n }\n\n /**\n * Formats the component props\n */\n protected formatProps(props) {\n const version = props.version || resolveSupportedVersion(latestSupportedVersion);\n const supportedNetworks = props.brands?.length ? mapBrands(props.brands) : props.supportedNetworks;\n\n return {\n ...props,\n configuration: props.configuration,\n supportedNetworks,\n version,\n totalPriceLabel: props.totalPriceLabel || props.configuration?.merchantName\n };\n }\n\n /**\n * Formats the component data output\n */\n protected formatData(): ApplePayElementData {\n const { applePayToken, billingAddress, deliveryAddress } = this.state;\n\n return {\n paymentMethod: {\n type: ApplePayElement.type,\n applePayToken\n },\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n };\n }\n\n public submit = (): void => {\n // Analytics\n if (this.props.isInstantPayment) {\n this.submitAnalytics({ type: ANALYTICS_SELECTED_STR, target: ANALYTICS_INSTANT_PAYMENT_BUTTON });\n }\n void this.startSession();\n };\n\n private startSession() {\n const { version, onValidateMerchant, onPaymentMethodSelected, onShippingMethodSelected, onShippingContactSelected } = this.props;\n\n const paymentRequest = preparePaymentRequest({\n companyName: this.props.configuration.merchantName,\n countryCode: this.core.options.countryCode,\n ...this.props\n });\n\n const session = new ApplePayService(paymentRequest, {\n version,\n onError: (error: unknown) => {\n this.handleError(\n new AdyenCheckoutError('ERROR', 'ApplePay - Something went wrong on ApplePayService', {\n cause: error\n })\n );\n },\n onCancel: event => {\n this.handleError(new AdyenCheckoutError('CANCEL', 'ApplePay UI dismissed', { cause: event }));\n },\n onPaymentMethodSelected,\n onShippingMethodSelected,\n onShippingContactSelected,\n onValidateMerchant: onValidateMerchant || this.validateMerchant,\n onPaymentAuthorized: (resolve, reject, event) => {\n const billingAddress = formatApplePayContactToAdyenAddressFormat(event.payment.billingContact);\n const deliveryAddress = formatApplePayContactToAdyenAddressFormat(event.payment.shippingContact, true);\n\n this.setState({\n applePayToken: btoa(JSON.stringify(event.payment.token.paymentData)),\n authorizedEvent: event,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n });\n\n this.handleAuthorization()\n .then(this.makePaymentsCall)\n .then(sanitizeResponse)\n .then(verifyPaymentDidNotFail)\n .then(this.collectOrderTrackingDetailsIfNeeded)\n .then(({ paymentResponse, orderDetails }) => {\n resolve({\n status: ApplePaySession.STATUS_SUCCESS,\n ...(orderDetails && { orderDetails })\n });\n return paymentResponse;\n })\n .then(paymentResponse => {\n this.handleResponse(paymentResponse);\n })\n .catch((paymentResponse?: RawPaymentResponse) => {\n const errors = paymentResponse?.error?.applePayError;\n\n reject({\n status: ApplePaySession.STATUS_FAILURE,\n errors: errors ? (Array.isArray(errors) ? errors : [errors]) : undefined\n });\n\n const responseWithError: RawPaymentResponse = {\n ...paymentResponse,\n error: {\n applePayError: errors\n }\n };\n\n this.handleFailedResult(responseWithError);\n });\n }\n });\n\n return new Promise((resolve, reject) => this.props.onClick(resolve, reject))\n .then(() => {\n session.begin();\n })\n .catch(() => ({\n // Swallow exception triggered by onClick reject\n }));\n }\n\n /**\n * Call the 'onAuthorized' callback if available.\n * Must be resolved/reject for the payment flow to continue\n *\n * @private\n */\n private async handleAuthorization(): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n if (!this.props.onAuthorized) {\n resolve();\n }\n\n const { authorizedEvent, billingAddress, deliveryAddress } = this.state;\n\n this.props.onAuthorized(\n {\n authorizedEvent,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n },\n { resolve, reject }\n );\n }).catch((error?: ApplePayJS.ApplePayError) => {\n // Format error in a way that the 'catch' of the 'onPaymentAuthorize' block accepts it\n const data = { error: { applePayError: error } };\n return Promise.reject(data);\n });\n }\n\n /**\n * Verify if the 'onOrderTrackingRequest' is provided. If so, triggers the callback expecting an\n * Apple Pay order details back\n *\n * @private\n */\n private async collectOrderTrackingDetailsIfNeeded(\n paymentResponse: PaymentResponseData\n ): Promise<{ orderDetails?: ApplePayPaymentOrderDetails; paymentResponse: PaymentResponseData }> {\n return new Promise<ApplePayPaymentOrderDetails | void>((resolve, reject) => {\n if (!this.props.onOrderTrackingRequest) {\n return resolve();\n }\n\n this.props.onOrderTrackingRequest(resolve, reject);\n })\n .then(orderDetails => {\n return {\n paymentResponse,\n ...(orderDetails && { orderDetails })\n };\n })\n .catch(() => {\n return { paymentResponse };\n });\n }\n\n private async validateMerchant(resolve, reject) {\n const { hostname: domainName } = window.location;\n const { clientKey, configuration, loadingContext, initiative } = this.props;\n const { merchantName, merchantId } = configuration;\n const path = `${APPLEPAY_SESSION_ENDPOINT}?clientKey=${clientKey}`;\n const options = { loadingContext, path };\n const request: ApplePaySessionRequest = {\n displayName: merchantName,\n domainName,\n initiative,\n merchantIdentifier: merchantId\n };\n\n try {\n const response = await httpPost(options, request);\n const decodedData = base64.decode(response.data);\n if (!decodedData) reject('Could not decode Apple Pay session');\n const session = JSON.parse(decodedData as string);\n resolve(session);\n } catch (e) {\n reject('Could not get Apple Pay session');\n }\n }\n\n /**\n * Validation\n *\n * @remarks\n * Apple Pay does not require any specific validation\n */\n get isValid(): boolean {\n return true;\n }\n\n /**\n * Determine a shopper's ability to return a form of payment from Apple Pay.\n * @returns Promise Resolve/Reject whether the shopper can use Apple Pay\n */\n public override async isAvailable(): Promise<void> {\n if (document.location.protocol !== 'https:') {\n return Promise.reject(new AdyenCheckoutError('IMPLEMENTATION_ERROR', 'Trying to start an Apple Pay session from an insecure document'));\n }\n\n if (!this.props.onValidateMerchant && !this.props.clientKey) {\n return Promise.reject(new AdyenCheckoutError('IMPLEMENTATION_ERROR', 'clientKey was not provided'));\n }\n\n try {\n if (window.ApplePaySession && ApplePaySession.canMakePayments() && ApplePaySession.supportsVersion(this.props.version)) {\n return Promise.resolve();\n }\n } catch (error) {\n console.warn(error);\n }\n\n return Promise.reject(new AdyenCheckoutError('ERROR', 'Apple Pay is not available on this device'));\n }\n\n /**\n * Renders the Apple Pay button or nothing in the Dropin\n */\n render() {\n if (this.props.showPayButton) {\n return (\n <ApplePayButton\n i18n={this.props.i18n}\n buttonColor={this.props.buttonColor}\n buttonType={this.props.buttonType}\n onClick={e => {\n e.preventDefault();\n this.submit();\n }}\n />\n );\n }\n\n return null;\n }\n}\n\nexport default ApplePayElement;\n"],"names":["ApplePayElement","UIElement","formatProps","props","version","resolveSupportedVersion","supportedNetworks","brands","length","mapBrands","_object_spread_props","configuration","totalPriceLabel","merchantName","formatData","applePayToken","billingAddress","deliveryAddress","this","state","_object_spread","paymentMethod","type","startSession","onValidateMerchant","onPaymentMethodSelected","onShippingMethodSelected","onShippingContactSelected","paymentRequest","preparePaymentRequest","companyName","countryCode","core","options","session","ApplePayService","onError","error","handleError","AdyenCheckoutError","cause","onCancel","event","validateMerchant","onPaymentAuthorized","resolve","reject","formatApplePayContactToAdyenAddressFormat","payment","billingContact","shippingContact","setState","btoa","JSON","stringify","token","paymentData","authorizedEvent","handleAuthorization","then","makePaymentsCall","sanitizeResponse","verifyPaymentDidNotFail","collectOrderTrackingDetailsIfNeeded","paymentResponse","orderDetails","status","ApplePaySession","STATUS_SUCCESS","handleResponse","catch","errors","applePayError","STATUS_FAILURE","Array","isArray","undefined","responseWithError","handleFailedResult","Promise","onClick","begin","onAuthorized","data","onOrderTrackingRequest","hostname","domainName","window","location","clientKey","loadingContext","initiative","merchantId","path","APPLEPAY_SESSION_ENDPOINT","request","displayName","merchantIdentifier","response","httpPost","decodedData","base64","decode","parse","e","isValid","isAvailable","document","protocol","canMakePayments","supportsVersion","console","warn","render","showPayButton","h","ApplePayButton","i18n","buttonColor","buttonType","preventDefault","submit","constructor","checkout","super","_define_property","isInstantPayment","submitAnalytics","ANALYTICS_SELECTED_STR","target","ANALYTICS_INSTANT_PAYMENT_BUTTON","bind","TxVariants","applepay","defaultProps"],"mappings":"yvDAoBA,MAAMA,UAAwBC,EAgBhBC,WAAAA,CAAYC,OAEQA,EAOoBA,EAR9C,MAAMC,EAAUD,EAAMC,SAAWC,EAnBV,IAoBjBC,GAAoBH,QAAAA,EAAAA,EAAMI,cAANJ,IAAAA,OAAAA,EAAAA,EAAcK,QAASC,EAAUN,EAAMI,QAAUJ,EAAMG,kBAEjF,OAAO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BACFtG,KAAKuG,QAAM,IAMpB,IACX,CAtQAC,WAAAA,CAAYC,EAAiBxH,GACzByH,MAAMD,EAAUxH,GAwCpB0H,EAAA3G,KAAOuG,UAAS,KAERvG,KAAKf,MAAM2H,kBACX5G,KAAK6G,gBAAgB,CAAEzG,KAAM0G,EAAwBC,OAAQC,IAE5DhH,KAAKK,cAAY,IA5CtBL,KAAKK,aAAeL,KAAKK,aAAa4G,KAAKjH,MAC3CA,KAAKuG,OAASvG,KAAKuG,OAAOU,KAAKjH,MAC/BA,KAAKyB,iBAAmBzB,KAAKyB,iBAAiBwF,KAAKjH,MACnDA,KAAK6C,oCAAsC7C,KAAK6C,oCAAoCoE,KAAKjH,MACzFA,KAAKwC,oBAAsBxC,KAAKwC,oBAAoByE,KAAKjH,KAC7D,EAVA2G,EADE7H,EACYsB,OAAO8G,EAAWC,UAChCR,EAFE7H,EAEesI,eAAeA"}
@@ -1,2 +1,2 @@
1
- import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import o from"./defaultProps.js";import{DropinComponent as n}from"./components/DropinComponent.js";import r from"../../core/Context/CoreProvider.js";import{getCommonProps as i}from"./components/utils.js";import s from"./elements/createElements.js";import a from"./elements/createStoredElements.js";import h from"./elements/createInstantPaymentElements.js";import{hasOwnProperty as p}from"../../utils/hasOwnProperty.js";import d from"../../core/Errors/SRPanelProvider.js";import c from"./elements/splitPaymentMethods.js";function m(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function l(t){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{},n=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(o).filter((function(t){return Object.getOwnPropertyDescriptor(o,t).enumerable})))),n.forEach((function(e){m(t,e,o[e])}))}return t}function f(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t,e){var o=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),o.push.apply(o,n)}return o}(Object(e)).forEach((function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(e,o))})),t}const y=["paywithgoogle","googlepay","applepay"];class u extends e{storeElementRefOnCore(){this.core.storeElementReference(this)}formatProps(t){return f(l({type:"dropin"},super.formatProps(t)),{instantPaymentTypes:Array.from(new Set(t.instantPaymentTypes)).filter((t=>y.includes(t)))})}get isValid(){return!!this.dropinRef&&!!this.dropinRef.state.activePaymentMethod&&!!this.dropinRef.state.activePaymentMethod.isValid}showValidation(){return this.dropinRef.state.activePaymentMethod&&this.dropinRef.state.activePaymentMethod.showValidation(),this}setStatus(t,e={}){var o;return null===(o=this.dropinRef)||void 0===o||o.setStatus(t,e),this}get activePaymentMethod(){var t,e;return(null===(t=this.dropinRef)||void 0===t?void 0:t.state)||(null===(e=this.dropinRef)||void 0===e?void 0:e.state.activePaymentMethod)?this.dropinRef.state.activePaymentMethod:null}get data(){return this.activePaymentMethod?this.dropinRef.state.activePaymentMethod.data:null}submit(){if(!this.activePaymentMethod)throw new Error("No active payment method.");this.activePaymentMethod.isValid||this.activePaymentMethod.showValidation(),this.activePaymentMethod.isInstantPayment&&this.closeActivePaymentMethod(),this.activePaymentMethod.submit()}handleAction(t,e={}){var o,n;if(!t||!t.type){if(p(t,"action")&&p(t,"resultCode"))throw new Error('handleAction::Invalid Action - the passed action object itself has an "action" property and a "resultCode": have you passed in the whole response object by mistake?');throw new Error('handleAction::Invalid Action - the passed action object does not have a "type" property')}if("redirect"!==t.type&&(null===(o=this.activePaymentMethod)||void 0===o?void 0:o.updateWithAction))return this.activePaymentMethod.updateWithAction(t);this.elementRef instanceof u&&(e=l({},null===(n=this.elementRef.activePaymentMethod)||void 0===n?void 0:n.props,e));const r=this.core.createFromAction(t,f(l({},e),{elementRef:this.elementRef,onAdditionalDetails:this.handleAdditionalDetails,isDropin:!0}));return r?(this.setStatus(r.props.statusType,{component:r}),this.componentFromAction=r,this):null}closeActivePaymentMethod(){this.dropinRef.closeActivePaymentMethod()}render(){return t(r,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},t(d,{srPanel:this.props.modules.srPanel},t(n,f(l({},this.props),{core:this.core,onChange:this.setState,elementRef:this.elementRef,onCreateElements:this.handleCreate,ref:t=>{this.dropinRef=t}}))))}constructor(t,e){super(t,e),m(this,"dropinRef",null),m(this,"paymentMethodsConfiguration",void 0),m(this,"componentFromAction",void 0),m(this,"handleCreate",(()=>{const{paymentMethodsConfiguration:t,showStoredPaymentMethods:e,showPaymentMethods:o,instantPaymentTypes:n}=this.props,{paymentMethods:r,storedPaymentMethods:p,instantPaymentMethods:d}=c(this.core.paymentMethodsResponse,n),m=i(f(l({},this.props),{elementRef:this.elementRef}));return[e?a(p,t,m,this.core):[],o?s(r,t,m,this.core):[],h(d,t,m,this.core)]})),m(this,"handleOrder",(({order:t})=>{this.updateParent({order:t})})),this.submit=this.submit.bind(this),this.handleAction=this.handleAction.bind(this),this.props.paymentMethodComponents.forEach((t=>this.core.register(t))),this.paymentMethodsConfiguration=this.props.paymentMethodsConfiguration||{}}}m(u,"defaultProps",o);export{u as default};
1
+ import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import o from"./defaultProps.js";import{DropinComponent as n}from"./components/DropinComponent.js";import i from"../../core/Context/CoreProvider.js";import{getCommonProps as r}from"./components/utils.js";import s from"./elements/createElements.js";import a from"./elements/createStoredElements.js";import h from"./elements/createInstantPaymentElements.js";import{hasOwnProperty as p}from"../../utils/hasOwnProperty.js";import d from"../../core/Errors/SRPanelProvider.js";import c from"./elements/splitPaymentMethods.js";function m(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function l(t){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{},n=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(o).filter((function(t){return Object.getOwnPropertyDescriptor(o,t).enumerable})))),n.forEach((function(e){m(t,e,o[e])}))}return t}function f(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t,e){var o=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),o.push.apply(o,n)}return o}(Object(e)).forEach((function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(e,o))})),t}const y=["paywithgoogle","googlepay","applepay"];class u extends e{storeElementRefOnCore(){this.core.storeElementReference(this)}formatProps(t){return f(l({type:"dropin"},super.formatProps(t)),{instantPaymentTypes:Array.from(new Set(t.instantPaymentTypes)).filter((t=>y.includes(t)))})}get isValid(){return!!this.dropinRef&&!!this.dropinRef.state.activePaymentMethod&&!!this.dropinRef.state.activePaymentMethod.isValid}showValidation(){return this.dropinRef.state.activePaymentMethod&&this.dropinRef.state.activePaymentMethod.showValidation(),this}setStatus(t,e={}){var o;return null===(o=this.dropinRef)||void 0===o||o.setStatus(t,e),this}get activePaymentMethod(){var t,e;return(null===(t=this.dropinRef)||void 0===t?void 0:t.state)||(null===(e=this.dropinRef)||void 0===e?void 0:e.state.activePaymentMethod)?this.dropinRef.state.activePaymentMethod:null}get data(){return this.activePaymentMethod?this.dropinRef.state.activePaymentMethod.data:null}displayFinalAnimation(t){this.props.disableFinalAnimation||this.dropinRef.setStatus(t)}submit(){if(!this.activePaymentMethod)throw new Error("No active payment method.");this.activePaymentMethod.isValid||this.activePaymentMethod.showValidation(),this.activePaymentMethod.isInstantPayment&&this.closeActivePaymentMethod(),this.activePaymentMethod.submit()}handleAction(t,e={}){var o,n;if(!t||!t.type){if(p(t,"action")&&p(t,"resultCode"))throw new Error('handleAction::Invalid Action - the passed action object itself has an "action" property and a "resultCode": have you passed in the whole response object by mistake?');throw new Error('handleAction::Invalid Action - the passed action object does not have a "type" property')}if("redirect"!==t.type&&(null===(o=this.activePaymentMethod)||void 0===o?void 0:o.updateWithAction))return this.activePaymentMethod.updateWithAction(t);this.elementRef instanceof u&&(e=l({},null===(n=this.elementRef.activePaymentMethod)||void 0===n?void 0:n.props,e));const i=this.core.createFromAction(t,f(l({},e),{elementRef:this.elementRef,onAdditionalDetails:this.handleAdditionalDetails,isDropin:!0}));return i?(this.setStatus(i.props.statusType,{component:i}),this.componentFromAction=i,this):null}closeActivePaymentMethod(){this.dropinRef.closeActivePaymentMethod()}render(){return t(i,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},t(d,{srPanel:this.props.modules.srPanel},t(n,f(l({},this.props),{core:this.core,onChange:this.setState,elementRef:this.elementRef,onCreateElements:this.handleCreate,ref:t=>{this.dropinRef=t}}))))}constructor(t,e){super(t,e),m(this,"dropinRef",null),m(this,"paymentMethodsConfiguration",void 0),m(this,"componentFromAction",void 0),m(this,"handleCreate",(()=>{const{paymentMethodsConfiguration:t,showStoredPaymentMethods:e,showPaymentMethods:o,instantPaymentTypes:n}=this.props,{paymentMethods:i,storedPaymentMethods:p,instantPaymentMethods:d}=c(this.core.paymentMethodsResponse,n),m=r(f(l({},this.props),{elementRef:this.elementRef}));return[e?a(p,t,m,this.core):[],o?s(i,t,m,this.core):[],h(d,t,m,this.core)]})),m(this,"handleOrder",(({order:t})=>{this.updateParent({order:t})})),this.submit=this.submit.bind(this),this.handleAction=this.handleAction.bind(this),this.props.paymentMethodComponents.forEach((t=>this.core.register(t))),this.paymentMethodsConfiguration=this.props.paymentMethodsConfiguration||{}}}m(u,"defaultProps",o);export{u as default};
2
2
  //# sourceMappingURL=Dropin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Dropin.js","sources":["../../../../src/components/Dropin/Dropin.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport defaultProps from './defaultProps';\nimport DropinComponent from '../../components/Dropin/components/DropinComponent';\nimport CoreProvider from '../../core/Context/CoreProvider';\nimport { PaymentAction, PaymentResponseData } from '../../types/global-types';\nimport { DropinConfiguration, InstantPaymentTypes, PaymentMethodsConfiguration } from './types';\nimport { getCommonProps } from './components/utils';\nimport { createElements, createStoredElements } from './elements';\nimport createInstantPaymentElements from './elements/createInstantPaymentElements';\nimport { hasOwnProperty } from '../../utils/hasOwnProperty';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport splitPaymentMethods from './elements/splitPaymentMethods';\nimport type { ICore } from '../../core/types';\nimport type { IDropin } from './types';\n\nconst SUPPORTED_INSTANT_PAYMENTS = ['paywithgoogle', 'googlepay', 'applepay'];\n\nclass DropinElement extends UIElement<DropinConfiguration> implements IDropin {\n protected static defaultProps = defaultProps;\n\n public dropinRef = null;\n\n private paymentMethodsConfiguration: PaymentMethodsConfiguration;\n /**\n * Reference to the component created from `handleAction` (Ex.: ThreeDS2Challenge)\n */\n public componentFromAction?: UIElement;\n\n constructor(checkout: ICore, props?: DropinConfiguration) {\n super(checkout, props);\n this.submit = this.submit.bind(this);\n this.handleAction = this.handleAction.bind(this);\n\n this.props.paymentMethodComponents.forEach(PaymentMethod => this.core.register(PaymentMethod));\n this.paymentMethodsConfiguration = this.props.paymentMethodsConfiguration || {};\n }\n\n protected override storeElementRefOnCore() {\n this.core.storeElementReference(this);\n }\n\n formatProps(props) {\n return {\n type: 'dropin', // for analytics\n ...super.formatProps(props),\n instantPaymentTypes: Array.from<InstantPaymentTypes>(new Set(props.instantPaymentTypes)).filter(value =>\n SUPPORTED_INSTANT_PAYMENTS.includes(value)\n )\n };\n }\n\n get isValid() {\n return !!this.dropinRef && !!this.dropinRef.state.activePaymentMethod && !!this.dropinRef.state.activePaymentMethod.isValid;\n }\n\n showValidation() {\n if (this.dropinRef.state.activePaymentMethod) {\n this.dropinRef.state.activePaymentMethod.showValidation();\n }\n\n return this;\n }\n\n public setStatus(status, props = {}): this {\n this.dropinRef?.setStatus(status, props);\n return this;\n }\n\n get activePaymentMethod() {\n if (!this.dropinRef?.state && !this.dropinRef?.state.activePaymentMethod) {\n return null;\n }\n\n return this.dropinRef.state.activePaymentMethod;\n }\n\n get data() {\n if (!this.activePaymentMethod) {\n return null;\n }\n\n return this.dropinRef.state.activePaymentMethod.data;\n }\n\n /**\n * Calls the onSubmit event with the state of the activePaymentMethod\n */\n public override submit(): void {\n if (!this.activePaymentMethod) {\n throw new Error('No active payment method.');\n }\n\n if (!this.activePaymentMethod.isValid) {\n this.activePaymentMethod.showValidation();\n }\n\n if (this.activePaymentMethod.isInstantPayment) {\n this.closeActivePaymentMethod();\n }\n\n this.activePaymentMethod.submit();\n }\n\n /**\n * Creates the Drop-in elements\n */\n private handleCreate = () => {\n const { paymentMethodsConfiguration, showStoredPaymentMethods, showPaymentMethods, instantPaymentTypes } = this.props;\n\n const { paymentMethods, storedPaymentMethods, instantPaymentMethods } = splitPaymentMethods(\n this.core.paymentMethodsResponse,\n instantPaymentTypes\n );\n\n const commonProps = getCommonProps({ ...this.props, elementRef: this.elementRef });\n\n const storedElements = showStoredPaymentMethods\n ? createStoredElements(storedPaymentMethods, paymentMethodsConfiguration, commonProps, this.core)\n : [];\n const elements = showPaymentMethods ? createElements(paymentMethods, paymentMethodsConfiguration, commonProps, this.core) : [];\n const instantPaymentElements = createInstantPaymentElements(instantPaymentMethods, paymentMethodsConfiguration, commonProps, this.core);\n\n return [storedElements, elements, instantPaymentElements];\n };\n\n public handleAction(action: PaymentAction, props = {}): this | null {\n if (!action || !action.type) {\n if (hasOwnProperty(action, 'action') && hasOwnProperty(action, 'resultCode')) {\n throw new Error(\n 'handleAction::Invalid Action - the passed action object itself has an \"action\" property and ' +\n 'a \"resultCode\": have you passed in the whole response object by mistake?'\n );\n }\n throw new Error('handleAction::Invalid Action - the passed action object does not have a \"type\" property');\n }\n\n if (action.type !== 'redirect' && this.activePaymentMethod?.updateWithAction) {\n return this.activePaymentMethod.updateWithAction(action);\n }\n\n if (this.elementRef instanceof DropinElement) {\n props = {\n ...this.elementRef.activePaymentMethod?.props,\n ...props\n };\n }\n\n const paymentAction: UIElement = this.core.createFromAction(action, {\n ...props,\n elementRef: this.elementRef, // maintain elementRef for 3DS2 flow\n onAdditionalDetails: this.handleAdditionalDetails,\n isDropin: true\n });\n\n if (paymentAction) {\n this.setStatus(paymentAction.props.statusType, { component: paymentAction });\n this.componentFromAction = paymentAction;\n return this;\n }\n\n return null;\n }\n\n /**\n * handleOrder is implemented so we don't trigger a callback like in the components\n * @param response - PaymentResponse\n */\n protected handleOrder = ({ order }: PaymentResponseData): void => {\n this.updateParent({ order });\n };\n\n closeActivePaymentMethod() {\n this.dropinRef.closeActivePaymentMethod();\n }\n\n render() {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n <DropinComponent\n {...this.props}\n core={this.core}\n onChange={this.setState}\n elementRef={this.elementRef}\n onCreateElements={this.handleCreate}\n ref={dropinRef => {\n this.dropinRef = dropinRef;\n }}\n />\n </SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n\nexport default DropinElement;\n"],"names":["SUPPORTED_INSTANT_PAYMENTS","DropinElement","UIElement","storeElementRefOnCore","this","core","storeElementReference","formatProps","props","_object_spread_props","_object_spread","type","super","instantPaymentTypes","Array","from","Set","filter","value","includes","isValid","dropinRef","state","activePaymentMethod","showValidation","setStatus","status","_this_dropinRef","_this_dropinRef1","data","submit","Error","isInstantPayment","closeActivePaymentMethod","handleAction","action","_this_activePaymentMethod","_this_elementRef_activePaymentMethod","hasOwnProperty","updateWithAction","elementRef","paymentAction","createFromAction","onAdditionalDetails","handleAdditionalDetails","isDropin","statusType","component","componentFromAction","render","h","CoreProvider","i18n","loadingContext","resources","SRPanelProvider","srPanel","modules","DropinComponent","onChange","setState","onCreateElements","handleCreate","ref","constructor","checkout","_define_property","paymentMethodsConfiguration","showStoredPaymentMethods","showPaymentMethods","paymentMethods","storedPaymentMethods","instantPaymentMethods","splitPaymentMethods","paymentMethodsResponse","commonProps","getCommonProps","createStoredElements","createElements","createInstantPaymentElements","handleOrder","order","updateParent","bind","paymentMethodComponents","forEach","PaymentMethod","register","defaultProps"],"mappings":"ohDAgBA,MAAMA,EAA6B,CAAC,gBAAiB,YAAa,YAElE,MAAMC,UAAsBC,EAoBLC,qBAAAA,GACfC,KAAKC,KAAKC,sBAAsBF,KACpC,CAEAG,WAAAA,CAAYC,GACR,OAAOC,EAAAC,EAAA,CACHC,KAAM,UACHC,MAAML,YAAYC,IAAAA,CACrBK,oBAAqBC,MAAMC,KAA0B,IAAIC,IAAIR,EAAMK,sBAAsBI,QAAOC,GAC5FlB,EAA2BmB,SAASD,MAGhD,CAEA,WAAIE,GACA,QAAShB,KAAKiB,aAAejB,KAAKiB,UAAUC,MAAMC,uBAAyBnB,KAAKiB,UAAUC,MAAMC,oBAAoBH,OACxH,CAEAI,cAAAA,GAKI,OAJIpB,KAAKiB,UAAUC,MAAMC,qBACrBnB,KAAKiB,UAAUC,MAAMC,oBAAoBC,iBAGtCpB,IACX,CAEOqB,SAAAA,CAAUC,EAAQlB,EAAQ,IAC7B,IAAAmB,EACA,OADc,QAAdA,EAAAvB,KAAKiB,qBAALM,GAAAA,EAAgBF,UAAUC,EAAQlB,GAC3BJ,IACX,CAEA,uBAAImB,OACKI,EAA0BC,EAA/B,OAAK,QAAAD,EAAAvB,KAAKiB,iBAAL,IAAAM,OAAA,EAAAA,EAAgBL,SAAwB,QAAdM,EAAAxB,KAAKiB,qBAALO,SAAAA,EAAgBN,MAAMC,qBAI9CnB,KAAKiB,UAAUC,MAAMC,oBAHjB,IAIf,CAEA,QAAIM,GACA,OAAKzB,KAAKmB,oBAIHnB,KAAKiB,UAAUC,MAAMC,oBAAoBM,KAHrC,IAIf,CAKA,MAAAC,GACI,I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UIElement from '../internal/UIElement/UIElement';\nimport defaultProps from './defaultProps';\nimport DropinComponent from '../../components/Dropin/components/DropinComponent';\nimport CoreProvider from '../../core/Context/CoreProvider';\nimport { getCommonProps } from './components/utils';\nimport { createElements, createStoredElements } from './elements';\nimport createInstantPaymentElements from './elements/createInstantPaymentElements';\nimport { hasOwnProperty } from '../../utils/hasOwnProperty';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport splitPaymentMethods from './elements/splitPaymentMethods';\n\nimport type { DropinConfiguration, InstantPaymentTypes, PaymentMethodsConfiguration } from './types';\nimport type { PaymentAction, PaymentResponseData } from '../../types/global-types';\nimport type { ICore } from '../../core/types';\nimport type { IDropin } from './types';\n\nconst SUPPORTED_INSTANT_PAYMENTS = ['paywithgoogle', 'googlepay', 'applepay'];\n\nclass DropinElement extends UIElement<DropinConfiguration> implements IDropin {\n protected static defaultProps = defaultProps;\n\n public dropinRef = null;\n\n private paymentMethodsConfiguration: PaymentMethodsConfiguration;\n /**\n * Reference to the component created from `handleAction` (Ex.: ThreeDS2Challenge)\n */\n public componentFromAction?: UIElement;\n\n constructor(checkout: ICore, props?: DropinConfiguration) {\n super(checkout, props);\n this.submit = this.submit.bind(this);\n this.handleAction = this.handleAction.bind(this);\n\n this.props.paymentMethodComponents.forEach(PaymentMethod => this.core.register(PaymentMethod));\n this.paymentMethodsConfiguration = this.props.paymentMethodsConfiguration || {};\n }\n\n protected override storeElementRefOnCore() {\n this.core.storeElementReference(this);\n }\n\n formatProps(props) {\n return {\n type: 'dropin', // for analytics\n ...super.formatProps(props),\n instantPaymentTypes: Array.from<InstantPaymentTypes>(new Set(props.instantPaymentTypes)).filter(value =>\n SUPPORTED_INSTANT_PAYMENTS.includes(value)\n )\n };\n }\n\n get isValid() {\n return !!this.dropinRef && !!this.dropinRef.state.activePaymentMethod && !!this.dropinRef.state.activePaymentMethod.isValid;\n }\n\n showValidation() {\n if (this.dropinRef.state.activePaymentMethod) {\n this.dropinRef.state.activePaymentMethod.showValidation();\n }\n\n return this;\n }\n\n public setStatus(status, props = {}): this {\n this.dropinRef?.setStatus(status, props);\n return this;\n }\n\n get activePaymentMethod() {\n if (!this.dropinRef?.state && !this.dropinRef?.state.activePaymentMethod) {\n return null;\n }\n\n return this.dropinRef.state.activePaymentMethod;\n }\n\n get data() {\n if (!this.activePaymentMethod) {\n return null;\n }\n\n return this.dropinRef.state.activePaymentMethod.data;\n }\n\n public displayFinalAnimation(type: 'success' | 'error') {\n if (this.props.disableFinalAnimation) return;\n\n this.dropinRef.setStatus(type);\n }\n\n /**\n * Calls the onSubmit event with the state of the activePaymentMethod\n */\n public override submit(): void {\n if (!this.activePaymentMethod) {\n throw new Error('No active payment method.');\n }\n\n if (!this.activePaymentMethod.isValid) {\n this.activePaymentMethod.showValidation();\n }\n\n if (this.activePaymentMethod.isInstantPayment) {\n this.closeActivePaymentMethod();\n }\n\n this.activePaymentMethod.submit();\n }\n\n /**\n * Creates the Drop-in elements\n */\n private handleCreate = () => {\n const { paymentMethodsConfiguration, showStoredPaymentMethods, showPaymentMethods, instantPaymentTypes } = this.props;\n\n const { paymentMethods, storedPaymentMethods, instantPaymentMethods } = splitPaymentMethods(\n this.core.paymentMethodsResponse,\n instantPaymentTypes\n );\n\n const commonProps = getCommonProps({ ...this.props, elementRef: this.elementRef });\n\n const storedElements = showStoredPaymentMethods\n ? createStoredElements(storedPaymentMethods, paymentMethodsConfiguration, commonProps, this.core)\n : [];\n const elements = showPaymentMethods ? createElements(paymentMethods, paymentMethodsConfiguration, commonProps, this.core) : [];\n const instantPaymentElements = createInstantPaymentElements(instantPaymentMethods, paymentMethodsConfiguration, commonProps, this.core);\n\n return [storedElements, elements, instantPaymentElements];\n };\n\n public handleAction(action: PaymentAction, props = {}): this | null {\n if (!action || !action.type) {\n if (hasOwnProperty(action, 'action') && hasOwnProperty(action, 'resultCode')) {\n throw new Error(\n 'handleAction::Invalid Action - the passed action object itself has an \"action\" property and ' +\n 'a \"resultCode\": have you passed in the whole response object by mistake?'\n );\n }\n throw new Error('handleAction::Invalid Action - the passed action object does not have a \"type\" property');\n }\n\n if (action.type !== 'redirect' && this.activePaymentMethod?.updateWithAction) {\n return this.activePaymentMethod.updateWithAction(action);\n }\n\n if (this.elementRef instanceof DropinElement) {\n props = {\n ...this.elementRef.activePaymentMethod?.props,\n ...props\n };\n }\n\n const paymentAction: UIElement = this.core.createFromAction(action, {\n ...props,\n elementRef: this.elementRef, // maintain elementRef for 3DS2 flow\n onAdditionalDetails: this.handleAdditionalDetails,\n isDropin: true\n });\n\n if (paymentAction) {\n this.setStatus(paymentAction.props.statusType, { component: paymentAction });\n this.componentFromAction = paymentAction;\n return this;\n }\n\n return null;\n }\n\n /**\n * handleOrder is implemented so we don't trigger a callback like in the components\n * @param response - PaymentResponse\n */\n protected handleOrder = ({ order }: PaymentResponseData): void => {\n this.updateParent({ order });\n };\n\n closeActivePaymentMethod() {\n this.dropinRef.closeActivePaymentMethod();\n }\n\n render() {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n <DropinComponent\n {...this.props}\n core={this.core}\n onChange={this.setState}\n elementRef={this.elementRef}\n onCreateElements={this.handleCreate}\n ref={dropinRef => {\n this.dropinRef = dropinRef;\n }}\n />\n </SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n\nexport default DropinElement;\n"],"names":["SUPPORTED_INSTANT_PAYMENTS","DropinElement","UIElement","storeElementRefOnCore","this","core","storeElementReference","formatProps","props","_object_spread_props","_object_spread","type","super","instantPaymentTypes","Array","from","Set","filter","value","includes","isValid","dropinRef","state","activePaymentMethod","showValidation","setStatus","status","_this_dropinRef","_this_dropinRef1","data","displayFinalAnimation","disableFinalAnimation","submit","Error","isInstantPayment","closeActivePaymentMethod","handleAction","action","_this_activePaymentMethod","_this_elementRef_activePaymentMethod","hasOwnProperty","updateWithAction","elementRef","paymentAction","createFromAction","onAdditionalDetails","handleAdditionalDetails","isDropin","statusType","component","componentFromAction","render","h","CoreProvider","i18n","loadingContext","resources","SRPanelProvider","srPanel","modules","DropinComponent","onChange","setState","onCreateElements","handleCreate","ref","constructor","checkout","_define_property","paymentMethodsConfiguration","showStoredPaymentMethods","showPaymentMethods","paymentMethods","storedPaymentMethods","instantPaymentMethods","splitPaymentMethods","paymentMethodsResponse","commonProps","getCommonProps","createStoredElements","createElements","createInstantPaymentElements","handleOrder","order","updateParent","bind","paymentMethodComponents","forEach","PaymentMethod","register","defaultProps"],"mappings":"ohDAiBA,MAAMA,EAA6B,CAAC,gBAAiB,YAAa,YAElE,MAAMC,UAAsBC,EAoBLC,qBAAAA,GACfC,KAAKC,KAAKC,sBAAsBF,KACpC,CAEAG,WAAAA,CAAYC,GACR,OAAOC,EAAAC,EAAA,CACHC,KAAM,UACHC,MAAML,YAAYC,IAAAA,CACrBK,oBAAqBC,MAAMC,KAA0B,IAAIC,IAAIR,EAAMK,sBAAsBI,QAAOC,GAC5FlB,EAA2BmB,SAASD,MAGhD,CAEA,WAAIE,GACA,QAAShB,KAAKiB,aAAejB,KAAKiB,UAAUC,MAAMC,uBAAyBnB,KAAKiB,UAAUC,MAAMC,oBAAoBH,OACxH,CAEAI,cAAAA,GAKI,OAJIpB,KAAKiB,UAAUC,MAAMC,qBACrBnB,KAAKiB,UAAUC,MAAMC,oBAAoBC,iBAGtCpB,IACX,CAEOqB,SAAAA,CAAUC,EAAQlB,EAAQ,IAC7B,IAAAmB,EACA,OADc,QAAdA,EAAAvB,KAAKiB,qBAALM,GAAAA,EAAgBF,UAAUC,EAAQlB,GAC3BJ,IACX,CAEA,uBAAImB,OACKI,EAA0BC,EAA/B,OAAK,QAAAD,EAAAvB,KAAKiB,iBAAL,IAAAM,OAAA,EAAAA,EAAgBL,SAAwB,QAAdM,EAAAxB,KAAKiB,qBAALO,SAAAA,EAAgBN,MAAMC,qBAI9CnB,KAAKiB,UAAUC,MAAMC,oBAHjB,IAIf,CAEA,QAAIM,GACA,O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AC/EpF,KAAKiE,4BAA8BjE,KAAKI,MAAM6D,6BAA+B,CAAA,CACjF,EAjBAD,EADEnE,EACeyF,eAAeA"}
@@ -1,2 +1,2 @@
1
- import{Component as t,createElement as e}from"../../../external/preact/dist/preact.js";import s from"./PaymentMethod/PaymentMethodList.js";import n from"./status/index.js";import o from"../../../core/Services/order-status.js";import{ANALYTICS_RENDERED_STR as r}from"../../../core/Analytics/constants.js";function a(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function i(t){for(var e=1;e<arguments.length;e++){var s=null!=arguments[e]?arguments[e]:{},n=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(s).filter((function(t){return Object.getOwnPropertyDescriptor(s,t).enumerable})))),n.forEach((function(e){a(t,e,s[e])}))}return t}function d(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),s.push.apply(s,n)}return s}(Object(e)).forEach((function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(e,s))})),t}class p extends t{componentDidMount(){this.prepareDropinData()}componentDidUpdate(t,e){e.status.type!==this.state.status.type&&this.state.activePaymentMethod&&this.state.activePaymentMethod.setStatus(this.state.status.type),"ready"===this.state.status.type&&"ready"!==e.status.type&&this.props.onReady&&this.props.onReady()}closeActivePaymentMethod(){this.setState({activePaymentMethod:null})}render(t,{elements:o,instantPaymentElements:r,storedPaymentElements:a,status:i,activePaymentMethod:d,cachedPaymentMethods:p}){const l="loading"===i.type,c="redirect"===i.type,h=(null==o?void 0:o.length)||(null==r?void 0:r.length)||(null==a?void 0:a.length);switch(i.type){case"success":var m,y;return e(n.Success,{message:0===(null==t||null===(m=t.amount)||void 0===m?void 0:m.value)?"resultMessages.preauthorized":null===(y=i.props)||void 0===y?void 0:y.message});case"error":var u;return e(n.Error,{message:null===(u=i.props)||void 0===u?void 0:u.message});case"custom":var P,v;return null===(v=i.props)||void 0===v||null===(P=v.component)||void 0===P?void 0:P.render();default:return e("div",{className:`adyen-checkout__dropin adyen-checkout__dropin--${i.type}`},c&&i.props.component&&i.props.component.render(),l&&i.props&&i.props.component&&i.props.component.render(),h&&e(s,{isLoading:l||c,isDisablingPaymentMethod:this.state.isDisabling,paymentMethods:o,instantPaymentMethods:r,storedPaymentMethods:a,activePaymentMethod:d,cachedPaymentMethods:p,order:this.props.order,orderStatus:this.state.orderStatus,onOrderCancel:this.onOrderCancel,onSelect:this.handleOnSelectPaymentMethod,openFirstPaymentMethod:this.props.openFirstPaymentMethod,openFirstStoredPaymentMethod:this.props.openFirstStoredPaymentMethod,onDisableStoredPaymentMethod:this.handleDisableStoredPaymentMethod,showRemovePaymentMethodButton:this.props.showRemovePaymentMethodButton,showRadioButton:this.props.showRadioButton}))}}constructor(...t){super(...t),a(this,"state",{elements:[],instantPaymentElements:[],storedPaymentElements:[],orderStatus:null,isDisabling:!1,status:{type:"loading",props:void 0},activePaymentMethod:null,cachedPaymentMethods:{}}),a(this,"prepareDropinData",(()=>{const{order:t,clientKey:e,loadingContext:s}=this.props,[n,a,i]=this.props.onCreateElements(),d=t?o({clientKey:e,loadingContext:s},t):null;Promise.all([n,a,i,d]).then((([t,e,s,n])=>{var o;this.setState({instantPaymentElements:s,elements:e,storedPaymentElements:t,orderStatus:n}),this.setStatus("ready"),null===(o=this.props.modules)||void 0===o||o.analytics.sendAnalytics("dropin",{type:r})})),this.onOrderCancel=this.getOnOrderCancel()})),a(this,"setStatus",((t,e={})=>{this.setState({status:{type:t,props:e}})})),a(this,"setActivePaymentMethod",(t=>{this.setState((e=>({activePaymentMethod:t,cachedPaymentMethods:d(i({},e.cachedPaymentMethods),{[t._id]:!0})})))})),a(this,"handleOnSelectPaymentMethod",(t=>{const{activePaymentMethod:e}=this.state;this.setActivePaymentMethod(t),(e&&e._id!==t._id||!e)&&(this.props.onSelect(t),t.submitAnalytics({type:r}))})),a(this,"handleDisableStoredPaymentMethod",(t=>{this.setState({isDisabling:!0}),new Promise(((e,s)=>this.props.onDisableStoredPaymentMethod(t.props.storedPaymentMethodId,e,s))).then((()=>{this.setState((e=>({elements:e.elements.filter((e=>e._id!==t._id))}))),this.setState({isDisabling:!1})})).catch((()=>{this.setState({isDisabling:!1})}))})),a(this,"getOnOrderCancel",(()=>this.props.onOrderCancel?t=>{this.props.onOrderCancel(t)}:this.props.session?t=>this.props.session.cancelOrder(t).then((()=>this.props.core.update({order:null}))).catch((t=>this.setStatus((null==t?void 0:t.message)||"error"))):null)),a(this,"onOrderCancel",void 0)}}export{p as DropinComponent,p as default};
1
+ import{Component as t,createElement as e}from"../../../external/preact/dist/preact.js";import s from"./PaymentMethod/PaymentMethodList.js";import n from"./status/index.js";import o from"../../../core/Services/order-status.js";import{ANALYTICS_RENDERED_STR as r}from"../../../core/Analytics/constants.js";function a(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function i(t){for(var e=1;e<arguments.length;e++){var s=null!=arguments[e]?arguments[e]:{},n=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(s).filter((function(t){return Object.getOwnPropertyDescriptor(s,t).enumerable})))),n.forEach((function(e){a(t,e,s[e])}))}return t}function d(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),s.push.apply(s,n)}return s}(Object(e)).forEach((function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(e,s))})),t}class p extends t{componentDidMount(){this.prepareDropinData()}componentDidUpdate(t,e){e.status.type!==this.state.status.type&&this.state.activePaymentMethod&&this.state.activePaymentMethod.setStatus(this.state.status.type),"ready"===this.state.status.type&&"ready"!==e.status.type&&this.props.onReady&&this.props.onReady()}closeActivePaymentMethod(){this.setState({activePaymentMethod:null})}render(t,{elements:o,instantPaymentElements:r,storedPaymentElements:a,status:i,activePaymentMethod:d,cachedPaymentMethods:p}){const l="loading"===i.type,c="redirect"===i.type,h=(null==o?void 0:o.length)||(null==r?void 0:r.length)||(null==a?void 0:a.length);switch(i.type){case"success":var m,y;return e(n.Success,{message:0===(null==t||null===(m=t.amount)||void 0===m?void 0:m.value)?"resultMessages.preauthorized":null===(y=i.props)||void 0===y?void 0:y.message});case"error":var u;return e(n.Error,{message:null===(u=i.props)||void 0===u?void 0:u.message});case"custom":var P,v;return null===(v=i.props)||void 0===v||null===(P=v.component)||void 0===P?void 0:P.render();default:return e("div",{className:`adyen-checkout__dropin adyen-checkout__dropin--${i.type}`},c&&i.props.component&&i.props.component.render(),l&&i.props&&i.props.component&&i.props.component.render(),h&&e(s,{isLoading:l||c,isDisablingPaymentMethod:this.state.isDisabling,paymentMethods:o,instantPaymentMethods:r,storedPaymentMethods:a,activePaymentMethod:d,cachedPaymentMethods:p,order:this.props.order,orderStatus:this.state.orderStatus,onOrderCancel:this.onOrderCancel,onSelect:this.handleOnSelectPaymentMethod,openFirstPaymentMethod:this.props.openFirstPaymentMethod,openFirstStoredPaymentMethod:this.props.openFirstStoredPaymentMethod,onDisableStoredPaymentMethod:this.handleDisableStoredPaymentMethod,showRemovePaymentMethodButton:this.props.showRemovePaymentMethodButton,showRadioButton:this.props.showRadioButton}))}}constructor(...t){super(...t),a(this,"state",{elements:[],instantPaymentElements:[],storedPaymentElements:[],orderStatus:null,isDisabling:!1,status:{type:"loading",props:void 0},activePaymentMethod:null,cachedPaymentMethods:{}}),a(this,"prepareDropinData",(()=>{const{order:t,clientKey:e,loadingContext:s}=this.props,[n,a,i]=this.props.onCreateElements(),d=t?o({clientKey:e,loadingContext:s},t):null;Promise.all([n,a,i,d]).then((([t,e,s,n])=>{var o;this.setState({instantPaymentElements:s,elements:e,storedPaymentElements:t,orderStatus:n}),this.setStatus("ready"),null===(o=this.props.modules)||void 0===o||o.analytics.sendAnalytics("dropin",{type:r})})),this.onOrderCancel=this.getOnOrderCancel()})),a(this,"setStatus",((t,e={})=>{this.setState({status:{type:t,props:e}})})),a(this,"setActivePaymentMethod",(t=>{this.setState((e=>({activePaymentMethod:t,cachedPaymentMethods:d(i({},e.cachedPaymentMethods),{[t._id]:!0})})))})),a(this,"handleOnSelectPaymentMethod",(t=>{const{activePaymentMethod:e}=this.state;var s,n;(this.setActivePaymentMethod(t),e&&e._id!==t._id||!e)&&(null===(s=(n=this.props).onSelect)||void 0===s||s.call(n,t),t.submitAnalytics({type:r}))})),a(this,"handleDisableStoredPaymentMethod",(t=>{this.setState({isDisabling:!0}),new Promise(((e,s)=>this.props.onDisableStoredPaymentMethod(t.props.storedPaymentMethodId,e,s))).then((()=>{this.setState((e=>({elements:e.elements.filter((e=>e._id!==t._id))}))),this.setState({isDisabling:!1})})).catch((()=>{this.setState({isDisabling:!1})}))})),a(this,"getOnOrderCancel",(()=>this.props.onOrderCancel?t=>{this.props.onOrderCancel(t)}:this.props.session?t=>this.props.session.cancelOrder(t).then((()=>this.props.core.update({order:null}))).catch((t=>this.setStatus((null==t?void 0:t.message)||"error"))):null)),a(this,"onOrderCancel",void 0)}}export{p as DropinComponent,p as default};
2
2
  //# sourceMappingURL=DropinComponent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DropinComponent.js","sources":["../../../../../src/components/Dropin/components/DropinComponent.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport PaymentMethodList from './PaymentMethod/PaymentMethodList';\nimport Status from './status';\nimport getOrderStatus from '../../../core/Services/order-status';\nimport { DropinComponentProps, DropinComponentState, DropinStatusProps, onOrderCancelData } from '../types';\nimport './DropinComponent.scss';\nimport { UIElementStatus } from '../../internal/UIElement/types';\nimport { ANALYTICS_RENDERED_STR } from '../../../core/Analytics/constants';\n\nexport class DropinComponent extends Component<DropinComponentProps, DropinComponentState> {\n public state: DropinComponentState = {\n elements: [],\n instantPaymentElements: [],\n storedPaymentElements: [],\n orderStatus: null,\n isDisabling: false,\n status: { type: 'loading', props: undefined },\n activePaymentMethod: null,\n cachedPaymentMethods: {}\n };\n\n componentDidMount() {\n this.prepareDropinData();\n }\n\n public prepareDropinData = () => {\n const { order, clientKey, loadingContext } = this.props;\n const [storedElementsPromises, elementsPromises, instantPaymentsPromises] = this.props.onCreateElements();\n const orderStatusPromise = order ? getOrderStatus({ clientKey, loadingContext }, order) : null;\n\n Promise.all([storedElementsPromises, elementsPromises, instantPaymentsPromises, orderStatusPromise]).then(\n ([storedPaymentElements, elements, instantPaymentElements, orderStatus]) => {\n this.setState({ instantPaymentElements, elements, storedPaymentElements, orderStatus });\n this.setStatus('ready');\n\n this.props.modules?.analytics.sendAnalytics('dropin', { type: ANALYTICS_RENDERED_STR });\n }\n );\n\n this.onOrderCancel = this.getOnOrderCancel();\n };\n\n public setStatus = (status: UIElementStatus, props: DropinStatusProps = {}) => {\n this.setState({ status: { type: status, props } });\n };\n\n private setActivePaymentMethod = paymentMethod => {\n this.setState(prevState => ({\n activePaymentMethod: paymentMethod,\n cachedPaymentMethods: { ...prevState.cachedPaymentMethods, [paymentMethod._id]: true }\n }));\n };\n\n componentDidUpdate(prevProps, prevState) {\n if (prevState.status.type !== this.state.status.type && this.state.activePaymentMethod) {\n this.state.activePaymentMethod.setStatus(this.state.status.type);\n }\n\n if (this.state.status.type === 'ready' && prevState.status.type !== 'ready' && this.props.onReady) {\n this.props.onReady();\n }\n }\n\n private handleOnSelectPaymentMethod = paymentMethod => {\n const { activePaymentMethod } = this.state;\n\n this.setActivePaymentMethod(paymentMethod);\n\n // onSelect event\n if ((activePaymentMethod && activePaymentMethod._id !== paymentMethod._id) || !activePaymentMethod) {\n this.props.onSelect(paymentMethod);\n\n paymentMethod.submitAnalytics({ type: ANALYTICS_RENDERED_STR });\n }\n };\n\n private handleDisableStoredPaymentMethod = storedPaymentMethod => {\n this.setState({ isDisabling: true });\n\n new Promise((resolve, reject) => this.props.onDisableStoredPaymentMethod(storedPaymentMethod.props.storedPaymentMethodId, resolve, reject))\n .then(() => {\n this.setState(prevState => ({ elements: prevState.elements.filter(pm => pm._id !== storedPaymentMethod._id) }));\n this.setState({ isDisabling: false });\n })\n .catch(() => {\n this.setState({ isDisabling: false });\n });\n };\n\n closeActivePaymentMethod() {\n this.setState({ activePaymentMethod: null });\n }\n\n /**\n * getOnOrderCancel decides which onOrderCancel logic should be used, manual or sessions\n */\n private getOnOrderCancel = () => {\n if (this.props.onOrderCancel) {\n return (data: onOrderCancelData) => {\n this.props.onOrderCancel(data);\n };\n }\n if (this.props.session) {\n return (data: onOrderCancelData) =>\n this.props.session\n .cancelOrder(data)\n .then(() => this.props.core.update({ order: null }))\n .catch(error => this.setStatus(error?.message || 'error'));\n }\n return null;\n };\n\n private onOrderCancel: (data: onOrderCancelData) => void;\n\n render(props, { elements, instantPaymentElements, storedPaymentElements, status, activePaymentMethod, cachedPaymentMethods }) {\n const isLoading = status.type === 'loading';\n const isRedirecting = status.type === 'redirect';\n const hasPaymentMethodsToBeDisplayed = elements?.length || instantPaymentElements?.length || storedPaymentElements?.length;\n\n switch (status.type) {\n case 'success':\n return <Status.Success message={props?.amount?.value === 0 ? 'resultMessages.preauthorized' : status.props?.message} />;\n\n case 'error':\n return <Status.Error message={status.props?.message} />;\n\n case 'custom':\n return status.props?.component?.render();\n\n default:\n return (\n <div className={`adyen-checkout__dropin adyen-checkout__dropin--${status.type}`}>\n {isRedirecting && status.props.component && status.props.component.render()}\n {isLoading && status.props && status.props.component && status.props.component.render()}\n {hasPaymentMethodsToBeDisplayed && (\n <PaymentMethodList\n isLoading={isLoading || isRedirecting}\n isDisablingPaymentMethod={this.state.isDisabling}\n paymentMethods={elements}\n instantPaymentMethods={instantPaymentElements}\n storedPaymentMethods={storedPaymentElements}\n activePaymentMethod={activePaymentMethod}\n cachedPaymentMethods={cachedPaymentMethods}\n order={this.props.order}\n orderStatus={this.state.orderStatus}\n onOrderCancel={this.onOrderCancel}\n onSelect={this.handleOnSelectPaymentMethod}\n openFirstPaymentMethod={this.props.openFirstPaymentMethod}\n openFirstStoredPaymentMethod={this.props.openFirstStoredPaymentMethod}\n onDisableStoredPaymentMethod={this.handleDisableStoredPaymentMethod}\n showRemovePaymentMethodButton={this.props.showRemovePaymentMethodButton}\n showRadioButton={this.props.showRadioButton}\n />\n )}\n </div>\n );\n }\n }\n}\n\nexport default DropinComponent;\n"],"names":["DropinComponent","Component","componentDidMount","this","prepareDropinData","componentDidUpdate","prevProps","prevState","status","type","state","activePaymentMethod","setStatus","props","onReady","closeActivePaymentMethod","setState","render","elements","instantPaymentElements","storedPaymentElements","cachedPaymentMethods","isLoading","isRedirecting","hasPaymentMethodsToBeDisplayed","length","h","Status","Success","message","amount","value","Error","component","div","className","PaymentMethodList","isDisablingPaymentMethod","isDisabling","paymentMethods","instantPaymentMethods","storedPaymentMethods","order","orderStatus","onOrderCancel","onSelect","handleOnSelectPaymentMethod","openFirstPaymentMethod","openFirstStoredPaymentMethod","onDisableStoredPaymentMethod","handleDisableStoredPaymentMethod","showRemovePaymentMethodButton","showRadioButton","_define_property","undefined","clientKey","loadingContext","storedElementsPromises","elementsPromises","instantPaymentsPromises","onCreateElements","orderStatusPromise","getOrderStatus","Promise","all","then","_this_props_modules","modules","analytics","sendAnalytics","ANALYTICS_RENDERED_STR","getOnOrderCancel","setActivePaymentMethod","paymentMethod","_object_spread_props","_object_spread","_id","submitAnalytics","storedPaymentMethod","resolve","reject","storedPaymentMethodId","filter","pm","catch","data","session","cancelOrder","core","update","error"],"mappings":"wrCASO,MAAMA,UAAwBC,EAYjCC,iBAAAA,GACIC,KAAKC,mBACT,CA8BAC,kBAAAA,CAAmBC,EAAWC,GACtBA,EAAUC,OAAOC,OAASN,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AAAA,EAAAA,EAAO7D,UAAW,WAEtD,OAGXwB,EAAAlD,KAAQyC,qBAAR"}
1
+ {"version":3,"file":"DropinComponent.js","sources":["../../../../../src/components/Dropin/components/DropinComponent.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport PaymentMethodList from './PaymentMethod/PaymentMethodList';\nimport Status from './status';\nimport getOrderStatus from '../../../core/Services/order-status';\nimport { DropinComponentProps, DropinComponentState, DropinStatusProps, onOrderCancelData } from '../types';\nimport './DropinComponent.scss';\nimport { UIElementStatus } from '../../internal/UIElement/types';\nimport { ANALYTICS_RENDERED_STR } from '../../../core/Analytics/constants';\n\nexport class DropinComponent extends Component<DropinComponentProps, DropinComponentState> {\n public state: DropinComponentState = {\n elements: [],\n instantPaymentElements: [],\n storedPaymentElements: [],\n orderStatus: null,\n isDisabling: false,\n status: { type: 'loading', props: undefined },\n activePaymentMethod: null,\n cachedPaymentMethods: {}\n };\n\n componentDidMount() {\n this.prepareDropinData();\n }\n\n public prepareDropinData = () => {\n const { order, clientKey, loadingContext } = this.props;\n const [storedElementsPromises, elementsPromises, instantPaymentsPromises] = this.props.onCreateElements();\n const orderStatusPromise = order ? getOrderStatus({ clientKey, loadingContext }, order) : null;\n\n Promise.all([storedElementsPromises, elementsPromises, instantPaymentsPromises, orderStatusPromise]).then(\n ([storedPaymentElements, elements, instantPaymentElements, orderStatus]) => {\n this.setState({ instantPaymentElements, elements, storedPaymentElements, orderStatus });\n this.setStatus('ready');\n\n this.props.modules?.analytics.sendAnalytics('dropin', { type: ANALYTICS_RENDERED_STR });\n }\n );\n\n this.onOrderCancel = this.getOnOrderCancel();\n };\n\n public setStatus = (status: UIElementStatus, props: DropinStatusProps = {}) => {\n this.setState({ status: { type: status, props } });\n };\n\n private setActivePaymentMethod = paymentMethod => {\n this.setState(prevState => ({\n activePaymentMethod: paymentMethod,\n cachedPaymentMethods: { ...prevState.cachedPaymentMethods, [paymentMethod._id]: true }\n }));\n };\n\n componentDidUpdate(prevProps, prevState) {\n if (prevState.status.type !== this.state.status.type && this.state.activePaymentMethod) {\n this.state.activePaymentMethod.setStatus(this.state.status.type);\n }\n\n if (this.state.status.type === 'ready' && prevState.status.type !== 'ready' && this.props.onReady) {\n this.props.onReady();\n }\n }\n\n private handleOnSelectPaymentMethod = paymentMethod => {\n const { activePaymentMethod } = this.state;\n\n this.setActivePaymentMethod(paymentMethod);\n\n // onSelect event\n if ((activePaymentMethod && activePaymentMethod._id !== paymentMethod._id) || !activePaymentMethod) {\n this.props.onSelect?.(paymentMethod);\n\n paymentMethod.submitAnalytics({ type: ANALYTICS_RENDERED_STR });\n }\n };\n\n private handleDisableStoredPaymentMethod = storedPaymentMethod => {\n this.setState({ isDisabling: true });\n\n new Promise((resolve, reject) => this.props.onDisableStoredPaymentMethod(storedPaymentMethod.props.storedPaymentMethodId, resolve, reject))\n .then(() => {\n this.setState(prevState => ({ elements: prevState.elements.filter(pm => pm._id !== storedPaymentMethod._id) }));\n this.setState({ isDisabling: false });\n })\n .catch(() => {\n this.setState({ isDisabling: false });\n });\n };\n\n closeActivePaymentMethod() {\n this.setState({ activePaymentMethod: null });\n }\n\n /**\n * getOnOrderCancel decides which onOrderCancel logic should be used, manual or sessions\n */\n private getOnOrderCancel = () => {\n if (this.props.onOrderCancel) {\n return (data: onOrderCancelData) => {\n this.props.onOrderCancel(data);\n };\n }\n if (this.props.session) {\n return (data: onOrderCancelData) =>\n this.props.session\n .cancelOrder(data)\n .then(() => this.props.core.update({ order: null }))\n .catch(error => this.setStatus(error?.message || 'error'));\n }\n return null;\n };\n\n private onOrderCancel: (data: onOrderCancelData) => void;\n\n render(props, { elements, instantPaymentElements, storedPaymentElements, status, activePaymentMethod, cachedPaymentMethods }) {\n const isLoading = status.type === 'loading';\n const isRedirecting = status.type === 'redirect';\n const hasPaymentMethodsToBeDisplayed = elements?.length || instantPaymentElements?.length || storedPaymentElements?.length;\n\n switch (status.type) {\n case 'success':\n return <Status.Success message={props?.amount?.value === 0 ? 'resultMessages.preauthorized' : status.props?.message} />;\n\n case 'error':\n return <Status.Error message={status.props?.message} />;\n\n case 'custom':\n return status.props?.component?.render();\n\n default:\n return (\n <div className={`adyen-checkout__dropin adyen-checkout__dropin--${status.type}`}>\n {isRedirecting && status.props.component && status.props.component.render()}\n {isLoading && status.props && status.props.component && status.props.component.render()}\n {hasPaymentMethodsToBeDisplayed && (\n <PaymentMethodList\n isLoading={isLoading || isRedirecting}\n isDisablingPaymentMethod={this.state.isDisabling}\n paymentMethods={elements}\n instantPaymentMethods={instantPaymentElements}\n storedPaymentMethods={storedPaymentElements}\n activePaymentMethod={activePaymentMethod}\n cachedPaymentMethods={cachedPaymentMethods}\n order={this.props.order}\n orderStatus={this.state.orderStatus}\n onOrderCancel={this.onOrderCancel}\n onSelect={this.handleOnSelectPaymentMethod}\n openFirstPaymentMethod={this.props.openFirstPaymentMethod}\n openFirstStoredPaymentMethod={this.props.openFirstStoredPaymentMethod}\n onDisableStoredPaymentMethod={this.handleDisableStoredPaymentMethod}\n showRemovePaymentMethodButton={this.props.showRemovePaymentMethodButton}\n showRadioButton={this.props.showRadioButton}\n />\n )}\n </div>\n );\n }\n }\n}\n\nexport default DropinComponent;\n"],"names":["DropinComponent","Component","componentDidMount","this","prepareDropinData","componentDidUpdate","prevProps","prevState","status","type","state","activePaymentMethod","setStatus","props","onReady","closeActivePaymentMethod","setState","render","elements","instantPaymentElements","storedPaymentElements","cachedPaymentMethods","isLoading","isRedirecting","hasPaymentMethodsToBeDisplayed","length","h","Status","Success","message","amount","value","Error","component","div","className","PaymentMethodList","isDisablingPaymentMethod","isDisabling","paymentMethods","instantPaymentMethods","storedPaymentMethods","order","orderStatus","onOrderCancel","onSelect","handleOnSelectPaymentMethod","openFirstPaymentMethod","openFirstStoredPaymentMethod","onDisableStoredPaymentMethod","handleDisableStoredPaymentMethod","showRemovePaymentMethodButton","showRadioButton","_define_property","undefined","clientKey","loadingContext","storedElementsPromises","elementsPromises","instantPaymentsPromises","onCreateElements","orderStatusPromise","getOrderStatus","Promise","all","then","_this_props_modules","modules","analytics","sendAnalytics","ANALYTICS_RENDERED_STR","getOnOrderCancel","setActivePaymentMethod","paymentMethod","_object_spread_props","_object_spread","_id","_this_props_onSelect","_this_props","call","submitAnalytics","storedPaymentMethod","resolve","reject","storedPaymentMethodId","filter","pm","catch","data","session","cancelOrder","core","update","error"],"mappings":"wrCASO,MAAMA,UAAwBC,EAYjCC,iBAAAA,GACIC,KAAKC,mBACT,CA8BAC,kBAAAA,CAAmBC,EAAWC,GACtBA,EAAUC,OAAOC,OAASN,KAAKO,MAAMF,OAAOC,MAAQN,KAAKO,MAAMC,qBAC/DR,KAAKO,MAAMC,oBAAoBC,UAAUT,KAAKO,MAAMF,OAAOC,MAGhC,UAA3BN,KAAKO,MAAMF,OAAOC,MAA8C,UAA1BF,EAAUC,OAAOC,MAAoBN,KAAKU,MAAMC,SACtFX,KAAKU,MAAMC,SAEnB,CA4BAC,wBAAAA,GACIZ,KAAKa,SAAS,CAAEL,oBAAqB,MACzC,CAuBAM,MAAAA,CAAOJ,GAAOK,SAAEA,EAAQC,uBAAEA,EAAsBC,sBAAEA,EAAqBZ,OAAEA,EAAMG,oBAAEA,EAAmBU,qBAAEA,IAClG,MAAMC,EAA4B,YAAhBd,EAAOC,KACnBc,EAAgC,aAAhBf,EAAOC,KACvBe,GAAiCN,aAAAA,EAAAA,EAAUO,UAAUN,aAAAA,EAAAA,EAAwBM,UAAUL,aAAAA,EAAAA,EAAuBK,QAEpH,OAAQjB,EAAOC,MACX,IAAK,cAC+BI,EAA8DL,EAA9F,OAAOkB,EAACC,EAAOC,QAAO,CAACC,QAAkC,KAAzBhB,iBAAAA,EAAAA,EAAOiB,cAAPjB,IAAAA,OAAAA,EAAAA,EAAekB,OAAc,+BAAiCvB,QAAAA,EAAAA,EAAOK,aAAPL,IAAAA,OAAAA,EAAAA,EAAcqB,UAEhH,IAAK,QAC6BrB,IAAAA,EAA9B,OAAOkB,EAACC,EAAOK,MAAK,CAACH,Q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UX,EAAUW,SAASmE,QAAOC,GAAMA,EAAGV,MAAQK,EAAoBL,UACvGzE,KAAKa,SAAS,CAAEsB,aAAa,GAAM,IAEtCiD,OAAM,KACHpF,KAAKa,SAAS,CAAEsB,aAAa,GAAM,GACvC,IAURe,OAAQkB,oBAAmB,IACnBpE,KAAKU,MAAM+B,cACH4C,IACJrF,KAAKU,MAAM+B,cAAc4C,EAAAA,EAG7BrF,KAAKU,MAAM4E,QACHD,GACJrF,KAAKU,MAAM4E,QACNC,YAAYF,GACZvB,MAAK,IAAM9D,KAAKU,MAAM8E,KAAKC,OAAO,CAAElD,MAAO,SAC3C6C,OAAMM,GAAS1F,KAAKS,WAAUiF,aAAAA,EAAAA,EAAOhE,UAAW,WAEtD,OAGXwB,EAAAlD,KAAQyC,qBAAR"}
@@ -1,2 +1,2 @@
1
- var e={instantPaymentTypes:[],paymentMethodComponents:[],isDropin:!0,onReady:()=>{},onComplete:()=>{},onError:()=>{},onSelect:()=>{},onDisableStoredPaymentMethod:null,onChange:()=>{},amount:{},paymentMethodsConfiguration:{},openFirstPaymentMethod:!0,openFirstStoredPaymentMethod:!0,showStoredPaymentMethods:!0,showPaymentMethods:!0,showRemoveStoredPaymentMethodButton:!1};export{e as default};
1
+ const t={isDropin:!0,instantPaymentTypes:[],paymentMethodComponents:[],paymentMethodsConfiguration:{},openFirstPaymentMethod:!0,openFirstStoredPaymentMethod:!0,showStoredPaymentMethods:!0,showPaymentMethods:!0,disableFinalAnimation:!1};export{t as default};
2
2
  //# sourceMappingURL=defaultProps.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"defaultProps.js","sources":["../../../../src/components/Dropin/defaultProps.ts"],"sourcesContent":["export default {\n instantPaymentTypes: [],\n paymentMethodComponents: [],\n\n isDropin: true,\n onReady: () => {}, // triggered when the Dropin is fully loaded\n onComplete: () => {}, // triggered when the shopper completes a payment\n onError: () => {}, // triggered when an error occurs (for example, could not submit a payment)\n onSelect: () => {}, // triggered when a paymentMethod is selected\n onDisableStoredPaymentMethod: null, // triggered when a shopper removes a storedPaymentMethod\n onChange: () => {},\n\n amount: {},\n paymentMethodsConfiguration: {}, // per paymentMethod configuration\n openFirstPaymentMethod: true, // focus the first payment method automatically on load\n openFirstStoredPaymentMethod: true, // focus the first one click payment method automatically on load\n showStoredPaymentMethods: true, // shows/hides oneclick paymentMethods\n showPaymentMethods: true, // shows/hides regular paymentMethods\n showRemoveStoredPaymentMethodButton: false\n};\n"],"names":["defaultProps","instantPaymentTypes","paymentMethodComponents","isDropin","onReady","onComplete","onError","onSelect","onDisableStoredPaymentMethod","onChange","amount","paymentMethodsConfiguration","openFirstPaymentMethod","openFirstStoredPaymentMethod","showStoredPaymentMethods","showPaymentMethods","showRemoveStoredPaymentMethodButton"],"mappings":"AAAA,IAAeA,EAAA,CACXC,oBAAqB,GACrBC,wBAAyB,GAEzBC,UAAU,EACVC,QAAS,OACTC,WAAY,OACZC,QAAS,OACTC,SAAU,OACVC,6BAA8B,KAC9BC,SAAU,OAEVC,OAAQ,CAAC,EACTC,4BAA6B,CAAC,EAC9BC,wBAAwB,EACxBC,8BAA8B,EAC9BC,0BAA0B,EAC1BC,oBAAoB,EACpBC,qCAAqC"}
1
+ {"version":3,"file":"defaultProps.js","sources":["../../../../src/components/Dropin/defaultProps.ts"],"sourcesContent":["import type { DropinConfiguration } from './types';\n\nconst props: DropinConfiguration = {\n isDropin: true,\n instantPaymentTypes: [],\n paymentMethodComponents: [],\n paymentMethodsConfiguration: {},\n openFirstPaymentMethod: true,\n openFirstStoredPaymentMethod: true,\n showStoredPaymentMethods: true,\n showPaymentMethods: true,\n disableFinalAnimation: false\n};\n\nexport default props;\n"],"names":["props","isDropin","instantPaymentTypes","paymentMethodComponents","paymentMethodsConfiguration","openFirstPaymentMethod","openFirstStoredPaymentMethod","showStoredPaymentMethods","showPaymentMethods","disableFinalAnimation"],"mappings":"AAEA,MAAMA,EAA6B,CAC/BC,UAAU,EACVC,oBAAqB,GACrBC,wBAAyB,GACzBC,4BAA6B,CAAC,EAC9BC,wBAAwB,EACxBC,8BAA8B,EAC9BC,0BAA0B,EAC1BC,oBAAoB,EACpBC,uBAAuB"}
@@ -1,2 +1,2 @@
1
- import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import o from"./GooglePayService.js";import r from"./components/GooglePayButton.js";import n from"./defaultProps.js";import{getGooglePayLocale as s,formatGooglePayContactToAdyenAddressFormat as i}from"./utils.js";import a from"../../utils/browserInfo.js";import l from"../../core/Errors/AdyenCheckoutError.js";import{TxVariants as p}from"../tx-variants.js";import{sanitizeResponse as c,verifyPaymentDidNotFail as h}from"../internal/UIElement/utils.js";import{ANALYTICS_SELECTED_STR as u,ANALYTICS_INSTANT_PAYMENT_BUTTON as d}from"../../core/Analytics/constants.js";function y(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function g(t){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{},r=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(o).filter((function(t){return Object.getOwnPropertyDescriptor(o,t).enumerable})))),r.forEach((function(e){y(t,e,o[e])}))}return t}function m(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t,e){var o=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),o.push.apply(o,r)}return o}(Object(e)).forEach((function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(e,o))})),t}class b extends e{formatProps(t){var e,o;const r=null!==(o=t.buttonSizeMode)&&void 0!==o?o:t.isDropin?"fill":"static";var n;const i=s(null!==(n=t.buttonLocale)&&void 0!==n?n:null===(e=t.i18n)||void 0===e?void 0:e.locale),a=[...t.callbackIntents,"PAYMENT_AUTHORIZATION"];return m(g({},t),{configuration:t.configuration,buttonSizeMode:r,buttonLocale:i,callbackIntents:a})}formatData(){const{googlePayCardNetwork:t,googlePayToken:e,billingAddress:o,deliveryAddress:r}=this.state;return g({paymentMethod:{type:this.type,googlePayCardNetwork:t,googlePayToken:e},browserInfo:this.browserInfo,origin:!!window&&window.location.origin},o&&{billingAddress:o},r&&{deliveryAddress:r})}async handleAuthorization(){return new Promise(((t,e)=>{this.props.onAuthorized||t();const{authorizedEvent:o,billingAddress:r,deliveryAddress:n}=this.state;this.props.onAuthorized(g({authorizedEvent:o},r&&{billingAddress:r},n&&{deliveryAddress:n}),{resolve:t,reject:e})})).catch((t=>{const e={error:{googlePayError:t}};return Promise.reject(e)}))}get isValid(){return!!this.state.googlePayToken}async isAvailable(){return this.isReadyToPay().then((t=>{if(!t.result)throw new Error("Google Pay is not available");if(!1===t.paymentMethodPresent)throw new Error("Google Pay - No paymentMethodPresent");return Promise.resolve()})).catch((t=>Promise.reject(t)))}get browserInfo(){return a()}get icon(){var t;return null!==(t=this.props.icon)&&void 0!==t?t:this.resources.getImage()("googlepay")}render(){return this.props.showPayButton?t(r,{buttonColor:this.props.buttonColor,buttonType:this.props.buttonType,buttonSizeMode:this.props.buttonSizeMode,buttonLocale:this.props.buttonLocale,buttonRootNode:this.props.buttonRootNode,paymentsClient:this.googlePay.paymentsClient,onClick:this.submit}):null}constructor(t,e){super(t,e),y(this,"googlePay",void 0),y(this,"submit",(()=>{this.props.isInstantPayment&&this.submitAnalytics({type:u,target:d}),new Promise(((t,e)=>this.props.onClick(t,e))).then((()=>this.googlePay.initiatePayment(this.props,this.core.options.countryCode))).catch((t=>{"CANCELED"===t.statusCode?this.handleError(new l("CANCEL",t.toString(),{cause:t})):this.handleError(new l("ERROR",t.toString(),{cause:t}))}))})),y(this,"onPaymentAuthorized",(async t=>{const e=i(t.paymentMethodData.info.billingAddress),o=i(t.shippingAddress,!0);return this.setState(g({authorizedEvent:t,googlePayToken:t.paymentMethodData.tokenizationData.token,googlePayCardNetwork:t.paymentMethodData.info.cardNetwork},e&&{billingAddress:e},o&&{deliveryAddress:o})),new Promise((t=>{this.handleAuthorization().then(this.makePaymentsCall).then(c).then(h).then((e=>(t({transactionState:"SUCCESS"}),e))).then((t=>{this.handleResponse(t)})).catch((e=>{var o;this.setElementStatus("ready");const r=null===(o=e.error)||void 0===o?void 0:o.googlePayError,n=this.props.i18n.get("error.subtitle.payment"),s="string"==typeof r?{intent:"PAYMENT_AUTHORIZATION",reason:"OTHER_ERROR",message:r||n}:{intent:(null==r?void 0:r.intent)||"PAYMENT_AUTHORIZATION",reason:(null==r?void 0:r.reason)||"OTHER_ERROR",message:(null==r?void 0:r.message)||n};t({transactionState:"ERROR",error:s}),this.handleFailedResult(e)}))}))})),y(this,"isReadyToPay",(()=>this.googlePay.isReadyToPay(this.props))),y(this,"prefetch",(()=>this.googlePay.prefetchPaymentData(this.props,this.core.options.countryCode))),this.handleAuthorization=this.handleAuthorization.bind(this),this.googlePay=new o(m(g({},this.props),{paymentDataCallbacks:m(g({},this.props.paymentDataCallbacks),{onPaymentAuthorized:this.onPaymentAuthorized})}))}}y(b,"type",p.googlepay),y(b,"txVariants",[p.googlepay,p.paywithgoogle]),y(b,"defaultProps",n);export{b as default};
1
+ import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import o from"./GooglePayService.js";import r from"./components/GooglePayButton.js";import n from"./defaultProps.js";import{getGooglePayLocale as s,formatGooglePayContactToAdyenAddressFormat as i}from"./utils.js";import a from"../../utils/browserInfo.js";import l from"../../core/Errors/AdyenCheckoutError.js";import{TxVariants as p}from"../tx-variants.js";import{sanitizeResponse as c,verifyPaymentDidNotFail as h}from"../internal/UIElement/utils.js";import{ANALYTICS_SELECTED_STR as u,ANALYTICS_INSTANT_PAYMENT_BUTTON as d}from"../../core/Analytics/constants.js";function y(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function g(t){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{},r=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(o).filter((function(t){return Object.getOwnPropertyDescriptor(o,t).enumerable})))),r.forEach((function(e){y(t,e,o[e])}))}return t}function m(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t,e){var o=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),o.push.apply(o,r)}return o}(Object(e)).forEach((function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(e,o))})),t}class b extends e{formatProps(t){var e,o;const r=null!==(o=t.buttonSizeMode)&&void 0!==o?o:t.isDropin?"fill":"static";var n;const i=s(null!==(n=t.buttonLocale)&&void 0!==n?n:null===(e=t.i18n)||void 0===e?void 0:e.locale),a=[...t.callbackIntents,"PAYMENT_AUTHORIZATION"];return m(g({},t),{configuration:t.configuration,buttonSizeMode:r,buttonLocale:i,callbackIntents:a})}formatData(){const{googlePayCardNetwork:t,googlePayToken:e,billingAddress:o,deliveryAddress:r}=this.state;return g({paymentMethod:{type:this.type,googlePayCardNetwork:t,googlePayToken:e},browserInfo:this.browserInfo,origin:!!window&&window.location.origin},o&&{billingAddress:o},r&&{deliveryAddress:r})}async handleAuthorization(){return new Promise(((t,e)=>{this.props.onAuthorized||t();const{authorizedEvent:o,billingAddress:r,deliveryAddress:n}=this.state;this.props.onAuthorized(g({authorizedEvent:o},r&&{billingAddress:r},n&&{deliveryAddress:n}),{resolve:t,reject:e})})).catch((t=>{const e={error:{googlePayError:t}};return Promise.reject(e)}))}get isValid(){return!!this.state.googlePayToken}async isAvailable(){return this.isReadyToPay().then((t=>{if(!t.result)throw new l("ERROR","GooglePay is not available");if(!1===t.paymentMethodPresent)throw new l("ERROR","GooglePay - No paymentMethodPresent");return Promise.resolve()})).catch((t=>Promise.reject(t)))}get browserInfo(){return a()}get icon(){var t;return null!==(t=this.props.icon)&&void 0!==t?t:this.resources.getImage()("googlepay")}render(){return this.props.showPayButton?t(r,{buttonColor:this.props.buttonColor,buttonType:this.props.buttonType,buttonSizeMode:this.props.buttonSizeMode,buttonLocale:this.props.buttonLocale,buttonRootNode:this.props.buttonRootNode,paymentsClient:this.googlePay.paymentsClient,onClick:this.submit}):null}constructor(t,e){super(t,e),y(this,"googlePay",void 0),y(this,"submit",(()=>{this.props.isInstantPayment&&this.submitAnalytics({type:u,target:d}),new Promise(((t,e)=>this.props.onClick(t,e))).then((()=>this.googlePay.initiatePayment(this.props,this.core.options.countryCode))).catch((t=>{"CANCELED"===t.statusCode?this.handleError(new l("CANCEL",t.toString(),{cause:t})):this.handleError(new l("ERROR",t.toString(),{cause:t}))}))})),y(this,"onPaymentAuthorized",(async t=>{const e=i(t.paymentMethodData.info.billingAddress),o=i(t.shippingAddress,!0);return this.setState(g({authorizedEvent:t,googlePayToken:t.paymentMethodData.tokenizationData.token,googlePayCardNetwork:t.paymentMethodData.info.cardNetwork},e&&{billingAddress:e},o&&{deliveryAddress:o})),new Promise((t=>{this.handleAuthorization().then(this.makePaymentsCall).then(c).then(h).then((e=>(t({transactionState:"SUCCESS"}),e))).then((t=>{this.handleResponse(t)})).catch((e=>{var o;this.setElementStatus("ready");const r=null==e||null===(o=e.error)||void 0===o?void 0:o.googlePayError,n=this.props.i18n.get("error.subtitle.payment"),s="string"==typeof r?{intent:"PAYMENT_AUTHORIZATION",reason:"OTHER_ERROR",message:r||n}:{intent:(null==r?void 0:r.intent)||"PAYMENT_AUTHORIZATION",reason:(null==r?void 0:r.reason)||"OTHER_ERROR",message:(null==r?void 0:r.message)||n};t({transactionState:"ERROR",error:s});const i=m(g({},e),{error:{googlePayError:s}});this.handleFailedResult(i)}))}))})),y(this,"isReadyToPay",(()=>this.googlePay.isReadyToPay(this.props))),y(this,"prefetch",(()=>this.googlePay.prefetchPaymentData(this.props,this.core.options.countryCode))),this.handleAuthorization=this.handleAuthorization.bind(this),this.googlePay=new o(m(g({},this.props),{paymentDataCallbacks:m(g({},this.props.paymentDataCallbacks),{onPaymentAuthorized:this.onPaymentAuthorized})}))}}y(b,"type",p.googlepay),y(b,"txVariants",[p.googlepay,p.paywithgoogle]),y(b,"defaultProps",n);export{b as default};
2
2
  //# sourceMappingURL=GooglePay.js.map