Skip to content

Instantly share code, notes, and snippets.

@alanef
Created January 11, 2023 10:24
Show Gist options
  • Select an option

  • Save alanef/a050e72fa316fe8be3c6e7f4d4e833ba to your computer and use it in GitHub Desktop.

Select an option

Save alanef/a050e72fa316fe8be3c6e7f4d4e833ba to your computer and use it in GitHub Desktop.
checkout freemius
/**
* Pricing Table Buttons and Freemius Functionlity.
*/
$('.pricing-table__button__trigger').click(function (e) {
debugger;
let coupon = null;
const article = document.querySelector("#home-pricing-id");
if ( article != null ) {
coupon = article.dataset.coupon;
}
var fs_plugin_id = $(this).attr('data-plugin-id'),
fs_plan_id = $(this).attr('data-plan-id'),
fs_public_key = $(this).attr('data-public-key'),
fs_modal_title = $(this).attr('modal-title'),
fs_image = $(this).attr('image'),
fs_licenses = $(this).attr('data-licenses');
var fs_billing_cycle = 'annual';
if ($('.pricing-table__offers--monthly').hasClass('pricing-table__offers--visible')) {
fs_billing_cycle = 'monthly';
}
var handler = FS.Checkout.configure({
plugin_id: fs_plugin_id,
plan_id: fs_plan_id,
public_key: fs_public_key,
image: fs_image
});
handler.open({
name: fs_modal_title,
licenses: fs_licenses,
trial: 'true',
billing_cycle: fs_billing_cycle,
currency: 'auto',
coupon: coupon,
// You can consume the response for after purchase logic.
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);
}
});
e.preventDefault();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment