View file File name : wpforms-stripe-elements.min.js Content :"use strict";var WPFormsStripeElements=window.WPFormsStripeElements||function(e,t,n){const l={stripe:null,lockedPageToSwitch:0,init:function(){l.stripe=Stripe(wpforms_stripe.publishable_key,{locale:wpforms_stripe.data.element_locale}),n(e).on("wpformsReady",function(){n(".wpforms-stripe form").filter((e,t)=>"number"==typeof n(t).data("formid")).each(l.setupStripeForm)}),n(e).on("wpformsBeforePageChange",l.pageChange)},setupStripeForm:function(){var e=n(this);l.updateFormSubmitHandler(e),e.on("wpformsAjaxSubmitActionRequired",l.handleCardActionCallback),l.updateCardElementStylesModern(e)},setupCardElement:function(r,i){const s=r.find(".wpforms-stripe-credit-card-hidden-input");if(s&&0!==s.length){var t=s.data("stripe-element");if(!t){let e=wpforms_stripe.data.element_style;n.isEmptyObject(e)&&(e=l.getElementStyleDefault(s));var a={classes:wpforms_stripe.data.element_classes,hidePostalCode:!0,style:e};(t=l.stripe.elements().create("card",a)).mount(r.find(".wpforms-field-stripe-credit-card-cardnumber").get(0)),t.on("change",function(t){if(t.error){let e=t.error.message;"incomplete_number"!==t.error.code&&"invalid_number"!==t.error.code||(e=wpforms_settings.val_creditcard),l.displayStripeError(r,e)}else i.hideThese(i.errorsFor(s.get(0)))}),s.data("stripe-element",t)}return t}},getElementStyleDefault:function(t){if(t&&0!==t.length){var r=t.css("color"),i=t.css("font-size"),i={base:{fontSize:i,color:r,"::placeholder":{color:r,fontSize:i}},invalid:{color:r}};let e=t.css("font-family");r=/[“”<>!@$%^&*=~`|{}[\]]/;return!r.test(e)&&-1===e.indexOf("MS Shell Dlg")||(e=n("p").css("font-family")),r.test(e)||(i.base.fontFamily=e,i.base["::placeholder"].fontFamily=e),i}},updateFormSubmitHandler:function(a){let e=a.validate(),n=e.settings.submitHandler,o=l.setupCardElement(a,e),d=a.find(".wpforms-field-stripe-credit-card-cardnumber");e.settings.submitHandler=function(){let e=a.validate().form(),t=d.hasClass(wpforms_stripe.data.element_classes.empty),r=d.data("required"),i=d.closest(".wpforms-field-stripe-credit-card").hasClass("wpforms-conditional-hide"),s=i?!1:r||!t&&!r;if(e&&s)a.find(".wpforms-submit").prop("disabled",!0),l.createPaymentMethod(a,o,r,n);else{if(e)return a.find(".wpforms-submit").prop("disabled",!1),n(a);a.find(".wpforms-submit").prop("disabled",!1),a.validate().cancelSubmit=!0}}},createPaymentMethod:function(t,e,r,i){l.stripe.createPaymentMethod("card",e,{billing_details:{name:t.find(".wpforms-field-stripe-credit-card-cardname").val()}}).then(function(e){e.error&&r?(t.find(".wpforms-submit").prop("disabled",!1),l.displayStripeError(t,e.error.message),t.validate().cancelSubmit=!0):(e.error||(t.find(".wpforms-stripe-payment-method-id").remove(),e.paymentMethod&&t.append('<input type="hidden" class="wpforms-stripe-payment-method-id" name="wpforms[payment_method_id]" value="'+e.paymentMethod.id+'">')),i(t))})},handleCardActionCallback:function(e,t){const r=n(this);t.success&&t.data.action_required&&l.stripe.handleCardPayment(t.data.payment_intent_client_secret).then(function(e){l.handleCardPaymentCallback(r,e)})},handleCardPaymentCallback:function(e,t){t.error?(l.formAjaxUnblock(e),e.find(".wpforms-field-stripe-credit-card-cardnumber").addClass(wpforms_stripe.data.element_classes.invalid),l.displayStripeError(e,t.error.message)):t.paymentIntent&&"succeeded"===t.paymentIntent.status?(e.find(".wpforms-stripe-payment-method-id").remove(),e.find(".wpforms-stripe-payment-intent-id").remove(),e.append('<input type="hidden" class="wpforms-stripe-payment-intent-id" name="wpforms[payment_intent_id]" value="'+t.paymentIntent.id+'">'),wpforms.formSubmitAjax(e)):l.formAjaxUnblock(e)},displayStripeError:function(e,t){var r=e.find(".wpforms-stripe-credit-card-hidden-input").attr("name"),i=e.find(".wpforms-field-stripe-credit-card-cardnumber"),s={};s[r]=t,wpforms.displayFormAjaxFieldErrors(e,s),!i.is(":visible")&&0<e.find(".wpforms-page-indicator-steps").length&&wpforms.setCurrentPage(e,{}),wpforms.scrollToError(i)},formAjaxUnblock:function(e){var t=e.closest(".wpforms-container"),r=e.find(".wpforms-submit-spinner"),e=e.find(".wpforms-submit"),i=e.data("submit-text");i&&e.text(i),e.prop("disabled",!1),t.css("opacity",""),r.hide()},pageChange:function(e,t,r,i){var s=r.find(".wpforms-field-stripe-credit-card-cardnumber"),a=s.hasClass(wpforms_stripe.data.element_classes.complete),n=s.hasClass(wpforms_stripe.data.element_classes.empty),o=s.hasClass(wpforms_stripe.data.element_classes.invalid);!s.is(":visible")||!s.data("required")&&n||l.lockedPageToSwitch&&l.lockedPageToSwitch!==t||"prev"===i||(a?s.find(".wpforms-error").remove():(l.lockedPageToSwitch=t,e.preventDefault(),o||l.displayStripeError(r,wpforms_stripe.i18n.empty_details)))},getCssPropertyValue(e,t){try{return e.css(t)}catch(e){return""}},updateCardElementStylesModern(e){t.WPForms&&WPForms.FrontendModern&&n.isEmptyObject(wpforms_stripe.data.element_style)&&e&&0!==e.length&&e.find(".wpforms-stripe-credit-card-hidden-input").each(function(){var e=n(this),t=e.data("stripe-element"),e={fontSize:l.getCssPropertyValue(e,"font-size"),colorText:l.getCssPropertyValue(e,"color")};t&&(e={base:{color:e.colorText,fontSize:e.fontSize,"::placeholder":{color:WPForms.FrontendModern.getColorWithOpacity(e.colorText,"0.5"),fontSize:e.fontSize}},invalid:{color:e.colorText}},t.update({style:e}))})}};return l}(document,window,jQuery);WPFormsStripeElements.init();