Guest User

Untitled

a guest
May 22nd, 2017
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.19 KB | None | 0 0
  1.  // Sandbox mode, Optionally add callbacks
  2.                 store.inappbilling.setTestMode(function () {
  3.                         //successfully loaded test data
  4.                         console.log("Success");
  5.                     },
  6.                     function () {
  7.                         //failed to load test data
  8.                         console.log("Failed");
  9.                     });
  10.  
  11.                 store.register({
  12.                     id: productId,
  13.                     type: store.PAID_SUBSCRIPTION
  14.                 });
  15.  
  16.                 // Listen to the 'updated' event for individual product
  17.                 store.when(productId).updated(function (p) {
  18.                     $ionicLoading.hide();
  19.                 });
  20.  
  21.                 // Initiate a purchase
  22.                 store.order(productId);
  23.  
  24.                 // When the purchase is approved, show an alert
  25.                 store.when(productId).approved(function (order) {
  26.                     Store.subscribeWindows(month, order);
  27.                     order.finish();
  28.                 });
  29.  
  30.                 // When the purchase is approved, show an alert
  31.                 store.when(productId).cancelled(function (order) {
  32.                     $ionicPopup.alert({
  33.                         title: 'Subscribe was cancelled!',
  34.                         template: 'Try again!'
  35.                     });
  36.                     order.finish();
  37.                 });
  38.  
  39.                 // When the store is ready all products are loaded and in their "final" state.
  40.                 store.ready(function () {
  41.                     console.log("The store is ready");
  42.                 });
  43.  
  44.                 // Deal with errors:
  45.                 store.error(function (err) {
  46.                     $ionicLoading.hide();
  47.                     $ionicPopup.alert({
  48.                         title: 'Something went wrong',
  49.                         template: err.message
  50.                     });
  51.                 })
  52.  
  53.  
  54.                 // This will contact the server to check all registered products validity and ownership status.
  55.                 // It's mostly fine to do this only at application startup but you can refresh it more often.
  56.                 store.refresh();
Add Comment
Please, Sign In to add comment