*This project is a part of The [SOOMLA](http://www.soom.la) Framework, which is a series of open source initiatives with a joint goal to help mobile game developers do more together. SOOMLA encourages better game design, economy modeling, social engagement, and faster development.*
Haven't you ever wanted an in-app purchase one liner that looks like this ?!
```cs
StoreInventory.BuyItem("[itemId]");
```
unity3d-store
---
*SOOMLA's Store Module for Unity3d*
**March 9th:** v1.7.15 **Unity 5** compatibility patch.
> If you are upgrading an already imported store module, make sure to delete the `<project>/Assets/Soomla/compilations` folder.
> If you get the “API Update Required” window, click the "I Made a Backup. Go Ahead!" button, Unity will automatically update some of our code.
**October 29th:** v1.7 **Work in editor!** When you're in the Unity editor, data will be saved to PlayerPrefs.
**October 3rd, 2013:** iOS Server Side Verification is now implemented into unity3d-store. The server is a complimentary server provided by [SOOMLA](http://soom.la) to help you get your in-game purchases a bit more secured. This feature is not enabled by default. In order to enable Server Side verification go to the Soomla prefab and set **ios Server Side Verification -> true**.
* More documentation and information in SOOMLA's [Knowledge Base](http://know.soom.la/docs/platforms/unity)
* For issues you can use the [issues](https://github.com/soomla/unity3d-store/issues) section or SOOMLA's [Answers Website](http://answers.soom.la)
unity3d-store is the Unity3d flavor of SOOMLA's Store Module.
## Economy Model
![SOOMLA's Economy Model](http://know.soom.la/img/tutorial_img/soomla_diagrams/EconomyModel.png)
## Download
####Pre baked unitypackages:
> If you're upgrading from a version below v1.7.x make sure you take soomla-unity3d-core again.
[unity3d-store v1.9.3](https://www.assetstore.unity3d.com/en/#!/content/6103)
#### From sources:
- Clone this repository recursively: `git clone --recursive https://github.com/soomla/unity3d-store.git`
- Run `./build_all` from project directory
## Debugging
If you want to see full debug messages from android-store and ios-store you just need to check the box that says "Debug Messages" in the SOOMLA Settings.
Unity debug messages will only be printed out if you build the project with _Development Build_ checked.
## Cloning
There are some necessary files in submodules lined with symbolic links. If you're cloning the project make sure you clone it with the `--recursive` flag.
```
$ git clone --recursive git@github.com:soomla/unity3d-store.git
```
## Getting Started
1. First, you'll need to either download (RECOMMENDED) the unity3d-store pre-baked packages, or clone unity3d-store.
- RECOMMENDED: Download [unity3d-store](https://www.assetstore.unity3d.com/en/#!/content/6103)
OR, if you'd like to work with sources:
- Clone unity3d-store from SOOMLA's github page.
```
$ git clone --recursive git@github.com:soomla/unity3d-store.git
```
>There are some necessary files in submodules linked with symbolic links. If you're cloning the project make sure to include the `--recursive` flag.
2. ~~Drag the "StoreEvents" and "CoreEvents" Prefabs from `Assets/Soomla/Prefabs` into your scene. You should see them listed in the "Hierarchy" panel.~~
>This step is no longer required starting from Store v1.9.0
![alt text](http://know.soom.la/img/tutorial_img/unity_getting_started/prefabs.png?v=2 "Prefabs")
3. On the menu bar click **Window > Soomla > Edit Settings** and change the values for "Soomla Secret" and "Public Key":
- **Soomla Secret** - This is an encryption secret you provide that will be used to secure your data. (If you used versions before v1.5.2 this secret MUST be the same as Custom Secret)
- **Public Key** - If your billing service provider is Google Play, you'll need to insert the public key given to you from Google. (Learn more in step 4 [here](/android/store/Store_GooglePlayIAB)). **Choose both secrets wisely. You can't change them after you launch your game!**
- **Fraud Protection** - If your billing service provider supports Fraud Protection, you can turn on this option and provide needed data.
Optionally, you can turn on `Verify On Server Failure` if you want to get purchases automatically verified in case of network failures during the verification process.
> In order to get clientId, clientSecret and refreshToken for Google Play go over [Google Play Purchase Verification](/android/store/Store_GooglePlayVerification).
![alt text](http://know.soom.la/img/tutorial_img/unity_getting_started/soomlaSettings.png "Soomla Settings")
4. Create your own implementation of `IStoreAssets` in order to describe your game's specific assets.
- For a brief example, see the [example](#example) at the bottom.
- For a more detailed example, see our MuffinRush [example](https://github.com/soomla/unity3d-store/blob/master/Soomla/Assets/Examples/MuffinRush/MuffinRushAssets.cs).
5. Initialize `SoomlaStore` with the class you just created:
``` cs
SoomlaStore.Initialize(new YourStoreAssetsImplementation());
```
> Initialize SoomlaStore in the `Start` function of `MonoBehaviour` and NOT in the `Awake` function. SOOMLA has its own `MonoBehaviour` and it needs to be "Awakened" before you initialize.
> Initialize SoomlaStore ONLY ONCE when your application loads.
6. You'll need an event handler in order to be notified about in-app purchasing related events. Refer to the document about [Event Handling](https://github.com/soomla/unity3d-store#event-handling) for more information.
That's it! You now have storage and in-app purchasing capabilities ALL-IN-ONE!
###Unity & Android
**Starting IAB Service in background**
If you have your own storefront implemented inside your game, it's recommended that you open the IAB Service in the background when the store opens and close it when the store is closed.
``` cs
// Start Iab Service
SoomlaStore.StartIabServiceInBg();
// Stop Iab Service
SoomlaStore.StopIabServiceInBg();
```
This is not mandatory, your game will work without this, but we do recommend it because it enhances performance. The
idea here is to preemptively start the in-app billing setup process with Google's (or Amazon's) servers.
In many games the user has to navigate into the in-game store, or start a game session in order to reach the point of
making purchases. You want the user experience to be fast and smooth and prevent any lag that could be caused by network
latency and setup routines you could have done silently in the background.
### Unity & Windows Phone 8
#### Compatibility
This WP8 plugin work on Unity 4.5.4 and above 4.x versions.
For Unity 5 the plugin work with 5.0.1p1 patch release 1 version and above.
To build for WP8 target you need to configure the assemblies with the new plugins setting panel introduce in the 5.0 version.
For Assets/Plugins/soomla-wp-core.dll Check Editor platform only
For Assets/Plugins/wp-store.dll Check Editor platform only
For Assets/Plugins/WP8/soomla-wp-core.dll Check WP8Player platform only and select Assets/Plugins/soomla-wp-core.dll for the Placeholder
For Assets/Plugins/WP8/wp-store.dll Check WP8Player platform only and select Assets/Plugins/wp-store.dll for the Placeholder
#### IAP Test Mode
To activate the IAP Test Mode select the checkbox in the Soomla Config Panel. Declare your test IAP in Assets/Plugins/WP8/IAPMock.xml
#### Simulator build
To run your app in the simulator select the checkbox in the Soomla config panel. This option copy the right assembly into the Assets/Plugins/WP8/ folder
#### Clone and Develop on Windows (workaround)
One major issue is that Git didn't manage symlink on Windows...
Before launching Unity you have to run "fix-symlinks-windows\setup-symlinks.bat" from the root of the repo in a Git bash. If you forget to call it before launching Unity, j