-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Organize all files into core and ecom packages
The second step in the public ecommerce repo that needs to take place in order to make sharing code between the private pos repo and this repo pain free; all while allowing for both repos to evolve independently Signed-off-by: Devin Morgan <[email protected]>
- Loading branch information
1 parent
be479a9
commit 1772e21
Showing
96 changed files
with
621 additions
and
504 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# This ensures that the ProxyRequestObject property names (like card_number_token) are preserved | ||
# and are not obfuscated when consumed by clients who use ProGuard. | ||
-keepclassmembers class com.joinforage.forage.android.vault.ProxyRequestObject { | ||
-keepclassmembers class com.joinforage.forage.android.ecom.services.vault.bt.ProxyRequestObject { | ||
*; | ||
} |
25 changes: 0 additions & 25 deletions
25
forage-android/src/main/java/com/joinforage/forage/android/Utils.kt
This file was deleted.
Oops, something went wrong.
8 changes: 4 additions & 4 deletions
8
...rage/forage/android/ForageSDKInterface.kt → ...forage/android/core/ForageSDKInterface.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 0 additions & 9 deletions
9
forage-android/src/main/java/com/joinforage/forage/android/core/StopgapGlobalState.kt
This file was deleted.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
...inforage/forage/android/core/EnvConfig.kt → ...forage/android/core/services/EnvConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
forage-android/src/main/java/com/joinforage/forage/android/core/services/Utils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
package com.joinforage.forage.android.core.services | ||
|
||
import com.joinforage.forage.android.core.services.forageapi.network.ForageError | ||
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("") | ||
} | ||
|
||
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" | ||
} | ||
|
||
object RequestBody { | ||
const val CARD_NUMBER_TOKEN = "card_number_token" | ||
|
||
// POS-only | ||
const val REASON = "reason" | ||
const val METADATA = "metadata" | ||
const val AMOUNT = "amount" | ||
const val POS_TERMINAL = "pos_terminal" | ||
const val PROVIDER_TERMINAL_ID = "provider_terminal_id" | ||
} | ||
|
||
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" | ||
} | ||
|
||
object ErrorResponseObjects { | ||
val INCOMPLETE_PIN_ERROR = listOf( | ||
ForageError( | ||
400, | ||
"user_error", | ||
"Invalid EBT Card PIN entered. Please enter your 4-digit 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 { | ||
return value | ||
} | ||
} | ||
|
||
// This extension splits the path by "/" and adds each segment individually to the path. | ||
// This is to prevent the URL from getting corrupted through internal OKHttp URL encoding. | ||
internal fun HttpUrl.Builder.addPathSegmentsSafe(path: String): HttpUrl.Builder { | ||
path.split("/").forEach { segment -> | ||
if (segment.isNotEmpty()) { | ||
this.addPathSegment(segment) | ||
} | ||
} | ||
return this | ||
} | ||
|
||
/** | ||
* [JSONObject.optString] has trouble falling back to `null` and seems to fallback to `"null"` (string) instead | ||
*/ | ||
internal fun JSONObject.getStringOrNull(fieldName: String): String? { | ||
if (!has(fieldName) || isNull(fieldName)) { | ||
return null | ||
} | ||
return optString(fieldName) | ||
} | ||
|
||
internal fun JSONObject.hasNonNull(fieldName: String): Boolean { | ||
return has(fieldName) && !isNull(fieldName) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ge/forage/android/model/EncryptionKeys.kt → ...es/forageapi/encryptkey/EncryptionKeys.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...ndroid/network/model/ForageApiResponse.kt → ...es/forageapi/network/ForageApiResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...ge/android/network/OkHttpClientBuilder.kt → .../forageapi/network/OkHttpClientBuilder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 5 additions & 3 deletions
8
...e/forage/android/network/model/Payment.kt → ...ore/services/forageapi/payment/Payment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...e/forage/android/network/model/Balance.kt → ...rvices/forageapi/paymentmethod/Balance.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...rage/forage/android/network/model/Card.kt → .../services/forageapi/paymentmethod/Card.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...network/model/PaymentMethodRequestBody.kt → ...paymentmethod/PaymentMethodRequestBody.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.