/// <summary> /// Reports that your app has fullfilled the consumable product, the product cannot be purchased again until this is called /// </summary> /// <param name="id">The id of the product</param> /// <param name="transactionId">The transaction id</param> /// <param name="response">A callback indicating the result</param> public static void ReportConsumableProductFulfillment(string id, Guid transactionId, Action <WSAFulfillmentResult> response) { #if NETFX_CORE || (ENABLE_IL2CPP && UNITY_WSA_10_0) if (_isTest) { UnityEngine.WSA.Application.InvokeOnUIThread(async() => { FulfillmentResult result = await CurrentAppSimulator.ReportConsumableFulfillmentAsync(id, transactionId); UnityEngine.WSA.Application.InvokeOnAppThread(() => { if (response != null) { response(MapFulfillmentResult(result)); } }, true); }, false); } else { UnityEngine.WSA.Application.InvokeOnUIThread(async() => { FulfillmentResult result = await CurrentApp.ReportConsumableFulfillmentAsync(id, transactionId); UnityEngine.WSA.Application.InvokeOnAppThread(() => { if (response != null) { response(MapFulfillmentResult(result)); } }, true); }, false); } #endif }
private async void Example2() { //<ReportFulfillment> FulfillmentResult result = await CurrentAppSimulator.ReportConsumableFulfillmentAsync( "product2", product2TempTransactionId); //</ReportFulfillment> }
private IAsyncOperation <FulfillmentResult> ReportConsumableFulfillmentAsync(string productId, Guid transactionId) { if (_useSimulator) { return(CurrentAppSimulator.ReportConsumableFulfillmentAsync(productId, transactionId)); } else { return(CurrentApp.ReportConsumableFulfillmentAsync(productId, transactionId)); } }
private async void ReportFulfillment() { ListingInformation listing = await CurrentAppSimulator.LoadListingInformationAsync(); var product1 = listing.ProductListings["product1"]; string product1ListingName = string.Empty; string productId = product1.ProductId; Guid transactionId = new Guid(); //<ReportFulfillment> string offerId = "1234"; product1ListingName = product1.Name; string displayPropertiesName = "MusicOffer1"; if (String.IsNullOrEmpty(displayPropertiesName)) { displayPropertiesName = product1ListingName; } var offerIdMsg = " with offer id " + offerId; if (String.IsNullOrEmpty(offerId)) { offerIdMsg = " with no offer id"; } FulfillmentResult result = await CurrentAppSimulator.ReportConsumableFulfillmentAsync(productId, transactionId); switch (result) { case FulfillmentResult.Succeeded: Log("You bought and fulfilled " + displayPropertiesName + offerIdMsg); break; case FulfillmentResult.NothingToFulfill: Log("There is no purchased product 1 to fulfill."); break; case FulfillmentResult.PurchasePending: Log("You bought product 1. The purchase is pending so we cannot fulfill the product."); break; case FulfillmentResult.PurchaseReverted: Log("You bought product 1. But your purchase has been reverted."); // Since the user' s purchase was revoked, they got their money back. // You may want to revoke the user' s access to the consumable content that was granted. break; case FulfillmentResult.ServerError: Log("You bought product 1. There was an error when fulfilling."); break; } //</ReportFulfillment> }
private async void FulfillProduct(string productId, PurchaseResults purchaseResults) { string itemDescription = product1ListingName + BuildOfferStringForDisplay(purchaseResults.OfferId); string purchaseStringSimple = "You bought " + itemDescription + "."; if (purchaseResults.Status == ProductPurchaseStatus.NotFulfilled) { purchaseStringSimple = "You already purchased " + itemDescription + "."; } try { FulfillmentResult result = await CurrentAppSimulator.ReportConsumableFulfillmentAsync(productId, purchaseResults.TransactionId); switch (result) { case FulfillmentResult.Succeeded: if (purchaseResults.Status == ProductPurchaseStatus.NotFulfilled) { rootPage.NotifyUser("You already purchased " + itemDescription + " and it was just fulfilled.", NotifyType.StatusMessage); } else { rootPage.NotifyUser("You bought and fulfilled " + itemDescription, NotifyType.StatusMessage); } break; case FulfillmentResult.NothingToFulfill: rootPage.NotifyUser("There is no purchased product 1 to fulfill with that transaction id.", NotifyType.StatusMessage); break; case FulfillmentResult.PurchasePending: rootPage.NotifyUser(purchaseStringSimple + " The purchase is pending so we cannot fulfill the product.", NotifyType.StatusMessage); break; case FulfillmentResult.PurchaseReverted: rootPage.NotifyUser(purchaseStringSimple + " But your purchase has been reverted.", NotifyType.StatusMessage); // Since the user's purchase was revoked, they got their money back. // You may want to revoke the user's access to the consumable content that was granted. break; case FulfillmentResult.ServerError: rootPage.NotifyUser(purchaseStringSimple + " There was an error when fulfilling.", NotifyType.StatusMessage); break; } } catch (Exception) { rootPage.NotifyUser(purchaseStringSimple + " There was an error when fulfilling.", NotifyType.ErrorMessage); } }
public static IAsyncOperation <FulfillmentResult> ReportConsumableFulfillmentAsync(string productId, Guid transactionId) { if (testmode == null) { throw new NotSupportedException(); } else if (testmode.Value) { return(CurrentAppSimulator.ReportConsumableFulfillmentAsync(productId, transactionId)); } else { return(CurrentApp.ReportConsumableFulfillmentAsync(productId, transactionId)); } }
public static void ReportConsumableFulfillment(string productId, Guid transactionId, Action <CallbackResponse <FulfillmentResult> > OnReportConsumableFulfillmentFinished) { Utils.RunOnWindowsUIThread(async() => { Windows.ApplicationModel.Store.FulfillmentResult result = Windows.ApplicationModel.Store.FulfillmentResult.ServerError; try { if (_isLicenseSimulationOn) { result = await CurrentAppSimulator.ReportConsumableFulfillmentAsync(productId, transactionId); } else { result = await CurrentApp.ReportConsumableFulfillmentAsync(productId, transactionId); } } catch (Exception ex) { DebugLog.Log(LogLevel.Error, "Error while reporting consumable fulfillment " + ex.ToString()); Utils.RunOnUnityAppThread(() => { if (OnReportConsumableFulfillmentFinished != null) { OnReportConsumableFulfillmentFinished(new CallbackResponse <FulfillmentResult> { Status = CallbackStatus.Failure, Exception = ex, Result = FulfillmentResult.ServerError }); } }); return; } // This should not really be throwing exceptions.. If it does, they will be raised on the Unity thread anyways, so game should handle it Utils.RunOnUnityAppThread(() => { if (OnReportConsumableFulfillmentFinished != null) { OnReportConsumableFulfillmentFinished( new CallbackResponse <FulfillmentResult> { Result = (Microsoft.UnityPlugins.FulfillmentResult)result, Exception = null, Status = CallbackStatus.Success }); } }); }); }
private async void FulfillProduct(ProductPurchaseInfo info) { if (!IsLocallyFulfilled(info, info.tempTransactionId)) { GrantFeatureLocally(info, info.tempTransactionId); } try { FulfillmentResult result = await CurrentAppSimulator.ReportConsumableFulfillmentAsync(info.productId, info.tempTransactionId); switch (result) { case FulfillmentResult.Succeeded: info.numFulfillments++; rootPage.NotifyUser(info.nameRun.Text + " was fulfilled. You are now able to buy another one.", NotifyType.StatusMessage); break; case FulfillmentResult.NothingToFulfill: rootPage.NotifyUser("There is nothing to fulfill. You must purchase " + info.nameRun.Text + " before it can be fulfilled.", NotifyType.StatusMessage); break; case FulfillmentResult.PurchasePending: rootPage.NotifyUser("Purchase hasn't completed yet. Wait and try again.", NotifyType.StatusMessage); break; case FulfillmentResult.PurchaseReverted: rootPage.NotifyUser("Purchase was reverted before fulfillment.", NotifyType.StatusMessage); // Since the user's purchase was revoked, they got their money back. // You may want to revoke the user's access to the consumable content that was granted. break; case FulfillmentResult.ServerError: rootPage.NotifyUser("There was an error when fulfilling.", NotifyType.StatusMessage); break; } } catch (Exception) { rootPage.NotifyUser("There was an error when fulfilling.", NotifyType.ErrorMessage); } UpdateStatistics(); }
private async void FulfillProduct2Button_Click(object sender, RoutedEventArgs e) { if (!IsLocallyFulfilled("product2", product2TempTransactionId)) { GrantFeatureLocally("product2", product2TempTransactionId); } try { FulfillmentResult result = await CurrentAppSimulator.ReportConsumableFulfillmentAsync("product2", product2TempTransactionId); switch (result) { case FulfillmentResult.Succeeded: product2NumFulfillments++; Log("Product 2 was fulfilled. You are now able to buy product 2 again.", NotifyType.StatusMessage); break; case FulfillmentResult.NothingToFulfill: Log("There is nothing to fulfill. You must purchase product 2 before it can be fulfilled.", NotifyType.StatusMessage); break; case FulfillmentResult.PurchasePending: Log("Purchase hasn't completed yet. Wait and try again.", NotifyType.StatusMessage); break; case FulfillmentResult.PurchaseReverted: Log("Purchase was reverted before fulfillment.", NotifyType.StatusMessage); // Since the user's purchase was revoked, they got their money back. // You may want to revoke the user's access to the consumable content that was granted. break; case FulfillmentResult.ServerError: Log("There was an error when fulfilling.", NotifyType.StatusMessage); break; } } catch (Exception) { Log("There was an error when fulfilling.", NotifyType.ErrorMessage); } }
private IAsyncOperation <bool> FulfillProductInternal(Guid transactionId) { return(AsyncInfo.Run(async cancellationToken => { try { #if DEBUG FulfillmentResult result = await CurrentAppSimulator.ReportConsumableFulfillmentAsync("Credits", transactionId); #else FulfillmentResult result = await CurrentApp.ReportConsumableFulfillmentAsync("Credits", transactionId); Analytics.TrackEvent("credits.fulfillement", new Dictionary <string, string> { ["result"] = result.ToString() }); #endif switch (result) { case FulfillmentResult.Succeeded: return true; case FulfillmentResult.NothingToFulfill: return true; case FulfillmentResult.PurchasePending: return true; case FulfillmentResult.PurchaseReverted: return true; case FulfillmentResult.ServerError: return true; default: return false; } } catch (Exception) { return false; } })); }
private async void FulfillProduct1(string productId, Guid transactionId) { try { FulfillmentResult result = await CurrentAppSimulator.ReportConsumableFulfillmentAsync(productId, transactionId); switch (result) { case FulfillmentResult.Succeeded: Log("You bought and fulfilled product 1.", NotifyType.StatusMessage); break; case FulfillmentResult.NothingToFulfill: Log("There is no purchased product 1 to fulfill.", NotifyType.StatusMessage); break; case FulfillmentResult.PurchasePending: Log("You bought product 1. The purchase is pending so we cannot fulfill the product.", NotifyType.StatusMessage); break; case FulfillmentResult.PurchaseReverted: Log("You bought product 1. But your purchase has been reverted.", NotifyType.StatusMessage); // Since the user's purchase was revoked, they got their money back. // You may want to revoke the user's access to the consumable content that was granted. break; case FulfillmentResult.ServerError: Log("You bought product 1. There was an error when fulfilling.", NotifyType.StatusMessage); break; } } catch (Exception) { Log("You bought Product 1. There was an error when fulfilling.", NotifyType.ErrorMessage); } }
public static async Task <FulfillmentResult> ReportConsumableFulfillmentAsync(bool isTestingMode, string productId, Guid transactionId) { return(isTestingMode ? await CurrentAppSimulator.ReportConsumableFulfillmentAsync(productId, transactionId) : await CurrentApp.ReportConsumableFulfillmentAsync(productId, transactionId)); }
public IAsyncOperation <FulfillmentResult> ReportConsumableFulfillmentAsync(string productId, Guid transactionId) { return(CurrentAppSimulator.ReportConsumableFulfillmentAsync(productId, transactionId)); }
private async void FulfillProduct1(string productId, PurchaseResults purchaseResults) { string displayPropertiesName = DisplayPropertiesNameTextBox.Text; if (String.IsNullOrEmpty(displayPropertiesName)) { displayPropertiesName = product1ListingName; } string offerIdMsg = " with offer id " + purchaseResults.OfferId; if (String.IsNullOrEmpty(purchaseResults.OfferId)) { offerIdMsg = " with no offer id"; } string purchaseStringSimple = "You bought product 1."; if (purchaseResults.Status == ProductPurchaseStatus.NotFulfilled) { purchaseStringSimple = "You already purchased product 1."; } try { FulfillmentResult result = await CurrentAppSimulator.ReportConsumableFulfillmentAsync(productId, purchaseResults.TransactionId); switch (result) { case FulfillmentResult.Succeeded: if (purchaseResults.Status == ProductPurchaseStatus.NotFulfilled) { Log("You already purchased " + product1ListingName + offerIdMsg + " and it was just fulfilled.", NotifyType.StatusMessage); } else { Log("You bought and fulfilled " + displayPropertiesName + offerIdMsg, NotifyType.StatusMessage); } break; case FulfillmentResult.NothingToFulfill: Log("There is no purchased product 1 to fulfill with that transaction id.", NotifyType.StatusMessage); break; case FulfillmentResult.PurchasePending: Log(purchaseStringSimple + " The purchase is pending so we cannot fulfill the product.", NotifyType.StatusMessage); break; case FulfillmentResult.PurchaseReverted: Log(purchaseStringSimple + " But your purchase has been reverted.", NotifyType.StatusMessage); // Since the user's purchase was revoked, they got their money back. // You may want to revoke the user's access to the consumable content that was granted. break; case FulfillmentResult.ServerError: Log(purchaseStringSimple + " There was an error when fulfilling.", NotifyType.StatusMessage); break; } } catch (Exception) { Log(purchaseStringSimple + " There was an error when fulfilling.", NotifyType.ErrorMessage); } }
ReportConsumableFulfillmentAsync(string productId, Guid transactionId) { return(IsMockEnabled ? CurrentAppSimulator.ReportConsumableFulfillmentAsync(productId, transactionId) : CurrentApp.ReportConsumableFulfillmentAsync(productId, transactionId)); }