Skip to content

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.

@tomasz-keepsafe tomasz-keepsafe requested a review from emarc-m July 12, 2021 17:40
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.

autoParcel : "com.ryanharter.auto.value:auto-value-parcel:${versions.autoParcel}",
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.

@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.

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