public static RequestAppPurchaseAsync ( [ includeReceipt ) : IAsyncOperation |
||
includeReceipt | [ | |
return | IAsyncOperation |
/// <summary> /// Triggers an attempt to upgrade the app from trial mode to full mode. /// </summary> /// <returns></returns> /// <exception cref="System.InvalidOperationException"> /// Trial mode conversion failed with a COM exception. /// or /// Trial mode conversion failed with an argument exception. /// or /// Trial mode conversion failed with an out of memory exception. /// </exception> public async Task <String> TriggerTrialUpgrade() { // Request a purchase upgrade from the Trial Mode to the Full Feature Mode try { var receipt = await CurrentApp.RequestAppPurchaseAsync(true); return(receipt); } catch (System.Runtime.InteropServices.COMException comException) { // Happens with E_FAIL throw new InvalidOperationException("Trial mode conversion failed with a COM exception.", comException); } catch (ArgumentException argumentException) { // Happens with E_INVALIDARG result throw new InvalidOperationException("Trial mode conversion failed with an argument exception.", argumentException); } catch (OutOfMemoryException outOfMemoryException) { // Happens with E_OUTOFMEMORY result throw new InvalidOperationException("Trial mode conversion failed with an out of memory exception.", outOfMemoryException); } }
/// <summary> /// Invoked when the user asks purchase the app. /// </summary> private async void PurchaseFullLicense(bool isExitApp) { ResourceLoader resource = ResourceLoader.GetForCurrentView(); bool failed = false; string msg = null; LicenseInformation licenseInformation = IAPs.LicenseInformation; if (licenseInformation.IsTrial) { try { await IAPs.RequestAppPurchaseAsync(false); if (!licenseInformation.IsTrial && licenseInformation.IsActive) { Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().Title = ""; //구매해 주셔서 감사합니다. Vm.PaidLevel = Models.PaidLevelType.Full; Messenger.Default.Send(false, "LockByTrialExpired"); } else { failed = true; msg = resource.GetString("IAPs/Purchase/Failed/Content"); } } catch (Exception ex) { failed = true; msg = resource.GetString("IAPs/Purchase/Failed/Content") + "\n(" + ex.Message + ")"; } if (failed) { var dlg = DialogHelper.GetSimpleContentDialog( resource.GetString("IAPs/Purchase/Failed/Title"), msg, resource.GetString(isExitApp ? "Button/CCPClose/Content" : "Button/Close/Content"), resource.GetString("IAPs/Purchase/Button/Retry")); var result = await dlg.ShowAsync(); if (result == ContentDialogResult.Primary) { if (isExitApp) { App.Current.Exit(); } } else { PurchaseFullLicense(isExitApp); } App.ContentDlgOp = null; } } }