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

SDK 16.0.1 not working fully with Billing Client 5.0 - In-app purchase events are not sent. #1172

Open
5 tasks done
grzegorzmalopolski opened this issue Mar 29, 2023 · 9 comments

Comments

@grzegorzmalopolski
Copy link

Checklist before submitting a bug report

Java version

1.8

Android version

13

Android SDK version

33

Installation platform & version

Gradle plugin 7.4.x

Package

Other / I don't know

Goals

Upate billing client to 5.0 or 5.1 in Facebook SDK to send properly In-app purchase events to Meta analytics console.

Expected results

In our project we already use Google Billing Client with version 5.0.
This billing client is suggested in Google Play developer console. (Should be always updated)

I want to use latest Facebook SDK with this client, but currently Facebook SDK use version 3.0.0 that can connect to Billing client in version 5.0 because of class missing.

We can't revert billing client to 4.0 because of already implemented migration from Billing client 4.0 to 5.0.

Actual results

In Facebool SDK Google client wrapper is missing class:
com.android.billingclient.api.Purchase$PurchasesResult

This class exist in billing 3.x an 4.x but on billingclient.api.Purchase in 5.0 version this is changed.
Because of that Facebook SDK can't create instance of InAppPurchaseBillingClientWrapper.
When constructor create instance, try to find class by name
com.android.billingclient.api.Purchase$PurchasesResult
and this class is missing. So wrapper is created, but instance is null.

Result of that is that SDK can't query purchases and send it automatically as events to Facebook platform.

Steps to reproduce

Use Google billing client in version 5.0 and Facebook SDK in version 16.0.1
Make in-app purchase and see that no events are sent.
No add to cart event and no purchase event.

Code samples & details

fun getOrCreateInstance(context: Context): InAppPurchaseBillingClientWrapper? {
      if (initialized.get()) {
        return instance
      }
      createInstance(context)
      initialized.set(true)
      return instance
    }




    private fun createInstance(context: Context) {
      val inAppPurchaseSkuDetailsWrapper = getOrCreateInstance() ?: return
      val billingClientClazz = getClass(CLASSNAME_BILLING_CLIENT)
      val purchaseClazz = getClass(CLASSNAME_PURCHASE)
      val purchaseResultClazz = getClass(CLASSNAME_PURCHASES_RESULT)
      val skuDetailsClazz = getClass(CLASSNAME_SKU_DETAILS)
      val purchaseHistoryRecordClazz = getClass(CLASSNAME_PURCHASE_HISTORY_RECORD)
      val skuDetailsResponseListenerClazz = getClass(CLASSNAME_SKU_DETAILS_RESPONSE_LISTENER)
      val purchaseHistoryResponseListenerClazz =
          getClass(CLASSNAME_PURCHASE_HISTORY_RESPONSE_LISTENER)
      if (billingClientClazz == null ||
          purchaseResultClazz == null ||
          purchaseClazz == null ||
          skuDetailsClazz == null ||
          skuDetailsResponseListenerClazz == null ||
          purchaseHistoryRecordClazz == null ||
          purchaseHistoryResponseListenerClazz == null) {
        return
      }
      val queryPurchasesMethod =
          getMethod(billingClientClazz, METHOD_QUERY_PURCHASES, String::class.java)
      val getPurchaseListMethod = getMethod(purchaseResultClazz, METHOD_GET_PURCHASE_LIST)
      val getOriginalJsonMethod = getMethod(purchaseClazz, METHOD_GET_ORIGINAL_JSON)
      val getOriginalJsonSkuMethod = getMethod(skuDetailsClazz, METHOD_GET_ORIGINAL_JSON)
      val getOriginalJsonPurchaseHistoryMethod =
          getMethod(purchaseHistoryRecordClazz, METHOD_GET_ORIGINAL_JSON)
      val querySkuDetailsAsyncMethod =
          getMethod(
              billingClientClazz,
              METHOD_QUERY_SKU_DETAILS_ASYNC,
              inAppPurchaseSkuDetailsWrapper.skuDetailsParamsClazz,
              skuDetailsResponseListenerClazz)
      val queryPurchaseHistoryAsyncMethod =
          getMethod(
              billingClientClazz,
              METHOD_QUERY_PURCHASE_HISTORY_ASYNC,
              String::class.java,
              purchaseHistoryResponseListenerClazz)
      if (queryPurchasesMethod == null ||
          getPurchaseListMethod == null ||
          getOriginalJsonMethod == null ||
          getOriginalJsonSkuMethod == null ||
          getOriginalJsonPurchaseHistoryMethod == null ||
          querySkuDetailsAsyncMethod == null ||
          queryPurchaseHistoryAsyncMethod == null) {
        return
      }



Missing class is 
    private const val CLASSNAME_PURCHASES_RESULT =
        "com.android.billingclient.api.Purchase\$PurchasesResult"
@Fanketly
Copy link

Fanketly commented Sep 7, 2023

Please update it

@daniel-moonactive
Copy link

daniel-moonactive commented Oct 1, 2023

we experience the same issue

@dsanghan
Copy link

dsanghan commented Oct 6, 2023

+1

1 similar comment
@airx
Copy link

airx commented Oct 17, 2023

+1

@anoce
Copy link

anoce commented Nov 21, 2023

'com.facebook.android:facebook-android-sdk:16.2.0' 'com.android.billingclient:billing:6.0.1'

我在使用上面的版本SDK也是无法收到In-app purchase的事件记录,只能收到安装和启动的事件记录。

@weijielv
Copy link

weijielv commented Dec 6, 2023

me too
implementation 'com.facebook.android:facebook-android-sdk:latest.release'
implementation("com.android.billingclient:billing:6.0.1")

don't full work . no log iap event.

@weijielv
Copy link

weijielv commented Dec 6, 2023

'com.facebook.android:facebook-android-sdk:16.2.0' 'com.android.billingclient:billing:6.0.1'

我在使用上面的版本SDK也是无法收到In-app purchase的事件记录,只能收到安装和启动的事件记录。
所以请问,你最近解决这个问题了吗?求助

@abdulkadirgun
Copy link

abdulkadirgun commented Dec 29, 2023

'com.facebook.android:facebook-android-sdk:16.0.0' 
'com.android.billingclient:billing:6.1.0'

in-app-purchase event not triggered. other events(install, custom events) triggers.

When I researched in detail;

Google Play Billing Library version 3.0.0 appears in facebook-android-sdk. However, google has declared the following regarding the billing version.

  1. Starting on August 2, 2023, all new apps must use Billing Library version 5 or newer. By November 1, 2023, all updates to existing apps must use Billing Library version 5 or newer
  2. If your app is targeting Android 14 or higher, you must update to PBL 5.2.1 or PBL 6.0.1 or higher.
    So, active-updated apps use minimum v5. There are no more apps using v3.

How can facebook-android-sdk still use v3? How can it be so outdated?

@ilyasikirytski
Copy link

ilyasikirytski commented Jan 29, 2024

Same trouble - no purchase events. Is there any solution?

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

No branches or pull requests

9 participants