Fovea.Billing

is now IAPTIC, please go to the new and better version of our system.

Application Username

Fovea.Billing can identify users using your own identifiers. You can control how customers are identified, if you happen to use an internal login mechanism.

You can then retrieve your users’ purchase information from a reliable source instead of blindly trusting whatever the client app sends you.

This will also let you check the latest receipt of a given user from the user interface knowing his/her account login / username. Super helpful when handling support requests.

How?

plugin version >= 9

Starting with version 9 of the plugin, you should set store.applicationUsername whenever your user is logged in. The information will be passed along with all calls to the receipt validator.

store.applicationUsername = function() {
  return Session.getUserID(); // a string
}

If login is mandatory to activate purchases, the recommended pattern is to wait for the session to be ready before initializing the plugin, this way: applicationUsername will be set with all your validation requests.

SessionService.addEventListener("ready", initIAP);
function initIAP() {
  SessionService.removeEventListener("ready", initIAP); // only initialize the plugin once
  // initialize the plugin
  store.register(products);
  // (your event handlers)
  store.when("product")
    .approved(p => p.verify())
    .verified(p => p.finish());
  store.applicationUsername = () => SessionService.getUserID();
  store.refresh();
}

Check the official documentation for details.

plugin version < 9

With older version of the plugin, you had to add it as an additional argument when making a purchase with store.order().

store.order('my_product_id', {
    applicationUsername: 'application_user_id'});

You should then start seeing users identified by your applicationUsername.

This method might miss some purchases, in particular if they were initiated outside the app. That’s why the API changed, so we recommend you use the most up-to-date version of the plugin.