From c0fb91efcaecd1edd7e6be8c4fac3a1c6163cab2 Mon Sep 17 00:00:00 2001 From: Timothy Chow Date: Fri, 13 Sep 2024 09:20:49 -0500 Subject: [PATCH 1/4] Update classes, functions, and property access control for the external merchant interface and various other clean up. --- .../americanexpress/AmericanExpressClient.kt | 3 +- .../americanexpress/AmericanExpressResult.kt | 6 +- .../AmericanExpressRewardsBalance.kt | 5 +- .../api/core/AnalyticsEventBlob.kt | 2 +- .../api/core/BraintreeClient.kt | 4 +- .../api/core/BraintreeError.kt | 8 +-- .../braintreepayments/api/core/ClientToken.kt | 6 +- .../api/core/ConfigurationCallback.kt | 3 + .../api/core/ConfigurationException.kt | 2 +- .../api/core/ConfigurationLoader.kt | 2 +- .../api/core/DeviceInspector.kt | 2 - .../api/core/ErrorWithResponse.kt | 1 - .../api/core/GraphQLConstants.kt | 1 - .../api/core/IntegrationType.kt | 2 +- .../api/core/PostalAddressParser.kt | 1 - .../braintreepayments/api/core/UUIDHelper.kt | 21 ------ CHANGELOG.md | 3 +- .../api/card/AuthenticationInsight.kt | 6 +- .../com/braintreepayments/api/card/BinType.kt | 2 +- .../com/braintreepayments/api/card/Card.kt | 1 - .../braintreepayments/api/card/CardClient.kt | 3 +- .../braintreepayments/api/card/CardNonce.kt | 2 + .../braintreepayments/api/card/CardResult.kt | 4 +- .../api/card/CardUnitTest.kt | 16 ----- .../api/datacollector/DataCollector.kt | 27 ++++--- .../api/datacollector/DataCollectorResult.kt | 4 +- .../api/datacollector/MagnesInternalClient.kt | 4 +- .../demo/PayPalFragment.java | 1 + .../api/googlepay/GooglePayActivity.kt | 2 +- .../api/googlepay/GooglePayCapabilities.kt | 32 --------- .../api/googlepay/GooglePayCardNonce.kt | 4 +- .../api/googlepay/GooglePayClient.kt | 27 ++++--- .../api/googlepay/GooglePayLauncher.kt | 3 +- .../googlepay/GooglePayPaymentAuthRequest.kt | 6 +- .../api/googlepay/GooglePayReadinessResult.kt | 2 +- .../api/googlepay/GooglePayRequest.kt | 13 ++-- .../api/googlepay/GooglePayResult.kt | 4 +- .../GooglePayTokenizationParameters.kt | 7 +- .../api/googlepay/ReadyForGooglePayRequest.kt | 17 ++--- .../GooglePayCapabilitiesUnitTest.kt | 70 ------------------- .../localpayment/LocalPaymentAuthRequest.kt | 4 +- .../LocalPaymentAuthRequestParams.kt | 7 +- .../localpayment/LocalPaymentAuthResult.kt | 6 +- .../LocalPaymentAuthResultInfo.kt | 12 ---- .../api/localpayment/LocalPaymentClient.kt | 7 +- ...LocalPaymentInternalAuthRequestCallback.kt | 4 +- .../api/localpayment/LocalPaymentNonce.kt | 2 + .../LocalPaymentPendingRequest.kt | 4 +- .../api/localpayment/LocalPaymentRequest.kt | 2 +- .../api/localpayment/LocalPaymentResult.kt | 6 +- .../api/paypal/PayPalAccount.kt | 5 +- .../api/paypal/PayPalClient.kt | 3 +- .../api/paypal/PayPalCreditFinancing.kt | 2 + .../api/paypal/PayPalCreditFinancingAmount.kt | 4 +- .../api/paypal/PayPalLineItem.kt | 2 + .../api/paypal/PayPalLineItemKind.kt | 2 +- .../api/paypal/PayPalLineItemUpcType.kt | 2 +- .../api/paypal/PayPalPaymentAuthRequest.kt | 4 +- .../paypal/PayPalPaymentAuthRequestParams.kt | 3 + .../api/paypal/PayPalPaymentAuthResult.kt | 6 +- .../api/paypal/PayPalPaymentIntent.kt | 5 +- .../api/paypal/PayPalPaymentUserAction.kt | 2 +- .../api/paypal/PayPalPendingRequest.kt | 6 +- .../api/paypal/PayPalRequest.kt | 50 ++++++------- .../api/paypal/PayPalResult.kt | 6 +- .../sepadirectdebit/SEPADirectDebitClient.kt | 3 +- .../sepadirectdebit/SEPADirectDebitNonce.kt | 2 + .../SEPADirectDebitPaymentAuthRequest.kt | 6 +- .../SEPADirectDebitPaymentAuthResult.kt | 7 +- .../SEPADirectDebitPendingRequest.kt | 4 +- .../sepadirectdebit/SEPADirectDebitResult.kt | 4 +- .../api/sharedutils/AppHelper.java | 2 - .../api/sharedutils/CertificateHelper.java | 3 + .../api/sharedutils/ClassHelper.java | 15 ---- .../api/sharedutils/HttpClient.java | 7 -- .../api/sharedutils/HttpClientException.java | 3 + .../api/sharedutils/HttpRequest.java | 10 --- .../api/sharedutils/HttpResponse.kt | 3 + .../api/sharedutils/HttpResponseTiming.kt | 3 + .../api/sharedutils/Json.java | 2 - .../api/sharedutils/ManifestValidator.java | 6 -- .../api/sharedutils/RateLimitException.java | 3 + .../api/sharedutils/Scheduler.java | 3 + .../api/sharedutils/ServerException.java | 3 + .../ServiceUnavailableException.java | 3 + .../api/sharedutils/SignatureVerifier.java | 3 - .../sharedutils/SynchronousHttpClient.java | 3 + .../api/sharedutils/TLSSocketFactory.java | 1 - .../api/sharedutils/ThreadScheduler.java | 2 + .../api/sharedutils/UnexpectedException.java | 4 -- .../sharedutils/UpgradeRequiredException.java | 3 + .../EligiblePaymentsApiRequest.kt | 26 +++---- .../shopperinsights/ShopperInsightsClient.kt | 3 +- .../shopperinsights/ShopperInsightsInfo.kt | 2 +- .../shopperinsights/ShopperInsightsResult.kt | 4 +- .../threedsecure/ThreeDSecureAccountType.kt | 2 +- .../ThreeDSecureAdditionalInformation.kt | 2 + .../api/threedsecure/ThreeDSecureClient.kt | 2 + .../api/threedsecure/ThreeDSecureLauncher.kt | 2 + .../api/threedsecure/ThreeDSecureLookup.kt | 2 + .../ThreeDSecurePaymentAuthRequest.kt | 12 ++-- .../threedsecure/ThreeDSecurePostalAddress.kt | 2 + .../ThreeDSecurePrepareLookupResult.kt | 10 +-- .../api/threedsecure/ThreeDSecureRequest.kt | 2 + .../ThreeDSecureRequestedExemptionType.kt | 2 +- .../api/threedsecure/ThreeDSecureResult.kt | 7 +- .../ThreeDSecureV2ButtonCustomization.kt | 4 +- .../ThreeDSecureV2LabelCustomization.kt | 4 +- .../ThreeDSecureV2TextBoxCustomization.kt | 4 +- .../ThreeDSecureV2ToolbarCustomization.kt | 4 +- .../ThreeDSecureV2UiCustomization.kt | 4 +- .../api/venmo/VenmoAccount.kt | 15 +--- .../api/venmo/VenmoAccountNonce.kt | 2 + .../braintreepayments/api/venmo/VenmoApi.kt | 3 +- .../api/venmo/VenmoClient.kt | 3 +- .../api/venmo/VenmoLauncher.kt | 2 +- .../api/venmo/VenmoLauncherCallback.kt | 10 --- .../api/venmo/VenmoLineItem.kt | 2 + .../api/venmo/VenmoPaymentAuthRequest.kt | 6 +- .../api/venmo/VenmoPaymentAuthResult.kt | 6 +- .../api/venmo/VenmoPendingRequest.kt | 4 +- .../api/venmo/VenmoResult.kt | 4 +- .../api/venmo/VenmoSharedPrefsWriter.kt | 3 - .../api/venmo/VenmoAccountUnitTest.java | 6 +- .../api/visacheckout/VisaCheckoutAccount.kt | 3 - .../api/visacheckout/VisaCheckoutAddress.kt | 3 + .../api/visacheckout/VisaCheckoutNonce.kt | 2 + .../VisaCheckoutProfileBuilderResult.kt | 6 +- .../api/visacheckout/VisaCheckoutResult.kt | 4 +- .../api/visacheckout/VisaCheckoutUserData.kt | 3 + .../VisaCheckoutClientUnitTest.kt | 1 - 131 files changed, 325 insertions(+), 456 deletions(-) delete mode 100644 GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayCapabilities.kt delete mode 100644 GooglePay/src/test/java/com/braintreepayments/api/googlepay/GooglePayCapabilitiesUnitTest.kt delete mode 100644 LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentAuthResultInfo.kt delete mode 100644 SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/ClassHelper.java delete mode 100644 Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoLauncherCallback.kt diff --git a/AmericanExpress/src/main/java/com/braintreepayments/api/americanexpress/AmericanExpressClient.kt b/AmericanExpress/src/main/java/com/braintreepayments/api/americanexpress/AmericanExpressClient.kt index 52916b2d5c..d1c774fdf0 100644 --- a/AmericanExpress/src/main/java/com/braintreepayments/api/americanexpress/AmericanExpressClient.kt +++ b/AmericanExpress/src/main/java/com/braintreepayments/api/americanexpress/AmericanExpressClient.kt @@ -2,7 +2,6 @@ package com.braintreepayments.api.americanexpress import android.content.Context import android.net.Uri -import androidx.annotation.RestrictTo import com.braintreepayments.api.core.ApiClient.Companion.versionedPath import com.braintreepayments.api.core.BraintreeClient import org.json.JSONException @@ -10,7 +9,7 @@ import org.json.JSONException /** * Used to integrate with Braintree's American Express API */ -class AmericanExpressClient @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) constructor( +class AmericanExpressClient internal constructor( private val braintreeClient: BraintreeClient ) { diff --git a/AmericanExpress/src/main/java/com/braintreepayments/api/americanexpress/AmericanExpressResult.kt b/AmericanExpress/src/main/java/com/braintreepayments/api/americanexpress/AmericanExpressResult.kt index 07ff406393..e36d0affbd 100644 --- a/AmericanExpress/src/main/java/com/braintreepayments/api/americanexpress/AmericanExpressResult.kt +++ b/AmericanExpress/src/main/java/com/braintreepayments/api/americanexpress/AmericanExpressResult.kt @@ -8,10 +8,12 @@ sealed class AmericanExpressResult { /** * The [rewardsBalance] was successfully fetched */ - class Success(val rewardsBalance: AmericanExpressRewardsBalance) : AmericanExpressResult() + class Success internal constructor( + val rewardsBalance: AmericanExpressRewardsBalance + ) : AmericanExpressResult() /** * There was an [error] fetching rewards balance */ - class Failure(val error: Exception) : AmericanExpressResult() + class Failure internal constructor(val error: Exception) : AmericanExpressResult() } diff --git a/AmericanExpress/src/main/java/com/braintreepayments/api/americanexpress/AmericanExpressRewardsBalance.kt b/AmericanExpress/src/main/java/com/braintreepayments/api/americanexpress/AmericanExpressRewardsBalance.kt index 132f10364d..458605284d 100644 --- a/AmericanExpress/src/main/java/com/braintreepayments/api/americanexpress/AmericanExpressRewardsBalance.kt +++ b/AmericanExpress/src/main/java/com/braintreepayments/api/americanexpress/AmericanExpressRewardsBalance.kt @@ -1,7 +1,6 @@ package com.braintreepayments.api.americanexpress import android.os.Parcelable -import androidx.annotation.RestrictTo import com.braintreepayments.api.sharedutils.Json import kotlinx.parcelize.Parcelize import org.json.JSONException @@ -49,10 +48,8 @@ data class AmericanExpressRewardsBalance @JvmOverloads constructor( * @return The [AmericanExpressRewardsBalance] with rewards balance data. * @throws JSONException when parsing fails. */ - @JvmStatic - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @Throws(JSONException::class) - fun fromJson(jsonString: String): AmericanExpressRewardsBalance { + internal fun fromJson(jsonString: String): AmericanExpressRewardsBalance { val json = JSONObject(jsonString) val rewardsBalance = AmericanExpressRewardsBalance() diff --git a/BraintreeCore/src/main/java/com/braintreepayments/api/core/AnalyticsEventBlob.kt b/BraintreeCore/src/main/java/com/braintreepayments/api/core/AnalyticsEventBlob.kt index 482ed7a3f6..e1f72e5983 100644 --- a/BraintreeCore/src/main/java/com/braintreepayments/api/core/AnalyticsEventBlob.kt +++ b/BraintreeCore/src/main/java/com/braintreepayments/api/core/AnalyticsEventBlob.kt @@ -9,7 +9,7 @@ import androidx.room.PrimaryKey * at the JSON level. JSON encoded events can be sent directly to the analytics server. */ @Entity(tableName = "analytics_event_blob") -data class AnalyticsEventBlob( +internal data class AnalyticsEventBlob( @ColumnInfo(name = "json_string") val jsonString: String, @PrimaryKey(autoGenerate = true) @ColumnInfo(name = "_id") val id: Long = 0L ) diff --git a/BraintreeCore/src/main/java/com/braintreepayments/api/core/BraintreeClient.kt b/BraintreeCore/src/main/java/com/braintreepayments/api/core/BraintreeClient.kt index 64109fad59..40508b36b4 100644 --- a/BraintreeCore/src/main/java/com/braintreepayments/api/core/BraintreeClient.kt +++ b/BraintreeCore/src/main/java/com/braintreepayments/api/core/BraintreeClient.kt @@ -67,7 +67,6 @@ class BraintreeClient @VisibleForTesting internal constructor( /** * @suppress */ - @JvmOverloads constructor ( context: Context, authorization: String, @@ -129,7 +128,6 @@ class BraintreeClient @VisibleForTesting internal constructor( /** * @suppress */ - @JvmOverloads fun sendAnalyticsEvent( eventName: String, params: AnalyticsEventParams = AnalyticsEventParams() @@ -308,7 +306,7 @@ class BraintreeClient @VisibleForTesting internal constructor( /** * @suppress */ - fun reportCrash() = + internal fun reportCrash() = getConfiguration { configuration, _ -> analyticsClient.reportCrash( applicationContext, diff --git a/BraintreeCore/src/main/java/com/braintreepayments/api/core/BraintreeError.kt b/BraintreeCore/src/main/java/com/braintreepayments/api/core/BraintreeError.kt index 5b3a75d461..42e01cde1e 100644 --- a/BraintreeCore/src/main/java/com/braintreepayments/api/core/BraintreeError.kt +++ b/BraintreeCore/src/main/java/com/braintreepayments/api/core/BraintreeError.kt @@ -1,7 +1,6 @@ package com.braintreepayments.api.core import android.os.Parcelable -import androidx.annotation.RestrictTo import com.braintreepayments.api.core.GraphQLConstants.ErrorTypes import com.braintreepayments.api.sharedutils.Json import kotlinx.parcelize.Parcelize @@ -64,12 +63,7 @@ class BraintreeError internal constructor( return errors } - /** - * @suppress - */ - @JvmStatic - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) - fun fromGraphQLJsonArray(graphQLErrors: JSONArray?): List { + internal fun fromGraphQLJsonArray(graphQLErrors: JSONArray?): List { val errors = mutableListOf() if (graphQLErrors == null) { return errors diff --git a/BraintreeCore/src/main/java/com/braintreepayments/api/core/ClientToken.kt b/BraintreeCore/src/main/java/com/braintreepayments/api/core/ClientToken.kt index 03dadfb11b..3e4958e865 100644 --- a/BraintreeCore/src/main/java/com/braintreepayments/api/core/ClientToken.kt +++ b/BraintreeCore/src/main/java/com/braintreepayments/api/core/ClientToken.kt @@ -4,8 +4,6 @@ import android.util.Base64 import androidx.annotation.RestrictTo import org.json.JSONException import org.json.JSONObject -import java.lang.NullPointerException -import kotlin.jvm.Throws /** * A class containing the configuration url and authorization for the current Braintree environment. @@ -24,8 +22,8 @@ class ClientToken @Throws(InvalidArgumentException::class) internal constructor( override val configUrl: String override val bearer: String - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) internal val authorizationFingerprint: String - val customerId: String? + internal val authorizationFingerprint: String + internal val customerId: String? init { try { diff --git a/BraintreeCore/src/main/java/com/braintreepayments/api/core/ConfigurationCallback.kt b/BraintreeCore/src/main/java/com/braintreepayments/api/core/ConfigurationCallback.kt index 371c0754b2..be90b0c6a3 100644 --- a/BraintreeCore/src/main/java/com/braintreepayments/api/core/ConfigurationCallback.kt +++ b/BraintreeCore/src/main/java/com/braintreepayments/api/core/ConfigurationCallback.kt @@ -1,8 +1,11 @@ package com.braintreepayments.api.core +import androidx.annotation.RestrictTo + /** * Callback for receiving result of [BraintreeClient.getConfiguration]. */ +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) fun interface ConfigurationCallback { /** * @param configuration [Configuration] diff --git a/BraintreeCore/src/main/java/com/braintreepayments/api/core/ConfigurationException.kt b/BraintreeCore/src/main/java/com/braintreepayments/api/core/ConfigurationException.kt index c85da7bfbf..dd3a63ed86 100644 --- a/BraintreeCore/src/main/java/com/braintreepayments/api/core/ConfigurationException.kt +++ b/BraintreeCore/src/main/java/com/braintreepayments/api/core/ConfigurationException.kt @@ -5,7 +5,7 @@ import androidx.annotation.RestrictTo /** * Error class thrown when a configuration value is invalid */ -class ConfigurationException @JvmOverloads @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) constructor( +class ConfigurationException @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) constructor( message: String?, cause: Throwable? = null ) : BraintreeException(message, cause) diff --git a/BraintreeCore/src/main/java/com/braintreepayments/api/core/ConfigurationLoader.kt b/BraintreeCore/src/main/java/com/braintreepayments/api/core/ConfigurationLoader.kt index f6dee46e1d..f0fb6e8dcc 100644 --- a/BraintreeCore/src/main/java/com/braintreepayments/api/core/ConfigurationLoader.kt +++ b/BraintreeCore/src/main/java/com/braintreepayments/api/core/ConfigurationLoader.kt @@ -6,7 +6,7 @@ import android.util.Base64 import com.braintreepayments.api.sharedutils.HttpClient import org.json.JSONException -internal class ConfigurationLoader internal constructor( +internal class ConfigurationLoader( private val httpClient: BraintreeHttpClient, private val configurationCache: ConfigurationCache ) { diff --git a/BraintreeCore/src/main/java/com/braintreepayments/api/core/DeviceInspector.kt b/BraintreeCore/src/main/java/com/braintreepayments/api/core/DeviceInspector.kt index e9cf40abfe..3989d7e677 100644 --- a/BraintreeCore/src/main/java/com/braintreepayments/api/core/DeviceInspector.kt +++ b/BraintreeCore/src/main/java/com/braintreepayments/api/core/DeviceInspector.kt @@ -5,7 +5,6 @@ import android.content.Context import android.content.Intent import android.content.pm.PackageManager import android.os.Build -import androidx.annotation.VisibleForTesting import com.braintreepayments.api.sharedutils.AppHelper import com.braintreepayments.api.sharedutils.SignatureVerifier @@ -123,7 +122,6 @@ internal class DeviceInspector( private const val VENMO_APP_PACKAGE = "com.venmo" private const val VENMO_APP_SWITCH_ACTIVITY = "controller.SetupMerchantActivity" - @VisibleForTesting const val VENMO_BASE_64_ENCODED_SIGNATURE = "x34mMawEUcCG8l95riWCOK+kAJYejVmdt44l6tzcyUc=\n" private val venmoIntent: Intent get() = Intent().setComponent( diff --git a/BraintreeCore/src/main/java/com/braintreepayments/api/core/ErrorWithResponse.kt b/BraintreeCore/src/main/java/com/braintreepayments/api/core/ErrorWithResponse.kt index d060a897f1..964f4152aa 100644 --- a/BraintreeCore/src/main/java/com/braintreepayments/api/core/ErrorWithResponse.kt +++ b/BraintreeCore/src/main/java/com/braintreepayments/api/core/ErrorWithResponse.kt @@ -84,7 +84,6 @@ data class ErrorWithResponse internal constructor( */ @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @Throws(JSONException::class) - @JvmStatic fun fromJson(json: String?) = ErrorWithResponse(errorResponse = json).apply { parseJson(json) } diff --git a/BraintreeCore/src/main/java/com/braintreepayments/api/core/GraphQLConstants.kt b/BraintreeCore/src/main/java/com/braintreepayments/api/core/GraphQLConstants.kt index 6057ff812f..d8a3825dae 100644 --- a/BraintreeCore/src/main/java/com/braintreepayments/api/core/GraphQLConstants.kt +++ b/BraintreeCore/src/main/java/com/braintreepayments/api/core/GraphQLConstants.kt @@ -27,7 +27,6 @@ object GraphQLConstants { } object ErrorMessages { - const val UNKNOWN = "An unknown error occurred." const val USER = "Input is invalid." } diff --git a/BraintreeCore/src/main/java/com/braintreepayments/api/core/IntegrationType.kt b/BraintreeCore/src/main/java/com/braintreepayments/api/core/IntegrationType.kt index 8d19f0b0a4..fff3707d2c 100644 --- a/BraintreeCore/src/main/java/com/braintreepayments/api/core/IntegrationType.kt +++ b/BraintreeCore/src/main/java/com/braintreepayments/api/core/IntegrationType.kt @@ -11,7 +11,7 @@ enum class IntegrationType(val stringValue: String) { DROP_IN("dropin"); companion object { - fun fromString(stringValue: String?): IntegrationType? { + internal fun fromString(stringValue: String?): IntegrationType? { return values().firstOrNull { it.stringValue == stringValue } } } diff --git a/BraintreeCore/src/main/java/com/braintreepayments/api/core/PostalAddressParser.kt b/BraintreeCore/src/main/java/com/braintreepayments/api/core/PostalAddressParser.kt index 330e0bf732..3c9a953537 100644 --- a/BraintreeCore/src/main/java/com/braintreepayments/api/core/PostalAddressParser.kt +++ b/BraintreeCore/src/main/java/com/braintreepayments/api/core/PostalAddressParser.kt @@ -40,7 +40,6 @@ object PostalAddressParser { private const val VENMO_GQL_LOCALITY_KEY = "adminArea2" private const val VENMO_GQL_REGION_KEY = "adminArea1" - @JvmStatic fun fromJson(accountAddress: JSONObject?): PostalAddress = // If we don't have an account address, return an empty PostalAddress. accountAddress?.let { diff --git a/BraintreeCore/src/main/java/com/braintreepayments/api/core/UUIDHelper.kt b/BraintreeCore/src/main/java/com/braintreepayments/api/core/UUIDHelper.kt index 363115dcc1..8c3a9ac018 100644 --- a/BraintreeCore/src/main/java/com/braintreepayments/api/core/UUIDHelper.kt +++ b/BraintreeCore/src/main/java/com/braintreepayments/api/core/UUIDHelper.kt @@ -2,7 +2,6 @@ package com.braintreepayments.api.core import android.content.Context import androidx.annotation.RestrictTo -import androidx.annotation.VisibleForTesting import com.braintreepayments.api.sharedutils.BraintreeSharedPreferences import java.util.* @@ -12,24 +11,6 @@ import java.util.* @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) class UUIDHelper { - /** - * @param context Android Context - * @return A persistent UUID for this application install. - */ - fun getPersistentUUID(context: Context?): String? { - return getPersistentUUID(BraintreeSharedPreferences.getInstance(context)) - } - - @VisibleForTesting - internal fun getPersistentUUID(braintreeSharedPreferences: BraintreeSharedPreferences): String? { - var uuid = braintreeSharedPreferences.getString(BRAINTREE_UUID_KEY, null) - if (uuid == null) { - uuid = formattedUUID - braintreeSharedPreferences.putString(BRAINTREE_UUID_KEY, uuid) - } - return uuid - } - val formattedUUID: String get() = UUID.randomUUID().toString().replace("-", "") @@ -37,7 +18,6 @@ class UUIDHelper { return getInstallationGUID(BraintreeSharedPreferences.getInstance(context)) } - @VisibleForTesting internal fun getInstallationGUID(braintreeSharedPreferences: BraintreeSharedPreferences): String { var installationGUID = braintreeSharedPreferences.getString(INSTALL_GUID, null) if (installationGUID == null) { @@ -48,7 +28,6 @@ class UUIDHelper { } companion object { - private const val BRAINTREE_UUID_KEY = "braintreeUUID" private const val INSTALL_GUID = "InstallationGUID" } } diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ecbdc277b..b8ac71ace7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,8 +24,9 @@ * ThreeDSecure * Make `ThreeDSecureParams` internal * Make `ThreeDSecurePaymentAuthResult` parameters internal - * LocalPayment * Remove `ThreeDSecurePaymentAuthResultInfo` + * LocalPayment + * Remove `LocalPaymentAuthResultInfo` * Make `LocalPaymentAuthRequestParams` internal ## 5.0.0-beta2 (2024-08-28) diff --git a/Card/src/main/java/com/braintreepayments/api/card/AuthenticationInsight.kt b/Card/src/main/java/com/braintreepayments/api/card/AuthenticationInsight.kt index 33ad5006f5..d5f3955a4b 100644 --- a/Card/src/main/java/com/braintreepayments/api/card/AuthenticationInsight.kt +++ b/Card/src/main/java/com/braintreepayments/api/card/AuthenticationInsight.kt @@ -1,6 +1,7 @@ package com.braintreepayments.api.card import android.os.Parcelable +import androidx.annotation.RestrictTo import com.braintreepayments.api.sharedutils.Json import kotlinx.parcelize.Parcelize import org.json.JSONObject @@ -13,13 +14,16 @@ import org.json.JSONObject * v4#authentication-insight">Documentation for possible values. */ @Parcelize -data class AuthenticationInsight(val regulationEnvironment: String) : Parcelable { +data class AuthenticationInsight internal constructor( + val regulationEnvironment: String +) : Parcelable { companion object { private const val GRAPHQL_REGULATION_ENVIRONMENT_KEY = "customerAuthenticationRegulationEnvironment" private const val REST_REGULATION_ENVIRONMENT_KEY = "regulationEnvironment" + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @JvmStatic fun fromJson(json: JSONObject?): AuthenticationInsight? { diff --git a/Card/src/main/java/com/braintreepayments/api/card/BinType.kt b/Card/src/main/java/com/braintreepayments/api/card/BinType.kt index a6b24a3d6d..07aad7444f 100644 --- a/Card/src/main/java/com/braintreepayments/api/card/BinType.kt +++ b/Card/src/main/java/com/braintreepayments/api/card/BinType.kt @@ -6,7 +6,7 @@ enum class BinType { Unknown; companion object { - fun fromString(string: String): BinType { + internal fun fromString(string: String): BinType { return when (string.lowercase()) { Yes.name.lowercase() -> Yes No.name.lowercase() -> No diff --git a/Card/src/main/java/com/braintreepayments/api/card/Card.kt b/Card/src/main/java/com/braintreepayments/api/card/Card.kt index 12638e6085..a487449f2e 100644 --- a/Card/src/main/java/com/braintreepayments/api/card/Card.kt +++ b/Card/src/main/java/com/braintreepayments/api/card/Card.kt @@ -96,7 +96,6 @@ data class Card @JvmOverloads constructor( private const val AUTHENTICATION_INSIGHT_INPUT_KEY = "authenticationInsightInput" } - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) private fun buildMetadataJSON(): JSONObject { return MetadataBuilder() .sessionId(sessionId) diff --git a/Card/src/main/java/com/braintreepayments/api/card/CardClient.kt b/Card/src/main/java/com/braintreepayments/api/card/CardClient.kt index 9db16f999c..e3dd646ad2 100644 --- a/Card/src/main/java/com/braintreepayments/api/card/CardClient.kt +++ b/Card/src/main/java/com/braintreepayments/api/card/CardClient.kt @@ -1,7 +1,6 @@ package com.braintreepayments.api.card import android.content.Context -import androidx.annotation.VisibleForTesting import com.braintreepayments.api.card.CardNonce.Companion.fromJSON import com.braintreepayments.api.core.AnalyticsParamRepository import com.braintreepayments.api.core.ApiClient @@ -16,7 +15,7 @@ import org.json.JSONObject * Used to tokenize credit or debit cards using a [Card]. For more information see the * [documentation](https://developer.paypal.com/braintree/docs/guides/credit-cards/overview) */ -class CardClient @VisibleForTesting @JvmOverloads internal constructor( +class CardClient internal constructor( private val braintreeClient: BraintreeClient, private val apiClient: ApiClient = ApiClient(braintreeClient), private val analyticsParamRepository: AnalyticsParamRepository = AnalyticsParamRepository.instance diff --git a/Card/src/main/java/com/braintreepayments/api/card/CardNonce.kt b/Card/src/main/java/com/braintreepayments/api/card/CardNonce.kt index 6e8bca18ea..ccf92721da 100644 --- a/Card/src/main/java/com/braintreepayments/api/card/CardNonce.kt +++ b/Card/src/main/java/com/braintreepayments/api/card/CardNonce.kt @@ -173,7 +173,9 @@ constructor( } } + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) const val API_RESOURCE_KEY: String = "creditCards" + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) const val DATA_KEY: String = "data" private const val PAYMENT_METHOD_NONCE_KEY = "nonce" diff --git a/Card/src/main/java/com/braintreepayments/api/card/CardResult.kt b/Card/src/main/java/com/braintreepayments/api/card/CardResult.kt index 3ee31e5993..2ba023c5ab 100644 --- a/Card/src/main/java/com/braintreepayments/api/card/CardResult.kt +++ b/Card/src/main/java/com/braintreepayments/api/card/CardResult.kt @@ -8,10 +8,10 @@ sealed class CardResult { /** * The card tokenization completed successfully. This [nonce] should be sent to your server. */ - class Success(val nonce: CardNonce) : CardResult() + class Success internal constructor(val nonce: CardNonce) : CardResult() /** * There was an [error] during card tokenization. */ - class Failure(val error: Exception) : CardResult() + class Failure internal constructor(val error: Exception) : CardResult() } diff --git a/Card/src/test/java/com/braintreepayments/api/card/CardUnitTest.kt b/Card/src/test/java/com/braintreepayments/api/card/CardUnitTest.kt index 42ffa6177e..42285fcec6 100644 --- a/Card/src/test/java/com/braintreepayments/api/card/CardUnitTest.kt +++ b/Card/src/test/java/com/braintreepayments/api/card/CardUnitTest.kt @@ -241,22 +241,6 @@ class CardUnitTest { @Throws(JSONException::class) fun buildJSON_doesNotIncludeEmptyStrings() { val card = Card() -// card.number = "" -// card.expirationDate = "" -// card.expirationMonth = "" -// card.expirationYear = "" -// card.cvv = "" -// card.postalCode = "" -// card.cardholderName = "" -// card.firstName = "" -// card.lastName = "" -// card.company = "" -// card.streetAddress = "" -// card.extendedAddress = "" -// card.locality = "" -// card.postalCode = "" -// card.region = "" -// card.countryCode = "" assertEquals(1, card.buildJSON().getJSONObject(CREDIT_CARD_KEY).length()) assertTrue(card.buildJSON().getJSONObject(CREDIT_CARD_KEY).has("options")) diff --git a/DataCollector/src/main/java/com/braintreepayments/api/datacollector/DataCollector.kt b/DataCollector/src/main/java/com/braintreepayments/api/datacollector/DataCollector.kt index 07c33e02a0..9804dabda4 100644 --- a/DataCollector/src/main/java/com/braintreepayments/api/datacollector/DataCollector.kt +++ b/DataCollector/src/main/java/com/braintreepayments/api/datacollector/DataCollector.kt @@ -4,7 +4,6 @@ import android.content.Context import android.text.TextUtils import androidx.annotation.MainThread import androidx.annotation.RestrictTo -import androidx.annotation.VisibleForTesting import com.braintreepayments.api.core.BraintreeClient import com.braintreepayments.api.core.Configuration import com.braintreepayments.api.core.UUIDHelper @@ -14,10 +13,10 @@ import org.json.JSONObject /** * PayPalDataCollector is used to collect PayPal specific device information to aid in fraud detection and prevention. */ -class DataCollector @VisibleForTesting internal constructor( +class DataCollector @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) constructor( private val braintreeClient: BraintreeClient, - private val magnesInternalClient: MagnesInternalClient, - private val uuidHelper: UUIDHelper + private val magnesInternalClient: MagnesInternalClient = MagnesInternalClient(), + private val uuidHelper: UUIDHelper = UUIDHelper() ) { /** * Initializes a new [DataCollector] instance @@ -32,13 +31,6 @@ class DataCollector @VisibleForTesting internal constructor( ) ) - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) - constructor(braintreeClient: BraintreeClient) : this( - braintreeClient, - MagnesInternalClient(), - UUIDHelper() - ) - /** * @suppress */ @@ -99,14 +91,19 @@ class DataCollector @VisibleForTesting internal constructor( if (configuration != null) { val deviceData = JSONObject() try { - val internalRequest = DataCollectorInternalRequest(request.hasUserLocationConsent).apply { - applicationGuid = getPayPalInstallationGUID(context) - } + val internalRequest = + DataCollectorInternalRequest(request.hasUserLocationConsent).apply { + applicationGuid = getPayPalInstallationGUID(context) + } if (request.riskCorrelationId != null) { internalRequest.clientMetadataId = request.riskCorrelationId } val correlationId = - magnesInternalClient.getClientMetadataId(context, configuration, internalRequest) + magnesInternalClient.getClientMetadataId( + context, + configuration, + internalRequest + ) if (!TextUtils.isEmpty(correlationId)) { deviceData.put(CORRELATION_ID_KEY, correlationId) } diff --git a/DataCollector/src/main/java/com/braintreepayments/api/datacollector/DataCollectorResult.kt b/DataCollector/src/main/java/com/braintreepayments/api/datacollector/DataCollectorResult.kt index 0eb657b221..593ebbe593 100644 --- a/DataCollector/src/main/java/com/braintreepayments/api/datacollector/DataCollectorResult.kt +++ b/DataCollector/src/main/java/com/braintreepayments/api/datacollector/DataCollectorResult.kt @@ -8,10 +8,10 @@ sealed class DataCollectorResult { /** * The device information was collected for fraud detection. Send [deviceData] to your server */ - class Success(val deviceData: String) : DataCollectorResult() + class Success internal constructor(val deviceData: String) : DataCollectorResult() /** * There was an [error] during device data collection */ - class Failure(val error: Exception) : DataCollectorResult() + class Failure internal constructor(val error: Exception) : DataCollectorResult() } diff --git a/DataCollector/src/main/java/com/braintreepayments/api/datacollector/MagnesInternalClient.kt b/DataCollector/src/main/java/com/braintreepayments/api/datacollector/MagnesInternalClient.kt index 7d4b0c0415..73e85bc38f 100644 --- a/DataCollector/src/main/java/com/braintreepayments/api/datacollector/MagnesInternalClient.kt +++ b/DataCollector/src/main/java/com/braintreepayments/api/datacollector/MagnesInternalClient.kt @@ -3,6 +3,7 @@ package com.braintreepayments.api.datacollector import android.content.Context import android.util.Log import androidx.annotation.MainThread +import androidx.annotation.RestrictTo import com.braintreepayments.api.core.Configuration import lib.android.paypal.com.magnessdk.Environment import lib.android.paypal.com.magnessdk.InvalidInputException @@ -10,12 +11,13 @@ import lib.android.paypal.com.magnessdk.MagnesSDK import lib.android.paypal.com.magnessdk.MagnesSettings import lib.android.paypal.com.magnessdk.MagnesSource +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) class MagnesInternalClient( private val magnesSDK: MagnesSDK = MagnesSDK.getInstance() ) { @MainThread - fun getClientMetadataId( + internal fun getClientMetadataId( context: Context?, configuration: Configuration?, request: DataCollectorInternalRequest? diff --git a/Demo/src/main/java/com/braintreepayments/demo/PayPalFragment.java b/Demo/src/main/java/com/braintreepayments/demo/PayPalFragment.java index 7b33d5bdf1..2d989e4e6c 100644 --- a/Demo/src/main/java/com/braintreepayments/demo/PayPalFragment.java +++ b/Demo/src/main/java/com/braintreepayments/demo/PayPalFragment.java @@ -26,6 +26,7 @@ import com.braintreepayments.api.paypal.PayPalPendingRequest; import com.braintreepayments.api.paypal.PayPalRequest; import com.braintreepayments.api.paypal.PayPalResult; +import com.braintreepayments.api.sharedutils.AppHelper; import com.google.android.material.textfield.TextInputEditText; public class PayPalFragment extends BaseFragment { diff --git a/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayActivity.kt b/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayActivity.kt index 639ce1b7db..5e92c6938d 100644 --- a/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayActivity.kt +++ b/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayActivity.kt @@ -9,7 +9,7 @@ import com.google.android.gms.wallet.Wallet import com.google.android.gms.wallet.Wallet.WalletOptions import com.google.android.gms.wallet.WalletConstants -class GooglePayActivity : AppCompatActivity() { +internal class GooglePayActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) diff --git a/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayCapabilities.kt b/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayCapabilities.kt deleted file mode 100644 index 66779926bf..0000000000 --- a/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayCapabilities.kt +++ /dev/null @@ -1,32 +0,0 @@ -package com.braintreepayments.api.googlepay - -import android.content.Context -import com.braintreepayments.api.core.Configuration -import com.google.android.gms.common.ConnectionResult -import com.google.android.gms.common.GoogleApiAvailability -import com.google.android.gms.wallet.Wallet - -/** - * Class representing Google Pay payment capabilities - */ -object GooglePayCapabilities { - /** - * @return `true` if Google Pay is enabled and supported in the current environment, - * `false` otherwise. Note: this value only pertains to the Braintree configuration, to check if - * the user has Google Pay setup use [GooglePayClient.isReadyToPay] - */ - @SuppressWarnings("SwallowedException") - fun isGooglePayEnabled(context: Context, configuration: Configuration): Boolean { - return try { - Class.forName(Wallet::class.java.name) - - configuration.isGooglePayEnabled && GoogleApiAvailability.getInstance() - .isGooglePlayServicesAvailable(context) == - ConnectionResult.SUCCESS - } catch (e: ClassNotFoundException) { - false - } catch (e: NoClassDefFoundError) { - false - } - } -} diff --git a/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayCardNonce.kt b/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayCardNonce.kt index 6c06669fcf..0df6bd86a6 100644 --- a/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayCardNonce.kt +++ b/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayCardNonce.kt @@ -1,5 +1,6 @@ package com.braintreepayments.api.googlepay +import androidx.annotation.RestrictTo import com.braintreepayments.api.card.BinData import com.braintreepayments.api.core.PaymentMethodNonce import com.braintreepayments.api.core.PostalAddress @@ -35,7 +36,7 @@ data class GooglePayCardNonce internal constructor( val lastFour: String, val email: String, val cardNetwork: String, - var isNetworkTokenized: Boolean, + val isNetworkTokenized: Boolean, val billingAddress: PostalAddress, val shippingAddress: PostalAddress, val binData: BinData @@ -60,6 +61,7 @@ data class GooglePayCardNonce internal constructor( @Throws(JSONException::class) @JvmStatic + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) fun fromJSON(inputJson: JSONObject): PaymentMethodNonce { val tokenPayload = JSONObject( inputJson diff --git a/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayClient.kt b/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayClient.kt index c305772238..393ad8cce0 100644 --- a/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayClient.kt +++ b/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayClient.kt @@ -2,7 +2,7 @@ package com.braintreepayments.api.googlepay import android.content.Context import android.text.TextUtils -import androidx.annotation.VisibleForTesting +import androidx.annotation.RestrictTo import com.braintreepayments.api.core.AnalyticsParamRepository import com.braintreepayments.api.core.Authorization import com.braintreepayments.api.core.BraintreeClient @@ -28,7 +28,7 @@ import org.json.JSONObject * Used to create and tokenize Google Pay payment methods. For more information see the [documentation](https://developer.paypal.com/braintree/docs/guides/google-pay/overview) */ @SuppressWarnings("TooManyFunctions") -class GooglePayClient @VisibleForTesting internal constructor( +class GooglePayClient internal constructor( private val braintreeClient: BraintreeClient, private val internalGooglePayClient: GooglePayInternalClient = GooglePayInternalClient(), private val analyticsParamRepository: AnalyticsParamRepository = AnalyticsParamRepository.instance @@ -123,7 +123,12 @@ class GooglePayClient @VisibleForTesting internal constructor( } catch (ignored: JSONException) { } val readyToPayRequest = IsReadyToPayRequest.fromJson(json.toString()) - internalGooglePayClient.isReadyToPay(context, configuration, readyToPayRequest, callback) + internalGooglePayClient.isReadyToPay( + context, + configuration, + readyToPayRequest, + callback + ) } } @@ -155,7 +160,11 @@ class GooglePayClient @VisibleForTesting internal constructor( ) } else { if (e != null) { - callback.onTokenizationParametersResult(GooglePayTokenizationParameters.Failure(e)) + callback.onTokenizationParametersResult( + GooglePayTokenizationParameters.Failure( + e + ) + ) } else { callback.onTokenizationParametersResult(null) } @@ -184,7 +193,7 @@ class GooglePayClient @VisibleForTesting internal constructor( GooglePayPaymentAuthRequest.Failure( BraintreeException( "GooglePayActivity was not found in the Android " + - "manifest, or did not have a theme of R.style.bt_transparent_activity" + "manifest, or did not have a theme of R.style.bt_transparent_activity" ) ), callback ) @@ -225,7 +234,7 @@ class GooglePayClient @VisibleForTesting internal constructor( GooglePayPaymentAuthRequest.Failure( BraintreeException( "Google Pay is not enabled for your Braintree account, " + - "or Google Play Services are not configured correctly." + "or Google Play Services are not configured correctly." ) ), callback ) @@ -312,6 +321,7 @@ class GooglePayClient @VisibleForTesting internal constructor( } } + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) fun getTokenizationParameters( configuration: Configuration, authorization: Authorization @@ -349,6 +359,7 @@ class GooglePayClient @VisibleForTesting internal constructor( return parameters.build() } + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) fun getAllowedCardNetworks(configuration: Configuration): ArrayList { val allowedNetworks = ArrayList() for (network in configuration.googlePaySupportedNetworks) { @@ -541,7 +552,7 @@ class GooglePayClient @VisibleForTesting internal constructor( } val googlePayCanProcessPayPal = request.isPayPalEnabled && - !TextUtils.isEmpty(configuration.googlePayPayPalClientId) + !TextUtils.isEmpty(configuration.googlePayPayPalClientId) if (googlePayCanProcessPayPal) { if (request.getAllowedPaymentMethod("PAYPAL") == null) { @@ -566,7 +577,7 @@ class GooglePayClient @VisibleForTesting internal constructor( val activityInfo = braintreeClient.getManifestActivityInfo(GooglePayActivity::class.java) return activityInfo != null && - activityInfo.themeResource == R.style.bt_transparent_activity + activityInfo.themeResource == R.style.bt_transparent_activity } private fun callbackPaymentRequestSuccess( diff --git a/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayLauncher.kt b/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayLauncher.kt index 5d9bcde3d4..32f321b77c 100644 --- a/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayLauncher.kt +++ b/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayLauncher.kt @@ -3,14 +3,13 @@ package com.braintreepayments.api.googlepay import androidx.activity.ComponentActivity import androidx.activity.result.ActivityResultLauncher import androidx.activity.result.ActivityResultRegistry -import androidx.annotation.VisibleForTesting import androidx.fragment.app.Fragment import androidx.lifecycle.LifecycleOwner /** * Responsible for launching the Google Pay payment sheet */ -class GooglePayLauncher @VisibleForTesting internal constructor( +class GooglePayLauncher internal constructor( registry: ActivityResultRegistry, lifecycleOwner: LifecycleOwner, callback: GooglePayLauncherCallback diff --git a/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayPaymentAuthRequest.kt b/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayPaymentAuthRequest.kt index 0936ed4cb6..2d923d1122 100644 --- a/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayPaymentAuthRequest.kt +++ b/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayPaymentAuthRequest.kt @@ -11,10 +11,12 @@ sealed class GooglePayPaymentAuthRequest { * @param requestParams this parameter is intended for internal use only. It is not covered by * semantic versioning and may be changed or removed at any time. */ - class ReadyToLaunch(val requestParams: GooglePayPaymentAuthRequestParams) : GooglePayPaymentAuthRequest() + class ReadyToLaunch internal constructor( + val requestParams: GooglePayPaymentAuthRequestParams + ) : GooglePayPaymentAuthRequest() /** * There was an [error] creating the request */ - class Failure(val error: Exception) : GooglePayPaymentAuthRequest() + class Failure internal constructor(val error: Exception) : GooglePayPaymentAuthRequest() } diff --git a/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayReadinessResult.kt b/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayReadinessResult.kt index 73a7e66cb2..b989c702c0 100644 --- a/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayReadinessResult.kt +++ b/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayReadinessResult.kt @@ -15,5 +15,5 @@ sealed class GooglePayReadinessResult { * The Google Pay API is supported or not set up on this device, or there was an issue [error] * determining readiness. */ - class NotReadyToPay(val error: Exception?) : GooglePayReadinessResult() + class NotReadyToPay internal constructor(val error: Exception?) : GooglePayReadinessResult() } diff --git a/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayRequest.kt b/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayRequest.kt index cd45fe0dff..b4cd0e39d5 100644 --- a/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayRequest.kt +++ b/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayRequest.kt @@ -2,6 +2,7 @@ package com.braintreepayments.api.googlepay import android.os.Parcelable import android.text.TextUtils +import androidx.annotation.RestrictTo import com.google.android.gms.wallet.ShippingAddressRequirements import com.google.android.gms.wallet.TransactionInfo import com.google.android.gms.wallet.WalletConstants @@ -140,8 +141,8 @@ class GooglePayRequest @JvmOverloads constructor( * * @return String */ - @SuppressWarnings("LongMethod", "CyclomaticComplexMethod", "NestedBlockDepth") + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) fun toJson(): String { val transactionInfoJson = JSONObject() val transactionInfo = transactionInfo @@ -270,7 +271,7 @@ class GooglePayRequest @JvmOverloads constructor( } } - fun billingAddressFormatToString(): String { + internal fun billingAddressFormatToString(): String { var format = "MIN" if (billingAddressFormat == WalletConstants.BILLING_ADDRESS_FORMAT_FULL) { format = "FULL" @@ -281,7 +282,7 @@ class GooglePayRequest @JvmOverloads constructor( /** * @return Allowed payment methods for a given payment method type. */ - fun getAllowedPaymentMethod(type: String): JSONObject? { + internal fun getAllowedPaymentMethod(type: String): JSONObject? { return allowedPaymentMethods[type]?.let { JSONObject(it) } @@ -290,7 +291,7 @@ class GooglePayRequest @JvmOverloads constructor( /** * @return Tokenization specification for a given payment method type. */ - fun getTokenizationSpecificationForType(type: String): JSONObject? { + internal fun getTokenizationSpecificationForType(type: String): JSONObject? { return tokenizationSpecifications[type]?.let { JSONObject(it) } @@ -299,7 +300,7 @@ class GooglePayRequest @JvmOverloads constructor( /** * @return Allowed authentication methods for a given payment method type. */ - fun getAllowedAuthMethodsForType(type: String): JSONArray? { + internal fun getAllowedAuthMethodsForType(type: String): JSONArray? { return allowedAuthMethods[type]?.let { JSONArray(it) } @@ -308,7 +309,7 @@ class GooglePayRequest @JvmOverloads constructor( /** * @return Allowed card networks for a given payment method type. */ - fun getAllowedCardNetworksForType(type: String): JSONArray? { + internal fun getAllowedCardNetworksForType(type: String): JSONArray? { return allowedCardNetworks[type]?.let { JSONArray(it) } diff --git a/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayResult.kt b/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayResult.kt index af5f526dc5..1884e8a072 100644 --- a/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayResult.kt +++ b/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayResult.kt @@ -10,12 +10,12 @@ sealed class GooglePayResult { /** * The Google Pay flow completed successfully. This [nonce] should be sent to your server. */ - class Success(val nonce: PaymentMethodNonce) : GooglePayResult() + class Success internal constructor(val nonce: PaymentMethodNonce) : GooglePayResult() /** * There was an [error] in the Google Pay flow. */ - class Failure(val error: Exception) : GooglePayResult() + class Failure internal constructor(val error: Exception) : GooglePayResult() /** * The user canceled the Google Pay flow. diff --git a/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayTokenizationParameters.kt b/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayTokenizationParameters.kt index ba3402b7f0..6e2fbf4c20 100644 --- a/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayTokenizationParameters.kt +++ b/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayTokenizationParameters.kt @@ -10,12 +10,13 @@ sealed class GooglePayTokenizationParameters { /** * The request was successfully created */ - class Success(val parameters: PaymentMethodTokenizationParameters, - val allowedCardNetworks: Collection + class Success internal constructor( + val parameters: PaymentMethodTokenizationParameters, + val allowedCardNetworks: Collection ) : GooglePayTokenizationParameters() /** * There was an [error] creating the request */ - class Failure(val error: Exception) : GooglePayTokenizationParameters() + class Failure internal constructor(val error: Exception) : GooglePayTokenizationParameters() } diff --git a/GooglePay/src/main/java/com/braintreepayments/api/googlepay/ReadyForGooglePayRequest.kt b/GooglePay/src/main/java/com/braintreepayments/api/googlepay/ReadyForGooglePayRequest.kt index cda81fe28e..e84cd893e6 100644 --- a/GooglePay/src/main/java/com/braintreepayments/api/googlepay/ReadyForGooglePayRequest.kt +++ b/GooglePay/src/main/java/com/braintreepayments/api/googlepay/ReadyForGooglePayRequest.kt @@ -2,16 +2,11 @@ package com.braintreepayments.api.googlepay /** * Optional parameters to use when checking whether Google Pay is supported and set up on the customer's device. + * + * @property isExistingPaymentMethodRequired Indicates whether the customer must already have + * 1at least one payment method from your supported card networks in order to be considered + * ready to pay with Google Pay */ -class ReadyForGooglePayRequest { - /** - * If set to true, then the [GooglePayClient.isReadyToPay] - * method will call the listener with true if the customer is ready to pay with one or more of your - * supported card networks. - * - * @param existingPaymentMethodRequired Indicates whether the customer must already have - * at least one payment method from your supported card networks in order to be considered - * ready to pay with Google Pay - */ +data class ReadyForGooglePayRequest( var isExistingPaymentMethodRequired: Boolean = false -} +) diff --git a/GooglePay/src/test/java/com/braintreepayments/api/googlepay/GooglePayCapabilitiesUnitTest.kt b/GooglePay/src/test/java/com/braintreepayments/api/googlepay/GooglePayCapabilitiesUnitTest.kt deleted file mode 100644 index e8a39ef45e..0000000000 --- a/GooglePay/src/test/java/com/braintreepayments/api/googlepay/GooglePayCapabilitiesUnitTest.kt +++ /dev/null @@ -1,70 +0,0 @@ -package com.braintreepayments.api.googlepay - -import androidx.fragment.app.FragmentActivity -import com.braintreepayments.api.core.Configuration -import com.braintreepayments.api.testutils.TestConfigurationBuilder -import com.braintreepayments.api.testutils.TestConfigurationBuilder.TestGooglePayConfigurationBuilder -import com.google.android.gms.common.ConnectionResult -import com.google.android.gms.common.GoogleApiAvailability -import io.mockk.every -import io.mockk.mockk -import io.mockk.mockkStatic -import org.junit.Assert.assertFalse -import org.junit.Assert.assertTrue -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import org.robolectric.RobolectricTestRunner - -@RunWith(RobolectricTestRunner::class) -class GooglePayCapabilitiesUnitTest { - - private val configWithGooglePayEnabled: Configuration = TestConfigurationBuilder() - .googlePay(TestGooglePayConfigurationBuilder() - .enabled(true)) - .buildConfiguration() - - private val configWithGooglePayDisabled: Configuration = TestConfigurationBuilder() - .googlePay(TestGooglePayConfigurationBuilder() - .enabled(false)) - .buildConfiguration() - - lateinit var activity: FragmentActivity - lateinit var googleApiAvailability: GoogleApiAvailability - - @Before - fun beforeEach() { - activity = mockk(relaxed = true) - googleApiAvailability = mockk(relaxed = true) - - mockkStatic(GoogleApiAvailability::class) - every { GoogleApiAvailability.getInstance() } returns googleApiAvailability - } - - @Test - fun isGooglePayEnabled_whenConfigurationEnabledAndApiAvailable_returnsTrue() { - every { - googleApiAvailability.isGooglePlayServicesAvailable(any()) - } returns ConnectionResult.SUCCESS - - assertTrue(GooglePayCapabilities.isGooglePayEnabled(activity, configWithGooglePayEnabled)) - } - - @Test - fun isGooglePayEnabled_whenConfigurationNotEnabled_returnsFalse() { - every { - googleApiAvailability.isGooglePlayServicesAvailable(any()) - } returns ConnectionResult.SUCCESS - - assertFalse(GooglePayCapabilities.isGooglePayEnabled(activity, configWithGooglePayDisabled)) - } - - @Test - fun isGooglePayEnabled_whenApiNotAvailable_returnsFalse() { - every { - googleApiAvailability.isGooglePlayServicesAvailable(any()) - } returns ConnectionResult.NETWORK_ERROR - - assertFalse(GooglePayCapabilities.isGooglePayEnabled(activity, configWithGooglePayEnabled)) - } -} diff --git a/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentAuthRequest.kt b/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentAuthRequest.kt index a1f94e344c..c7d1b4cce0 100644 --- a/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentAuthRequest.kt +++ b/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentAuthRequest.kt @@ -11,11 +11,11 @@ sealed class LocalPaymentAuthRequest { * @param requestParams this parameter is intended for internal use only. It is not covered by * semantic versioning and may be changed or removed at any time. */ - class ReadyToLaunch(val requestParams: LocalPaymentAuthRequestParams) : + class ReadyToLaunch internal constructor(val requestParams: LocalPaymentAuthRequestParams) : LocalPaymentAuthRequest() /** * There was an [error] creating the request */ - class Failure(val error: Exception) : LocalPaymentAuthRequest() + class Failure internal constructor(val error: Exception) : LocalPaymentAuthRequest() } diff --git a/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentAuthRequestParams.kt b/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentAuthRequestParams.kt index 8019b1b7f2..f4f8434bb4 100644 --- a/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentAuthRequestParams.kt +++ b/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentAuthRequestParams.kt @@ -11,10 +11,9 @@ import com.braintreepayments.api.BrowserSwitchOptions * @property paymentId of the local payment after creation. */ @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) -data class LocalPaymentAuthRequestParams internal constructor( +data class LocalPaymentAuthRequestParams @JvmOverloads internal constructor( val request: LocalPaymentRequest, val approvalUrl: String, - val paymentId: String -) { + val paymentId: String, var browserSwitchOptions: BrowserSwitchOptions? = null -} +) diff --git a/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentAuthResult.kt b/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentAuthResult.kt index 536db92946..2f604cc251 100644 --- a/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentAuthResult.kt +++ b/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentAuthResult.kt @@ -10,13 +10,15 @@ sealed class LocalPaymentAuthResult { /** * A successful result that should be passed to [LocalPaymentClient.tokenize] to complete the flow */ - class Success(internal val browserSwitchSuccess: BrowserSwitchFinalResult.Success) : LocalPaymentAuthResult() + class Success internal constructor( + internal val browserSwitchSuccess: BrowserSwitchFinalResult.Success + ) : LocalPaymentAuthResult() /** * The browser switch failed. * @property [error] Error detailing the reason for the browser switch failure. */ - class Failure(val error: Exception) : LocalPaymentAuthResult() + class Failure internal constructor(val error: Exception) : LocalPaymentAuthResult() /** * If no matching result can be found for the [LocalPaymentPendingRequest.Started] passed to diff --git a/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentAuthResultInfo.kt b/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentAuthResultInfo.kt deleted file mode 100644 index 2d5fe2cdff..0000000000 --- a/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentAuthResultInfo.kt +++ /dev/null @@ -1,12 +0,0 @@ -package com.braintreepayments.api.localpayment - -import androidx.annotation.RestrictTo -import com.braintreepayments.api.BrowserSwitchFinalResult - -/** - * Details of a [LocalPaymentAuthResult.Success] - */ -@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) -class LocalPaymentAuthResultInfo internal constructor( - internal val browserSwitchSuccess: BrowserSwitchFinalResult.Success -) diff --git a/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentClient.kt b/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentClient.kt index 00ed9dd122..3985e6d21f 100644 --- a/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentClient.kt +++ b/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentClient.kt @@ -3,7 +3,6 @@ package com.braintreepayments.api.localpayment import android.content.Context import android.net.Uri import androidx.annotation.RestrictTo -import androidx.annotation.VisibleForTesting import com.braintreepayments.api.BrowserSwitchFinalResult import com.braintreepayments.api.BrowserSwitchOptions import com.braintreepayments.api.core.AnalyticsEventParams @@ -22,7 +21,7 @@ import java.util.Locale /** * Used to integrate with local payments. */ -class LocalPaymentClient @VisibleForTesting internal constructor( +class LocalPaymentClient internal constructor( private val braintreeClient: BraintreeClient, private val dataCollector: DataCollector = DataCollector(braintreeClient), private val localPaymentApi: LocalPaymentApi = LocalPaymentApi(braintreeClient), @@ -230,7 +229,7 @@ class LocalPaymentClient @VisibleForTesting internal constructor( } companion object { - const val LOCAL_PAYMENT_CANCEL: String = "local-payment-cancel" - const val LOCAL_PAYMENT_SUCCESS: String = "local-payment-success" + internal const val LOCAL_PAYMENT_CANCEL: String = "local-payment-cancel" + internal const val LOCAL_PAYMENT_SUCCESS: String = "local-payment-success" } } diff --git a/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentInternalAuthRequestCallback.kt b/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentInternalAuthRequestCallback.kt index e7cf02ccfd..197ae1f3ab 100644 --- a/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentInternalAuthRequestCallback.kt +++ b/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentInternalAuthRequestCallback.kt @@ -10,7 +10,7 @@ internal fun interface LocalPaymentInternalAuthRequestCallback { * @param error an exception that occurred while initiating a Local Payment */ fun onLocalPaymentInternalAuthResult( - localPaymentAuthRequestParams: LocalPaymentAuthRequestParams?, - error: Exception? + localPaymentAuthRequestParams: LocalPaymentAuthRequestParams?, + error: Exception? ) } diff --git a/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentNonce.kt b/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentNonce.kt index 8d9cd129e2..359dd8746e 100644 --- a/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentNonce.kt +++ b/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentNonce.kt @@ -1,5 +1,6 @@ package com.braintreepayments.api.localpayment +import androidx.annotation.RestrictTo import com.braintreepayments.api.core.PaymentMethodNonce import com.braintreepayments.api.core.PostalAddress import com.braintreepayments.api.core.PostalAddressParser.fromJson @@ -60,6 +61,7 @@ data class LocalPaymentNonce internal constructor( @Throws(JSONException::class) @Suppress("ThrowsCount") @JvmStatic + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) fun fromJSON(inputJson: JSONObject): LocalPaymentNonce { val json = inputJson.getJSONArray(API_RESOURCE_KEY).getJSONObject(0) val details = json.getJSONObject(DETAILS_KEY) diff --git a/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentPendingRequest.kt b/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentPendingRequest.kt index 97106c2662..653c7b5202 100644 --- a/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentPendingRequest.kt +++ b/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentPendingRequest.kt @@ -14,10 +14,10 @@ sealed class LocalPaymentPendingRequest { * @property pendingRequestString - This String should be stored and passed to * [LocalPaymentLauncher.handleReturnToAppFromBrowser]. */ - class Started(val pendingRequestString: String) : LocalPaymentPendingRequest() + class Started internal constructor(val pendingRequestString: String) : LocalPaymentPendingRequest() /** * An error occurred launching the local payment browser flow. See [error] for details. */ - class Failure(val error: Exception) : LocalPaymentPendingRequest() + class Failure internal constructor(val error: Exception) : LocalPaymentPendingRequest() } diff --git a/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentRequest.kt b/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentRequest.kt index ddad423e91..c7b53f30c3 100644 --- a/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentRequest.kt +++ b/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentRequest.kt @@ -55,7 +55,7 @@ data class LocalPaymentRequest @JvmOverloads constructor( var surname: String? = null ) { - fun build(returnUrl: String?, cancelUrl: String?): String { + internal fun build(returnUrl: String?, cancelUrl: String?): String { try { val payload = JSONObject() .put(INTENT_KEY, "sale") diff --git a/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentResult.kt b/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentResult.kt index 67721df02d..3c9593889b 100644 --- a/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentResult.kt +++ b/LocalPayment/src/main/java/com/braintreepayments/api/localpayment/LocalPaymentResult.kt @@ -8,15 +8,15 @@ sealed class LocalPaymentResult { /** * The local payment flow completed successfully. This [nonce] should be sent to your server. */ - class Success(val nonce: LocalPaymentNonce) : LocalPaymentResult() + class Success internal constructor(val nonce: LocalPaymentNonce) : LocalPaymentResult() /** * There was an [error] in the local payment flow. */ - class Failure(val error: Exception) : LocalPaymentResult() + class Failure internal constructor(val error: Exception) : LocalPaymentResult() /** * The user canceled the local payment flow. */ - object Cancel : LocalPaymentResult() + data object Cancel : LocalPaymentResult() } diff --git a/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalAccount.kt b/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalAccount.kt index 5ef228e53d..cdbc1ad6b1 100644 --- a/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalAccount.kt +++ b/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalAccount.kt @@ -1,6 +1,5 @@ package com.braintreepayments.api.paypal -import androidx.annotation.RestrictTo import com.braintreepayments.api.core.IntegrationType import com.braintreepayments.api.core.MetadataBuilder import com.braintreepayments.api.core.PaymentMethod @@ -24,8 +23,7 @@ import org.json.JSONObject * @property paymentType Payment type from original PayPal request. Either "billing-agreement" or * "single-payment" */ -@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) -data class PayPalAccount( +internal data class PayPalAccount( val clientMetadataId: String?, val urlResponseData: JSONObject, val intent: PayPalPaymentIntent?, @@ -36,7 +34,6 @@ data class PayPalAccount( override var integration: IntegrationType? = IntegrationType.CUSTOM ) : PaymentMethod { - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) private fun buildMetadataJSON(): JSONObject { return MetadataBuilder() .sessionId(sessionId) diff --git a/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalClient.kt b/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalClient.kt index 135bccdc95..8cab5dd89e 100644 --- a/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalClient.kt +++ b/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalClient.kt @@ -3,7 +3,6 @@ package com.braintreepayments.api.paypal import android.content.Context import android.net.Uri import android.text.TextUtils -import androidx.annotation.VisibleForTesting import com.braintreepayments.api.BrowserSwitchOptions import com.braintreepayments.api.core.AnalyticsEventParams import com.braintreepayments.api.core.BraintreeClient @@ -19,7 +18,7 @@ import org.json.JSONObject /** * Used to tokenize PayPal accounts. For more information see the [documentation](https://developer.paypal.com/braintree/docs/guides/paypal/overview/android/v4) */ -class PayPalClient @VisibleForTesting internal constructor( +class PayPalClient internal constructor( private val braintreeClient: BraintreeClient, private val internalPayPalClient: PayPalInternalClient = PayPalInternalClient(braintreeClient), ) { diff --git a/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalCreditFinancing.kt b/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalCreditFinancing.kt index 3a99e55771..7d7d28bccf 100644 --- a/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalCreditFinancing.kt +++ b/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalCreditFinancing.kt @@ -1,6 +1,7 @@ package com.braintreepayments.api.paypal import android.os.Parcelable +import androidx.annotation.RestrictTo import kotlinx.parcelize.Parcelize import org.json.JSONException import org.json.JSONObject @@ -40,6 +41,7 @@ data class PayPalCreditFinancing internal constructor( @JvmStatic @Throws(JSONException::class) + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) fun fromJson(creditFinancing: JSONObject?): PayPalCreditFinancing { return if (creditFinancing == null) { PayPalCreditFinancing() diff --git a/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalCreditFinancingAmount.kt b/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalCreditFinancingAmount.kt index f8a035e353..c042fc6d25 100644 --- a/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalCreditFinancingAmount.kt +++ b/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalCreditFinancingAmount.kt @@ -1,6 +1,7 @@ package com.braintreepayments.api.paypal import android.os.Parcelable +import androidx.annotation.RestrictTo import com.braintreepayments.api.sharedutils.Json import kotlinx.parcelize.Parcelize import org.json.JSONObject @@ -14,7 +15,7 @@ import org.json.JSONObject * [ISO 4217](http://www.iso.org/iso/home/standards/currency_codes.htm) for the given currency. */ @Parcelize -data class PayPalCreditFinancingAmount( +data class PayPalCreditFinancingAmount internal constructor( val currency: String?, val value: String?, ) : Parcelable { @@ -24,6 +25,7 @@ data class PayPalCreditFinancingAmount( private const val VALUE_KEY = "value" @JvmStatic + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) fun fromJson(amount: JSONObject?): PayPalCreditFinancingAmount { return PayPalCreditFinancingAmount( currency = Json.optString(amount, CURRENCY_KEY, null), diff --git a/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalLineItem.kt b/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalLineItem.kt index 37a45de571..d3e6980c76 100644 --- a/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalLineItem.kt +++ b/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalLineItem.kt @@ -1,6 +1,7 @@ package com.braintreepayments.api.paypal import android.os.Parcelable +import androidx.annotation.RestrictTo import kotlinx.parcelize.Parcelize import org.json.JSONException import org.json.JSONObject @@ -41,6 +42,7 @@ data class PayPalLineItem var url: String? = null ) : Parcelable { + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) fun toJson(): JSONObject { return try { JSONObject() diff --git a/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalLineItemKind.kt b/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalLineItemKind.kt index 437b84ec38..5c54775068 100644 --- a/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalLineItemKind.kt +++ b/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalLineItemKind.kt @@ -6,7 +6,7 @@ package com.braintreepayments.api.paypal * [CREDIT] A line item that is a credit. * [DEBIT] A line item that debits. */ -enum class PayPalLineItemKind(val stringValue: String) { +enum class PayPalLineItemKind(internal val stringValue: String) { CREDIT("credit"), DEBIT("debit") } diff --git a/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalLineItemUpcType.kt b/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalLineItemUpcType.kt index f20f914237..dd385a1970 100644 --- a/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalLineItemUpcType.kt +++ b/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalLineItemUpcType.kt @@ -3,7 +3,7 @@ package com.braintreepayments.api.paypal /** * The upc type of PayPal line item. */ -enum class PayPalLineItemUpcType(val stringValue: String) { +enum class PayPalLineItemUpcType(internal val stringValue: String) { UPC_TYPE_A("UPC-A"), UPC_TYPE_B("UPC-B"), UPC_TYPE_C("UPC-C"), diff --git a/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalPaymentAuthRequest.kt b/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalPaymentAuthRequest.kt index e2eb3db2e3..ebad1b4c31 100644 --- a/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalPaymentAuthRequest.kt +++ b/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalPaymentAuthRequest.kt @@ -11,11 +11,11 @@ sealed class PayPalPaymentAuthRequest { * @param requestParams this parameter is intended for internal use only. It is not covered by * semantic versioning and may be changed or removed at any time. */ - class ReadyToLaunch(val requestParams: PayPalPaymentAuthRequestParams) : + class ReadyToLaunch internal constructor(val requestParams: PayPalPaymentAuthRequestParams) : PayPalPaymentAuthRequest() /** * There was an [error] creating the request */ - class Failure(val error: Exception) : PayPalPaymentAuthRequest() + class Failure internal constructor(val error: Exception) : PayPalPaymentAuthRequest() } diff --git a/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalPaymentAuthRequestParams.kt b/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalPaymentAuthRequestParams.kt index 8f99d490b1..4a0b10f1ac 100644 --- a/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalPaymentAuthRequestParams.kt +++ b/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalPaymentAuthRequestParams.kt @@ -13,12 +13,15 @@ data class PayPalPaymentAuthRequestParams @JvmOverloads internal constructor( val successUrl: String? = null, ) { + @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) val intent: PayPalPaymentIntent? get() = if (payPalRequest is PayPalCheckoutRequest) payPalRequest.intent else null + @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) val isBillingAgreement: Boolean get() = payPalRequest is PayPalVaultRequest + @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) val merchantAccountId: String? get() = payPalRequest.merchantAccountId } diff --git a/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalPaymentAuthResult.kt b/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalPaymentAuthResult.kt index aa1d38b763..f6751e59b1 100644 --- a/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalPaymentAuthResult.kt +++ b/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalPaymentAuthResult.kt @@ -10,13 +10,15 @@ sealed class PayPalPaymentAuthResult { /** * A successful result that should be passed to [PayPalClient.tokenize] to complete the flow */ - class Success(internal val browserSwitchSuccess: BrowserSwitchFinalResult.Success) : PayPalPaymentAuthResult() + class Success internal constructor( + internal val browserSwitchSuccess: BrowserSwitchFinalResult.Success + ) : PayPalPaymentAuthResult() /** * The browser switch failed. * @property [error] Error detailing the reason for the browser switch failure. */ - class Failure(val error: Exception) : PayPalPaymentAuthResult() + class Failure internal constructor(val error: Exception) : PayPalPaymentAuthResult() /** * If no matching result can be found for the [PayPalPendingRequest.Started] passed to diff --git a/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalPaymentIntent.kt b/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalPaymentIntent.kt index 8d78691f92..d31807afac 100644 --- a/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalPaymentIntent.kt +++ b/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalPaymentIntent.kt @@ -1,9 +1,11 @@ package com.braintreepayments.api.paypal +import androidx.annotation.RestrictTo + /** * The payment intent in the PayPal Checkout flow */ -enum class PayPalPaymentIntent(val stringValue: String) { +enum class PayPalPaymentIntent(internal val stringValue: String) { /** * Payment intent to create an order @@ -22,6 +24,7 @@ enum class PayPalPaymentIntent(val stringValue: String) { companion object { @JvmStatic + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) fun fromString(string: String?): PayPalPaymentIntent? { return PayPalPaymentIntent.values().firstOrNull { it.stringValue == string } } diff --git a/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalPaymentUserAction.kt b/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalPaymentUserAction.kt index e0345d83c9..f1a462fe2f 100644 --- a/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalPaymentUserAction.kt +++ b/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalPaymentUserAction.kt @@ -3,7 +3,7 @@ package com.braintreepayments.api.paypal /** * The call-to-action in the PayPal Checkout flow */ -enum class PayPalPaymentUserAction(val stringValue: String) { +enum class PayPalPaymentUserAction(internal val stringValue: String) { /** * Shows the default call-to-action text on the PayPal Express Checkout page. This option diff --git a/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalPendingRequest.kt b/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalPendingRequest.kt index ff68119b87..a9ddadc745 100644 --- a/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalPendingRequest.kt +++ b/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalPendingRequest.kt @@ -14,10 +14,12 @@ sealed class PayPalPendingRequest { * @property pendingRequestString - This String should be stored and passed to * [PayPalLauncher.handleReturnToAppFromBrowser]. */ - class Started(val pendingRequestString: String) : PayPalPendingRequest() + class Started internal constructor( + val pendingRequestString: String + ) : PayPalPendingRequest() /** * An error occurred launching the PayPal browser flow. See [error] for details. */ - class Failure(val error: Exception) : PayPalPendingRequest() + class Failure internal constructor(val error: Exception) : PayPalPendingRequest() } diff --git a/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalRequest.kt b/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalRequest.kt index d4c376973a..b3def2906e 100644 --- a/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalRequest.kt +++ b/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalRequest.kt @@ -1,6 +1,7 @@ package com.braintreepayments.api.paypal import android.os.Parcelable +import androidx.annotation.RestrictTo import com.braintreepayments.api.core.Authorization import com.braintreepayments.api.core.Configuration import com.braintreepayments.api.core.PostalAddress @@ -87,6 +88,7 @@ abstract class PayPalRequest internal constructor( ) : Parcelable { @Throws(JSONException::class) + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) abstract fun createRequestBody( configuration: Configuration?, authorization: Authorization?, @@ -95,29 +97,29 @@ abstract class PayPalRequest internal constructor( ): String? companion object { - const val NO_SHIPPING_KEY: String = "no_shipping" - const val ADDRESS_OVERRIDE_KEY: String = "address_override" - const val LOCALE_CODE_KEY: String = "locale_code" - const val REQUEST_BILLING_AGREEMENT_KEY: String = "request_billing_agreement" - const val BILLING_AGREEMENT_DETAILS_KEY: String = "billing_agreement_details" - const val DESCRIPTION_KEY: String = "description" - const val PAYER_EMAIL_KEY: String = "payer_email" - const val AUTHORIZATION_FINGERPRINT_KEY: String = "authorization_fingerprint" - const val TOKENIZATION_KEY: String = "client_key" - const val RETURN_URL_KEY: String = "return_url" - const val OFFER_CREDIT_KEY: String = "offer_paypal_credit" - const val OFFER_PAY_LATER_KEY: String = "offer_pay_later" - const val CANCEL_URL_KEY: String = "cancel_url" - const val EXPERIENCE_PROFILE_KEY: String = "experience_profile" - const val AMOUNT_KEY: String = "amount" - const val CURRENCY_ISO_CODE_KEY: String = "currency_iso_code" - const val INTENT_KEY: String = "intent" - const val LANDING_PAGE_TYPE_KEY: String = "landing_page_type" - const val DISPLAY_NAME_KEY: String = "brand_name" - const val SHIPPING_ADDRESS_KEY: String = "shipping_address" - const val MERCHANT_ACCOUNT_ID: String = "merchant_account_id" - const val CORRELATION_ID_KEY: String = "correlation_id" - const val LINE_ITEMS_KEY: String = "line_items" - const val USER_ACTION_KEY: String = "user_action" + internal const val NO_SHIPPING_KEY: String = "no_shipping" + internal const val ADDRESS_OVERRIDE_KEY: String = "address_override" + internal const val LOCALE_CODE_KEY: String = "locale_code" + internal const val REQUEST_BILLING_AGREEMENT_KEY: String = "request_billing_agreement" + internal const val BILLING_AGREEMENT_DETAILS_KEY: String = "billing_agreement_details" + internal const val DESCRIPTION_KEY: String = "description" + internal const val PAYER_EMAIL_KEY: String = "payer_email" + internal const val AUTHORIZATION_FINGERPRINT_KEY: String = "authorization_fingerprint" + internal const val TOKENIZATION_KEY: String = "client_key" + internal const val RETURN_URL_KEY: String = "return_url" + internal const val OFFER_CREDIT_KEY: String = "offer_paypal_credit" + internal const val OFFER_PAY_LATER_KEY: String = "offer_pay_later" + internal const val CANCEL_URL_KEY: String = "cancel_url" + internal const val EXPERIENCE_PROFILE_KEY: String = "experience_profile" + internal const val AMOUNT_KEY: String = "amount" + internal const val CURRENCY_ISO_CODE_KEY: String = "currency_iso_code" + internal const val INTENT_KEY: String = "intent" + internal const val LANDING_PAGE_TYPE_KEY: String = "landing_page_type" + internal const val DISPLAY_NAME_KEY: String = "brand_name" + internal const val SHIPPING_ADDRESS_KEY: String = "shipping_address" + internal const val MERCHANT_ACCOUNT_ID: String = "merchant_account_id" + internal const val CORRELATION_ID_KEY: String = "correlation_id" + internal const val LINE_ITEMS_KEY: String = "line_items" + internal const val USER_ACTION_KEY: String = "user_action" } } diff --git a/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalResult.kt b/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalResult.kt index 9733c19481..9b6e8c14f6 100644 --- a/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalResult.kt +++ b/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalResult.kt @@ -8,15 +8,15 @@ sealed class PayPalResult { /** * The PayPal flow completed successfully. This [nonce] should be sent to your server. */ - class Success(val nonce: PayPalAccountNonce) : PayPalResult() + class Success internal constructor(val nonce: PayPalAccountNonce) : PayPalResult() /** * There was an [error] in the PayPal payment flow. */ - class Failure(val error: Exception) : PayPalResult() + class Failure internal constructor(val error: Exception) : PayPalResult() /** * The user canceled the PayPal payment flow. */ - object Cancel : PayPalResult() + data object Cancel : PayPalResult() } diff --git a/SEPADirectDebit/src/main/java/com/braintreepayments/api/sepadirectdebit/SEPADirectDebitClient.kt b/SEPADirectDebit/src/main/java/com/braintreepayments/api/sepadirectdebit/SEPADirectDebitClient.kt index 4761c039c8..991054740e 100644 --- a/SEPADirectDebit/src/main/java/com/braintreepayments/api/sepadirectdebit/SEPADirectDebitClient.kt +++ b/SEPADirectDebit/src/main/java/com/braintreepayments/api/sepadirectdebit/SEPADirectDebitClient.kt @@ -3,7 +3,6 @@ package com.braintreepayments.api.sepadirectdebit import android.content.Context import android.net.Uri import android.webkit.URLUtil -import androidx.annotation.VisibleForTesting import com.braintreepayments.api.BrowserSwitchFinalResult import com.braintreepayments.api.BrowserSwitchOptions import com.braintreepayments.api.core.BraintreeClient @@ -15,7 +14,7 @@ import org.json.JSONObject /** * Used to integrate with SEPA Direct Debit. */ -class SEPADirectDebitClient @VisibleForTesting internal constructor( +class SEPADirectDebitClient internal constructor( private val braintreeClient: BraintreeClient, private val sepaDirectDebitApi: SEPADirectDebitApi = SEPADirectDebitApi(braintreeClient) ) { diff --git a/SEPADirectDebit/src/main/java/com/braintreepayments/api/sepadirectdebit/SEPADirectDebitNonce.kt b/SEPADirectDebit/src/main/java/com/braintreepayments/api/sepadirectdebit/SEPADirectDebitNonce.kt index dab826d0a5..7dea3a1b36 100644 --- a/SEPADirectDebit/src/main/java/com/braintreepayments/api/sepadirectdebit/SEPADirectDebitNonce.kt +++ b/SEPADirectDebit/src/main/java/com/braintreepayments/api/sepadirectdebit/SEPADirectDebitNonce.kt @@ -1,5 +1,6 @@ package com.braintreepayments.api.sepadirectdebit +import androidx.annotation.RestrictTo import com.braintreepayments.api.core.PaymentMethodNonce import kotlinx.parcelize.Parcelize import org.json.JSONException @@ -35,6 +36,7 @@ class SEPADirectDebitNonce internal constructor( @Throws(JSONException::class) @JvmStatic + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) fun fromJSON(inputJson: JSONObject): SEPADirectDebitNonce { val nonce = inputJson.getString(PAYMENT_METHOD_NONCE_KEY) val details = inputJson.optJSONObject(DETAILS_KEY) diff --git a/SEPADirectDebit/src/main/java/com/braintreepayments/api/sepadirectdebit/SEPADirectDebitPaymentAuthRequest.kt b/SEPADirectDebit/src/main/java/com/braintreepayments/api/sepadirectdebit/SEPADirectDebitPaymentAuthRequest.kt index 6e97d63a89..6c00bf5d9d 100644 --- a/SEPADirectDebit/src/main/java/com/braintreepayments/api/sepadirectdebit/SEPADirectDebitPaymentAuthRequest.kt +++ b/SEPADirectDebit/src/main/java/com/braintreepayments/api/sepadirectdebit/SEPADirectDebitPaymentAuthRequest.kt @@ -11,16 +11,16 @@ sealed class SEPADirectDebitPaymentAuthRequest { * @param requestParams this parameter is intended for internal use only. It is not covered by * semantic versioning and may be changed or removed at any time. */ - class ReadyToLaunch(val requestParams: SEPADirectDebitPaymentAuthRequestParams) : + class ReadyToLaunch internal constructor(val requestParams: SEPADirectDebitPaymentAuthRequestParams) : SEPADirectDebitPaymentAuthRequest() /** * No web-based mandate is required. Send this [nonce] to your server */ - class LaunchNotRequired(val nonce: SEPADirectDebitNonce) : SEPADirectDebitPaymentAuthRequest() + class LaunchNotRequired internal constructor(val nonce: SEPADirectDebitNonce) : SEPADirectDebitPaymentAuthRequest() /** * There was an [error] creating the request */ - class Failure(val error: Exception) : SEPADirectDebitPaymentAuthRequest() + class Failure internal constructor(val error: Exception) : SEPADirectDebitPaymentAuthRequest() } diff --git a/SEPADirectDebit/src/main/java/com/braintreepayments/api/sepadirectdebit/SEPADirectDebitPaymentAuthResult.kt b/SEPADirectDebit/src/main/java/com/braintreepayments/api/sepadirectdebit/SEPADirectDebitPaymentAuthResult.kt index ea7030dcb9..c3fc69b893 100644 --- a/SEPADirectDebit/src/main/java/com/braintreepayments/api/sepadirectdebit/SEPADirectDebitPaymentAuthResult.kt +++ b/SEPADirectDebit/src/main/java/com/braintreepayments/api/sepadirectdebit/SEPADirectDebitPaymentAuthResult.kt @@ -10,14 +10,15 @@ sealed class SEPADirectDebitPaymentAuthResult { /** * A successful result that should be passed to [SEPADirectDebitClient.tokenize] to complete the flow */ - class Success(internal val browserSwitchSuccess: BrowserSwitchFinalResult.Success) : - SEPADirectDebitPaymentAuthResult() + class Success internal constructor( + internal val browserSwitchSuccess: BrowserSwitchFinalResult.Success + ) : SEPADirectDebitPaymentAuthResult() /** * The browser switch failed. * @property [error] Error detailing the reason for the browser switch failure. */ - class Failure(val error: Exception) : SEPADirectDebitPaymentAuthResult() + class Failure internal constructor(val error: Exception) : SEPADirectDebitPaymentAuthResult() /** * If no matching result can be found for the [SEPADirectDebitPendingRequest.Started] passed to diff --git a/SEPADirectDebit/src/main/java/com/braintreepayments/api/sepadirectdebit/SEPADirectDebitPendingRequest.kt b/SEPADirectDebit/src/main/java/com/braintreepayments/api/sepadirectdebit/SEPADirectDebitPendingRequest.kt index 413e88b962..ad7004f268 100644 --- a/SEPADirectDebit/src/main/java/com/braintreepayments/api/sepadirectdebit/SEPADirectDebitPendingRequest.kt +++ b/SEPADirectDebit/src/main/java/com/braintreepayments/api/sepadirectdebit/SEPADirectDebitPendingRequest.kt @@ -14,10 +14,10 @@ sealed class SEPADirectDebitPendingRequest { * @property pendingRequestString - This String should be stored and passed to * [SEPADirectDebitLauncher.handleReturnToAppFromBrowser]. */ - class Started(val pendingRequestString: String) : SEPADirectDebitPendingRequest() + class Started internal constructor(val pendingRequestString: String) : SEPADirectDebitPendingRequest() /** * An error occurred launching the SEPA Direct Debit browser flow. See [error] for details. */ - class Failure(val error: Exception) : SEPADirectDebitPendingRequest() + class Failure internal constructor(val error: Exception) : SEPADirectDebitPendingRequest() } diff --git a/SEPADirectDebit/src/main/java/com/braintreepayments/api/sepadirectdebit/SEPADirectDebitResult.kt b/SEPADirectDebit/src/main/java/com/braintreepayments/api/sepadirectdebit/SEPADirectDebitResult.kt index b721a1b8c5..a3249bb194 100644 --- a/SEPADirectDebit/src/main/java/com/braintreepayments/api/sepadirectdebit/SEPADirectDebitResult.kt +++ b/SEPADirectDebit/src/main/java/com/braintreepayments/api/sepadirectdebit/SEPADirectDebitResult.kt @@ -9,12 +9,12 @@ sealed class SEPADirectDebitResult { * The SEPA Direct Debit flow completed successfully. This [nonce] should be sent to * your server. */ - class Success(val nonce: SEPADirectDebitNonce) : SEPADirectDebitResult() + class Success internal constructor(val nonce: SEPADirectDebitNonce) : SEPADirectDebitResult() /** * There was an [error] in the SEPA Direct Debit flow. */ - class Failure(val error: Exception) : SEPADirectDebitResult() + class Failure internal constructor(val error: Exception) : SEPADirectDebitResult() /** * The user canceled the SEPA Direct Debit flow. diff --git a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/AppHelper.java b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/AppHelper.java index c7aeab415e..9ff1a7e3be 100644 --- a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/AppHelper.java +++ b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/AppHelper.java @@ -15,13 +15,11 @@ public class AppHelper { private static final int NO_FLAGS = 0; - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public boolean isIntentAvailable(Context context, Intent intent) { List activities = context.getPackageManager().queryIntentActivities(intent, 0); return activities != null && activities.size() == 1; } - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public boolean isAppInstalled(Context context, String packageName) { PackageManager packageManager = context.getPackageManager(); try { diff --git a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/CertificateHelper.java b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/CertificateHelper.java index 04303497bb..6a4ff6e6da 100644 --- a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/CertificateHelper.java +++ b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/CertificateHelper.java @@ -1,11 +1,14 @@ package com.braintreepayments.api.sharedutils; +import androidx.annotation.RestrictTo; + import java.io.ByteArrayInputStream; import java.io.InputStream; import java.security.cert.CertificateException; import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate; +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) class CertificateHelper { byte[] getEncodedCertificate(byte[] signatureBytes) throws CertificateException { diff --git a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/ClassHelper.java b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/ClassHelper.java deleted file mode 100644 index 01be6a11af..0000000000 --- a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/ClassHelper.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.braintreepayments.api.sharedutils; - -class ClassHelper { - - ClassHelper() {} - - boolean isClassAvailable(String className) { - try { - Class.forName(className); - return true; - } catch (ClassNotFoundException ignored) { - return false; - } - } -} diff --git a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/HttpClient.java b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/HttpClient.java index 59ea6d71a5..0453489960 100644 --- a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/HttpClient.java +++ b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/HttpClient.java @@ -19,13 +19,10 @@ public class HttpClient { @IntDef({NO_RETRY, RETRY_MAX_3_TIMES}) @Retention(RetentionPolicy.SOURCE) - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public @interface RetryStrategy { } - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public static final int NO_RETRY = 0; - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public static final int RETRY_MAX_3_TIMES = 1; static final int MAX_RETRY_ATTEMPTS = 3; @@ -35,7 +32,6 @@ public class HttpClient { private final Map retryCountMap; - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public HttpClient(SSLSocketFactory socketFactory, HttpResponseParser httpResponseParser) { this(new SynchronousHttpClient(socketFactory, httpResponseParser), new ThreadScheduler()); } @@ -47,17 +43,14 @@ public HttpClient(SSLSocketFactory socketFactory, HttpResponseParser httpRespons this.retryCountMap = new HashMap<>(); } - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public String sendRequest(HttpRequest request) throws Exception { return syncHttpClient.request(request).getBody(); } - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public void sendRequest(HttpRequest request, NetworkResponseCallback callback) { sendRequest(request, HttpClient.NO_RETRY, callback); } - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public void sendRequest(HttpRequest request, @RetryStrategy int retryStrategy, NetworkResponseCallback callback) { scheduleRequest(request, retryStrategy, callback); diff --git a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/HttpClientException.java b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/HttpClientException.java index 7f3b4102be..c281141859 100644 --- a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/HttpClientException.java +++ b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/HttpClientException.java @@ -1,10 +1,13 @@ package com.braintreepayments.api.sharedutils; +import androidx.annotation.RestrictTo; + /** * Exception thrown when an HTTP request fails. */ public class HttpClientException extends Exception { + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) HttpClientException(String message) { super(message); } diff --git a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/HttpRequest.java b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/HttpRequest.java index f8b57add32..d9515d8a10 100644 --- a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/HttpRequest.java +++ b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/HttpRequest.java @@ -35,7 +35,6 @@ static HttpRequest newInstance() { return new HttpRequest(); } - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public HttpRequest() { headers = null; additionalHeaders = new HashMap<>(); @@ -45,31 +44,26 @@ public HttpRequest() { connectTimeout = THIRTY_SECONDS_MS; } - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public HttpRequest path(String path) { this.path = path; return this; } - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public HttpRequest baseUrl(String baseUrl) { this.baseUrl = baseUrl; return this; } - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public HttpRequest data(String dataAsString) { this.data = dataAsString.getBytes(StandardCharsets.UTF_8); return this; } - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public HttpRequest method(String method) { this.method = method; return this; } - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public HttpRequest addHeader(String name, String value) { additionalHeaders.put(name, value); return this; @@ -79,7 +73,6 @@ String getPath() { return path; } - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public byte[] getData() { return data; } @@ -91,12 +84,10 @@ void dispose() { } } - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public String getMethod() { return method; } - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public Map getHeaders() { if (headers == null) { headers = new HashMap<>(); @@ -115,7 +106,6 @@ int getConnectTimeout() { return connectTimeout; } - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public URL getURL() throws MalformedURLException, URISyntaxException { URL url; if (path.startsWith("http")) { diff --git a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/HttpResponse.kt b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/HttpResponse.kt index d72a0f3152..7215585db0 100644 --- a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/HttpResponse.kt +++ b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/HttpResponse.kt @@ -1,5 +1,8 @@ package com.braintreepayments.api.sharedutils +import androidx.annotation.RestrictTo + +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) data class HttpResponse( val body: String? = null, val timing: HttpResponseTiming diff --git a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/HttpResponseTiming.kt b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/HttpResponseTiming.kt index 3b3e5be442..bfaa779236 100644 --- a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/HttpResponseTiming.kt +++ b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/HttpResponseTiming.kt @@ -1,5 +1,8 @@ package com.braintreepayments.api.sharedutils +import androidx.annotation.RestrictTo + +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) data class HttpResponseTiming( var startTime: Long, var endTime: Long, diff --git a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/Json.java b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/Json.java index ef87a9ded2..c4cf11a3b8 100644 --- a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/Json.java +++ b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/Json.java @@ -18,7 +18,6 @@ public class Json { * @param fallback * @return {@link String} */ - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public static String optString(JSONObject json, String name, String fallback) { if (json == null || json.isNull(name)) { return fallback; @@ -27,7 +26,6 @@ public static String optString(JSONObject json, String name, String fallback) { } } - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public static Boolean optBoolean(JSONObject json, String name, Boolean fallback) { if (json == null || json.isNull(name)) { return fallback; diff --git a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/ManifestValidator.java b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/ManifestValidator.java index c1982572aa..8c759faa34 100644 --- a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/ManifestValidator.java +++ b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/ManifestValidator.java @@ -14,11 +14,6 @@ @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public class ManifestValidator { - boolean isActivityDeclaredInAndroidManifest(Context context, Class klass) { - return getActivityInfo(context, klass) != null; - } - - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public boolean isUrlSchemeDeclaredInAndroidManifest(Context context, String urlScheme, Class klass) { Intent intent = new Intent(Intent.ACTION_VIEW) @@ -33,7 +28,6 @@ public boolean isUrlSchemeDeclaredInAndroidManifest(Context context, String appHelper.isIntentAvailable(context, intent)); } - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @Nullable public ActivityInfo getActivityInfo(Context context, Class klass) { try { diff --git a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/RateLimitException.java b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/RateLimitException.java index abf690ab72..af64a50f6a 100644 --- a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/RateLimitException.java +++ b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/RateLimitException.java @@ -1,11 +1,14 @@ package com.braintreepayments.api.sharedutils; +import androidx.annotation.RestrictTo; + /** * Exception thrown when a 429 HTTP_TOO_MANY_REQUESTS response is encountered. Indicates the client has hit a request * limit and should wait a period of time and try again. */ public class RateLimitException extends Exception { + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) RateLimitException(String message) { super(message); } diff --git a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/Scheduler.java b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/Scheduler.java index 46c5abecda..bd69c0a073 100644 --- a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/Scheduler.java +++ b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/Scheduler.java @@ -1,5 +1,8 @@ package com.braintreepayments.api.sharedutils; +import androidx.annotation.RestrictTo; + +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) interface Scheduler { void runOnMain(Runnable runnable); void runOnBackground(Runnable runnable); diff --git a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/ServerException.java b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/ServerException.java index 33b488f432..a2e0c85ac1 100644 --- a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/ServerException.java +++ b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/ServerException.java @@ -1,11 +1,14 @@ package com.braintreepayments.api.sharedutils; +import androidx.annotation.RestrictTo; + /** * Exception thrown when a 500 HTTP_INTERNAL_ERROR response is encountered. Indicates an unexpected * error from the server. */ public class ServerException extends Exception { + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) ServerException(String message) { super(message); } diff --git a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/ServiceUnavailableException.java b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/ServiceUnavailableException.java index 13dd88e050..e9566c04a0 100644 --- a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/ServiceUnavailableException.java +++ b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/ServiceUnavailableException.java @@ -1,11 +1,14 @@ package com.braintreepayments.api.sharedutils; +import androidx.annotation.RestrictTo; + /** * Exception thrown when a 503 HTTP_UNAVAILABLE response is encountered. Indicates the server is * unreachable or the request timed out. */ public class ServiceUnavailableException extends Exception { + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) ServiceUnavailableException(String message) { super(message); } diff --git a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/SignatureVerifier.java b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/SignatureVerifier.java index d502339c49..236ddc6247 100644 --- a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/SignatureVerifier.java +++ b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/SignatureVerifier.java @@ -19,12 +19,10 @@ public class SignatureVerifier { private final CertificateHelper certificateHelper; - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public SignatureVerifier() { this(new CertificateHelper()); } - @VisibleForTesting SignatureVerifier(CertificateHelper certificateHelper) { this.certificateHelper = certificateHelper; } @@ -39,7 +37,6 @@ public SignatureVerifier() { * @return true is signature is valid or signature verification has been disabled. */ @SuppressLint("PackageManagerGetSignatures") - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public boolean isSignatureValid(Context context, String packageName, String base64EncodedSignature) { PackageManager packageManager = context.getPackageManager(); diff --git a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/SynchronousHttpClient.java b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/SynchronousHttpClient.java index c138cca795..8cccfbf5e8 100644 --- a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/SynchronousHttpClient.java +++ b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/SynchronousHttpClient.java @@ -1,5 +1,7 @@ package com.braintreepayments.api.sharedutils; +import androidx.annotation.RestrictTo; + import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; @@ -13,6 +15,7 @@ * This class performs an http request on the calling thread. The external caller is * responsible for thread scheduling to ensure that this is not called on the main thread. */ +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) class SynchronousHttpClient { private SSLSocketFactory socketFactory; diff --git a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/TLSSocketFactory.java b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/TLSSocketFactory.java index afd749aee4..ae71a72709 100644 --- a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/TLSSocketFactory.java +++ b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/TLSSocketFactory.java @@ -44,7 +44,6 @@ static TLSSocketFactory newInstance() throws SSLException { /** * @see Android Documentation */ - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public TLSSocketFactory(InputStream certificateStream) throws SSLException { try { KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); diff --git a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/ThreadScheduler.java b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/ThreadScheduler.java index a7221756b9..bdc664cbbb 100644 --- a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/ThreadScheduler.java +++ b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/ThreadScheduler.java @@ -3,11 +3,13 @@ import android.os.Handler; import android.os.Looper; +import androidx.annotation.RestrictTo; import androidx.annotation.VisibleForTesting; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) class ThreadScheduler implements Scheduler { private final Handler mainThreadHandler; diff --git a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/UnexpectedException.java b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/UnexpectedException.java index b3fcd19f37..fd4c168451 100644 --- a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/UnexpectedException.java +++ b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/UnexpectedException.java @@ -12,8 +12,4 @@ public class UnexpectedException extends Exception { public UnexpectedException(String message) { super(message); } - - UnexpectedException(String message, Throwable cause) { - super(message, cause); - } } diff --git a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/UpgradeRequiredException.java b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/UpgradeRequiredException.java index 3c7511c7b7..dad3f0c674 100644 --- a/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/UpgradeRequiredException.java +++ b/SharedUtils/src/main/java/com/braintreepayments/api/sharedutils/UpgradeRequiredException.java @@ -1,11 +1,14 @@ package com.braintreepayments.api.sharedutils; +import androidx.annotation.RestrictTo; + /** * Exception thrown when a 426 HTTP_UPGRADE_REQUIRED response is encountered. Indicates that the * API used or current SDK version is deprecated and must be updated. */ public class UpgradeRequiredException extends Exception { + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) UpgradeRequiredException(String message) { super(message); } diff --git a/ShopperInsights/src/main/java/com/braintreepayments/api/shopperinsights/EligiblePaymentsApiRequest.kt b/ShopperInsights/src/main/java/com/braintreepayments/api/shopperinsights/EligiblePaymentsApiRequest.kt index e408e535c0..d042c03c2c 100644 --- a/ShopperInsights/src/main/java/com/braintreepayments/api/shopperinsights/EligiblePaymentsApiRequest.kt +++ b/ShopperInsights/src/main/java/com/braintreepayments/api/shopperinsights/EligiblePaymentsApiRequest.kt @@ -59,18 +59,18 @@ internal data class EligiblePaymentsApiRequest( }.toString() } - internal const val KEY_COUNTRY_CODE = "country_code" - internal const val KEY_NATIONAL_NUMBER = "national_number" - internal const val KEY_CUSTOMER = "customer" - internal const val KEY_EMAIL = "email" - internal const val KEY_PHONE = "phone" - internal const val KEY_PURCHASE_UNITS = "purchase_units" - internal const val KEY_AMOUNT = "amount" - internal const val KEY_CURRENCY_CODE = "currency_code" - internal const val KEY_PREFERENCES = "preferences" - internal const val KEY_INCLUDE_ACCOUNT_DETAILS = "include_account_details" - internal const val KEY_PAYMENT_SOURCE_CONSTRAINT = "payment_source_constraint" - internal const val KEY_CONSTRAINT_TYPE = "constraint_type" - internal const val KEY_PAYMENT_SOURCES = "payment_sources" + private const val KEY_COUNTRY_CODE = "country_code" + private const val KEY_NATIONAL_NUMBER = "national_number" + private const val KEY_CUSTOMER = "customer" + private const val KEY_EMAIL = "email" + private const val KEY_PHONE = "phone" + private const val KEY_PURCHASE_UNITS = "purchase_units" + private const val KEY_AMOUNT = "amount" + private const val KEY_CURRENCY_CODE = "currency_code" + private const val KEY_PREFERENCES = "preferences" + private const val KEY_INCLUDE_ACCOUNT_DETAILS = "include_account_details" + private const val KEY_PAYMENT_SOURCE_CONSTRAINT = "payment_source_constraint" + private const val KEY_CONSTRAINT_TYPE = "constraint_type" + private const val KEY_PAYMENT_SOURCES = "payment_sources" } } diff --git a/ShopperInsights/src/main/java/com/braintreepayments/api/shopperinsights/ShopperInsightsClient.kt b/ShopperInsights/src/main/java/com/braintreepayments/api/shopperinsights/ShopperInsightsClient.kt index f125b77060..324bf26b05 100644 --- a/ShopperInsights/src/main/java/com/braintreepayments/api/shopperinsights/ShopperInsightsClient.kt +++ b/ShopperInsights/src/main/java/com/braintreepayments/api/shopperinsights/ShopperInsightsClient.kt @@ -1,7 +1,6 @@ package com.braintreepayments.api.shopperinsights import android.content.Context -import androidx.annotation.VisibleForTesting import com.braintreepayments.api.core.AnalyticsParamRepository import com.braintreepayments.api.core.BraintreeClient import com.braintreepayments.api.core.BraintreeException @@ -24,7 +23,7 @@ import com.braintreepayments.api.shopperinsights.ShopperInsightsAnalytics.VENMO_ * Note: **This feature is in beta. It's public API may change in future releases.** */ @ExperimentalBetaApi -class ShopperInsightsClient @VisibleForTesting internal constructor( +class ShopperInsightsClient internal constructor( private val braintreeClient: BraintreeClient, private val analyticsParamRepository: AnalyticsParamRepository = AnalyticsParamRepository.instance, private val api: ShopperInsightsApi = ShopperInsightsApi( diff --git a/ShopperInsights/src/main/java/com/braintreepayments/api/shopperinsights/ShopperInsightsInfo.kt b/ShopperInsights/src/main/java/com/braintreepayments/api/shopperinsights/ShopperInsightsInfo.kt index fcac1ce3cd..3594e6e90b 100644 --- a/ShopperInsights/src/main/java/com/braintreepayments/api/shopperinsights/ShopperInsightsInfo.kt +++ b/ShopperInsights/src/main/java/com/braintreepayments/api/shopperinsights/ShopperInsightsInfo.kt @@ -19,7 +19,7 @@ import com.braintreepayments.api.core.ExperimentalBetaApi * Note: **This feature is in beta. It's public API may change in future releases.** */ @ExperimentalBetaApi -data class ShopperInsightsInfo( +data class ShopperInsightsInfo internal constructor( val isEligibleInPayPalNetwork: Boolean, val isPayPalRecommended: Boolean, val isVenmoRecommended: Boolean diff --git a/ShopperInsights/src/main/java/com/braintreepayments/api/shopperinsights/ShopperInsightsResult.kt b/ShopperInsights/src/main/java/com/braintreepayments/api/shopperinsights/ShopperInsightsResult.kt index 23457d57df..39c88589ab 100644 --- a/ShopperInsights/src/main/java/com/braintreepayments/api/shopperinsights/ShopperInsightsResult.kt +++ b/ShopperInsights/src/main/java/com/braintreepayments/api/shopperinsights/ShopperInsightsResult.kt @@ -11,10 +11,10 @@ sealed class ShopperInsightsResult { * @property response The response object describing the shopper's insights. */ @OptIn(ExperimentalBetaApi::class) - class Success(val response: ShopperInsightsInfo) : ShopperInsightsResult() + class Success internal constructor(val response: ShopperInsightsInfo) : ShopperInsightsResult() /** * @property error An object that describes the error that occurred. */ - class Failure(val error: Exception) : ShopperInsightsResult() + class Failure internal constructor(val error: Exception) : ShopperInsightsResult() } diff --git a/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureAccountType.kt b/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureAccountType.kt index ccb8af21dc..640b95387f 100644 --- a/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureAccountType.kt +++ b/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureAccountType.kt @@ -1,6 +1,6 @@ package com.braintreepayments.api.threedsecure -enum class ThreeDSecureAccountType(val stringValue: String) { +enum class ThreeDSecureAccountType(internal val stringValue: String) { CREDIT("credit"), DEBIT("debit") } diff --git a/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureAdditionalInformation.kt b/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureAdditionalInformation.kt index 1dd5cf4fa6..e45590735c 100644 --- a/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureAdditionalInformation.kt +++ b/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureAdditionalInformation.kt @@ -1,6 +1,7 @@ package com.braintreepayments.api.threedsecure import android.os.Parcelable +import androidx.annotation.RestrictTo import kotlinx.parcelize.Parcelize import org.json.JSONException import org.json.JSONObject @@ -204,6 +205,7 @@ data class ThreeDSecureAdditionalInformation( * @return JSONObject representation of [ThreeDSecureAdditionalInformation]. */ @Suppress("LongMethod") + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) fun toJson(): JSONObject { val additionalInformation = JSONObject() try { diff --git a/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureClient.kt b/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureClient.kt index 0f3bfc5952..b6957e476a 100644 --- a/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureClient.kt +++ b/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureClient.kt @@ -1,6 +1,7 @@ package com.braintreepayments.api.threedsecure import android.content.Context +import androidx.annotation.RestrictTo import com.braintreepayments.api.core.BraintreeClient import com.braintreepayments.api.core.BraintreeException import com.braintreepayments.api.core.BuildConfig @@ -248,6 +249,7 @@ class ThreeDSecureClient internal constructor( } } + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) fun sendAnalyticsAndCallbackResult( result: ThreeDSecureParams, callback: ThreeDSecurePaymentAuthRequestCallback diff --git a/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureLauncher.kt b/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureLauncher.kt index 8f4922a455..b73d2c866b 100644 --- a/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureLauncher.kt +++ b/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureLauncher.kt @@ -4,6 +4,7 @@ import android.os.TransactionTooLargeException import androidx.activity.ComponentActivity import androidx.activity.result.ActivityResultLauncher import androidx.activity.result.ActivityResultRegistry +import androidx.annotation.RestrictTo import androidx.fragment.app.Fragment import androidx.lifecycle.LifecycleOwner import com.braintreepayments.api.core.BraintreeException @@ -17,6 +18,7 @@ class ThreeDSecureLauncher internal constructor( private val callback: ThreeDSecureLauncherCallback ) { + @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) var activityLauncher: ActivityResultLauncher = registry.register( THREE_D_SECURE_RESULT, lifecycleOwner, diff --git a/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureLookup.kt b/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureLookup.kt index 228d40ccb7..17767f15ca 100644 --- a/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureLookup.kt +++ b/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureLookup.kt @@ -1,6 +1,7 @@ package com.braintreepayments.api.threedsecure import android.os.Parcelable +import androidx.annotation.RestrictTo import com.braintreepayments.api.sharedutils.Json import kotlinx.parcelize.Parcelize import org.json.JSONException @@ -36,6 +37,7 @@ data class ThreeDSecureLookup internal constructor( */ @JvmStatic @Throws(JSONException::class) + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) fun fromJson(jsonString: String): ThreeDSecureLookup { val json = JSONObject(jsonString) val pareq = json.optString(PA_REQ_KEY, "") diff --git a/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecurePaymentAuthRequest.kt b/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecurePaymentAuthRequest.kt index 4f01125587..9916695230 100644 --- a/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecurePaymentAuthRequest.kt +++ b/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecurePaymentAuthRequest.kt @@ -11,19 +11,21 @@ sealed class ThreeDSecurePaymentAuthRequest { * @param requestParams this parameter is intended for internal use only. It is not covered by * semantic versioning and may be changed or removed at any time. */ - class ReadyToLaunch(val requestParams: ThreeDSecureParams) : - ThreeDSecurePaymentAuthRequest() + class ReadyToLaunch internal constructor( + val requestParams: ThreeDSecureParams + ) : ThreeDSecurePaymentAuthRequest() /** * No additional authentication challenge is required for the [ThreeDSecureNonce], this * [nonce] can be sent to your server. */ - class LaunchNotRequired(val nonce: ThreeDSecureNonce, val threeDSecureLookup: - ThreeDSecureLookup + class LaunchNotRequired internal constructor( + val nonce: ThreeDSecureNonce, + val threeDSecureLookup: ThreeDSecureLookup ) : ThreeDSecurePaymentAuthRequest() /** * There was an [error] creating the request */ - class Failure(val error: Exception) : ThreeDSecurePaymentAuthRequest() + class Failure internal constructor(val error: Exception) : ThreeDSecurePaymentAuthRequest() } diff --git a/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecurePostalAddress.kt b/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecurePostalAddress.kt index efaf2bbe46..efb8838d2f 100644 --- a/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecurePostalAddress.kt +++ b/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecurePostalAddress.kt @@ -1,6 +1,7 @@ package com.braintreepayments.api.threedsecure import android.os.Parcelable +import androidx.annotation.RestrictTo import kotlinx.parcelize.Parcelize import org.json.JSONException import org.json.JSONObject @@ -54,6 +55,7 @@ data class ThreeDSecurePostalAddress( /** * @return JSONObject representation of [ThreeDSecurePostalAddress]. */ + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) fun toJson(): JSONObject { val base = JSONObject() val billingAddress = JSONObject() diff --git a/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecurePrepareLookupResult.kt b/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecurePrepareLookupResult.kt index cca3671cd3..e1384c7313 100644 --- a/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecurePrepareLookupResult.kt +++ b/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecurePrepareLookupResult.kt @@ -4,18 +4,20 @@ package com.braintreepayments.api.threedsecure * Callback for receiving result of * {@link ThreeDSecureClient#prepareLookup(Context, ThreeDSecureRequest, * ThreeDSecurePrepareLookupCallback)}. -*/ + */ sealed class ThreeDSecurePrepareLookupResult { /** * The lookup was successfully prepared. The [clientData] JSON string of client data can be sent * to server for lookup */ - class Success(val request: ThreeDSecureRequest, val clientData: String) : - ThreeDSecurePrepareLookupResult() + class Success internal constructor( + val request: ThreeDSecureRequest, + val clientData: String + ) : ThreeDSecurePrepareLookupResult() /** * There was an [error] preparing the lookup */ - class Failure(val error: Exception) : ThreeDSecurePrepareLookupResult() + class Failure internal constructor(val error: Exception) : ThreeDSecurePrepareLookupResult() } diff --git a/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureRequest.kt b/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureRequest.kt index c1522d3bd3..626bbb015b 100644 --- a/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureRequest.kt +++ b/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureRequest.kt @@ -1,6 +1,7 @@ package com.braintreepayments.api.threedsecure import android.os.Parcelable +import androidx.annotation.RestrictTo import kotlinx.parcelize.Parcelize import org.json.JSONException import org.json.JSONObject @@ -73,6 +74,7 @@ data class ThreeDSecureRequest @JvmOverloads constructor( /** * @return String representation of [ThreeDSecureRequest] for API use. */ + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) fun build(dfReferenceId: String?): String { val additionalInfo: JSONObject = additionalInformation?.toJson() ?: JSONObject() val base = JSONObject() diff --git a/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureRequestedExemptionType.kt b/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureRequestedExemptionType.kt index 12c19e8ca4..c82b4f4935 100644 --- a/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureRequestedExemptionType.kt +++ b/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureRequestedExemptionType.kt @@ -1,6 +1,6 @@ package com.braintreepayments.api.threedsecure -enum class ThreeDSecureRequestedExemptionType(val stringValue: String) { +enum class ThreeDSecureRequestedExemptionType(internal val stringValue: String) { LOW_VALUE("low_value"), SECURE_CORPORATE("secure_corporate"), TRUSTED_BENEFICIARY("trusted_beneficiary"), diff --git a/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureResult.kt b/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureResult.kt index ba65a59d53..8ec9f148cc 100644 --- a/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureResult.kt +++ b/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureResult.kt @@ -8,14 +8,17 @@ sealed class ThreeDSecureResult { /** * The 3DS flow completed successfully. This [nonce] should be sent to your server. */ - class Success(val nonce: ThreeDSecureNonce) : ThreeDSecureResult() + class Success internal constructor(val nonce: ThreeDSecureNonce) : ThreeDSecureResult() /** * There was an [error] in the 3DS authentication flow. Optionally may return a [nonce] if * the authentication was not successful but the [nonce] from the [ThreeDSecureLookup] can be * transacted with. */ - class Failure(val error: Exception, val nonce: ThreeDSecureNonce?) : ThreeDSecureResult() + class Failure internal constructor( + val error: Exception, + val nonce: ThreeDSecureNonce? + ) : ThreeDSecureResult() /** * The user canceled the 3DS authentication flow. diff --git a/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureV2ButtonCustomization.kt b/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureV2ButtonCustomization.kt index bac1e95806..8e8d2f9bec 100644 --- a/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureV2ButtonCustomization.kt +++ b/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureV2ButtonCustomization.kt @@ -1,6 +1,7 @@ package com.braintreepayments.api.threedsecure import android.os.Parcelable +import androidx.annotation.RestrictTo import com.cardinalcommerce.shared.userinterfaces.ButtonCustomization import kotlinx.parcelize.Parcelize @@ -15,7 +16,7 @@ import kotlinx.parcelize.Parcelize * @property cornerRadius Radius (integer value) for the button corners. */ @Parcelize -data class ThreeDSecureV2ButtonCustomization( +data class ThreeDSecureV2ButtonCustomization @JvmOverloads constructor( var textFontName: String? = null, var textColor: String? = null, var textFontSize: Int = 0, @@ -23,6 +24,7 @@ data class ThreeDSecureV2ButtonCustomization( var cornerRadius: Int = 0 ) : Parcelable { + @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) val cardinalButtonCustomization: ButtonCustomization get() { return ButtonCustomization().also { diff --git a/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureV2LabelCustomization.kt b/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureV2LabelCustomization.kt index 2e12c16f16..6fcac52deb 100644 --- a/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureV2LabelCustomization.kt +++ b/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureV2LabelCustomization.kt @@ -1,6 +1,7 @@ package com.braintreepayments.api.threedsecure import android.os.Parcelable +import androidx.annotation.RestrictTo import com.cardinalcommerce.shared.userinterfaces.LabelCustomization import kotlinx.parcelize.Parcelize @@ -16,7 +17,7 @@ import kotlinx.parcelize.Parcelize * @property headingTextFontSize Font size for the heading label text. */ @Parcelize -data class ThreeDSecureV2LabelCustomization( +data class ThreeDSecureV2LabelCustomization @JvmOverloads constructor( var textFontName: String? = null, var textColor: String? = null, var textFontSize: Int = 0, @@ -25,6 +26,7 @@ data class ThreeDSecureV2LabelCustomization( var headingTextFontSize: Int = 0 ) : Parcelable { + @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) val cardinalLabelCustomization: LabelCustomization get() { return LabelCustomization().also { diff --git a/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureV2TextBoxCustomization.kt b/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureV2TextBoxCustomization.kt index 8888664717..f312ffe6da 100644 --- a/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureV2TextBoxCustomization.kt +++ b/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureV2TextBoxCustomization.kt @@ -1,6 +1,7 @@ package com.braintreepayments.api.threedsecure import android.os.Parcelable +import androidx.annotation.RestrictTo import com.cardinalcommerce.shared.userinterfaces.TextBoxCustomization import kotlinx.parcelize.Parcelize @@ -15,7 +16,7 @@ import kotlinx.parcelize.Parcelize * @property cornerRadius Radius (integer value) for the text box corners. */ @Parcelize -data class ThreeDSecureV2TextBoxCustomization( +data class ThreeDSecureV2TextBoxCustomization @JvmOverloads constructor( var textFontName: String? = null, var textColor: String? = null, var textFontSize: Int = 0, @@ -24,6 +25,7 @@ data class ThreeDSecureV2TextBoxCustomization( var cornerRadius: Int = 0 ) : Parcelable { + @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) val cardinalTextBoxCustomization: TextBoxCustomization get() { return TextBoxCustomization().also { diff --git a/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureV2ToolbarCustomization.kt b/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureV2ToolbarCustomization.kt index 2107201382..563b4732d7 100644 --- a/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureV2ToolbarCustomization.kt +++ b/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureV2ToolbarCustomization.kt @@ -1,6 +1,7 @@ package com.braintreepayments.api.threedsecure import android.os.Parcelable +import androidx.annotation.RestrictTo import com.cardinalcommerce.shared.userinterfaces.ToolbarCustomization import kotlinx.parcelize.Parcelize @@ -15,7 +16,7 @@ import kotlinx.parcelize.Parcelize * @property buttonText Text for the button. For example, “Cancel”. */ @Parcelize -data class ThreeDSecureV2ToolbarCustomization( +data class ThreeDSecureV2ToolbarCustomization @JvmOverloads constructor( var textFontName: String? = null, var textColor: String? = null, var textFontSize: Int = 0, @@ -24,6 +25,7 @@ data class ThreeDSecureV2ToolbarCustomization( var buttonText: String? = null ) : Parcelable { + @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) val cardinalToolbarCustomization: ToolbarCustomization get() { return ToolbarCustomization().also { diff --git a/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureV2UiCustomization.kt b/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureV2UiCustomization.kt index 1bdec40980..e539a91fe4 100644 --- a/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureV2UiCustomization.kt +++ b/ThreeDSecure/src/main/java/com/braintreepayments/api/threedsecure/ThreeDSecureV2UiCustomization.kt @@ -1,6 +1,7 @@ package com.braintreepayments.api.threedsecure import android.os.Parcelable +import androidx.annotation.RestrictTo import com.cardinalcommerce.shared.models.enums.ButtonType import com.cardinalcommerce.shared.userinterfaces.UiCustomization import kotlinx.parcelize.Parcelize @@ -15,7 +16,7 @@ import kotlinx.parcelize.Parcelize * @property toolbarCustomization toolbar customization options for 3D Secure 2 flows */ @Parcelize -data class ThreeDSecureV2UiCustomization( +data class ThreeDSecureV2UiCustomization @JvmOverloads constructor( var buttonCustomization: ThreeDSecureV2ButtonCustomization? = null, var buttonType: ThreeDSecureV2ButtonType? = null, var labelCustomization: ThreeDSecureV2LabelCustomization? = null, @@ -23,6 +24,7 @@ data class ThreeDSecureV2UiCustomization( var toolbarCustomization: ThreeDSecureV2ToolbarCustomization? = null, ) : Parcelable { + @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) val cardinalUiCustomization: UiCustomization get() { return UiCustomization().also { diff --git a/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoAccount.kt b/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoAccount.kt index b0bfc36086..8626b451fc 100644 --- a/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoAccount.kt +++ b/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoAccount.kt @@ -1,6 +1,5 @@ package com.braintreepayments.api.venmo -import androidx.annotation.RestrictTo import com.braintreepayments.api.core.IntegrationType import com.braintreepayments.api.core.MetadataBuilder import com.braintreepayments.api.core.PaymentMethod @@ -9,13 +8,12 @@ import org.json.JSONException import org.json.JSONObject internal class VenmoAccount( - var nonce: String? = null, + private val nonce: String? = null, override var sessionId: String? = null, override var source: String? = DEFAULT_SOURCE, override var integration: IntegrationType? = IntegrationType.CUSTOM ) : PaymentMethod { - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) private fun buildMetadataJSON(): JSONObject { return MetadataBuilder() .sessionId(sessionId) @@ -24,10 +22,6 @@ internal class VenmoAccount( .build() } - /** - * @hide - */ - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @Throws(JSONException::class) override fun buildJSON(): JSONObject { val paymentMethodNonceJson = JSONObject() @@ -39,12 +33,7 @@ internal class VenmoAccount( } } - @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) - override val apiPath: String - /** - * @hide - */ - get() = "venmo_accounts" + override val apiPath = "venmo_accounts" companion object { private const val VENMO_ACCOUNT_KEY = "venmoAccount" diff --git a/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoAccountNonce.kt b/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoAccountNonce.kt index d88f27a6a6..e5c7ac72c1 100644 --- a/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoAccountNonce.kt +++ b/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoAccountNonce.kt @@ -1,5 +1,6 @@ package com.braintreepayments.api.venmo +import androidx.annotation.RestrictTo import com.braintreepayments.api.core.PaymentMethodNonce import com.braintreepayments.api.core.PostalAddress import com.braintreepayments.api.core.PostalAddressParser.fromJson @@ -59,6 +60,7 @@ data class VenmoAccountNonce internal constructor( @Throws(JSONException::class) @JvmStatic + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) fun fromJSON(inputJson: JSONObject): VenmoAccountNonce { val json = if (inputJson.has(API_RESOURCE_KEY)) { inputJson.getJSONArray(API_RESOURCE_KEY).getJSONObject(0) diff --git a/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoApi.kt b/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoApi.kt index b39c792ecc..f4c7138126 100644 --- a/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoApi.kt +++ b/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoApi.kt @@ -173,8 +173,7 @@ internal class VenmoApi( } fun vaultVenmoAccountNonce(nonce: String?, callback: VenmoInternalCallback) { - val venmoAccount = VenmoAccount() - venmoAccount.nonce = nonce + val venmoAccount = VenmoAccount(nonce) apiClient.tokenizeREST(venmoAccount) { tokenizationResponse: JSONObject?, exception: Exception? -> if (tokenizationResponse != null) { diff --git a/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoClient.kt b/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoClient.kt index 108117d8ad..c380d2e78e 100644 --- a/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoClient.kt +++ b/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoClient.kt @@ -4,7 +4,6 @@ import android.content.Context import android.net.Uri import android.text.TextUtils import android.util.Base64 -import androidx.annotation.VisibleForTesting import com.braintreepayments.api.BrowserSwitchFinalResult import com.braintreepayments.api.BrowserSwitchOptions import com.braintreepayments.api.core.AnalyticsEventParams @@ -25,7 +24,7 @@ import java.util.Objects /** * Used to create and tokenize Venmo accounts. For more information see the [documentation](https://developer.paypal.com/braintree/docs/guides/venmo/overview) */ -class VenmoClient @VisibleForTesting internal constructor( +class VenmoClient internal constructor( private val braintreeClient: BraintreeClient, private val apiClient: ApiClient = ApiClient(braintreeClient), private val venmoApi: VenmoApi = VenmoApi(braintreeClient, apiClient), diff --git a/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoLauncher.kt b/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoLauncher.kt index 2f2f2484ff..d754aab51d 100644 --- a/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoLauncher.kt +++ b/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoLauncher.kt @@ -105,7 +105,7 @@ class VenmoLauncher internal constructor( } companion object { - const val VENMO_PACKAGE_NAME = "com.venmo" + private const val VENMO_PACKAGE_NAME = "com.venmo" private fun createBrowserSwitchError(exception: BrowserSwitchException): Exception { return BraintreeException( "AndroidManifest.xml is incorrectly configured or another app defines the same " + diff --git a/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoLauncherCallback.kt b/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoLauncherCallback.kt deleted file mode 100644 index 96123c05e6..0000000000 --- a/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoLauncherCallback.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.braintreepayments.api.venmo - -/** - * Used to receive notification that the Venmo payment authorization flow completed - * Once this is invoked, continue the flow by calling [VenmoClient.tokenize] - */ -fun interface VenmoLauncherCallback { - - fun onVenmoPaymentAuthResult(venmoPaymentAuthResult: VenmoPaymentAuthResult) -} diff --git a/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoLineItem.kt b/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoLineItem.kt index 7c110180e5..b0c47f4403 100644 --- a/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoLineItem.kt +++ b/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoLineItem.kt @@ -1,6 +1,7 @@ package com.braintreepayments.api.venmo import android.os.Parcelable +import androidx.annotation.RestrictTo import kotlinx.parcelize.Parcelize import org.json.JSONException import org.json.JSONObject @@ -30,6 +31,7 @@ class VenmoLineItem @JvmOverloads constructor( var url: String? = null ) : Parcelable { + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) fun toJson(): JSONObject { return try { JSONObject() diff --git a/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoPaymentAuthRequest.kt b/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoPaymentAuthRequest.kt index 0e0e9004cb..16ee4f5d1b 100644 --- a/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoPaymentAuthRequest.kt +++ b/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoPaymentAuthRequest.kt @@ -11,10 +11,12 @@ sealed class VenmoPaymentAuthRequest { * @param requestParams this parameter is intended for internal use only. It is not covered by * semantic versioning and may be changed or removed at any time. */ - class ReadyToLaunch(val requestParams: VenmoPaymentAuthRequestParams) : VenmoPaymentAuthRequest() + class ReadyToLaunch internal constructor( + val requestParams: VenmoPaymentAuthRequestParams + ) : VenmoPaymentAuthRequest() /** * There was an [error] creating the request */ - class Failure(val error: Exception) : VenmoPaymentAuthRequest() + class Failure internal constructor(val error: Exception) : VenmoPaymentAuthRequest() } diff --git a/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoPaymentAuthResult.kt b/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoPaymentAuthResult.kt index b1ba4e87ed..f0471ee02f 100644 --- a/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoPaymentAuthResult.kt +++ b/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoPaymentAuthResult.kt @@ -10,13 +10,15 @@ sealed class VenmoPaymentAuthResult { /** * A successful result that should be passed to [VenmoClient.tokenize] to complete the flow */ - class Success(internal val browserSwitchSuccess: BrowserSwitchFinalResult.Success) : VenmoPaymentAuthResult() + class Success internal constructor( + internal val browserSwitchSuccess: BrowserSwitchFinalResult.Success + ) : VenmoPaymentAuthResult() /** * The browser switch failed. * @property [error] Error detailing the reason for the browser switch failure. */ - class Failure(val error: Exception) : VenmoPaymentAuthResult() + class Failure internal constructor(val error: Exception) : VenmoPaymentAuthResult() /** * If no matching result can be found for the [VenmoPendingRequest.Started] passed to diff --git a/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoPendingRequest.kt b/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoPendingRequest.kt index b5553074dd..2da98fd0dc 100644 --- a/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoPendingRequest.kt +++ b/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoPendingRequest.kt @@ -14,10 +14,10 @@ sealed class VenmoPendingRequest { * @property pendingRequestString - This String should be stored and passed to * [VenmoLauncher.handleReturnToApp]. */ - class Started(val pendingRequestString: String) : VenmoPendingRequest() + class Started internal constructor(val pendingRequestString: String) : VenmoPendingRequest() /** * An error occurred launching the Venmo flow. See [error] for details. */ - class Failure(val error: Exception) : VenmoPendingRequest() + class Failure internal constructor(val error: Exception) : VenmoPendingRequest() } diff --git a/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoResult.kt b/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoResult.kt index 3cf0be6262..38cb7e5904 100644 --- a/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoResult.kt +++ b/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoResult.kt @@ -8,12 +8,12 @@ sealed class VenmoResult { /** * The Venmo flow completed successfully. This [nonce] should be sent to your server. */ - class Success(val nonce: VenmoAccountNonce) : VenmoResult() + class Success internal constructor(val nonce: VenmoAccountNonce) : VenmoResult() /** * There was an [error] in the Venmo payment flow. */ - class Failure(val error: Exception) : VenmoResult() + class Failure internal constructor(val error: Exception) : VenmoResult() /** * The user canceled the Venmo payment flow. diff --git a/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoSharedPrefsWriter.kt b/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoSharedPrefsWriter.kt index 4dd3127688..3ad1bb9148 100644 --- a/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoSharedPrefsWriter.kt +++ b/Venmo/src/main/java/com/braintreepayments/api/venmo/VenmoSharedPrefsWriter.kt @@ -1,7 +1,6 @@ package com.braintreepayments.api.venmo import android.content.Context -import androidx.annotation.VisibleForTesting import com.braintreepayments.api.sharedutils.BraintreeSharedPreferences internal class VenmoSharedPrefsWriter { @@ -9,7 +8,6 @@ internal class VenmoSharedPrefsWriter { persistVenmoVaultOption(BraintreeSharedPreferences.getInstance(context), shouldVault) } - @VisibleForTesting fun persistVenmoVaultOption( braintreeSharedPreferences: BraintreeSharedPreferences, shouldVault: Boolean @@ -21,7 +19,6 @@ internal class VenmoSharedPrefsWriter { return getVenmoVaultOption(BraintreeSharedPreferences.getInstance(context)) } - @VisibleForTesting fun getVenmoVaultOption(braintreeSharedPreferences: BraintreeSharedPreferences): Boolean { return braintreeSharedPreferences.getBoolean(VAULT_VENMO_KEY) } diff --git a/Venmo/src/test/java/com/braintreepayments/api/venmo/VenmoAccountUnitTest.java b/Venmo/src/test/java/com/braintreepayments/api/venmo/VenmoAccountUnitTest.java index e7832cd7dd..dfb008a26c 100644 --- a/Venmo/src/test/java/com/braintreepayments/api/venmo/VenmoAccountUnitTest.java +++ b/Venmo/src/test/java/com/braintreepayments/api/venmo/VenmoAccountUnitTest.java @@ -2,6 +2,9 @@ import static junit.framework.Assert.assertEquals; +import com.braintreepayments.api.core.IntegrationType; +import com.braintreepayments.api.core.PaymentMethod; + import org.json.JSONException; import org.json.JSONObject; import org.junit.Test; @@ -13,8 +16,7 @@ public class VenmoAccountUnitTest { @Test public void correctlyBuildsVenmoVaultRequest() throws JSONException { - VenmoAccount sut = new VenmoAccount(); - sut.setNonce("some-nonce"); + VenmoAccount sut = new VenmoAccount("some-nonce", null, PaymentMethod.DEFAULT_SOURCE, IntegrationType.CUSTOM); JSONObject fullJson = sut.buildJSON(); JSONObject venmoAccountJson = fullJson.getJSONObject("venmoAccount"); diff --git a/VisaCheckout/src/main/java/com/braintreepayments/api/visacheckout/VisaCheckoutAccount.kt b/VisaCheckout/src/main/java/com/braintreepayments/api/visacheckout/VisaCheckoutAccount.kt index b0c36bf630..29fd8846b0 100644 --- a/VisaCheckout/src/main/java/com/braintreepayments/api/visacheckout/VisaCheckoutAccount.kt +++ b/VisaCheckout/src/main/java/com/braintreepayments/api/visacheckout/VisaCheckoutAccount.kt @@ -19,7 +19,6 @@ internal class VisaCheckoutAccount( override var integration: IntegrationType? = IntegrationType.CUSTOM ) : PaymentMethod { - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) private fun buildMetadataJSON(): JSONObject { return MetadataBuilder() .sessionId(sessionId) @@ -28,7 +27,6 @@ internal class VisaCheckoutAccount( .build() } - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @Throws(JSONException::class) override fun buildJSON(): JSONObject { val json = JSONObject() @@ -42,7 +40,6 @@ internal class VisaCheckoutAccount( return json } - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) override val apiPath = "visa_checkout_cards" companion object { diff --git a/VisaCheckout/src/main/java/com/braintreepayments/api/visacheckout/VisaCheckoutAddress.kt b/VisaCheckout/src/main/java/com/braintreepayments/api/visacheckout/VisaCheckoutAddress.kt index e34bffd160..9458dd41c8 100644 --- a/VisaCheckout/src/main/java/com/braintreepayments/api/visacheckout/VisaCheckoutAddress.kt +++ b/VisaCheckout/src/main/java/com/braintreepayments/api/visacheckout/VisaCheckoutAddress.kt @@ -2,6 +2,7 @@ package com.braintreepayments.api.visacheckout import android.os.Parcel import android.os.Parcelable +import androidx.annotation.RestrictTo import com.braintreepayments.api.sharedutils.Json import kotlinx.parcelize.Parcelize import org.json.JSONObject @@ -32,7 +33,9 @@ data class VisaCheckoutAddress internal constructor( val phoneNumber: String?, ) : Parcelable { companion object { + @JvmStatic + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) fun fromJson(jsonIn: JSONObject?): VisaCheckoutAddress { val json = jsonIn ?: JSONObject() return VisaCheckoutAddress( diff --git a/VisaCheckout/src/main/java/com/braintreepayments/api/visacheckout/VisaCheckoutNonce.kt b/VisaCheckout/src/main/java/com/braintreepayments/api/visacheckout/VisaCheckoutNonce.kt index b7c91a9843..3c439f62ab 100644 --- a/VisaCheckout/src/main/java/com/braintreepayments/api/visacheckout/VisaCheckoutNonce.kt +++ b/VisaCheckout/src/main/java/com/braintreepayments/api/visacheckout/VisaCheckoutNonce.kt @@ -2,6 +2,7 @@ package com.braintreepayments.api.visacheckout import android.os.Parcel import android.os.Parcelable +import androidx.annotation.RestrictTo import com.braintreepayments.api.card.BinData import com.braintreepayments.api.core.PaymentMethodNonce import com.braintreepayments.api.sharedutils.Json @@ -51,6 +52,7 @@ data class VisaCheckoutNonce internal constructor( @Throws(JSONException::class) @JvmStatic + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) fun fromJSON(inputJson: JSONObject): VisaCheckoutNonce { val json = if (inputJson.has(API_RESOURCE_KEY)) { inputJson.getJSONArray(API_RESOURCE_KEY).getJSONObject(0) diff --git a/VisaCheckout/src/main/java/com/braintreepayments/api/visacheckout/VisaCheckoutProfileBuilderResult.kt b/VisaCheckout/src/main/java/com/braintreepayments/api/visacheckout/VisaCheckoutProfileBuilderResult.kt index a663dbdf68..03b04f9b5c 100644 --- a/VisaCheckout/src/main/java/com/braintreepayments/api/visacheckout/VisaCheckoutProfileBuilderResult.kt +++ b/VisaCheckout/src/main/java/com/braintreepayments/api/visacheckout/VisaCheckoutProfileBuilderResult.kt @@ -10,10 +10,12 @@ sealed class VisaCheckoutProfileBuilderResult { /** * The [profileBuilder] was successfully created */ - class Success(val profileBuilder: Profile.ProfileBuilder) : VisaCheckoutProfileBuilderResult() + class Success internal constructor( + val profileBuilder: Profile.ProfileBuilder + ) : VisaCheckoutProfileBuilderResult() /** * There was an [error] creating the profile builder */ - class Failure(val error: Exception) : VisaCheckoutProfileBuilderResult() + class Failure internal constructor(val error: Exception) : VisaCheckoutProfileBuilderResult() } diff --git a/VisaCheckout/src/main/java/com/braintreepayments/api/visacheckout/VisaCheckoutResult.kt b/VisaCheckout/src/main/java/com/braintreepayments/api/visacheckout/VisaCheckoutResult.kt index 684054e484..f3ea2d1e35 100644 --- a/VisaCheckout/src/main/java/com/braintreepayments/api/visacheckout/VisaCheckoutResult.kt +++ b/VisaCheckout/src/main/java/com/braintreepayments/api/visacheckout/VisaCheckoutResult.kt @@ -8,10 +8,10 @@ sealed class VisaCheckoutResult { /** * The Visa Checkout flow completed successfully. This [nonce] should be sent to your server. */ - class Success(val nonce: VisaCheckoutNonce) : VisaCheckoutResult() + class Success internal constructor(val nonce: VisaCheckoutNonce) : VisaCheckoutResult() /** * There was an [error] in the Visa Checkout flow. */ - class Failure(val error: Exception) : VisaCheckoutResult() + class Failure internal constructor(val error: Exception) : VisaCheckoutResult() } diff --git a/VisaCheckout/src/main/java/com/braintreepayments/api/visacheckout/VisaCheckoutUserData.kt b/VisaCheckout/src/main/java/com/braintreepayments/api/visacheckout/VisaCheckoutUserData.kt index dc211f1816..48c87b82fc 100644 --- a/VisaCheckout/src/main/java/com/braintreepayments/api/visacheckout/VisaCheckoutUserData.kt +++ b/VisaCheckout/src/main/java/com/braintreepayments/api/visacheckout/VisaCheckoutUserData.kt @@ -2,6 +2,7 @@ package com.braintreepayments.api.visacheckout import android.os.Parcel import android.os.Parcelable +import androidx.annotation.RestrictTo import com.braintreepayments.api.sharedutils.Json import kotlinx.parcelize.Parcelize import org.json.JSONObject @@ -24,7 +25,9 @@ data class VisaCheckoutUserData internal constructor( val userEmail: String?, ) : Parcelable { companion object { + @JvmStatic + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) fun fromJson(jsonIn: JSONObject?): VisaCheckoutUserData { val json = jsonIn ?: JSONObject() return VisaCheckoutUserData( diff --git a/VisaCheckout/src/test/java/com/braintreepayments/api/visacheckout/VisaCheckoutClientUnitTest.kt b/VisaCheckout/src/test/java/com/braintreepayments/api/visacheckout/VisaCheckoutClientUnitTest.kt index 3a8fa722cb..4791f2894d 100644 --- a/VisaCheckout/src/test/java/com/braintreepayments/api/visacheckout/VisaCheckoutClientUnitTest.kt +++ b/VisaCheckout/src/test/java/com/braintreepayments/api/visacheckout/VisaCheckoutClientUnitTest.kt @@ -159,7 +159,6 @@ class VisaCheckoutClientUnitTest { @Test fun `when createProfileBuilder is called and configuration and exception are null, a failure is returned`() { - val exception = ConfigurationException("Error getting configuration.") val callback = mockk(relaxed = true) val braintreeClient = MockkBraintreeClientBuilder().build() val sut = VisaCheckoutClient(braintreeClient, mockk()) From b4de7c4d56533701893e989a4e2b086ae1f6cca3 Mon Sep 17 00:00:00 2001 From: Timothy Chow Date: Fri, 13 Sep 2024 10:22:06 -0500 Subject: [PATCH 2/4] Remove unused functions in GooglePayRequest --- .../api/googlepay/GooglePayRequest.kt | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayRequest.kt b/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayRequest.kt index ac58e787a6..59304d3dc0 100644 --- a/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayRequest.kt +++ b/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayRequest.kt @@ -210,28 +210,6 @@ class GooglePayRequest @JvmOverloads constructor( return json.toString() } - private fun totalPriceStatusToString(): String { - - return transactionInfo?.let { - when (it.totalPriceStatus) { - WalletConstants.TOTAL_PRICE_STATUS_NOT_CURRENTLY_KNOWN -> "NOT_CURRENTLY_KNOWN" - WalletConstants.TOTAL_PRICE_STATUS_ESTIMATED -> "ESTIMATED" - WalletConstants.TOTAL_PRICE_STATUS_FINAL -> "FINAL" - else -> "FINAL" - } - } ?: run { - "FINAL" - } - } - - internal fun billingAddressFormatToString(): String { - var format = "MIN" - if (billingAddressFormat == WalletConstants.BILLING_ADDRESS_FORMAT_FULL) { - format = "FULL" - } - return format - } - /** * @return Allowed payment methods for a given payment method type. */ From 5cfa45554ea7b6ca94bbccbeb52e6482b52a1c64 Mon Sep 17 00:00:00 2001 From: Timothy Chow Date: Fri, 13 Sep 2024 12:17:26 -0500 Subject: [PATCH 3/4] Formatting update --- .../com/braintreepayments/api/googlepay/GooglePayClient.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayClient.kt b/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayClient.kt index ac104b43cf..7d36e53d10 100644 --- a/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayClient.kt +++ b/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayClient.kt @@ -161,9 +161,7 @@ class GooglePayClient internal constructor( } else { if (e != null) { callback.onTokenizationParametersResult( - GooglePayTokenizationParameters.Failure( - e - ) + GooglePayTokenizationParameters.Failure(e) ) } else { callback.onTokenizationParametersResult(null) From b34377f3735e3dfd3090cfd67279ac2046e12d51 Mon Sep 17 00:00:00 2001 From: Timothy Chow Date: Mon, 16 Sep 2024 09:33:15 -0500 Subject: [PATCH 4/4] Remove unused import --- .../java/com/braintreepayments/api/googlepay/GooglePayRequest.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayRequest.kt b/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayRequest.kt index 59304d3dc0..5e97a551e6 100644 --- a/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayRequest.kt +++ b/GooglePay/src/main/java/com/braintreepayments/api/googlepay/GooglePayRequest.kt @@ -2,7 +2,6 @@ package com.braintreepayments.api.googlepay import android.os.Parcelable import androidx.annotation.RestrictTo -import com.google.android.gms.wallet.WalletConstants import kotlinx.parcelize.Parcelize import org.json.JSONArray import org.json.JSONException