Skip to content

Commit

Permalink
Merge pull request #476 from orbital17/main
Browse files Browse the repository at this point in the history
Update PlayBilling version to V6
  • Loading branch information
PEConn authored Jul 24, 2024
2 parents 2945ee4 + 77234df commit 653bfd2
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 80 deletions.
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 @@ -63,6 +63,9 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
fail("Could not parse SKU.");
return;
}
if (mMethodData.isPriceChangeConfirmation) {
fail("Price change confirmation flow is not supported");
}

/**
* Note that we have temporarily disabled the IMMEDIATE_WITHOUT_PRORATION mode
Expand Down Expand Up @@ -114,21 +117,7 @@ private void onSkusQueried(BillingResult result, List<SkuDetails> skus) {

SkuDetails sku = skus.get(0);

if (mMethodData.isPriceChangeConfirmation) {
launchPriceChangeConfirmationFlow(sku);
} else {
launchPaymentFlow(sku);
}
}

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);
}
});
launchPaymentFlow(sku);
}

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);
}
}

0 comments on commit 653bfd2

Please sign in to comment.