Skip to content

Instantly share code, notes, and snippets.

@jmont96
Created December 27, 2024 16:27
Show Gist options
  • Save jmont96/a25f3a6a0929b31380255ffb7971697c to your computer and use it in GitHub Desktop.
Save jmont96/a25f3a6a0929b31380255ffb7971697c to your computer and use it in GitHub Desktop.
Android Chargeback Protection
commit d45e6310e0838c8d3a7e05b89f43e92114e78e18
Author: Jake Montgomery <[email protected]>
Date: Mon Aug 19 20:50:45 2024 -0500
android nsure
diff --git a/apps/sweep-dfs/android/app/build.gradle b/apps/sweep-dfs/android/app/build.gradle
index 18b1185..a6143aa 100644
--- a/apps/sweep-dfs/android/app/build.gradle
+++ b/apps/sweep-dfs/android/app/build.gradle
@@ -146,6 +146,10 @@ dependencies {
// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")
+ implementation(name:'NSure', ext:'aar')
+ implementation 'com.android.volley:volley:1.2.0'
+ implementation 'com.google.code.gson:gson:2.8.6'
+
def isGifEnabled = (findProperty('expo.gif.enabled') ?: "") == "true";
def isWebpEnabled = (findProperty('expo.webp.enabled') ?: "") == "true";
def isWebpAnimatedEnabled = (findProperty('expo.webp.animated') ?: "") == "true";
@@ -174,4 +178,4 @@ dependencies {
apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim(), "../native_modules.gradle");
applyNativeModulesAppBuildGradle(project)
-apply plugin: 'com.google.gms.google-services'
\ No newline at end of file
+apply plugin: 'com.google.gms.google-services'
diff --git a/apps/sweep-dfs/android/app/libs/NSure.aar b/apps/sweep-dfs/android/app/libs/NSure.aar
new file mode 100644
index 0000000..412836d
Binary files /dev/null and b/apps/sweep-dfs/android/app/libs/NSure.aar differ
diff --git a/apps/sweep-dfs/android/app/src/main/java/com/phantasia/MainApplication.kt b/apps/sweep-dfs/android/app/src/main/java/com/phantasia/MainApplication.kt
index 0678180..97ca70f 100644
--- a/apps/sweep-dfs/android/app/src/main/java/com/phantasia/MainApplication.kt
+++ b/apps/sweep-dfs/android/app/src/main/java/com/phantasia/MainApplication.kt
@@ -15,6 +15,8 @@ import com.facebook.soloader.SoLoader
import expo.modules.ApplicationLifecycleDispatcher
import expo.modules.ReactNativeHostWrapper
+import com.phantasia.NSureSDKPackage;
+
class MainApplication : Application(), ReactApplication {
override val reactNativeHost: ReactNativeHost = ReactNativeHostWrapper(
@@ -23,7 +25,13 @@ class MainApplication : Application(), ReactApplication {
override fun getPackages(): List<ReactPackage> {
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
- return PackageList(this).packages
+
+ return PackageList(this).packages.toMutableList().apply {
+ // Packages that cannot be autolinked yet can be added manually here, for example:
+ // add(MyReactNativePackage())
+
+ add(NSureSDKPackage())
+ }
}
override fun getJSMainModuleName(): String = ".expo/.virtual-metro-entry"
diff --git a/apps/sweep-dfs/android/app/src/main/java/com/phantasia/NSureSDK.java b/apps/sweep-dfs/android/app/src/main/java/com/phantasia/NSureSDK.java
new file mode 100644
index 0000000..cb628a9
--- /dev/null
+++ b/apps/sweep-dfs/android/app/src/main/java/com/phantasia/NSureSDK.java
@@ -0,0 +1,28 @@
+package com.phantasia;
+
+import com.facebook.react.bridge.Callback;
+import com.facebook.react.bridge.ReactApplicationContext;
+import com.facebook.react.bridge.ReactContextBaseJavaModule;
+import com.facebook.react.bridge.ReactMethod;
+import com.nsure.nsure.NSure;
+
+import javax.annotation.Nonnull;
+
+public class NSureSDK extends ReactContextBaseJavaModule {
+
+ public NSureSDK(ReactApplicationContext reactContext) {
+ super(reactContext);
+ }
+
+ @Nonnull
+ @Override
+ public String getName() {
+ return "NSureSDK";
+ }
+
+ @ReactMethod
+ public void getDeviceId(String appId, Callback callback){
+ NSure nSure = NSure.getInstance(this.getReactApplicationContext(), appId);
+ callback.invoke(nSure.getDeviceId());
+ }
+}
diff --git a/apps/sweep-dfs/android/app/src/main/java/com/phantasia/NSureSDKPackage.java b/apps/sweep-dfs/android/app/src/main/java/com/phantasia/NSureSDKPackage.java
new file mode 100644
index 0000000..332eac7
--- /dev/null
+++ b/apps/sweep-dfs/android/app/src/main/java/com/phantasia/NSureSDKPackage.java
@@ -0,0 +1,27 @@
+package com.phantasia;
+
+import com.facebook.react.ReactPackage;
+import com.facebook.react.bridge.NativeModule;
+import com.facebook.react.bridge.ReactApplicationContext;
+import com.facebook.react.uimanager.ViewManager;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public class NSureSDKPackage implements ReactPackage {
+
+ @Override
+ public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
+ List<NativeModule> modules = new ArrayList<>();
+
+ modules.add(new NSureSDK(reactContext));
+
+ return modules;
+ }
+}
diff --git a/apps/sweep-dfs/android/build.gradle b/apps/sweep-dfs/android/build.gradle
index be2b361..0ae9f4c 100644
--- a/apps/sweep-dfs/android/build.gradle
+++ b/apps/sweep-dfs/android/build.gradle
@@ -40,5 +40,11 @@ allprojects {
google()
mavenCentral()
maven { url 'https://www.jitpack.io' }
+
+ flatDir {
+ dirs 'libs'
+ }
}
+
+
}
diff --git a/apps/sweep-dfs/eas.json b/apps/sweep-dfs/eas.json
index 3202b90..3ff5376 100644
--- a/apps/sweep-dfs/eas.json
+++ b/apps/sweep-dfs/eas.json
@@ -33,7 +33,8 @@
"EXPO_PUBLIC_RPC_URL": "https://rpc.helius.xyz/?api-key=8e675c50-9ccb-4b07-8b96-e4c7bfda9dfa",
"EXPO_PUBLIC_CRISP_ID": "1c506c89-295c-4df4-8606-a2ae5d3b3aac"
},
- "channel": "production"
+ "channel": "production",
+ "autoIncrement": true
}
},
"submit": {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment