Skip to content

Instantly share code, notes, and snippets.

@swashata
Created May 1, 2022 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swashata/4a45c7eecb91c0d27ae8246239a69fd4 to your computer and use it in GitHub Desktop.
Save swashata/4a45c7eecb91c0d27ae8246239a69fd4 to your computer and use it in GitHub Desktop.
Separate Lifetime & Annual Buy Button Freemius
<html>
<body>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="https://checkout.freemius.com/checkout.min.js"></script>
<button id="purchase_lifetime">Buy Lifetime License</button>
<button id="purchase_annual">Buy Annual License</button>
<script type="text/javascript">
const handler = FS.Checkout.configure({
plugin_id: 'XXX', // replace with plugin_id
plan_id: 'XXX', // replace with plan_id
public_key: 'pk_xxxxxx', // replace with public_key
image: 'https://your-plugin-site.com/logo-100x100.png', // replace with image
});
// Open prompt with billing_cycle set to 'lifetime' for Lifetime purchase.
document.querySelector('#purchase_lifetime').addEventListener('click', e => {
e.preventDefault();
handler.open({
name: 'Your Plugin Name',
billing_cycle: 'unlimited',
// ... other needed configs
});
});
// Open prompt with billing_cycle set to 'annual' for Annual billing cycles.
document.querySelector('#purchase_annual').addEventListener('click', e => {
e.preventDefault();
handler.open({
name: 'Your Plugin Name',
billing_cycle: 'annual',
// ... other needed configs
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment