Priceur.js integration
What is Priceur.js?
priceur.js
wraps the Priceur API into a lightweight javascript library for easy integration into your website or javascript application.
With priceur.js
you can:
- Fetch localized plans into the client browser.
- Update landing pages, marketing pages and payment workflow to show localized plans.
- Integrate localized plans into your javascript application.
Loading
Use the following javascript snippet to load the library:
(function(pr, i, c, e, u, r) {
pr['PriceurCommand'] = e;
pr[e] = pr[e] || function() { (pr[e].q = pr[e].q || []).push(arguments) };
u = i.createElement('script');
r = i.getElementsByTagName('script')[0];
u.async = 1;
u.src = c;
r.parentNode.insertBefore(u, r);
})(window, document, "//priceur.com/api/v1/priceur.js", 'priceur');
Upon loading, the script registers a global priceur()
function that you can use to interact with Priceur. The first argument of the priceur()
is the command to execute (see below for the list of commands).
The first command to execute is priceur('init', 'public_test_123EXAMPLE321');
.
init
fetches the localized plans and store them locally.
Available Commands
Command | Arguments | Description |
---|---|---|
fetch |
|
Fetches the localized plans from the API and store them in memory. If a callback is passed, the callback will be called with the plans object as argument. Example:
|
get |
|
Returns the plan curresponding to the given id. If a callback is passed, the callback will be called with the plan as argument. Examples:
|
getAll |
|
Returns all plans (as an object with plan IDs as keys). If a callback is passed, the callback will be called with the plans object as argument. Examples:
|
getAPIKey |
|
Returns the Priceur API Key set during init .If a callback is passed, the callback will be called with the API key as argument. Examples:
|
getMeta |
|
Returns the value of the meta information for the given key. Possible meta keys are:
Examples:
|
getValue |
|
Returns the value of the plan at the given key path. Possible values for path: see result example in API Documentation. If a callback is passed, the callback will be called with the value as argument. Examples:
|
init |
|
Sets the API Key, fetches the localized plans from the API and store them in memory. This command needs to be executed before any other. If updatePage is set to true , Priceur will update the page with localized plans.Example:
|
update |
|
Update the page with localized plans once fetched (see
Landing Page integration section for more informations). Example:
|