private static void StartPurchaseCallbackImpl(IntPtr ptr, Result result) { GCHandle h = GCHandle.FromIntPtr(ptr); StartPurchaseHandler callback = (StartPurchaseHandler)h.Target; h.Free(); callback(result); }
/// <summary> /// Opens the overlay to begin the in-app purchase dialogue for the given SKU ID. You must call /// <see cref="FetchSkus" /> first before being able to access SKUs in this way. /// If the user has enabled the overlay for your game, a purchase modal will appear in the overlay. Otherwise, the /// Discord client will be auto-focused with a purchase modal. /// </summary> /// <param name="skuId"></param> /// <param name="callback"></param> public void StartPurchase(long skuId, StartPurchaseHandler callback) { GCHandle wrapped = GCHandle.Alloc(callback); Methods.StartPurchase(methodsPtr, skuId, GCHandle.ToIntPtr(wrapped), StartPurchaseCallbackImpl); }