Created
May 13, 2019 20:42
-
-
Save msciotti/a86b0cbd8c479b6c9e4c5721ab6e848d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void Main() | |
| { | |
| // Instantiate Discord and make a StoreManager | |
| var discord = new Discord.Create(MY_APPLICATION_ID, (UInt64)Discord.CreateFlags.Default); | |
| var storeManager = discord.GetStoreManager(); | |
| storeManager.FetchSkus(); | |
| storeManager.OnEntitlementCreate += (ref Discord.Entitlement entitlement) => | |
| { | |
| Console.WriteLine(string.Format("User {0} just got entitlement to {1}", entitlement.User.Id, entitlement.SkuId)); | |
| var sku = storeManager.GetSku(entitlement.SkuId); | |
| if (sku.Type == Discord.SkuType.Consumable) | |
| { | |
| // "Consume" the entitlement | |
| // https://discordapp.com/developers/docs/game-sdk/store#consume-sku | |
| } | |
| // Give the user what they bought | |
| } | |
| // Call StartPurchase on the SKU you want the user to buy | |
| // The SKU ID will be dependent on what the user selects in-game to buy | |
| storeManager.StartPurchase(CHOSEN_SKU_ID, (res) => | |
| { | |
| if (res == Discord.Result.Ok) | |
| { | |
| Console.WriteLine("User is in the purchase flow"); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment