Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ allprojects {
tasks.withType(Sign) {
onlyIf { isReleaseBuild() }
}

tasks.withType(JavaCompile) {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}

if (JavaVersion.current().isJava8Compatible()) {
Expand All @@ -112,4 +117,4 @@ if (JavaVersion.current().isJava8Compatible()) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}
}
2 changes: 1 addition & 1 deletion gdx-pay-android-googlebilling/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ configurations {

dependencies {
api project(':gdx-pay-client')
api "com.android.billingclient:billing:6.0.1"
api "com.android.billingclient:billing:8.0.0"

testImplementation libraries.junit
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.app.Activity;
import android.os.Handler;
import android.os.Looper;
import androidx.annotation.NonNull;
import com.android.billingclient.api.*;
import com.android.billingclient.api.BillingClient.ProductType;
import com.badlogic.gdx.Gdx;
Expand Down Expand Up @@ -44,8 +45,15 @@ public class PurchaseManagerGoogleBilling implements PurchaseManager, PurchasesU

public PurchaseManagerGoogleBilling(Activity activity) {
this.activity = activity;
mBillingClient = BillingClient.newBuilder(activity).setListener(this)
.enablePendingPurchases().build();
PendingPurchasesParams params = PendingPurchasesParams.newBuilder()
.enableOneTimeProducts()
.enablePrepaidPlans()
.build();

mBillingClient = BillingClient.newBuilder(activity)
.setListener(this)
.enablePendingPurchases(params)
.build();
}

@Override
Expand Down Expand Up @@ -155,7 +163,8 @@ private void fetchOfferDetails() {
mBillingClient.queryProductDetailsAsync(
params,
new ProductDetailsResponseListener() {
public void onProductDetailsResponse(@Nonnull BillingResult billingResult, @Nonnull List<ProductDetails> productDetailsList) {
@Override
public void onProductDetailsResponse(@NonNull BillingResult billingResult, @NonNull QueryProductDetailsResult productDetailsResult) {
int responseCode = billingResult.getResponseCode();
// it might happen that this was already disposed until the response comes back
if (observer == null || Gdx.app == null)
Expand All @@ -166,12 +175,11 @@ public void onProductDetailsResponse(@Nonnull BillingResult billingResult, @Nonn
if (!installationComplete) {
observer.handleInstallError(new FetchItemInformationException(String.valueOf(responseCode)));
}

} else {
Gdx.app.debug(TAG,"Retrieved product count: " + productDetailsList.size());
List<ProductDetails> productDetailsList = productDetailsResult.getProductDetailsList();
Gdx.app.debug(TAG,"Retrieved product count: " + productDetailsList.size());
for (ProductDetails productDetails : productDetailsList) {
informationMap.put(productDetails.getProductId(), convertProductDetailsToInformation
(productDetails));
informationMap.put(productDetails.getProductId(), convertProductDetailsToInformation(productDetails));
productDetailsMap.put(productDetails.getProductId(), productDetails);
}

Expand Down Expand Up @@ -231,7 +239,7 @@ private void convertSubscriptionProductToInformation(Information.Builder builder
.priceCurrencyCode(paidForPricingPhase.getPriceCurrencyCode())
.priceInCents((int) paidForPricingPhase.getPriceAmountMicros() / 10_000)
.priceAsDouble(paidForPricingPhase.getPriceAmountMicros() / 1_000_000.0)
;
;

ProductDetails.PricingPhase freeTrialSubscriptionPhase = getFreeTrialSubscriptionPhase(details.getPricingPhases());

Expand All @@ -248,9 +256,9 @@ private ProductDetails.SubscriptionOfferDetails getActiveSubscriptionOfferDetail
@Nullable
private ProductDetails.PricingPhase getPaidRecurringPricingPhase(ProductDetails.SubscriptionOfferDetails details) {
for(ProductDetails.PricingPhase phase : details.getPricingPhases().getPricingPhaseList()) {
if (isPaidForSubscriptionPhase(phase)) {
return phase;
}
if (isPaidForSubscriptionPhase(phase)) {
return phase;
}
}
return null;
}
Expand Down Expand Up @@ -374,7 +382,7 @@ protected BillingFlowParams.Builder getBillingFlowParams(ProductDetails productD
Gdx.app.error(TAG, "subscriptionOfferDetails are empty for product: " + productDetails);
offerToken = null;
} else {
offerToken = getActiveSubscriptionOfferDetails(subscriptionOfferDetails) // HOW TO SPECIFY AN ALTERNATE OFFER USING gdx-pay?
offerToken = getActiveSubscriptionOfferDetails(subscriptionOfferDetails) // HOW TO SPECIFY AN ALTERNATE OFFER USING gdx-pay?
.getOfferToken();
}

Expand Down Expand Up @@ -510,4 +518,4 @@ public void onAcknowledgePurchaseResponse(@Nonnull BillingResult billingResult)
if (fromRestore)
observer.handleRestore(transactions.toArray(new Transaction[0]));
}
}
}
Loading