Java 类com.badlogic.gdx.pay.OfferType 实例源码

项目:gdx-pay    文件:AndroidGooglePlayPurchaseManager.java   
@Override
public void purchaseRestore() {

    try {
        List<Transaction> transactions = googleInAppBillingService.getPurchases();
        Array<Transaction> entitlements = new Array<>(Transaction.class);
        for (int i = 0; i < transactions.size(); i++) {
            Transaction transaction = transactions.get(i);
            if (OfferType.CONSUMABLE == getOfferType(transaction.getIdentifier())) {
                googleInAppBillingService.consumePurchase(transaction, observer);
            } else {
                entitlements.add(transaction);
            }
        }


        if (observer != null) {
            observer.handleRestore(entitlements.toArray());
        }
    } catch (GdxPayException e) {
        if (observer != null) {
            observer.handleRestoreError(e);
        }
    }
}
项目:space-travels-3    文件:AndroidServices.java   
@Override
protected PurchaseManagerConfig getPurchaseManagerConfig()
{
    PurchaseManagerConfig purchaseManagerConfig = new PurchaseManagerConfig();

    for (LevelPack levelPack : LevelManager.getLevelPacks())
    {
        if (!levelPack.isFree())
        {
            Offer offer = new Offer();
            offer
                .setType(OfferType.ENTITLEMENT)
                .setIdentifier(levelPack.getGoogleSku());
            offer.putIdentifierForStore(
                PurchaseManagerConfig.STORE_NAME_ANDROID_GOOGLE,
                levelPack.getGoogleSku());
            purchaseManagerConfig.addOffer(offer);
        }
    }

    String key = PhysicsComponent.s(com.draga.shape.Circle.s(
        GraphicComponent.s(Circle.s)
            + MenuScreen.s(IngameMenuScreen.s, -3)
            + GraphicComponent.s(HudScreen.s)
            + MenuScreen.s(DeadZoneInputModifier.s, 4)
            + GraphicComponent.s(Joystick.s)));
    purchaseManagerConfig.addStoreParam(
        PurchaseManagerConfig.STORE_NAME_ANDROID_GOOGLE,
        key);

    return purchaseManagerConfig;
}
项目:gdx-pay    文件:AndroidGooglePlayPurchaseManager.java   
private void getPurchaseIdsByType(List<String> inAppPurchasesIds, List<String> subsPurchasesIds) {
    for (int i = 0; i < purchaseManagerConfig.getOfferCount(); i++) {
        Offer offer = purchaseManagerConfig.getOffer(i);
        if (offer.getType().equals(OfferType.SUBSCRIPTION))
            subsPurchasesIds.add(offer.getIdentifier());
        else
            inAppPurchasesIds.add(offer.getIdentifier());
    }
}
项目:gdx-pay    文件:AndroidGooglePlayPurchaseManager.java   
private OfferType getOfferType(String identifier) {
    Offer offer = purchaseManagerConfig.getOffer(identifier);
    if (offer == null || offer.getType() == null) {
        throw new IllegalStateException("No offer or offerType configured for identifier: " + identifier + ", offer: " + offer);
    }

    return offer.getType();
}
项目:gdx-pay    文件:PurchaseManagerAndroidOpenIAB.java   
private List<String> getIdsForEntitlementsAndConsumables() {
    final List<String> result = new ArrayList<String>();
    final int offerCount = config.getOfferCount();
    for (int i = 0; i < offerCount; i++) {
        Offer offer = config.getOffer(i);
        if (offer.getType() == OfferType.ENTITLEMENT || offer.getType() == OfferType.CONSUMABLE) {
            result.add(offer.getIdentifier());
        }
    }
    return result;
}
项目:gdx-pay    文件:PurchaseManagerAndroidOpenIAB.java   
private List<String> getIdsForSubscriptions() {
    final List<String> result = new ArrayList<String>();
    final int offerCount = config.getOfferCount();
    for (int i = 0; i < offerCount; i++) {
        Offer offer = config.getOffer(i);
        if (offer.getType() == OfferType.SUBSCRIPTION) {
            result.add(offer.getIdentifier());
        }
    }
    return result;
}
项目:gdx-pay    文件:AndroidGooglePlayPurchaseManager.java   
@Override
public void purchase(final String identifier) {
    assertInstalled();
    final OfferType offerType = getOfferType(identifier);

    googleInAppBillingService.startPurchaseRequest(identifier, OfferToInAppPurchaseConverter.convertOfferType(offerType), new PurchaseRequestCallback() {
        @Override
        public void purchaseSuccess(Transaction transaction) {
            if (observer != null) {
                switch (offerType) {
                    case CONSUMABLE:
                        // Warning: observer.handlePurchase is called in googleInAppBillingService.consumePurchase.
                        // That is not clean, I would prefer to keep it on one place.
                        // Should be refactored later.
                        googleInAppBillingService.consumePurchase(transaction, observer);
                        break;
                    case ENTITLEMENT:
                    case SUBSCRIPTION:
                        observer.handlePurchase(transaction);
                        break;
                    default:
                        String error = "Unsupported OfferType=" + getOfferType(identifier)
                                + " for identifier=" + identifier;
                        throw new GdxPayException(error);
                }
            }
        }

        @Override
        public void purchaseError(GdxPayException exception) {
            if (observer != null) {
                observer.handlePurchaseError(exception);
            }

        }

        @Override
        public void purchaseCanceled() {
            if (observer != null) {
                observer.handlePurchaseCanceled();
            }
        }
    });
}
项目:gdx-pay    文件:OfferToInAppPurchaseConverter.java   
static public  String convertOfferType(OfferType offerType ) {
    if (offerType.equals(OfferType.SUBSCRIPTION))
        return PURCHASE_TYPE_SUBSCRIPTION;

    return PURCHASE_TYPE_IN_APP;
}
项目:gdx-pay    文件:OfferObjectMother.java   
public static Offer offerFullEditionEntitlement() {
    Offer offer = new Offer();
    offer.setIdentifier(PRODUCT_IDENTIFIER_FULL_EDITION);
    offer.setType(OfferType.ENTITLEMENT);
    return offer;
}
项目:gdx-pay    文件:OfferObjectMother.java   
public static Offer offerSubscription() {
    Offer offer = new Offer();
    offer.setIdentifier("com.appname.subscription");
    offer.setType(OfferType.SUBSCRIPTION);
    return offer;
}
项目:gdx-pay    文件:OfferObjectMother.java   
public static Offer offerConsumable() {
    Offer offer = new Offer();
    offer.setIdentifier("com.appname.consumable.100.coins");
    offer.setType(OfferType.CONSUMABLE);
    return offer;
}