jQuery(document).ready(function(e){function a(a,t){var n=e(".ff_paddle_payment_container").closest("form").data("form_id")||e("form[data-form_id]").first().data("form_id");if(n){var i="fluentform_gateway_messages_"+n;if(window[i]&&window[i][a])return window[i][a]}return t}var t=e("body").find(".ff_paddle_payment_container"),n=e("body").find(".ff_frameless_header");if(t.length){var i=window.ff_paddle_vars,d=i.frame_initial_height||"450",o=i.frame_style||"width: 100%; min-width: 312px; background-color: transparent; border: none;",r=i.allowed_payment_methods||["alipay","apple_pay","bancontact","card","google_pay","ideal","paypal"],f=i.payment_mode||"sandbox",l=i.theme||"light",s=i.locale||"en",_=i.client_token,c=i.redirect_delay||1e3;_&&(Paddle.Environment.set(f),Paddle.Initialize({token:_,checkout:{settings:{displayMode:"inline",allowedPaymentMethods:r,theme:l,locale:s,frameTarget:"ff_paddle_payment_container",frameInitialHeight:d,frameStyle:o}},eventCallback:function(d){if("checkout.completed"==d.name){var o={action:"fluentform_paddle_confirm_payment",transaction_hash:i.transaction_hash,submission_id:i.submission_id,_ff_payment_nonce:i._ff_payment_nonce||"",paddle_payment:d.data};e.post(i.ajax_url,o).then(function(e){e.data&&e.data.payment.data.id==d.data.transaction_id&&(t.find("p").text(e.data.success_message),n.text(i.title_message),setTimeout(function(){window.location.href=e.data.redirect_url||i.success_redirect},c))}).catch(function(e){var n=a("request_failed","Request failed. Please try again");e&&e.responseJSON&&(n=e.responseJSON.errors),t.find("p").text(n),setTimeout(function(){window.location.href=i.failure_redirect},c)})}if("checkout.error"==d.name){var r=a("payment_failed","Paddle payment process failed!");d.data&&d.data.error&&(r=d.data.error.detail),t.find("p").text(r),setTimeout(function(){window.location.href=i.failure_redirect},c)}}}))}});