Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ android {
buildConfigField "String", "VERSION_NAME", "\"${version}\""
buildConfigField "boolean", "IS_HERMES_ENABLED", hermesEnabled
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", newArchEnabled
manifestPlaceholders = [
hermesEnabled: hermesEnabled,
newArchEnabled : newArchEnabled
]
// manifestPlaceholders = [
// hermesEnabled: hermesEnabled,
// newArchEnabled : newArchEnabled
// ]
}
buildFeatures {
buildConfig true
Expand Down Expand Up @@ -113,6 +113,7 @@ android {
}

sourceSets.main {
manifest.srcFile "src/main/AndroidManifest.xml"
java {
srcDirs += [
"generated/java",
Expand All @@ -126,10 +127,14 @@ android {
]
}

if (REACT_NATIVE_MINOR_VERSION >= 75) {

if (REACT_NATIVE_MINOR_VERSION >= 81) {
srcDirs += [
"src/rn81/java",
]
} else {

srcDirs += [
"src/rn79/java",
]
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
<manifest xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android">
<application android:enableOnBackInvokedCallback="true"
tools:targetApi="33">
<meta-data
android:name="io.hyperswitch.hermes_enabled"
android:value="${hermesEnabled}" />
<meta-data
android:name="io.hyperswitch.new_architecture_enabled"
android:value="${newArchEnabled}" />
<meta-data
android:name="io.hyperswitch.load_so_files"
android:value="true" />
</application>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hyperswitchsdkreactnative">
</manifest>

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class ReactNativeHyperswitchModule(reactContext: ReactApplicationContext) :
customEndpoints: ReadableMap?,
promise: Promise?
) {
val activity = currentActivity
val activity = reactApplicationContext.currentActivity
if (publishableKey.isNullOrBlank()) {
promise?.reject("INITIALIZATION_ERROR", "publishableKey is required")
return
Expand All @@ -64,7 +64,6 @@ class ReactNativeHyperswitchModule(reactContext: ReactApplicationContext) :
paymentSessionReactLauncher = PaymentSessionReactLauncher(activity)
paymentSessionReactLauncher?.initializeReactNativeInstance()
}

val overrideEndpoints: OverrideEndpoints? = customEndpoints?.getMap("overrideEndpoints")?.let {
val overrideEndpointsMap = customEndpoints.getMap("overrideEndpoints")
OverrideEndpoints(
Expand Down Expand Up @@ -119,8 +118,6 @@ class ReactNativeHyperswitchModule(reactContext: ReactApplicationContext) :
put("reason", e.message.toString())
}
promise?.resolve(map)
}finally {
// isPresented.set(false)
}
}

Expand Down Expand Up @@ -148,7 +145,7 @@ class ReactNativeHyperswitchModule(reactContext: ReactApplicationContext) :
)
}
GetPaymentSessionCallBackManager.setCallback(
params?.getMap("sessionConfig")?.getString("sdkAuthorization"),
params?.getMap("paymentSessionConfig")?.getString("sdkAuthorization"),
savedPaymentMethodCallback
)
paymentSessionReactLauncher?.recreateReactContext(it)
Expand All @@ -163,7 +160,14 @@ class ReactNativeHyperswitchModule(reactContext: ReactApplicationContext) :
promise.resolve(ConversionUtils.convertMapToJson(data.toMap()).toString())
},
onFailure = { error ->
promise.resolve(error.toString())
val pmError = error as? PMError
promise.resolve(
StandardResult.Failed(
code = pmError?.code ?: "UNKNOWN",
message = pmError?.message ?: error.message ?: "Unknown error",
error = Throwable(pmError?.message ?: error.message ?: "Unknown error")
).toJSONString()
)
}
)
}
Expand All @@ -176,7 +180,14 @@ class ReactNativeHyperswitchModule(reactContext: ReactApplicationContext) :
promise.resolve(ConversionUtils.convertMapToJson(data.toMap()).toString())
},
onFailure = { error ->
promise.reject(error.toString())
val pmError = error as? PMError
promise.resolve(
StandardResult.Failed(
code = pmError?.code ?: "UNKNOWN",
message = pmError?.message ?: error.message ?: "Unknown error",
error = Throwable(pmError?.message ?: error.message ?: "Unknown error")
).toJSONString()
)
}
)
}
Expand All @@ -195,7 +206,14 @@ class ReactNativeHyperswitchModule(reactContext: ReactApplicationContext) :
promise.resolve(jsonArray.toString())
},
onFailure = { error ->
promise.reject(error.toString())
val pmError = error as? PMError
promise.resolve(
StandardResult.Failed(
code = pmError?.code ?: "UNKNOWN",
message = pmError?.message ?: error.message ?: "Unknown error",
error = Throwable(pmError?.message ?: error.message ?: "Unknown error")
).toJSONString()
)
}
)
}
Expand Down Expand Up @@ -231,7 +249,7 @@ class ReactNativeHyperswitchModule(reactContext: ReactApplicationContext) :
code = pmError?.code ?: "UNKNOWN",
message = pmError?.message ?: error.message ?: "Unknown error",
error = Throwable(pmError?.message ?: error.message ?: "Unknown error")
)
).toJSONString()
)
}
)
Expand Down Expand Up @@ -272,7 +290,7 @@ class ReactNativeHyperswitchModule(reactContext: ReactApplicationContext) :
code = pmError?.code ?: "UNKNOWN",
message = pmError?.message ?: error.message ?: "Unknown error",
error = Throwable(pmError?.message ?: error.message ?: "Unknown error")
)
).toJSONString()
)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ class PaymentElementViewManager : SimpleViewManager<PaymentWidgetView>(),

