Quarters Unity SDK - PlayFab In App Purchases Module
PlayFab Module allows very simple way for the user to purchase Quarters using platform native In App Purchases process
Videos
Make sure to check out our step-by-step SDK setup videos on our Youtube channel
Supported platforms: iOS
Prerequisites:
QuartersPlayFabModulecorrectly configured and PlayFab Title configured. If you haven't done this step installQuartersSDK/Modules/PlayFab/PlayFabModule.unitypackageand follow the documentation.Unity IAPPackage https://docs.unity3d.com/Manual/UnityIAPSettingUp.html- For iOS:
- iTunes Connect account with valid "Paid Applications" agreements. This step is critical for testing and validating purchases
- iTunes Connect App setup with added IAP Consumable products
Installation:
- Import content of
QuartersSDK/Modules/PlayFab/PlayFabIAPModule.unitypackageto your project - Add
Unity IAPpackage to your project - Add content of
QuartersSDK/Modules/PlayFabIAP/QuartersPlayFabIAPServer.txtto your existing PlayFab Cloud Script. -
Setup IAP Products on
iTunesConnect/<YourApp>/FeaturesRequirements for Quarters IAP products (critical, make sure this is configured correctly)Example:
Reference Name: 4 Quarters Type: Consumable Product ID: 4QuartersNote: All quarters IAP product IDs MUST follow this naming convention:
<numberOfQuarters>Quarters examples: 4Quarters 8Quarters ..To test IAP Purchases with iOS you don't have to submit Products to review. If "Paid Applications" agreements is valid and product is in "Ready to Submit" status testing purchases with Apples sandbox server will work. For more information how to test Apple IAP follow this link: https://developer.apple.com/apple-pay/sandbox-testing/
Buying Quarters through PlayFab In App Purchases Module
- Authorize user with Quarters
- Call
Quarters.Instance.GetUserDetails -
Login PlayFab user with PlayFab.
Example:
//login user to playfab title using device id LoginWithCustomIDRequest loginRequest = new LoginWithCustomIDRequest(); loginRequest.CustomId = SystemInfo.deviceUniqueIdentifier; loginRequest.CreateAccount = true; PlayFabClientAPI.LoginWithCustomID(loginRequest, delegate(LoginResult result) { Debug.Log("Playfab user logged in: " + result.PlayFabId); }, delegate (PlayFabError error){ Debug.LogError(error.ErrorMessage); });
-
Call
QuartersIAP.Initialize- All products data will be pulled from store serverExample:
QuartersIAP.Instance.Initialize(testProducts, delegate(Product[] products) { //products loaded }, delegate(InitializationFailureReason reason) { Debug.LogError(reason.ToString()); }); -
You can now call QuartersIAP.Instance.BuyProduct - Native popup will be presented to the user to confirm the purchase. After successful payment Playfab IAP module will validate transaction and automatically transfer quarters to user account.
Example:
QuartersIAP.Instance.BuyProduct(QuartersIAP.Instance.products[0], (Product product, string txId) => { Debug.Log("Purchase complete"); },(string error) => { Debug.LogError("Purchase error: " + error); });
For another example look at Assets/QuartersSDK/Example/Example scene