diff --git a/.gitignore b/.gitignore index 9fa12c7..1edf079 100644 --- a/.gitignore +++ b/.gitignore @@ -85,3 +85,6 @@ android/generated # Ignoring the pods folder. Make sure you run pod install ios/Pods/ *.xcworkspacedata + +# Local properties (*.example are non-local illustations, however) +example/android/app/app.properties diff --git a/example/android/app/app.properties.example b/example/android/app/app.properties.example new file mode 100644 index 0000000..f776730 --- /dev/null +++ b/example/android/app/app.properties.example @@ -0,0 +1,13 @@ +# You can copy this file to app.properties (lose ".example"), and set the values +# from https://developer.squareup.com/apps/${app_id}, but .gitignore will keep +# the "secret" values out of source control. + +# This identifies your application to Square +APP_ID="INSERT APP_ID HERE" + +# This identifies the merchant. In most cases, OAuth is best for production +# usage (read https://developer.squareup.com/docs/oauth-api/overview), but that +# requires a server, and we can't know where or how developers configure that. +# The dashboard values can be put here for quick test access. +LOCATION_ID="INSERT LOCATION_ID HERE" +ACCESS_TOKEN="INSERT ACCESS TOKEN HERE" diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index c4aaa21..ad17ffe 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -2,6 +2,15 @@ apply plugin: "com.android.application" apply plugin: "org.jetbrains.kotlin.android" apply plugin: "com.facebook.react" +/* Load custom properties for the app, if any */ +Properties localProperties = new Properties() +if (project.file("app.properties").exists()) { + localProperties.load(project.file('app.properties').newDataInputStream()) + project.logger.warn("FKA3: localProps has " + localProperties["APP_ID"]) +} else { + throw new GradleException("Please create app.properties with APP_ID, LOCATION_ID, and ACCESS_TOKEN") +} + /** * This is the configuration block to customize your React Native Android app. * By default you don't need to apply any configuration, just uncomment the lines you need. @@ -84,6 +93,9 @@ android { targetSdkVersion rootProject.ext.targetSdkVersion versionCode 1 versionName "1.0" + buildConfigField "String", "APP_ID", localProperties["APP_ID"] + buildConfigField "String", "LOCATION_ID", localProperties["LOCATION_ID"] + buildConfigField "String", "ACCESS_TOKEN", localProperties["ACCESS_TOKEN"] } signingConfigs { debug { diff --git a/example/android/app/src/main/java/mobilepaymentssdkreactnative/example/MainApplication.kt b/example/android/app/src/main/java/mobilepaymentssdkreactnative/example/MainApplication.kt index 42f9be4..18822b0 100644 --- a/example/android/app/src/main/java/mobilepaymentssdkreactnative/example/MainApplication.kt +++ b/example/android/app/src/main/java/mobilepaymentssdkreactnative/example/MainApplication.kt @@ -17,7 +17,7 @@ class MainApplication : Application(), ReactApplication { object : DefaultReactNativeHost(this) { override fun getPackages(): List = PackageList(this).packages.apply { - // Packages that cannot be autolinked yet can be added manually here, for example: + RNBuildConfigPackage(BuildConfig.class) // Add the package } override fun getJSMainModuleName(): String = "index" @@ -34,14 +34,10 @@ class MainApplication : Application(), ReactApplication { override fun onCreate() { super.onCreate() SoLoader.init(this, false) - MobilePaymentsSdk.initialize(MOBILE_PAYMENT_SDK_APPLICATION_ID, this) + MobilePaymentsSdk.initialize(BuildConfig.APP_ID, this) if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) { // If you opted-in for the New Architecture, we load the native entry point for this app. load() } } - - companion object { - private const val MOBILE_PAYMENT_SDK_APPLICATION_ID = "REPLACE_ME" - } } diff --git a/example/android/gradle.properties b/example/android/gradle.properties index 9fb1566..ef7c50f 100644 --- a/example/android/gradle.properties +++ b/example/android/gradle.properties @@ -37,3 +37,4 @@ newArchEnabled=false # Use this property to enable or disable the Hermes JS engine. # If set to false, you will be using JSC instead. hermesEnabled=true + diff --git a/example/android/settings.gradle b/example/android/settings.gradle index cbd0a52..01b9b61 100644 --- a/example/android/settings.gradle +++ b/example/android/settings.gradle @@ -2,6 +2,8 @@ pluginManagement { includeBuild("../node_modules/@react-native/gradle-plugin") } plugins { id("com.facebook.react.settings") } extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autolinkLibrariesFromCommand() } rootProject.name = 'mobilepaymentssdkreactnative.example' + +include ':react-native-build-config' include ':app' includeBuild('../node_modules/@react-native/gradle-plugin') @@ -14,4 +16,4 @@ dependencyResolutionManagement { maven { url("https://sdk.squareup.com/public/android/") } // It's better to explicitly define the React Native repository if needed } -} \ No newline at end of file +} diff --git a/lefthook.yml b/lefthook.yml new file mode 100644 index 0000000..e18689e --- /dev/null +++ b/lefthook.yml @@ -0,0 +1,42 @@ +# EXAMPLE USAGE: +# +# Refer for explanation to following link: +# https://evilmartians.github.io/lefthook/configuration/ +# +# pre-push: +# jobs: +# - name: packages audit +# tags: +# - frontend +# - security +# run: yarn audit +# +# - name: gems audit +# tags: +# - backend +# - security +# run: bundle audit +# +# pre-commit: +# parallel: true +# jobs: +# - run: yarn eslint {staged_files} +# glob: "*.{js,ts,jsx,tsx}" +# +# - name: rubocop +# glob: "*.rb" +# exclude: +# - config/application.rb +# - config/routes.rb +# run: bundle exec rubocop --force-exclusion {all_files} +# +# - name: govet +# files: git ls-files -m +# glob: "*.go" +# run: go vet {files} +# +# - script: "hello.js" +# runner: node +# +# - script: "hello.go" +# runner: go run diff --git a/package.json b/package.json index 5354ac0..4314062 100644 --- a/package.json +++ b/package.json @@ -187,5 +187,9 @@ "type": "module-legacy", "languages": "kotlin-swift", "version": "0.41.2" + }, + "dependencies": { + "react-native-buildconfig": "^1.0.5", + "react-native-uuid": "^2.0.3" } }