Skip to content
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

Remove BT, VGS, and LD #302

Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,4 @@ The `/sample-app/` folder in this repository contains a very simple integration
- Minimum API Level Android 5.0 (API level 21)
- [kotlinx.coroutines](https://github.com/Kotlin/kotlinx.coroutines) v1.6.4
- 3rd party libraries:
- [VGS-Collect-Android](https://github.com/verygoodsecurity/vgs-collect-android) v1.7.3
- [Basis-Theory-Android](https://github.com/Basis-Theory/basistheory-android) v2.5.0
- [OkHttp](https://github.com/square/okhttp) v4.10.0
- [Launch Darkly](https://github.com/launchdarkly/android-client-sdk) v4.2.1
- [OkHttp](https://github.com/square/okhttp) v4.10.0
10 changes: 0 additions & 10 deletions forage-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,7 @@ dependencies {
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'com.launchdarkly:launchdarkly-android-client-sdk:4.2.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'
// VGS Collect SDK
api 'com.verygoodsecurity:vgscollect:1.7.3'

// Basis Theory SDK
implementation ('com.github.basis-theory:basistheory-android:4.2.2') {
// Unable to build without excluding this dependency
// based on advice from this thread: https://github.com/gradle/gradle/issues/3065#issuecomment-341418873
exclude group: 'javax.ws.rs'
}
implementation "javax.ws.rs:javax.ws.rs-api:2.1@jar"

testImplementation 'androidx.test:core-ktx:1.5.0'
Expand Down
5 changes: 0 additions & 5 deletions forage-android/consumer-rules.pro

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,8 @@ internal enum class EnvOption(val value: String) {

internal sealed class EnvConfig(
val FLAVOR: EnvOption,
val btProxyID: String,
val btAPIKey: String,
val vgsVaultId: String,
val vgsVaultType: String,
val apiBaseUrl: String,
val vaultBaseUrl: String,
val ldMobileKey: String,
val ddClientToken: String
) {
// For the time being, I figure we can consume BuildConfig in exactly
Expand All @@ -29,73 +24,43 @@ internal sealed class EnvConfig(

object Local : EnvConfig(
FLAVOR = EnvOption.LOCAL,
btProxyID = "N31FZgKpYZpo3oQ6XiM6M6",
btAPIKey = "key_AZfcBuKUsV38PEeYu6ZV8x",
vgsVaultId = "tntlqkidhc6",
vgsVaultType = "sandbox",
apiBaseUrl = "http://10.0.2.2:8000/",
vaultBaseUrl = "http://10.0.2.2:3999/",
ldMobileKey = "mob-03e025cb-5b4e-4d97-8685-39a22316d601",
ddClientToken = "pubf13cedf24ba2ad50d4b9cb0b0100bd4a"
)

object Dev : EnvConfig(
FLAVOR = EnvOption.DEV,
btProxyID = "N31FZgKpYZpo3oQ6XiM6M6",
btAPIKey = "key_AZfcBuKUsV38PEeYu6ZV8x",
vgsVaultId = "tntlqkidhc6",
vgsVaultType = "sandbox",
apiBaseUrl = "https://api.dev.joinforage.app/",
vaultBaseUrl = "https://vault.dev.joinforage.app/",
ldMobileKey = "mob-03e025cb-5b4e-4d97-8685-39a22316d601",
ddClientToken = "pubf13cedf24ba2ad50d4b9cb0b0100bd4a"
)

object Staging : EnvConfig(
FLAVOR = EnvOption.STAGING,
btProxyID = "ScWvAUkp53xz7muae7fW5p",
btAPIKey = "key_6B4cvpcDCEeNDYNow9zH7c",
vgsVaultId = "tnteykuh975",
vgsVaultType = "sandbox",
apiBaseUrl = "https://api.staging.joinforage.app/",
vaultBaseUrl = "https://vault.staging.joinforage.app/",
ldMobileKey = "mob-a9903698-759b-48e2-86e1-c551e2b69118",
ddClientToken = "pubf13cedf24ba2ad50d4b9cb0b0100bd4a"
)

object Sandbox : EnvConfig(
FLAVOR = EnvOption.SANDBOX,
btProxyID = "R1CNiogSdhnHeNq6ZFWrG1",
btAPIKey = "key_DQ5NfUAgiqzwX1pxqcrSzK",
vgsVaultId = "tntagcot4b1",
vgsVaultType = "sandbox",
apiBaseUrl = "https://api.sandbox.joinforage.app/",
vaultBaseUrl = "https://vault.sandbox.joinforage.app/",
ldMobileKey = "mob-22024b85-05b7-4e24-b290-a071310dfc3d",
ddClientToken = "pubf13cedf24ba2ad50d4b9cb0b0100bd4a"
)

object Cert : EnvConfig(
FLAVOR = EnvOption.CERT,
btProxyID = "AFSMtyyTGLKgmdWwrLCENX",
btAPIKey = "key_NdWtkKrZqztEfJRkZA8dmw",
vgsVaultId = "tntpnht7psv",
vgsVaultType = "sandbox",
apiBaseUrl = "https://api.cert.joinforage.app/",
vaultBaseUrl = "https://vault.cert.joinforage.app/",
ldMobileKey = "mob-d2261a08-784b-4300-a45f-ce0e46324d66",
ddClientToken = "pubf13cedf24ba2ad50d4b9cb0b0100bd4a"
)

object Prod : EnvConfig(
FLAVOR = EnvOption.PROD,
btProxyID = "UxbU4Jn2RmvCovABjwCwsa",
btAPIKey = "key_BypNREttGMPbZ1muARDUf4",
vgsVaultId = "tntbcrncmgi",
vgsVaultType = "live",
apiBaseUrl = "https://api.joinforage.app/",
vaultBaseUrl = "https://vault.joinforage.app/",
ldMobileKey = "mob-5c3dfa7a-fa6d-4cdf-93e8-d28ef8080696",
ddClientToken = "pubf13cedf24ba2ad50d4b9cb0b0100bd4a"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,6 @@ package com.joinforage.forage.android.core.services

import okhttp3.HttpUrl
import org.json.JSONObject
import kotlin.random.Random

/**
* We generate a random jitter amount to add to our retry delay when polling for the status of
* Payments and Payment Methods so that we can avoid a thundering herd scenario in which there are
* several requests retrying at the same exact time.
*
* Returns a random integer between -25 and 25
*/
internal fun getJitterAmount(random: Random = Random.Default): Int {
return random.nextInt(-25, 26)
}

internal fun HttpUrl.Builder.addTrailingSlash(): HttpUrl.Builder {
return this.addPathSegment("")
Expand All @@ -22,14 +10,12 @@ internal fun HttpUrl.Builder.addTrailingSlash(): HttpUrl.Builder {
internal object ForageConstants {

object Headers {
const val X_KEY = "X-KEY"
const val MERCHANT_ACCOUNT = "Merchant-Account"
const val IDEMPOTENCY_KEY = "IDEMPOTENCY-KEY"
const val TRACE_ID = "x-datadog-trace-id"
const val AUTHORIZATION = "Authorization"
const val BEARER = "Bearer"
const val API_VERSION = "API-VERSION"
const val BT_PROXY_KEY = "BT-PROXY-KEY"
const val CONTENT_TYPE = "Content-Type"
const val SESSION_TOKEN = "Session-Token"
}
Expand All @@ -46,23 +32,15 @@ internal object ForageConstants {
}

object PathSegment {
const val ISO_SERVER = "iso_server"
const val ENCRYPTION_ALIAS = "encryption_alias"
const val API = "api"
const val PAYMENT_METHODS = "payment_methods"
const val MESSAGE = "message"
const val PAYMENTS = "payments"
const val REFUNDS = "refunds"
}

object VGS {
const val PIN_FIELD_NAME = "pin"
}
}

internal enum class VaultType(val value: String) {
VGS_VAULT_TYPE("vgs"),
BT_VAULT_TYPE("basis_theory"),
FORAGE_VAULT_TYPE("forage");

override fun toString(): String {
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,15 @@ internal enum class EventOutcome(val value: String) {

internal enum class EventName(val value: String) {
/*
VAULT_RESPONSE refers to a response from the VGS or BT submit actions.
VAULT_RESPONSE refers to a response from the Rosetta submit actions.
*/
VAULT_RESPONSE("vault_response"),

/*
CUSTOMER_PERCEIVED_RESPONSE refers to the response from a balance or capture action. There are
multiple chained requests that come from the client when executing a balance or capture action.
Ex of a balance action:
[GET] EncryptionKey -> [GET] PaymentMethod -> [POST] to VGS/BT -> [GET] Poll for Response ->
[GET] PaymentMethod -> Return Balance
[GET] PaymentMethod -> [POST] to Rosetta -> Return Balance
*/
CUSTOMER_PERCEIVED_RESPONSE("customer_perceived_response");

Expand Down Expand Up @@ -120,17 +119,15 @@ internal abstract class ResponseMonitor<T>(metricsLogger: Log? = Log.getInstance
}

/*
VaultProxyResponseMonitor is used to track the response time from the VGS and BT submit
functions. The timer begins when a balance or capture request is submitted to VGS/BT
VaultProxyResponseMonitor is used to track the response time from the Rosetta submit
function. The timer begins when a balance or capture request is submitted to Rosetta
and ends when a response is received by the SDK.
*/
internal class VaultProxyResponseMonitor(vault: VaultType, userAction: UserAction, metricsLogger: Log?) : ResponseMonitor<VaultProxyResponseMonitor>(metricsLogger) {
private var vaultType: VaultType? = null
internal class VaultProxyResponseMonitor(userAction: UserAction, metricsLogger: Log?) : ResponseMonitor<VaultProxyResponseMonitor>(metricsLogger) {
private var userAction: UserAction? = null
private var eventName: EventName = EventName.VAULT_RESPONSE

init {
this.vaultType = vault
this.userAction = userAction
}

Expand All @@ -150,7 +147,7 @@ internal class VaultProxyResponseMonitor(vault: VaultType, userAction: UserActio
return
}

val vaultType = vaultType
val vaultType = VaultType.FORAGE_VAULT_TYPE
val userAction = userAction

val forageErrorCodeOrNull = forageErrorCode ?: UnknownForageErrorCode.UNKNOWN
Expand Down Expand Up @@ -178,17 +175,15 @@ internal class VaultProxyResponseMonitor(vault: VaultType, userAction: UserActio
that come from the client when executing a balance or capture action. The timer begins when the
first HTTP request is sent from the SDK and ends when the the SDK returns information back to
the user. Ex of a balance action:
Timer Begins -> [GET] EncryptionKey -> [GET] PaymentMethod -> [POST] to VGS/BT ->
Timer Begins -> [GET] PaymentMethod -> [POST] to Rosetta ->
[GET] Poll for Response -> [GET] PaymentMethod -> Timer Ends -> Return Balance
*/
internal class CustomerPerceivedResponseMonitor(vault: VaultType, userAction: UserAction, metricsLogger: Log?) : ResponseMonitor<CustomerPerceivedResponseMonitor>(metricsLogger) {
private var vaultType: VaultType? = null
internal class CustomerPerceivedResponseMonitor(userAction: UserAction, metricsLogger: Log?) : ResponseMonitor<CustomerPerceivedResponseMonitor>(metricsLogger) {
private var userAction: UserAction? = null
private var eventOutcome: EventOutcome? = null
private var eventName: EventName = EventName.CUSTOMER_PERCEIVED_RESPONSE

init {
this.vaultType = vault
this.userAction = userAction
}

Expand Down Expand Up @@ -232,7 +227,7 @@ internal class CustomerPerceivedResponseMonitor(vault: VaultType, userAction: Us
return
}

val vaultType = vaultType
val vaultType = VaultType.FORAGE_VAULT_TYPE
val userAction = userAction

val forageErrorCodeOrNull = forageErrorCode ?: UnknownForageErrorCode.UNKNOWN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.joinforage.forage.android.core.services.vault

import com.joinforage.forage.android.core.services.ForageConstants
import com.joinforage.forage.android.core.services.VaultType
import com.joinforage.forage.android.core.services.forageapi.encryptkey.EncryptionKeys
import com.joinforage.forage.android.core.services.forageapi.network.ForageApiResponse
import com.joinforage.forage.android.core.services.forageapi.network.UnknownErrorApiResponse
import com.joinforage.forage.android.core.services.forageapi.paymentmethod.EbtCard
Expand All @@ -18,7 +17,6 @@ internal val IncompletePinError = ForageApiResponse.Failure(
)

internal open class VaultSubmitterParams(
open val encryptionKeys: EncryptionKeys,
open val idempotencyKey: String,
open val merchantId: String,
open val path: String,
Expand Down Expand Up @@ -56,7 +54,6 @@ internal abstract class AbstractVaultSubmitter(
}

val vaultToken = getVaultToken(params.paymentMethod)
val encryptionKey = parseEncryptionKey(params.encryptionKeys)

// if a vault provider is missing a token, we will
// gracefully fail here
Expand All @@ -67,7 +64,6 @@ internal abstract class AbstractVaultSubmitter(

// ========= USED FOR REPORTING IMPORTANT METRICS =========
val proxyResponseMonitor = VaultProxyResponseMonitor(
vault = vaultType,
userAction = params.userAction,
metricsLogger = logger
)
Expand All @@ -78,7 +74,6 @@ internal abstract class AbstractVaultSubmitter(

val vaultProxyRequest = buildProxyRequest(
params = params,
encryptionKey = encryptionKey,
vaultToken = vaultToken
).setPath(params.path).setParams(params)

Expand All @@ -99,17 +94,14 @@ internal abstract class AbstractVaultSubmitter(
}

// abstract methods
internal abstract fun parseEncryptionKey(encryptionKeys: EncryptionKeys): String
internal abstract suspend fun submitProxyRequest(vaultProxyRequest: VaultProxyRequest): ForageApiResponse<String>
internal abstract fun getVaultToken(paymentMethod: PaymentMethod): String?

// concrete methods
protected open fun buildProxyRequest(
params: VaultSubmitterParams,
encryptionKey: String,
vaultToken: String
) = VaultProxyRequest.emptyRequest()
.setHeader(ForageConstants.Headers.X_KEY, encryptionKey)
.setHeader(ForageConstants.Headers.MERCHANT_ACCOUNT, params.merchantId)
.setHeader(ForageConstants.Headers.IDEMPOTENCY_KEY, params.idempotencyKey)
.setHeader(ForageConstants.Headers.TRACE_ID, logger.getTraceIdValue())
Expand Down
Loading
Loading