Skip to content

Moving app id, location id, and access token to local config file ignored by git #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 13 additions & 0 deletions example/android/app/app.properties.example
Original file line number Diff line number Diff line change
@@ -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"
12 changes: 12 additions & 0 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class MainApplication : Application(), ReactApplication {
object : DefaultReactNativeHost(this) {
override fun getPackages(): List<ReactPackage> =
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"
Expand All @@ -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"
}
}
1 change: 1 addition & 0 deletions example/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

4 changes: 3 additions & 1 deletion example/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand All @@ -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
}
}
}
42 changes: 42 additions & 0 deletions lefthook.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Loading