-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -63,7 +62,7 @@ | |
import java.util.List; | ||
import java.util.Set; | ||
|
||
public class GodotGooglePlayBilling extends GodotPlugin implements PurchasesUpdatedListener, BillingClientStateListener, PriceChangeConfirmationListener { | ||
public class GodotGooglePlayBilling extends GodotPlugin implements PurchasesUpdatedListener, BillingClientStateListener { | ||
|
||
private final BillingClient billingClient; | ||
private final HashMap<String, SkuDetails> skuDetailsCache = new HashMap<>(); // sku → SkuDetails | ||
|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
.setListener(this) | ||
.build(); | ||
calledStartConnection = false; | ||
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
Dictionary returnValue = new Dictionary(); | ||
returnValue.put("status", 0); // OK = 0 | ||
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
@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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
@@ -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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From here: |
||
.setSubscriptionReplacementMode(replacementMode) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See this comment |
||
.build(); | ||
purchaseParamsBuilder.setSubscriptionUpdateParams(updateParams); | ||
} | ||
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
@Override | ||
public void onMainResume() { | ||
if (calledStartConnection) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PriceChangeConfirmationListener
is deprecated