Reputation: 757
I created an App added In-App Purchase and uploaded it as beta for testing.
Here is the Code for In-App Purchase.
Private async void Purchase()
{
LicenseInformation licenseInformation = CurrentApp.LicenseInformation;
string str;
try
{
var listing = await CurrentApp.LoadListingInformationAsync();
var _price = listing.FormattedPrice;
// start product purchase
await CurrentApp.RequestProductPurchaseAsync("FeatureName", false);
ProductLicense productLicense = null;
if (CurrentApp.LicenseInformation.ProductLicenses.TryGetValue("FeatureName", out productLicense))
{
if (productLicense.IsActive)
{
MessageBox.Show("Product purchased");
CurrentApp.ReportProductFulfillment("FeatureName");
ProductPurchased(); // It display product purchased & trigger full version
return;
}
else
{
str = "Purchase failed";
ShowErrorPopup(str); // It shows error msg. purchase failed.
return;
}
}
}
catch (Exception)
{
str = "Purchase failed. Check internet connection and try again";
ShowErrorPopup(str);
return;
}
}
While installed the beta build I clicked the purchase button. I goes to the purchase point.
It asks for install or cancel.
By giving install or cancel will kills the app.
What is the mistake i did. Someone help to solve this????
Upvotes: 0
Views: 469
Reputation: 4635
What I've done in the past is created a Mock In-App Purchase project in my solution to test this out before-hand. Check out my answer here for more details. It basically lets you set up your in app purchases to work while debugging, and then seamlessly work from the store as well.
You basically set up all your in-app purchase items in the Mock Library, but only use it when debugging. When not debugging, use the real store:
#if DEBUG
using MockIAPLib;
using Store = MockIAPLib;
#else
using Windows.ApplicationModel.Store;
#endif
This way - you'll be able to step through your code and find out why the app is crashing. In addition to catching "crash reports" - check out Little Watson, I've implemented this and it works great as well!
Hope this helps!
Upvotes: 2