diff --git a/android/build.gradle b/android/build.gradle index 04d4092..d6cd406 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -11,6 +11,7 @@ buildscript { classpath "com.android.tools.build:gradle:7.4.0" // noinspection DifferentKotlinGradleVersion classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath "com.facebook.react:react-native-gradle-plugin" } } diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index 41dfb87..8049c68 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/android/src/main/java/com/chargebee/android/ChargebeeReactNativeModule.kt b/android/src/main/java/com/chargebee/android/ChargebeeReactNativeModule.kt index c741227..7c2d3be 100644 --- a/android/src/main/java/com/chargebee/android/ChargebeeReactNativeModule.kt +++ b/android/src/main/java/com/chargebee/android/ChargebeeReactNativeModule.kt @@ -1,8 +1,13 @@ -package com.chargebee.android +package com.chargebee.example +import com.chargebee.android.Chargebee +import com.chargebee.android.ChargebeeReactNativeSpec +import com.chargebee.android.billingservice.CBPurchase +import com.chargebee.android.exceptions.CBProductIDResult import com.facebook.react.bridge.ReactApplicationContext import com.facebook.react.bridge.ReactMethod import com.facebook.react.bridge.Promise +import com.facebook.react.bridge.ReadableMap class ChargebeeReactNativeModule internal constructor(context: ReactApplicationContext) : ChargebeeReactNativeSpec(context) { @@ -16,6 +21,27 @@ class ChargebeeReactNativeModule internal constructor(context: ReactApplicationC Chargebee.configure(site, publishableApiKey, true, sdkKey) } + @ReactMethod + override fun retrieveProductIdentifiers(queryParams: ReadableMap, promise: Promise) { + var formattedQueryParams = arrayOf() + if (queryParams != null) + formattedQueryParams = arrayOf(queryParams.getString("limit") ?: "") + CBPurchase.retrieveProductIdentifers(formattedQueryParams) { + when (it) { + is CBProductIDResult.ProductIds -> { + if (it.IDs.isNotEmpty()) { + promise.resolve(it) + } + } + is CBProductIDResult.Error -> { + promise.reject(it.exp.message, it.exp) + } + } + } + + } + + companion object { const val NAME = "ChargebeeReactNative" } diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 8cfedef..a3a1319 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -93,9 +93,9 @@ android { compileSdkVersion rootProject.ext.compileSdkVersion - namespace "com.chargebeereactnativeexample" + namespace "com.chargebee.example" defaultConfig { - applicationId "com.chargebeereactnativeexample" + applicationId "com.chargebee.example" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode 1 diff --git a/example/android/app/src/debug/java/com/chargebeereactnativeexample/ReactNativeFlipper.java b/example/android/app/src/debug/java/com/chargebee/example/ReactNativeFlipper.java similarity index 98% rename from example/android/app/src/debug/java/com/chargebeereactnativeexample/ReactNativeFlipper.java rename to example/android/app/src/debug/java/com/chargebee/example/ReactNativeFlipper.java index c416cfa..b5bd736 100644 --- a/example/android/app/src/debug/java/com/chargebeereactnativeexample/ReactNativeFlipper.java +++ b/example/android/app/src/debug/java/com/chargebee/example/ReactNativeFlipper.java @@ -4,7 +4,7 @@ *

This source code is licensed under the MIT license found in the LICENSE file in the root * directory of this source tree. */ -package com.chargebeereactnativeexample; +package com.chargebee.example; import android.content.Context; import com.facebook.flipper.android.AndroidFlipperClient; diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index 4122f36..4936c24 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -3,14 +3,14 @@ This source code is licensed under the MIT license found in the LICENSE file in the root * directory of this source tree. */ -package com.chargebeereactnativeexample; +package com.chargebee; import android.content.Context; import com.facebook.react.ReactInstanceManager;