UnityIAP Android не удалось совершить покупку
Я пытаюсь разработать систему для Android-покупки в приложении. Если я использую одно устройство, я смогу хорошо интегрировать систему. Когда пользователь покупает элемент noConsumible и переустанавливает приложение, этот элемент предоставляется.
Проблема становится при использовании другого устройства с таким же аккаунтом. При совершении покупки на одном устройстве другое не может обнаружить покупку при повторном запуске или переустановке приложения и отображать следующее сообщение "Элемент уже был в собственности", но я не могу отловить эту ошибку и выдать элемент.
- Шаги, чтобы следовать:
- Установите приложение на устройстве A
- Купить не расходуемый предмет на устройстве A
- Установите приложение на deice B
- Проверить пункт "Нет" на устройстве B
- Купить не расходуемый предмет на устройстве B
- Перезапустить приложение на устройстве A
- Проверить пункт "Нет" на устройстве А не выдан
Код:
private void initializeUnityIAP()
{
if (IStoreListener != null && IStoreListener.IsUnityIAPInicialized())
{
return;
}
// Create a builder, first passing in a suite of Unity provided stores.
var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
//Configure google play
builder.Configure<IGooglePlayConfiguration>().SetPublicKey(GOOGLE_PLAY_KEY);
// Adding currency pack
foreach (VirtualCurrencyPack currencyPack in storeAssets.packs)
{
builder.AddProduct(currencyPack.id, ProductType.Consumable, new IDs() {
{ currencyPack.id, AppleAppStore.Name },
{ currencyPack.id, GooglePlay.Name },
});
}
// Adding offers
foreach (VirtualOffer virtualOffer in storeAssets.offers)
{
builder.AddProduct(virtualOffer.id, ProductType.NonConsumable, new IDs() {
{ virtualOffer.id, AppleAppStore.Name },
{ virtualOffer.id, GooglePlay.Name },
});
}
IStoreListener = new AxesBillingStoreListener();
UnityPurchasing.Initialize(IStoreListener, builder);
}
public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
{
m_StoreController = controller;
m_StoreExtensionProvider = extensions;
foreach (var item in controller.products.all)
{
//Product is available
if (item.availableToPurchase)
{
// Update definition data product
AxesBillingManager.instance.GetElementById(item.definition.id).purchaseType.amount = (double)(item.metadata.localizedPrice);
AxesBillingManager.instance.GetElementById(item.definition.id).purchaseType.currencyCode = item.metadata.isoCurrencyCode;
// Product was purchase
if (item.hasReceipt)
{
VirtualObject element = AxesBillingManager.instance.GetElementById(item.definition.id);
element.Give(element.amountToGive);
}
}
else
{
//Product is not available in store
AxesBillingManager.instance.GetElementById(item.definition.id).isAvailableInGoogleStore = false;
}
}
}
Может кто-нибудь мне помочь?