window.GFStripe=null,function(c){GFStripe=function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);this.form=null,this.activeFeed=null,this.GFCCField=null,this.stripeResponse=null,this.hasPaymentIntent=!1,this.init=function(){var i,a,n,d,o,_,g,p,s;(this.isCreditCardOnPage()||"stripe.js"!==this.stripe_payment&&("elements"!==this.stripe_payment||c("#gf_stripe_response").length))&&(a=null,d=n=!1,o=(i=this).apiKey,this.form=c("#gform_"+this.formId),this.GFCCField=c("#input_"+this.formId+"_"+this.ccFieldId+"_1"),gform.addAction("gform_frontend_feeds_evaluated",function(e,t){if(t===i.formId){a=null,d=n=!1;for(var r=0;r div").length?(c(".ginput_container_creditcard > div:last").hide(),c(".ginput_container_creditcard > div:first").html("

"+gforms_stripe_frontend_strings.requires_action+"

")):c(".ginput_container_creditcard").html("

"+gforms_stripe_frontend_strings.requires_action+"

"),i.scaActionHandler(_,t)):(p.mount("#"+i.GFCCField.attr("id")),p.on("change",function(e){i.displayStripeCardError(e)}));break;case"stripe.js":Stripe.setPublishableKey(o)}break}n||("elements"===i.stripe_payment&&(null!=g&&p===g.getElement("card")&&p.destroy(),i.GFCCField.next(".validation_message").length||i.GFCCField.after('
'+gforms_stripe_frontend_strings.no_active_frontend_feed+"
"),wp.a11y.speak(gforms_stripe_frontend_strings.no_active_frontend_feed)),i.resetStripeStatus(i.form,t,i.isLastPage()),o=i.apiKey,i.activeFeed=null)}}),"elements"===this.stripe_payment&&(p=g=_=null,s=!1,c("#gf_stripe_response").length&&(this.stripeResponse=JSON.parse(c("#gf_stripe_response").val()),this.stripeResponse.hasOwnProperty("client_secret")&&(this.hasPaymentIntent=!0))),c("#gform_"+this.formId).on("submit",function(e){if(!(!n||c(this).data("gfstripesubmitting")||1==c("#gform_save_"+i.formId).val()||!i.isLastPage()&&"elements"!==i.stripe_payment||gformIsHidden(i.GFCCField)||i.maybeHitRateLimits()||i.invisibleCaptchaPending()))switch(e.preventDefault(),c(this).data("gfstripesubmitting",!0),i.maybeAddSpinner(),i.stripe_payment){case"elements":i.form=c(this),"form_total"===a.paymentAmount&&(gform.addFilter("gform_product_total",function(e,t){return window["gform_stripe_amount_"+t]=e},51),gformCalculateTotalPrice(i.formId)),i.updatePaymentAmount();var t=parseInt(c("#gform_source_page_number_"+i.formId).val(),10),r=parseInt(c("#gform_target_page_number_"+i.formId).val(),10);if((r').val(n.slice(-4))),r.append(c('').val(d)))}r.append(c('').val(c.toJSON(t))),r.submit()},this.elementsResponseHandler=function(e){var t,r=this.form,s=this,i=this.activeFeed,a=gform.applyFilters("gform_stripe_currency",this.currency,this.formId),n=0===gf_global.gf_currency_config.decimals?window["gform_stripe_amount_"+this.formId]:gformRoundPrice(100*window["gform_stripe_amount_"+this.formId]);if(e.error)return this.displayStripeCardError(e),void this.resetStripeStatus(r,this.formId,this.isLastPage());this.hasPaymentIntent?"product"===i.type?e.hasOwnProperty("paymentMethod")?(c("#gf_stripe_credit_card_last_four").val(e.paymentMethod.card.last4),c("#stripe_credit_card_type").val(e.paymentMethod.card.brand),c.ajax({async:!1,url:gforms_stripe_frontend_strings.ajaxurl,dataType:"json",method:"POST",data:{action:"gfstripe_update_payment_intent",nonce:gforms_stripe_frontend_strings.create_payment_intent_nonce,payment_intent:e.id,payment_method:e.paymentMethod,currency:a,amount:n,feed_id:i.feedId},success:function(e){e.success?(c("#gf_stripe_response").val(c.toJSON(e.data)),r.submit()):(e.error=e.data,delete e.data,s.displayStripeCardError(e),s.resetStripeStatus(r,s.formId,s.isLastPage()))}})):e.hasOwnProperty("amount")&&r.submit():((t=JSON.parse(c("#gf_stripe_response").val())).updatedToken=e.token.id,c("#gf_stripe_response").val(c.toJSON(t)),r.append(c('').val(e.token.card.last4)),r.append(c('').val(e.token.card.brand)),r.submit()):(c("#gf_stripe_response").length?c("#gf_stripe_response").val(c.toJSON(e)):r.append(c('').val(c.toJSON(e))),"product"===i.type?(r.append(c('').val(e.paymentMethod.card.last4)),r.append(c('').val(e.paymentMethod.card.brand)),c.ajax({async:!1,url:gforms_stripe_frontend_strings.ajaxurl,dataType:"json",method:"POST",data:{action:"gfstripe_create_payment_intent",nonce:gforms_stripe_frontend_strings.create_payment_intent_nonce,payment_method:e.paymentMethod,currency:a,amount:n,feed_id:i.feedId},success:function(e){e.success?(c("#gf_stripe_response").length?c("#gf_stripe_response").val(c.toJSON(e.data)):r.append(c('').val(c.toJSON(e.data))),r.submit()):(e.error=e.data,delete e.data,s.displayStripeCardError(e),s.resetStripeStatus(r,s.formId,s.isLastPage()))}})):(r.append(c('').val(e.token.card.last4)),r.append(c('').val(e.token.card.brand)),r.submit()))},this.scaActionHandler=function(t,r){var s,i;c("#gform_"+r).data("gfstripescaauth")||(c("#gform_"+r).data("gfstripescaauth",!0),s=this,i=JSON.parse(c("#gf_stripe_response").val()),"product"===this.activeFeed.type?t.retrievePaymentIntent(i.client_secret).then(function(e){"requires_action"===e.paymentIntent.status&&t.handleCardAction(i.client_secret).then(function(e){var t=JSON.parse(c("#gf_stripe_response").val());t.scaSuccess=!0,c("#gf_stripe_response").val(c.toJSON(t)),s.maybeAddSpinner(),c("#gform_"+r).data("gfstripescaauth",!1),c("#gform_"+r).data("gfstripesubmitting",!0).submit()})}):t.retrievePaymentIntent(i.client_secret).then(function(e){"requires_action"===e.paymentIntent.status&&t.handleCardPayment(i.client_secret).then(function(e){s.maybeAddSpinner(),c("#gform_"+r).data("gfstripescaauth",!1),c("#gform_"+r).data("gfstripesubmitting",!0).submit()})}))},this.isLastPage=function(){var e=c("#gform_target_page_number_"+this.formId);return!(0'))))},this.resetStripeStatus=function(e,t,r){c("#gf_stripe_response, #gf_stripe_credit_card_last_four, #stripe_credit_card_type").remove(),e.data("gfstripesubmitting",!1),c("#gform_ajax_spinner_"+t).remove(),r&&(window["gf_submitting_"+t]=!1)},this.displayStripeCardError=function(e){e.error&&!this.GFCCField.next(".validation_message").length&&this.GFCCField.after('
');var t=this.GFCCField.next(".validation_message");e.error?(t.html(e.error.message),wp.a11y.speak(e.error.message,"assertive"),0