|
jQuery(document).ready(function($) { |
|
var handler = FS.Checkout.configure({ |
|
plugin_id: "3690", |
|
plan_id: "5949", |
|
public_key: "pk_f990ec18700a90c02db544f1aa986", |
|
image: |
|
"https://wpsecurityninja.com/wp-content/uploads/2019/05/icon-256x256-simplified.png" |
|
}); |
|
|
|
// Expands the coupon input field |
|
jQuery(".expander").on("click", function() { |
|
jQuery("#couponcont").slideToggle(); |
|
}); |
|
|
|
// Toggles between billing cycles |
|
jQuery(".billingcycles").on("change", function(e) { |
|
// 'click' seems to be too early, so updated value are not always parsed. |
|
var billing_cycle = jQuery( |
|
"input:radio[name ='billing_cycle']:checked" |
|
).val(); |
|
switch (billing_cycle) { |
|
case "monthly": |
|
//jQuery('.tab-details .tab.monthly').show(); |
|
jQuery(".getlicense .monthly").show(); |
|
jQuery(".getlicense .annual").hide(); |
|
jQuery(".getlicense .lifetime").hide(); |
|
break; |
|
case "annual": |
|
jQuery(".getlicense .monthly").hide(); |
|
jQuery(".getlicense .annual").show(); |
|
jQuery(".getlicense .lifetime").hide(); |
|
break; |
|
case "lifetime": |
|
jQuery(".getlicense .monthly").hide(); |
|
jQuery(".getlicense .lifetime").show(); |
|
jQuery(".getlicense .annual").hide(); |
|
break; |
|
} |
|
}); |
|
|
|
jQuery(".fspurchase").on("click", function(e) { |
|
e.preventDefault(); |
|
handler.open({ |
|
name: "Security Ninja", |
|
coupon: $("#couponinput").val(), |
|
licenses: $("input:radio[name ='licences']:checked").val(), |
|
// You can consume the response for after purchase logic. |
|
billing_cycle: $("input:radio[name ='billing_cycle']:checked").val(), |
|
trial: $(this).data("fstrial"), // picked up from clicked button data-fstrial value |
|
purchaseCompleted: function(response) { |
|
// The logic here will be executed immediately after the purchase confirmation. // alert(response.user.email); |
|
}, |
|
success: function(response) { |
|
// The logic here will be executed after the customer closes the checkout, after a successful purchase. // alert(response.user.email); |
|
} |
|
}); |
|
}); |
|
}); |