アプリ内購入用にこのコードを持っています
string receipt = await Store.CurrentApp.RequestProductPurchaseAsync(pID, false);
ドキュメントには、このメソッドは次の場合でも成功値を返すと記載されています。
there's no network connection available
the user cancels out of the dialog
the user's authentication fails
You should treat a success result as indicating the async process completed without
errors. To ensure that the transaction itself was successful, check the
LicenseInformation element in the returned receipt.
購入機能のロックを解除する前に、特定のアイテムの受領が実際に成功したことを確認する簡単な方法はありますか? 現在、エラーがなければ、領収書が検証されていないため、機能は常にロック解除されます。
私のコード:
private async void inAppPurchase(string key)
{
if (!Store.CurrentApp.LicenseInformation.ProductLicenses[key].IsActive)
{
try
{
// The customer doesn't own this feature, so
// show the purchase dialog.
MockIAPLib.ListingInformation li = await Store.CurrentApp.LoadListingInformationAsync();
string pID = li.ProductListings[key].ProductId;
//purchase successful
string receipt = await Store.CurrentApp.RequestProductPurchaseAsync(pID, false);
//Check the receipt for
switch (key)
{
case "IsAdsVisibleSetting":
settings.IsAdsVisibleSetting = false;
break;
case "style_2":
fontFolder[key] = true;
settings.AllowedFontSetting = fontFolder;
break;
case "backgrounds_2":
backgroundGroups[key] = true;
settings.AllowedBackgroundGroupsSetting = backgroundGroups;
break;
case "backgrounds_3":
backgroundGroups[key] = true;
settings.AllowedBackgroundGroupsSetting = backgroundGroups;
break;
}
RenderStoreItems();
}
catch (Exception)
{
MessageBox.Show("Sorry, the in-app purchase was not completed because an error occurred.", "Purchasing Error", MessageBoxButton.OK);
}
}
}