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

Update PlayBilling version to V6 #476

Merged
merged 3 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 2 additions & 2 deletions playbilling/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'

def VERSION = "1.0.0-alpha10";
def VERSION = "1.0.0-alpha11";

android {
compileSdkVersion 31
Expand Down Expand Up @@ -56,7 +56,7 @@ dependencies {
api 'androidx.browser:browser:1.4.0'

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.billingclient:billing:5.2.1'
implementation 'com.android.billingclient:billing:6.2.1'

testImplementation 'junit:junit:4.12'
testImplementation 'org.robolectric:robolectric:4.4'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,23 +90,6 @@ public void successfulFlow() throws InterruptedException, JSONException {
assertActivityResult(Activity.RESULT_OK);
}

@Test
public void priceChangeConfirmationFlow() throws InterruptedException, JSONException {
mContext.startActivity(getIntent(SKU, true));
assertTrue(WrapperActivity.waitForLaunch());

assertTrue(mWrapper.waitForConnect());
mWrapper.triggerConnected();

assertTrue(mWrapper.waitForQuerySkuDetails());
mWrapper.triggerOnGotSkuDetails(getSkuDetailsList());

assertTrue(mWrapper.waitForLaunchPriceChangeConfirmationFlow());
mWrapper.triggerOnPriceChangeConfirmationResult();

assertActivityResult(Activity.RESULT_OK);
}

@Test
public void setsProxy() throws InterruptedException, JSONException {
mWrapper.setPaymentFlowWillBeSuccessful(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.android.billingclient.api.BillingClientStateListener;
import com.android.billingclient.api.BillingResult;
import com.android.billingclient.api.ConsumeResponseListener;
import com.android.billingclient.api.PriceChangeConfirmationListener;
import com.android.billingclient.api.PurchaseHistoryResponseListener;
import com.android.billingclient.api.PurchasesResponseListener;
import com.android.billingclient.api.SkuDetails;
Expand Down Expand Up @@ -120,11 +119,4 @@ public boolean launchPaymentFlow(Activity activity, SkuDetails sku, MethodData d
throw new IllegalStateException(
"EnsuredConnectionBillingWrapper doesn't handle launch Payment flow");
}

@Override
public void launchPriceChangeConfirmationFlow(Activity activity, SkuDetails sku,
PriceChangeConfirmationListener listener) {
throw new IllegalStateException("EnsuredConnectionBillingWrapper doesn't handle the " +
"price change confirmation flow");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.android.billingclient.api.BillingClientStateListener;
import com.android.billingclient.api.BillingResult;
import com.android.billingclient.api.ConsumeResponseListener;
import com.android.billingclient.api.PriceChangeConfirmationListener;
import com.android.billingclient.api.PurchaseHistoryResponseListener;
import com.android.billingclient.api.PurchasesResponseListener;
import com.android.billingclient.api.SkuDetails;
Expand Down Expand Up @@ -79,10 +78,4 @@ void queryPurchaseHistory(@BillingClient.SkuType String skuType,
*/
boolean launchPaymentFlow(Activity activity, SkuDetails sku, MethodData methodData);

/**
* Launches the price change confirmation flow.
*/
void launchPriceChangeConfirmationFlow(Activity activity, SkuDetails sku,
PriceChangeConfirmationListener listener);

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.android.billingclient.api.BillingClientStateListener;
import com.android.billingclient.api.BillingResult;
import com.android.billingclient.api.ConsumeResponseListener;
import com.android.billingclient.api.PriceChangeConfirmationListener;
import com.android.billingclient.api.Purchase;
import com.android.billingclient.api.PurchaseHistoryRecord;
import com.android.billingclient.api.PurchaseHistoryResponseListener;
Expand Down Expand Up @@ -58,9 +57,6 @@ public class MockBillingWrapper implements BillingWrapper {
private MultiSkuTypeInvocationTracker<Void, PurchaseHistoryResponseListener>
mQueryPurchaseHistoryInvocation = new MultiSkuTypeInvocationTracker<>();

private InvocationTracker<SkuDetails, PriceChangeConfirmationListener>
mPriceChangeConfirmationFlow = new InvocationTracker<>();

private Intent mPlayBillingFlowLaunchIntent;

private final CountDownLatch mConnectLatch = new CountDownLatch(1);
Expand Down Expand Up @@ -105,12 +101,6 @@ public boolean launchPaymentFlow(Activity activity, SkuDetails sku, MethodData d
return mPaymentFlowSuccessful;
}

@Override
public void launchPriceChangeConfirmationFlow(Activity activity, SkuDetails sku,
PriceChangeConfirmationListener listener) {
mPriceChangeConfirmationFlow.call(sku, listener);
}

public void triggerConnected() {
mConnectionStateListener.onBillingSetupFinished(
toResult(BillingClient.BillingResponseCode.OK));
Expand Down Expand Up @@ -171,11 +161,6 @@ public void triggerOnPurchasesUpdated() {
mListener.onPurchaseFlowComplete(toResult(BillingClient.BillingResponseCode.OK), "");
}

public void triggerOnPriceChangeConfirmationResult() {
mPriceChangeConfirmationFlow.getCallback().onPriceChangeConfirmationResult(
toResult(BillingClient.BillingResponseCode.OK));
}

public boolean waitForConnect() throws InterruptedException {
return wait(mConnectLatch);
}
Expand All @@ -188,10 +173,6 @@ public boolean waitForLaunchPaymentFlow() throws InterruptedException {
return wait(mLaunchPaymentFlowLatch);
}

public boolean waitForLaunchPriceChangeConfirmationFlow() throws InterruptedException {
return mPriceChangeConfirmationFlow.waitUntilCalled();
}

public boolean waitForQueryPurchases() throws InterruptedException {
return mQueryPurchasesInvocation.waitUntilCalled();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,7 @@ private void onSkusQueried(BillingResult result, List<SkuDetails> skus) {
}

private void launchPriceChangeConfirmationFlow(SkuDetails sku) {
mWrapper.launchPriceChangeConfirmationFlow(this, sku, result -> {
if (result.getResponseCode() == BillingClient.BillingResponseCode.OK) {
setResultAndFinish(PaymentResult.priceChangeSuccess());
} else {
fail("Price change confirmation flow ended with result: " + result);
}
});
fail("Price change confirmation flow is not supported");
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can fail earlier. At the moment, the PaymentActivity is launched, it connects to Play Billing (which is async) and queries the SKUs (which is async) then hits this, but we know in PaymentActivity#onCreate if the request is for a price change confirmation flow.

I think you could instead add if (mMethodData.isPricechangeConfirmation) { fail(...) } as soon as we create the MethodData.

}

private void launchPaymentFlow(SkuDetails sku) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
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.Purchase;
import com.android.billingclient.api.PurchaseHistoryResponseListener;
import com.android.billingclient.api.PurchasesResponseListener;
Expand Down Expand Up @@ -139,14 +137,4 @@ public boolean launchPaymentFlow(Activity activity, SkuDetails sku, MethodData m

return result.getResponseCode() == BillingClient.BillingResponseCode.OK;
}

@Override
public void launchPriceChangeConfirmationFlow(Activity activity, SkuDetails sku,
PriceChangeConfirmationListener listener) {
PriceChangeFlowParams params = PriceChangeFlowParams
.newBuilder()
.setSkuDetails(sku)
.build();
mClient.launchPriceChangeConfirmationFlow(activity, params, listener);
}
}
Loading