Skip to content

Commit

Permalink
Merge pull request j3k0#415 from yangguang2009/add_restore_purchases_…
Browse files Browse the repository at this point in the history
…example_usage_1

Add a restore purchases usage example in the source file refresh.js
  • Loading branch information
j3k0 committed Mar 5, 2016
2 parents 07c566b + 6f2cbb4 commit c5273f2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
26 changes: 22 additions & 4 deletions doc/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,16 +261,24 @@ The `verbosity` property defines how much you want `store.js` to write on the co
- `store.DEBUG` or `4` to enable internal debugging messages.

See the [logging levels](#logging-levels) constants.
## <a name="sandbox"></a>*store.sandbox*

The `sandbox` property defines if you want to invoke the platform purchase sandbox

- Windows will use the IAP simulator if true (see Windows docs)
- Android: NOT IN USE
- iOS: NOT IN USE

## Constants


### product types

store.FREE_SUBSCRIPTION = "free subscription";
store.PAID_SUBSCRIPTION = "paid subscription";
store.CONSUMABLE = "consumable";
store.NON_CONSUMABLE = "non consumable";
store.FREE_SUBSCRIPTION = "free subscription";
store.PAID_SUBSCRIPTION = "paid subscription";
store.NON_RENEWING_SUBSCRIPTION = "non renewing subscription";
store.CONSUMABLE = "consumable";
store.NON_CONSUMABLE = "non consumable";

### error codes

Expand Down Expand Up @@ -766,6 +774,16 @@ have a way to do just that.
store.refresh();
```

##### restore purchases example usage

Add a "Refresh Purchases" button to call the `store.refresh()` method, like:

`<button onclick="store.refresh()">Restore Purchases</button>`

To make the restore purchases work as expected, please make sure that
the "approved" event listener had be registered properly,
and in the callback `product.finish()` should be called.

## *store.log* object
### `store.log.error(message)`
Logs an error message, only if `store.verbosity` >= store.ERROR
Expand Down
10 changes: 10 additions & 0 deletions src/js/refresh.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@
/// store.refresh();
/// ```
///
/// ##### restore purchases example usage
///
/// Add a "Refresh Purchases" button to call the `store.refresh()` method, like:
///
/// `<button onclick="store.refresh()">Restore Purchases</button>`
///
/// To make the restore purchases work as expected, please make sure that
/// the "approved" event listener had be registered properly,
/// and in the callback `product.finish()` should be called.
///

var initialRefresh = true;

Expand Down

0 comments on commit c5273f2

Please sign in to comment.