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

Billing v4 #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Billing v4 #40

wants to merge 1 commit into from

Conversation

tomasz-keepsafe
Copy link
Contributor

This PR. updates Google Billing API to version 4.0.0.

  • I couldn't make AutoParcel to work, so all Parcelable objects are implemented by hand.
  • Added support for account Id in purchase
  • Added support for subscription acknowledging through existing consume cashier API.

Copy link
Contributor

@emarc-m emarc-m left a comment

Choose a reason for hiding this comment

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

Taking the discussion internally for now.

appCompat : "androidx.appcompat:appcompat:${versions.appCompat}",
supportAnnotations: "androidx.annotation:annotation:${versions.support}",
supportAnnotations: "com.android.support:support-annotations:${versions.support}",
Copy link
Contributor

Choose a reason for hiding this comment

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

Please clarify why this needs to be reverted to the support lib version.

tokensToBeConsumed.remove(purchaseToken);
listener.failure(purchase, getConsumeError(responseCode));
if (product.isSubscription()) {
api.acknowledgePurchase(purchase.token(), new AcknowledgePurchaseResponseListener() {
Copy link
Contributor

Choose a reason for hiding this comment

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

According to the docs, the purchase product needs to be check if it has already been acknowledge: https://developer.android.com/google/play/billing/integrate#process.

suspend fun handlePurchase() {
    if (purchase.purchaseState === PurchaseState.PURCHASED) {
        if (!purchase.isAcknowledged) {
            val acknowledgePurchaseParams = AcknowledgePurchaseParams.newBuilder()
                    .setPurchaseToken(purchase.purchaseToken)
            val ackPurchaseResult = withContext(Dispatchers.IO) {
               client.acknowledgePurchase(acknowledgePurchaseParams.build())
            }
        }
     }
}

What will be the effect if a purchase is repeatedly acknowledge?
I this something that the backend does?

Subscriptions are handled similarly to non-consumables. You can acknowledge a subscription Acknowledgement using either BillingClient.acknowledgePurchase() from the Google Play Billing Library or Purchases.Subscriptions.Acknowledge from the Google Play Developer API. All initial subscription purchases need to be acknowledged. Subscription renewals do not need to be acknowledged. For more information on when subscriptions need to be acknowledged, see the Sell subscriptions topic.

@@ -357,8 +380,9 @@ public void getProductDetails(@NonNull Context context, @NonNull final String sk
Collections.singletonList(sku),
new SkuDetailsResponseListener() {
@Override
public void onSkuDetailsResponse(int responseCode, List<SkuDetails> skuDetailsList) {
if (responseCode == BillingResponse.OK && skuDetailsList.size() == 1) {
public void onSkuDetailsResponse(BillingResult result, List<SkuDetails> skuDetailsList) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Please add the nullability annotation to the implementation:

void onSkuDetailsResponse(@NonNull BillingResult var1, @Nullable List<SkuDetails> var2);

Please see other implementations for this.

@@ -28,11 +28,8 @@ android {

dependencies {
api project(':cashier')

compileOnly deps.autoValue
\
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove

Comment on lines +235 to +237
if (accountId != null) {
throw new IllegalArgumentException("Account id 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.

Is it valid to throw the exception here? I know this is similar to the developerPayload but I think accountId is optional.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants