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

Add retry count to vpn billing (uplift to 1.48.x) #16811

Merged
merged 1 commit into from
Jan 24, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class InAppPurchaseWrapper {
public static final String RELEASE_MONTHLY_SUBSCRIPTION = "brave.vpn.monthly";
public static final String RELEASE_YEARLY_SUBSCRIPTION = "brave.vpn.yearly";
private BillingClient mBillingClient;
private int mRetryCount;

private final Map<String, SkuDetails> mSkusWithSkuDetails = new HashMap<>();

Expand Down Expand Up @@ -170,16 +171,21 @@ private void acknowledgePurchase(Context context, Purchase purchase) {
private PurchasesUpdatedListener getPurchasesUpdatedListener(Context context) {
return (billingResult, purchases) -> {
if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
if (purchases != null) processPurchases(context, purchases);
if (purchases != null) {
mRetryCount = 0;
processPurchases(context, purchases);
}
} else if (billingResult.getResponseCode()
== BillingClient.BillingResponseCode.ITEM_ALREADY_OWNED) {
Toast.makeText(context,
context.getResources().getString(R.string.already_subscribed),
Toast.LENGTH_SHORT)
.show();
} else if (billingResult.getResponseCode()
== BillingClient.BillingResponseCode.SERVICE_DISCONNECTED) {
== BillingClient.BillingResponseCode.SERVICE_DISCONNECTED
&& mRetryCount < 5) {
connectToBillingService();
mRetryCount++;
} else if (billingResult.getResponseCode()
== BillingClient.BillingResponseCode.USER_CANCELED) {
Toast.makeText(context,
Expand Down