public static RequestProductPurchaseAsync ( [ productId, [ includeReceipt ) : IAsyncOperation |
||
productId | [ | |
includeReceipt | [ | |
return | IAsyncOperation |
private async Task PurchaseProduct(string productId, ushort featureLevel) { LicenseInformation licenseInformation = IAPs.LicenseInformation; if (!licenseInformation.ProductLicenses[productId].IsActive) { try { await IAPs.RequestProductPurchaseAsync(productId); } catch (Exception ex) { var dlg = new ContentDialog { Content = new TextBlock() { Text = "Error occured : " + ex.Message, TextWrapping = TextWrapping.Wrap }, PrimaryButtonText = ResourceLoader.GetForCurrentView().GetString("Confirm"), }; await dlg.ShowAsync(); } } else { VersionHelper.FeatureLevel |= featureLevel; } }
private async void DoPurchase(string productId) { try { bool licenceActiv = false; if (StoreConfig.STORE_TEST_MODE) { // Kick off purchase; don't ask for a receipt when it returns await MockCurApp.RequestProductPurchaseAsync(productId, false); licInfosMock = MockCurApp.LicenseInformation; licenceActiv = licInfosMock.ProductLicenses[productId].IsActive; } else { // Kick off purchase; don't ask for a receipt when it returns await CurApp.RequestProductPurchaseAsync(productId, false); licInfos = CurApp.LicenseInformation; licenceActiv = licInfos.ProductLicenses[productId].IsActive; } if (licenceActiv) { OnItemPurchasedCB(productId); } else { SoomlaUtils.LogDebug(TAG, "Purchase cancelled " + productId); OnItemPurchaseCancelCB(productId, false); } } catch (Exception ex) { // When the user does not complete the purchase (e.g. cancels or navigates back from the Purchase Page), an exception with an HRESULT of E_FAIL is expected. SoomlaUtils.LogDebug(TAG, ex.Message); OnItemPurchaseCancelCB(productId, true); } }