libgdx / gdx-pay

A libGDX cross-platform API for InApp purchasing.
Apache License 2.0
224 stars 83 forks source link

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

Open xfwang515 opened 3 years ago

xfwang515 commented 3 years ago

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?

MrStahlfelge commented 3 years ago

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

Trurl101 commented 3 years ago

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)
MrStahlfelge commented 3 years ago

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