Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
6abcbb4
Feature: restore purchases related changes and added new classes
cb-amutha May 1, 2023
16d175c
1. Updated the test classes SubscriptionResourceTest.kt and ItemResou…
cb-amutha May 2, 2023
4680898
Refactor: handled error on restore api and added paused enum in store…
cb-amutha May 3, 2023
fbd02e7
Added empty checks on restore purchases
cb-amutha May 4, 2023
0ba3b56
Addressed review comments
cb-amutha May 4, 2023
55d788e
Addressed review comments
cb-amutha May 4, 2023
0106a81
Refactor: retrieveProducts and purchase product method on billing cli…
cb-amutha May 5, 2023
11d8053
Updated test class
cb-amutha May 5, 2023
83433bf
If includeInActivePurchases set as true, restore all the purchases in…
cb-amutha May 8, 2023
e09274e
Improvements on error handling and updated README.md
cb-amutha May 9, 2023
8f930f2
Removed unused property and updated README.md
cb-amutha May 11, 2023
78c7a52
Merge pull request #67 from cb-amutha/feature/restore_purchase
cb-amutha May 12, 2023
fd2abeb
Version bump and updated README.md
cb-amutha May 12, 2023
60cf5c5
Merge pull request #68 from chargebee/release/v1.0.16
cb-amutha May 12, 2023
306dfb3
Imp - cache receipt and retry mechanism
cb-amutha May 30, 2023
16aa7ae
CBCustomer object added and unit test
cb-amutha May 30, 2023
1de683e
Updated test case
cb-amutha May 30, 2023
cb724ac
Update example app to handle server not responding use case and READM…
cb-amutha May 31, 2023
6ccf835
Handled offline use case cache the product and retry validateReceipt
cb-amutha May 31, 2023
a2d5a9a
Addressed PR comments
cb-amutha Jun 6, 2023
505a877
Merge pull request #69 from cb-amutha/impro/cache_receipt_retry
cb-amutha Jun 6, 2023
ebd4b7f
Version bump and updated README.md
cb-amutha Jun 6, 2023
bc895b4
Merge pull request #70 from chargebee/release/v1.0.16
cb-amutha Jun 7, 2023
c3308a9
Implemented non subscription purchase method and validation
cb-amutha Jul 3, 2023
e7a3a88
Implemented retry mechanism for non subscription purchase
cb-amutha Jul 3, 2023
04fc184
Updated productType and Added unit test case for no subscription receipt
cb-amutha Jul 4, 2023
8ce9406
Updated test case and removed in-app checks on restore purchase
cb-amutha Jul 5, 2023
bdc3975
Removed in-app products to restore and updated product type filed in …
cb-amutha Jul 5, 2023
a462b36
Updated README.md
cb-amutha Jul 5, 2023
9c019f9
Address review comments
cb-amutha Jul 6, 2023
f1fa065
Addressed the review comments and improvements
cb-amutha Jul 7, 2023
703db22
Added Plan ID related information
cb-sabuj Jul 7, 2023
32a2224
fix
cb-sabuj Jul 7, 2023
3c21100
Merge pull request #73 from chargebee/OMNISUB-5544
cb-amutha Jul 10, 2023
2eb328d
Merge remote-tracking branch 'origin/master' into feature/otp_purchas…
cb-amutha Jul 10, 2023
9d16342
Addressed the review comments and improvements
cb-amutha Jul 10, 2023
15eef33
Merge pull request #72 from cb-amutha/feature/otp_purchase_support
cb-amutha Jul 10, 2023
268d22c
Version bump and updated README.md
cb-amutha Jul 11, 2023
36fbe5a
Merge pull request #74 from chargebee/release/v1.0.16
cb-amutha Jul 11, 2023
cf5b584
fix: adds additional logs prior to purchase
cb-haripriyan Jul 11, 2023
15dc0a3
Invoke showManageSubscriptions settings screen from SDK
cb-amutha Jul 11, 2023
c6c1257
docs: updates example app
cb-haripriyan Jul 12, 2023
8b5e89a
Updated comment lines
cb-amutha Jul 12, 2023
c8977d6
Adds intent flags for stacks
cb-amutha Jul 12, 2023
032102b
remove un-used imports
cb-amutha Jul 12, 2023
cb31fa4
fix: adds customer and product ids to log
cb-haripriyan Jul 12, 2023
b9769ea
Updated with pr comments and readme file
cb-amutha Jul 12, 2023
d7155d2
Merge pull request #75 from cb-haripriyan/adds-log-for-purchase-init
cb-amutha Jul 12, 2023
ac67d47
Merge branch 'master' of https://github.com/cb-amutha/chargebee-andro…
cb-amutha Jul 12, 2023
2171f04
Refactored code with suggested and tested
cb-amutha Jul 12, 2023
a6116a4
Merge pull request #76 from cb-amutha/feature/manage_subscriptions_se…
cb-amutha Jul 13, 2023
a64ae0a
Version bump and updated README.md
cb-amutha Jul 13, 2023
e0a1c66
Merge pull request #77 from chargebee/release/v1.0.16
cb-amutha Jul 13, 2023
c3e4700
code format issue
cb-amutha Jul 14, 2023
bbdef33
Merge pull request #78 from chargebee/release/v1.0.16
cb-amutha Jul 14, 2023
1829be8
OMNISUB-5544-Invoke Manage Subscriptions in your App
cb-sabuj Jul 17, 2023
cf24d90
Merge pull request #79 from chargebee/OMNISUB-5544
cb-amutha Jul 18, 2023
38c18c6
fix: adds customer object on restore
cb-amutha Aug 16, 2023
791df89
Merge pull request #80 from cb-amutha/fix/customer_restore
cb-amutha Aug 16, 2023
5e60611
version bump and readme updates
cb-amutha Aug 17, 2023
4b9a030
updates readme
cb-amutha Aug 17, 2023
2e7d042
Merge pull request #81 from chargebee/release/v1.0.21
cb-amutha Aug 17, 2023
4d65d80
updates readme
cb-amutha Aug 17, 2023
2610b5d
Merge pull request #82 from chargebee/release/v1.0.21
cb-amutha Aug 17, 2023
6cf7b3b
fix: fixes error when trying to valiate a non-purchased item
cb-haripriyan Sep 1, 2023
8e18a5e
build: updates release version
cb-haripriyan Sep 1, 2023
382ca73
Merge pull request #83 from cb-haripriyan/fix/validate-receipt
cb-amutha Sep 1, 2023
a93bb37
fix: release build code optimize
cb-amutha Sep 5, 2023
12f8227
version bump
cb-amutha Sep 6, 2023
ea9af83
Merge pull request #84 from cb-amutha/fix/release_build
cb-amutha Sep 6, 2023
4f67652
updates README.md
cb-amutha Sep 6, 2023
097c9cb
Merge pull request #85 from chargebee/release/v1.0.23
cb-amutha Sep 6, 2023
c5c4aee
Reverted progaurd rules from sdk and updated the version
cb-amutha Sep 6, 2023
532d48c
Merge branch 'master' of https://github.com/cb-amutha/chargebee-andro…
cb-amutha Sep 6, 2023
71f72bc
updates README.md
cb-amutha Sep 6, 2023
cbab9b8
Merge pull request #86 from cb-amutha/fix/release_build
cb-haripriyan Sep 6, 2023
107d57a
adds proguard rule
cb-amutha Sep 7, 2023
c721f27
Merge pull request #87 from cb-amutha/fix/release_build
cb-haripriyan Sep 7, 2023
8e8ca96
Changing productsList to mutableSet to handle Billing library 5 forma…
cb-venkateshravichandran Oct 5, 2023
67e5999
Changing the API contract to existing type
cb-venkateshravichandran Oct 5, 2023
e6a1430
Version change in build.gradle
cb-venkateshravichandran Oct 5, 2023
7a1901b
Merge pull request #89 from cb-venkateshravichandran/feat/retrieve-pr…
cb-haripriyan Oct 9, 2023
df682e0
Upgrades to Billing library 5.2.1
cb-haripriyan Oct 13, 2023
0d73e1d
Fixes unit tests
cb-haripriyan Oct 16, 2023
4cf01e0
updates example app
cb-haripriyan Oct 17, 2023
d7341f7
Updates Billing Library version to 5.2.1
cb-haripriyan Nov 9, 2023
c5f2a5e
Updates Readme
cb-haripriyan Nov 9, 2023
0e325ef
Merge pull request #92 from cb-haripriyan/upgrade-to-bl5-version
cb-haripriyan Nov 9, 2023
e8467fb
Merge branch 'master' of github.com:chargebee/chargebee-android into …
cb-haripriyan Nov 17, 2023
59ad176
Refactors Product for BL5
cb-haripriyan Nov 23, 2023
09c6ddf
Refactors example app
cb-haripriyan Nov 23, 2023
4da4427
Updates version
cb-haripriyan Nov 23, 2023
0d6fe7d
Fixes unit tests
cb-haripriyan Nov 24, 2023
41025c1
Updates docs
cb-haripriyan Nov 24, 2023
ed3513f
Updates version
cb-haripriyan Nov 24, 2023
8ec2e4a
Updates readme
cb-haripriyan Nov 27, 2023
015435b
Updates readme
cb-haripriyan Nov 27, 2023
b21555e
Merge pull request #93 from cb-haripriyan/billing-library-5
cb-haripriyan Nov 27, 2023
c772522
Update README.md
cb-haripriyan Nov 28, 2023
aa2276f
Merge pull request #94 from chargebee/update-readme-1
cb-haripriyan Nov 28, 2023
5e9058d
Passes customer params when customer id is empty
cb-haripriyan Apr 15, 2024
085ade6
bumps version to 2.0.0-beta-2
cb-haripriyan Apr 15, 2024
af503ff
Merge pull request #100 from cb-haripriyan/fix/pass-cust-params
cb-haripriyan Apr 16, 2024
1270dea
Fix multiple callbacks - 2
cb-palanim Apr 18, 2024
81c6d80
Updating version numbers
cb-palanim Apr 18, 2024
ba3d15d
Merge pull request #101 from chargebee/fix-multiple-callbacks-2
cb-haripriyan Apr 18, 2024
8d389b2
Updating billing client version
cb-palanim Jul 18, 2024
3577cb4
Updating version Name
cb-palanim Jul 18, 2024
dfb427d
Updating sdk version name
cb-palanim Jul 18, 2024
e8d03bb
Update readme.
cb-palanim Jul 18, 2024
463e384
Merge pull request #102 from chargebee/bl6-upgrade
cb-haripriyan Jul 18, 2024
71d1285
Update readme
cb-palanim Jul 18, 2024
dcb1e0b
Merge pull request #105 from chargebee/bl6-upgrade
cb-haripriyan Jul 19, 2024
a07f389
Secret scan workflow added for all the prs
cb-rohitsharma Mar 27, 2025
1572dab
Merge pull request #108 from chargebee/chore/workflow_secret_scan
cb-haripriyan Apr 16, 2025
6a9e83a
workflow updated
cb-rohitsharma Apr 21, 2025
269ea1e
Merge pull request #109 from chargebee/chore/workflow_secret_scan
cb-shreygupta Apr 22, 2025
1f914ee
Message for legacy version added.
cb-shreygupta Jun 16, 2025
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
32 changes: 32 additions & 0 deletions .github/workflows/secret.scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CB Secret PR Scan

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
scan:
name: Secret PR Scan
runs-on: ubuntu-latest
steps:
- name: Get the file name changed in the PR
id: pr_files
run: |
changed_files=$(curl -s -H "Authorization: token ${{
secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files | jq -r '.[].filename')
echo "Changed files: $changed_files"

