Simple IAP System
4.3
|
Stores IAP related data such as all purchases, selected items and ingame currency. Makes use of the JSON format and simple encryption. You should only modify below values once (if necessary at all), thus they aren't public. More...
Public Member Functions | |
void | Init () |
Initialization called by IAPManager in Awake(). More... | |
Static Public Member Functions | |
static DBManager | GetInstance () |
Returns a static reference to this script. More... | |
static void | SetPurchase (string id, int amount=1) |
Sets a product id to purchased state. By default, the purchase amount is 1. More... | |
static int | IncreasePurchase (string id, int value) |
This will increase the purchase amount by product id and return the new value. Or decrease by passing in a negative value. Should be used for non-consumable purchases only. More... | |
static int | GetPurchase (string id) |
Returns the purchase amount of a product. More... | |
static void | RemovePurchase (string id) |
Removes a product id from purchased state. Only used for expired subscriptions or fake purchases. More... | |
static bool | isPurchased (string id) |
Convenience method for checking whether a product is purchased or not. More... | |
static bool | isRequirementMet (IAPRequirement req) |
Returns whether a requirement has been met. More... | |
static void | SaveReceipt (string id, string data) |
Saves receipt data along with the product id on the device. Optionally supports encryption. More... | |
static string | GetReceipt (string id) |
Reads receipt data for a specific product id. Optional supports decryption. More... | |
static bool | VerifyVirtualPurchase (IAPObject obj) |
This method checks user's funds for a virtual purchase. Returns true and substracts funds if they own enough virtual currency for the product price. More... | |
static void | SetPlayerData (string id, JSONData data) |
Used for storing your own player-related data on the device. JSONData supports all primitive data types. More... | |
static int | IncreasePlayerData (string id, int value) |
This will increment the player-related data value defined by id and return the new value. Can only increase integer values (or decrease by passing in a negative value). More... | |
static JSONNode | GetPlayerData (string id) |
Returns a player data node for a specific id. More... | |
static void | RemovePlayerData (string id) |
Removes a player data node for a specific id and saves the modified data on the device. More... | |
static void | SetFunds (string currency, int value) |
Overwrites and/or sets the total amount of funds for a specific currency. More... | |
static int | IncreaseFunds (string currency, int value) |
Increases the amount of funds for a specific currency and return the new value. Or decrease by passing in a negative value. More... | |
static int | GetFunds (string currency) |
Returns the amount of funds for a specific currency. More... | |
static List< string > | GetAllPurchased (bool withUpgrades=false) |
Returns list that holds all purchased product ids. By default, for upgradeable products this only returns the current active one. More... | |
static Dictionary< string, int > | GetCurrencies () |
Returns a dictionary of all currencies (name, currently owned amount). More... | |
static Dictionary< string, List< string > > | GetAllSelected () |
Returns a dictionary that holds all group names with selected product ids. More... | |
static bool | SetSelected (string id, bool single) |
Sets a product id to selected state. If single is true, other ids in the same group get deselected. single = false allows for multi selection. Returns a boolean that indicates whether it was a new selection. More... | |
static void | SetDeselected (string id) |
Sets a product id to deselected state. More... | |
static bool | GetSelected (string id) |
Returns whether a product has been selected. More... | |
static List< string > | GetSelectedGroup (string groupName) |
Returns all selected products within a specific group. More... | |
static string | Read () |
Returns the local data in string format. More... | |
static void | Save (string id="") |
Save modified data to the device. Optionally supports encryption. More... | |
static void | Overwrite (string otherData) |
Overwrite the current storage with another JSON representation. E.g. after downloading data from a remote server. More... | |
static string | GetJSON (string key) |
Returns the desired JSON data node as a string. In case of content, free products are excluded. More... | |
static void | Clear (string data) |
Remove data defined by section key. E.g. content, selected or currency. Should be used for testing purposes only. More... | |
static void | ClearAll () |
Removes all PlayerPref data set in this project. Should be used for testing purposes only. More... | |
static string | GetDeviceId () |
Public Attributes | |
const string | prefsKey = "data" |
The name of the playerpref key on the device. More... | |
const string | idPrefixKey = "SIS_" |
The prefix for storing receipt keys on the device. More... | |
bool | memoryOnly = false |
Should purchase data only be saved in device memory rather than on disk? Warning: if you do not use some cloud save provider and login system (like PlayFab), your user's purchases will only exist throughout the current game session. More... | |
bool | encrypt = false |
Whether the data saved on the device should be encrypted. More... | |
string | obfuscKey |
56+8 bit key for encrypting the JSON string: 8 characters, do not use code characters (=.,? etc) and play-test that your key actually works! on Windows Phone this key must be exactly 16 characters (128 bit) long. SAVE THIS KEY SOMEWHERE ON YOUR END, SO IT DOES NOT GET LOST ON UPDATES More... | |
const string | currencyKey = "Currency" |
const string | contentKey = "Content" |
const string | selectedKey = "Selected" |
const string | playerKey = "Player" |
Events | |
static Action< string > | updatedDataEvent |
fired when a data save/update on the device happens More... | |
Stores IAP related data such as all purchases, selected items and ingame currency. Makes use of the JSON format and simple encryption. You should only modify below values once (if necessary at all), thus they aren't public.
|
static |
Remove data defined by section key. E.g. content, selected or currency. Should be used for testing purposes only.
|
static |
Removes all PlayerPref data set in this project. Should be used for testing purposes only.
|
static |
Returns list that holds all purchased product ids. By default, for upgradeable products this only returns the current active one.
|
static |
Returns a dictionary that holds all group names with selected product ids.
|
static |
Returns a dictionary of all currencies (name, currently owned amount).
|
static |
|
static |
Returns the amount of funds for a specific currency.
|
static |
Returns a static reference to this script.
|
static |
Returns the desired JSON data node as a string. In case of content, free products are excluded.
|
static |
Returns a player data node for a specific id.
|
static |
Returns the purchase amount of a product.
|
static |
Reads receipt data for a specific product id. Optional supports decryption.
|
static |
Returns whether a product has been selected.
|
static |
Returns all selected products within a specific group.
|
static |
Increases the amount of funds for a specific currency and return the new value. Or decrease by passing in a negative value.
|
static |
This will increment the player-related data value defined by id and return the new value. Can only increase integer values (or decrease by passing in a negative value).
|
static |
This will increase the purchase amount by product id and return the new value. Or decrease by passing in a negative value. Should be used for non-consumable purchases only.
void Init | ( | ) |
Initialization called by IAPManager in Awake().
|
static |
Convenience method for checking whether a product is purchased or not.
|
static |
Returns whether a requirement has been met.
|
static |
Overwrite the current storage with another JSON representation. E.g. after downloading data from a remote server.
|
static |
Returns the local data in string format.
|
static |
Removes a player data node for a specific id and saves the modified data on the device.
|
static |
Removes a product id from purchased state. Only used for expired subscriptions or fake purchases.
|
static |
Save modified data to the device. Optionally supports encryption.
|
static |
Saves receipt data along with the product id on the device. Optionally supports encryption.
|
static |
Sets a product id to deselected state.
|
static |
Overwrites and/or sets the total amount of funds for a specific currency.
|
static |
Used for storing your own player-related data on the device. JSONData supports all primitive data types.
|
static |
Sets a product id to purchased state. By default, the purchase amount is 1.
|
static |
Sets a product id to selected state. If single is true, other ids in the same group get deselected. single = false allows for multi selection. Returns a boolean that indicates whether it was a new selection.
|
static |
This method checks user's funds for a virtual purchase. Returns true and substracts funds if they own enough virtual currency for the product price.
const string contentKey = "Content" |
const string currencyKey = "Currency" |
bool encrypt = false |
Whether the data saved on the device should be encrypted.
const string idPrefixKey = "SIS_" |
The prefix for storing receipt keys on the device.
bool memoryOnly = false |
Should purchase data only be saved in device memory rather than on disk? Warning: if you do not use some cloud save provider and login system (like PlayFab), your user's purchases will only exist throughout the current game session.
string obfuscKey |
56+8 bit key for encrypting the JSON string: 8 characters, do not use code characters (=.,? etc) and play-test that your key actually works! on Windows Phone this key must be exactly 16 characters (128 bit) long. SAVE THIS KEY SOMEWHERE ON YOUR END, SO IT DOES NOT GET LOST ON UPDATES
const string playerKey = "Player" |
const string prefsKey = "data" |
The name of the playerpref key on the device.
const string selectedKey = "Selected" |
|
static |
fired when a data save/update on the device happens