libgdx/gdx-pay

PurchaseManager does not support consumables and subscriptions at the same time.

xfwang515 opened this issue · 3 comments

List offers = new ArrayList<>();
offers.add(new Offer().setType(OfferType.CONSUMABLE).setIdentifier(BuyCoinType.coins1.produceId));
offers.add(new Offer().setType(OfferType.CONSUMABLE).setIdentifier(BuyCoinType.coins2.produceId));
offers.add(new Offer().setType(OfferType.CONSUMABLE).setIdentifier(BuyCoinType.coins3.produceId));

offers.add(new Offer().setType(OfferType.SUBSCRIPTION).setIdentifier(BuyCoinType.weekly.produceId));
offers.add(new Offer().setType(OfferType.SUBSCRIPTION).setIdentifier(BuyCoinType.monthly.produceId));
offers.add(new Offer().setType(OfferType.SUBSCRIPTION).setIdentifier(BuyCoinType.yearly.produceId));

//
throw new IllegalStateException("Cannot support OfferType Subscription and other types in the same app");

What should I do if there are both "consumables" and "subscriptions" in the game?

Either use two purchase managers, or for the repo, enhance the framework and open a PR contributing your changes.

Its relatively easy to use two Purchase managers. I tried it with one of my apps last year and it works fine (and people on mobile seems to like subscriptions).

Anyway I think it should be reflected in the readme and wiki that you can not have both pay models with one Purchase Manager because here the readme suggest the opposite:

PurchaseManagerConfig pmc = new PurchaseManagerConfig();
pmc.addOffer(new Offer().setType(OfferType.ENTITLEMENT).setIdentifier(YOUR_ITEM_SKU));
pmc.addOffer(new Offer().setType(OfferType.CONSUMABLE).setIdentifier(YOUR_ITEM_SKU));
pmc.addOffer(new Offer().setType(OfferType.SUBSCRIPTION).setIdentifier(YOUR_ITEM_SKU));
// some payment services might need special parameters, see documentation
pmc.addStoreParam(storename, param)

If you have a good suggestion what to add where to the wiki, I'll be happy to add it!