@ReactProp(name = "options")
override fun setOptions(container: PaymentWidgetView, options: Dynamic?) {
options?.let {
container.setConfiguration(it.asMap())
options?.asMap()?.let {
container.setConfiguration(it)
}
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ class PaymentSessionReactLauncher(
.commitNowAllowingStateLoss()
}
}catch(e:Exception){
Log.i("Manideep", e.message.toString())
}

val newReactNativeFragmentSheet =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.facebook.react.bridge.Callback
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.ReactMethod
import com.facebook.react.bridge.ReadableMap
import com.facebook.react.fabric.mounting.SurfaceMountingManager
import com.facebook.react.uimanager.IllegalViewOperationException
import com.facebook.react.uimanager.UIManagerModule
import com.hyperswitchsdkreactnative.BuildConfig
Expand Down Expand Up @@ -203,7 +204,6 @@ class HyperModule internal constructor(private val rct: ReactApplicationContext)

@ReactMethod
override fun notifyWidgetPaymentResult(rootTag: Double, result: String) {
Log.i("Manideep", rootTag.toInt().toString())
findViewWithRootTag(rootTag.toInt(), { fragment ->
if (fragment == null) {
Log.w(
Expand Down Expand Up @@ -255,7 +255,6 @@ class HyperModule internal constructor(private val rct: ReactApplicationContext)

@ReactMethod
override fun emitPaymentEvent(rootTag: Double, eventType: String, payload: ReadableMap) {
Log.i("Manideep", rootTag.toInt().toString())
findViewWithRootTag(rootTag.toInt(), { fragment ->
if (fragment == null) {
Log.w("HyperModule", "emitPaymentEvent: no fragment found for rootTag=$rootTag")
Expand Down Expand Up @@ -383,23 +382,24 @@ class HyperModule internal constructor(private val rct: ReactApplicationContext)
}

private fun findViewWithRootTag(rootTag: Int, onFound: (HyperFragment?) -> Unit) {
val uiManagerModule =
reactApplicationContext.getNativeModule<UIManagerModule?>(UIManagerModule::class.java)

if (uiManagerModule == null) {
onFound(null)
return
}

uiManagerModule.addUIBlock { nvhm ->
try {
val reactRootView = nvhm.resolveView(rootTag)
onFound(FragmentManager.findFragment(reactRootView))
} catch (e: IllegalViewOperationException) {
onFound(null)
} catch (e: Exception) {
onFound(null)
}
}
// val uiManagerModule =
// reactApplicationContext.getNativeModule<UIManagerModule?>(UIManagerModule::class.java)
//
// if (uiManagerModule == null) {
// onFound(null)
// return
// }
//
// uiManagerModule.addUIBlock { nvhm ->
// try {
// val reactRootView = nvhm.resolveView(rootTag)
// onFound(reactRootView?.let { FragmentManager.findFragment(it) })
// } catch (e: IllegalViewOperationException) {
// onFound(null)
// } catch (e: Exception) {
// onFound(null)
// }
// }
onFound(null)
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import com.facebook.react.runtime.hermes.HermesInstance
import com.facebook.react.soloader.OpenSourceMergedSoMapping
import com.facebook.soloader.SoLoader
import com.hyperswitchsdkreactnative.BuildConfig
import com.hyperswitchsdkreactnative.HyperswitchSdkReactNativePackage
import com.hyperswitchsdkreactnative.R
import io.hyperswitch.logs.CrashHandler
import io.hyperswitch.logs.EventName
Expand Down Expand Up @@ -118,7 +119,7 @@ object ReactNativeController {
return object : DefaultReactNativeHost(application) {
override fun getPackages(): List<ReactPackage> {
return HyperPackageList(this).packages.apply {
add(HyperPackage())
add(HyperswitchSdkReactNativePackage())
}
}

Expand Down
Loading