echo "CHANGED_FILES<<EOF"$'\n'"$changed_files"$'\n'EOF >> $GITHUB_OUTPUT

- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: gitleaks/gitleaks-action@v2
env:
GITLEAKS_ENABLE_UPLOAD_ARTIFACT: false
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
GITLEAKS_LICENSE: '${{ secrets.GITLEAKS_LICENSE }}'
GITLEAKS_ENABLE_SUMMARY: false
170 changes: 150 additions & 20 deletions README.md

Large diffs are not rendered by default.

13 changes: 6 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

android {
compileSdkVersion 30
compileSdkVersion 33
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.chargebee.example"
minSdkVersion 21
targetSdkVersion 30
versionCode 3
minSdkVersion 24
targetSdkVersion 33
versionCode 6
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
Expand All @@ -41,7 +40,7 @@ dependencies {
implementation 'com.google.android.material:material:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

implementation 'com.google.code.gson:gson:2.8.8'

Expand Down
13 changes: 7 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
<activity android:name="com.chargebee.example.token.TokenizeActivity" />
<activity android:name="com.chargebee.example.plan.PlanInJavaActivity">
</activity>
<activity android:name=".billing.BillingActivity"/>
<activity android:name=".items.ItemsActivity"/>
<activity android:name=".items.ItemActivity"/>
<activity android:name=".plan.PlansActivity"/>
<activity android:name=".subscription.SubscriptionActivity"/>
<activity android:name="com.chargebee.example.MainActivity">
<activity android:name="com.chargebee.example.billing.BillingActivity"/>
<activity android:name="com.chargebee.example.items.ItemsActivity"/>
<activity android:name="com.chargebee.example.items.ItemActivity"/>
<activity android:name="com.chargebee.example.plan.PlansActivity"/>
<activity android:name="com.chargebee.example.subscription.SubscriptionActivity"/>
<activity android:name="com.chargebee.example.MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
108 changes: 99 additions & 9 deletions app/src/main/java/com/chargebee/example/ExampleApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,112 @@ package com.chargebee.example

import android.app.Application
import android.content.Context
import android.net.ConnectivityManager
import com.chargebee.android.Chargebee
import android.content.SharedPreferences
import android.util.Log
import com.chargebee.android.billingservice.CBCallback
import com.chargebee.android.billingservice.CBPurchase
import com.chargebee.android.billingservice.OneTimeProductType
import com.chargebee.android.billingservice.ProductType
import com.chargebee.android.exceptions.CBException
import com.chargebee.android.models.CBProduct
import com.chargebee.android.models.NonSubscription
import com.chargebee.android.network.CBCustomer
import com.chargebee.android.network.ReceiptDetail
import com.chargebee.example.util.NetworkUtil

class ExampleApplication: Application() {
class ExampleApplication : Application(), NetworkUtil.NetworkListener {
private lateinit var networkUtil: NetworkUtil
private var sharedPreference: SharedPreferences? = null
lateinit var mContext: Context
private val customer = CBCustomer(
id = "sync_receipt_android",
firstName = "Test",
lastName = "Purchase",
email = "testreceipt@gmail.com"
)

override fun onCreate() {
super.onCreate()
mContext = this
networkUtil = NetworkUtil(mContext, this)
networkUtil.registerCallbackEvents()
sharedPreference = mContext.getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)
}

override fun onNetworkConnectionAvailable() {
val productId = sharedPreference?.getString("productId", "")
if (productId?.isNotEmpty() == true) {
val productList = ArrayList<String>()
productList.add(productId)
retrieveProducts(productList)
}
}

override fun onNetworkConnectionLost() {
Log.e(javaClass.simpleName, "Network connectivity not available")
}

if (isInternetAvailable(this))
// Please add site/app details as required
Chargebee.configure(site = "", publishableApiKey= "",sdkKey= "", packageName = this.packageName)
private fun retrieveProducts(productIdList: ArrayList<String>) {
CBPurchase.retrieveProducts(
this,
productIdList,
object : CBCallback.ListProductsCallback<ArrayList<CBProduct>> {
override fun onSuccess(productIDs: ArrayList<CBProduct>) {
if (productIDs.first().type == ProductType.SUBS)
validateReceipt(mContext, productIDs.first())
else
validateNonSubscriptionReceipt(mContext, productIDs.first())
}

override fun onError(error: CBException) {
Log.e(javaClass.simpleName, "Exception: $error")
}
})
}

private fun isInternetAvailable(context: Context): Boolean {
val conMgr = context.getSystemService(CONNECTIVITY_SERVICE) as ConnectivityManager
return conMgr.activeNetworkInfo != null
private fun validateReceipt(context: Context, product: CBProduct) {

CBPurchase.validateReceipt(
context = context,
product = product,
customer = customer,
completionCallback = object : CBCallback.PurchaseCallback<String> {
override fun onSuccess(result: ReceiptDetail, status: Boolean) {
// Clear the local cache once receipt validation success
val editor = sharedPreference?.edit()
editor?.clear()?.apply()
Log.i(javaClass.simpleName, "Subscription ID: ${result.subscription_id}")
Log.i(javaClass.simpleName, "Plan ID: ${result.plan_id}")
Log.i(javaClass.simpleName, "Customer ID: ${result.customer_id}")
Log.i(javaClass.simpleName, "Status: $status")
}

override fun onError(error: CBException) {
Log.e(javaClass.simpleName, "Exception :$error")
}
})
}

private fun validateNonSubscriptionReceipt(context: Context, product: CBProduct) {
CBPurchase.validateReceiptForNonSubscriptions(
context = context,
product = product,
customer = customer,
productType = OneTimeProductType.CONSUMABLE,
completionCallback = object : CBCallback.OneTimePurchaseCallback {
override fun onSuccess(result: NonSubscription, status: Boolean) {
// Clear the local cache once receipt validation success
val editor = sharedPreference?.edit()
editor?.clear()?.apply()
Log.i(javaClass.simpleName, "Subscription ID: ${result.invoiceId}")
Log.i(javaClass.simpleName, "Plan ID: ${result.chargeId}")
Log.i(javaClass.simpleName, "Customer ID: ${result.customerId}")
Log.i(javaClass.simpleName, "Status: $status")
}

override fun onError(error: CBException) {
Log.e(javaClass.simpleName, "Exception :$error")
}
})
}
}
62 changes: 43 additions & 19 deletions app/src/main/java/com/chargebee/example/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import com.chargebee.android.Chargebee
import com.chargebee.android.billingservice.CBCallback
import com.chargebee.android.billingservice.CBPurchase
import com.chargebee.android.exceptions.CBException
import com.chargebee.android.exceptions.CBProductIDResult
import com.chargebee.android.exceptions.ChargebeeResult
import com.chargebee.android.models.CBProduct
import com.chargebee.example.adapter.ListItemsAdapter
import com.chargebee.example.addon.AddonActivity
Expand All @@ -38,12 +38,12 @@ import kotlinx.coroutines.launch

class MainActivity : BaseActivity(), ListItemsAdapter.ItemClickListener {
private var mItemsRecyclerView: RecyclerView? = null
private var list = arrayListOf<String>()
private var list = arrayListOf<String>()
var listItemsAdapter: ListItemsAdapter? = null
var featureList = mutableListOf<CBMenu>()
var mContext: Context? = null
private val gson = Gson()
private var mBillingViewModel : BillingViewModel? = null
private var mBillingViewModel: BillingViewModel? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down Expand Up @@ -73,9 +73,18 @@ class MainActivity : BaseActivity(), ListItemsAdapter.ItemClickListener {
Log.i(javaClass.simpleName, "Google play product identifiers: $it")
alertListProductId(it)
}

this.mBillingViewModel!!.restorePurchaseResult.observeForever {
hideProgressDialog()
if (it.isNotEmpty()) {
alertSuccess("${it.size} purchases restored successfully")
} else {
alertSuccess("Purchases not found to restore")
}
}
}

private fun setListAdapter(){
private fun setListAdapter() {
featureList = CBMenu.values().toMutableList()
listItemsAdapter = ListItemsAdapter(featureList, this)
val layoutManager: RecyclerView.LayoutManager = LinearLayoutManager(applicationContext)
Expand All @@ -85,7 +94,7 @@ class MainActivity : BaseActivity(), ListItemsAdapter.ItemClickListener {
}

override fun onItemClick(view: View?, position: Int) {
when(CBMenu.valueOf(featureList.get(position).toString()).value){
when (CBMenu.valueOf(featureList.get(position).toString()).value) {
CBMenu.Configure.value -> {
if (view != null) {
onClickConfigure(view)
Expand Down Expand Up @@ -132,8 +141,13 @@ class MainActivity : BaseActivity(), ListItemsAdapter.ItemClickListener {
CBMenu.GetEntitlements.value -> {
getSubscriptionId()
}
else ->{
Log.i(javaClass.simpleName, " Not implemented" )
CBMenu.RestorePurchase.value -> {
mBillingViewModel?.restorePurchases(this)
}
CBMenu.ManageSubscription.value ->
Chargebee.showManageSubscriptionsSettings(context = this, productId = "chargebee.pro.mobile",packageName = this.packageName)
else -> {
Log.i(javaClass.simpleName, " Not implemented")
}
}
}
Expand All @@ -148,9 +162,9 @@ class MainActivity : BaseActivity(), ListItemsAdapter.ItemClickListener {
val builder = AlertDialog.Builder(this)
val inflater = layoutInflater
val dialogLayout = inflater.inflate(R.layout.activity_configure, null)
val siteNameEditText = dialogLayout.findViewById<EditText>(R.id.etv_siteName)
val apiKeyEditText = dialogLayout.findViewById<EditText>(R.id.etv_apikey)
val sdkKeyEditText = dialogLayout.findViewById<EditText>(R.id.etv_sdkkey)
val siteNameEditText = dialogLayout.findViewById<EditText>(R.id.etv_siteName)
val apiKeyEditText = dialogLayout.findViewById<EditText>(R.id.etv_apikey)
val sdkKeyEditText = dialogLayout.findViewById<EditText>(R.id.etv_sdkkey)
builder.setView(dialogLayout)
builder.setPositiveButton("Initialize") { _, i ->

Expand All @@ -159,11 +173,20 @@ class MainActivity : BaseActivity(), ListItemsAdapter.ItemClickListener {
) && !TextUtils.isEmpty(sdkKeyEditText.text.toString())
)
Chargebee.configure(
siteNameEditText.text.toString(),
apiKeyEditText.text.toString(),
true,
sdkKeyEditText.text.toString(), this.packageName
)
site = siteNameEditText.text.toString(),
publishableApiKey = apiKeyEditText.text.toString(),
sdkKey = sdkKeyEditText.text.toString(),
packageName = this.packageName
) {
when (it) {
is ChargebeeResult.Success -> {
Log.i(javaClass.simpleName, "Configured")
}
is ChargebeeResult.Error -> {
Log.e(javaClass.simpleName, " Failed")
}
}
}
}
builder.show()
}
Expand All @@ -182,28 +205,29 @@ class MainActivity : BaseActivity(), ListItemsAdapter.ItemClickListener {
}
dialog.show()
}
private fun getProductIdList(productIdList: ArrayList<String>){

private fun getProductIdList(productIdList: ArrayList<String>) {
CBPurchase.retrieveProducts(
this,
productIdList,
object : CBCallback.ListProductsCallback<ArrayList<CBProduct>> {
override fun onSuccess(productIDs: ArrayList<CBProduct>) {
CoroutineScope(Dispatchers.Main).launch {
if (productIDs.size > 0) {
launchProductDetailsScreen(gson.toJson(productIDs))
launchProductDetailsScreen(gson.toJson(productIDs))
} else {
alertSuccess("Items not available to buy")
}
}
}

override fun onError(error: CBException) {
Log.e(javaClass.simpleName, "Error: ${error.message}")
showDialog(getCBError(error))
}
})
}


private fun alertListProductId(list: Array<String>) {
val builder = AlertDialog.Builder(this)
builder.setTitle("Chargebee Product IDs")
Expand All @@ -215,7 +239,7 @@ class MainActivity : BaseActivity(), ListItemsAdapter.ItemClickListener {
javaClass.simpleName,
" Item clicked :" + list[which] + " position :" + which
)
val productIdList = ArrayList<String>()
val productIdList = ArrayList<String>()
productIdList.add(list[which].trim())
getProductIdList(productIdList)
}
Expand Down
Loading
Loading