Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Play Billing Library: Update from v5.2.1 to v7.0.0 #67

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion GodotGooglePlayBilling.gdap
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ binary_type="local"
binary="GodotGooglePlayBilling.1.2.0.release.aar"

[dependencies]
remote=["com.android.billingclient:billing:5.2.1"]
remote=["com.android.billingclient:billing:7.0.0"]
2 changes: 1 addition & 1 deletion godot-google-play-billing/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ android {

dependencies {
implementation "androidx.legacy:legacy-support-v4:1.0.0"
implementation 'com.android.billingclient:billing:5.2.1'
implementation 'com.android.billingclient:billing:7.0.0'
compileOnly fileTree(dir: 'libs', include: ['godot-lib*.aar'])
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@
import com.android.billingclient.api.BillingResult;
import com.android.billingclient.api.ConsumeParams;
import com.android.billingclient.api.ConsumeResponseListener;
import com.android.billingclient.api.PriceChangeConfirmationListener;
import com.android.billingclient.api.PriceChangeFlowParams;
import com.android.billingclient.api.PendingPurchasesParams;
import com.android.billingclient.api.Purchase;
import com.android.billingclient.api.PurchasesResponseListener;
import com.android.billingclient.api.PurchasesUpdatedListener;
Expand All @@ -63,7 +62,7 @@
import java.util.List;
import java.util.Set;

public class GodotGooglePlayBilling extends GodotPlugin implements PurchasesUpdatedListener, BillingClientStateListener, PriceChangeConfirmationListener {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PriceChangeConfirmationListener is deprecated

public class GodotGooglePlayBilling extends GodotPlugin implements PurchasesUpdatedListener, BillingClientStateListener {

private final BillingClient billingClient;
private final HashMap<String, SkuDetails> skuDetailsCache = new HashMap<>(); // sku → SkuDetails
Expand All @@ -74,9 +73,12 @@ public class GodotGooglePlayBilling extends GodotPlugin implements PurchasesUpda
public GodotGooglePlayBilling(Godot godot) {
super(godot);

PendingPurchasesParams pendingPurchasesParams =
PendingPurchasesParams.newBuilder().enableOneTimeProducts().build();

billingClient = BillingClient
.newBuilder(getActivity())
.enablePendingPurchases()
.enablePendingPurchases(pendingPurchasesParams)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enablePendingPurchases is deprecated: This method is equivalent to enablePendingPurchases(PendingPurchasesParams.newBuilder().enableOneTimeProducts().build())

.setListener(this)
.build();
calledStartConnection = false;
Expand Down Expand Up @@ -203,11 +205,6 @@ public Dictionary confirmPriceChange(String sku) {
}

SkuDetails skuDetails = skuDetailsCache.get(sku);

PriceChangeFlowParams priceChangeFlowParams =
PriceChangeFlowParams.newBuilder().setSkuDetails(skuDetails).build();

billingClient.launchPriceChangeConfirmationFlow(getActivity(), priceChangeFlowParams, this);
Comment on lines -207 to -210
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PriceChangeFlowParams is deprecated


Dictionary returnValue = new Dictionary();
returnValue.put("status", 0); // OK = 0
Expand All @@ -216,14 +213,14 @@ public Dictionary confirmPriceChange(String sku) {
@UsedByGodot
public Dictionary purchase(String sku) {
return purchaseInternal("", sku,
BillingFlowParams.ProrationMode.UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY);
BillingFlowParams.SubscriptionUpdateParams.ReplacementMode.UNKNOWN_REPLACEMENT_MODE);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ProrationMode is deprecated: use SubscriptionUpdateParams.ReplacementMode instead

}
@UsedByGodot
public Dictionary updateSubscription(String oldToken, String sku, int prorationMode) {
return purchaseInternal(oldToken, sku, prorationMode);
public Dictionary updateSubscription(String oldToken, String sku, int replacementMode) {
return purchaseInternal(oldToken, sku, replacementMode);
Comment on lines +219 to +220
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the comment above

}

private Dictionary purchaseInternal(String oldToken, String sku, int prorationMode) {
private Dictionary purchaseInternal(String oldToken, String sku, int replacementMode) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the comment above

if (!skuDetailsCache.containsKey(sku)) {
Dictionary returnValue = new Dictionary();
returnValue.put("status", 1); // FAILED = 1
Expand All @@ -241,11 +238,11 @@ private Dictionary purchaseInternal(String oldToken, String sku, int prorationMo
if (!obfuscatedProfileId.isEmpty()) {
purchaseParamsBuilder.setObfuscatedProfileId(obfuscatedProfileId);
}
if (!oldToken.isEmpty() && prorationMode != BillingFlowParams.ProrationMode.UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY) {
if (!oldToken.isEmpty() && replacementMode != BillingFlowParams.SubscriptionUpdateParams.ReplacementMode.UNKNOWN_REPLACEMENT_MODE) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the comment above

BillingFlowParams.SubscriptionUpdateParams updateParams =
BillingFlowParams.SubscriptionUpdateParams.newBuilder()
.setOldSkuPurchaseToken(oldToken)
.setReplaceSkusProrationMode(prorationMode)
.setOldPurchaseToken(oldToken)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From here: Removed BillingFlowParams.SubscriptionUpdateParams.Builder#setOldSkuPurchaseToken(). Developers should use BillingFlowParams.SubscriptionUpdateParams.Builder#setOldPurchaseToken(java.lang.String) instead.

.setSubscriptionReplacementMode(replacementMode)
Copy link
Author

@kus04e4ek kus04e4ek Jul 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.build();
purchaseParamsBuilder.setSubscriptionUpdateParams(updateParams);
}
Expand Down Expand Up @@ -280,11 +277,6 @@ public void onPurchasesUpdated(final BillingResult billingResult, @Nullable fina
}
}

@Override
public void onPriceChangeConfirmationResult(BillingResult billingResult) {
emitSignal("price_change_acknowledged", billingResult.getResponseCode());
}
Comment on lines -283 to -286
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onPriceChangeConfirmationResult is a method from PriceChangeConfirmationListener, which is deprecated


@Override
public void onMainResume() {
if (calledStartConnection) {
Expand Down