From 73615bc8dd0199d343742c7b1e328cafb8760690 Mon Sep 17 00:00:00 2001 From: sshropshire <58225613+sshropshire@users.noreply.github.com> Date: Wed, 20 Sep 2023 10:56:34 -0500 Subject: [PATCH] Cleanup before GA Release (#190) * Suppress docs for CardResult deepLinkUrl. * Remove OrderRequest class that is no longer used. * Make ApproveOrderMetadata internal. * Make PaymentSource class internal. * Make additional classes internal that can be made internal. * Make ThreeDSecureResult private. * Move OrderIntent enum out of SDK and into Demo app. * Restrict analytics items to library group whenever possible. * Rename Error type to GraphQLError. * Rename Extension type to GraphQLExtension. * Update library restriction annotations and make GraphQL types library private. * Extract APIClientError codes into internal PayPalSDKErrorCode enum. * Add documentation suppression annotations for library restricted code. * Make Environment enum associated values internal. * Update restrict annotations. * Fix mockk errors that caused HttpResponseParserUnitTest to fail. * Mark CoreConfig magnesEnvironment extension internal. * Fix package name in PaymentButtons module. * Create PayPalWebCheckoutErrorCode type. * Update PayPalWeb restrictions. * Remove open modifier on PayPalSDKError class. * Restrict PayPalSDKError constructor to library group. * Remove SecureTokenServiceAPI.kt. * Remove Eligibility API files that are no longer used. * Flatten GraphQL package. * Fix detekt lint errors. * Remove unused eligibility query raw resource. * Update PayPalNativeViewModel to parse mxo errors. * Move CardResult into .cardpayments module. * Update PayPalSDKErrorCode type to make it visible for tests. * Fix lint errors. * Remove unecessary JSONObjectExt file. * Update CHANGELOG. * Cleanup unused classes. * Cleanup OrderIntent imports. * Revert NetworkModule deletion. --- CHANGELOG.md | 16 +++ .../cardpayments/ApproveOrderListener.kt | 1 - .../cardpayments/ApproveOrderMetadata.kt | 2 +- .../paypal/android/cardpayments/CardClient.kt | 1 - .../cardpayments/{model => }/CardResult.kt | 8 +- .../DataVaultPaymentMethodTokensAPI.kt | 2 +- .../android/cardpayments/OrderRequest.kt | 5 - .../android/cardpayments/model/Amount.kt | 2 +- .../model/AuthenticationResult.kt | 2 +- .../android/cardpayments/model/Payee.kt | 2 +- .../cardpayments/model/PaymentSource.kt | 2 +- .../cardpayments/model/PurchaseUnit.kt | 2 +- .../threedsecure/ThreeDSecureResult.kt | 2 +- .../cardpayments/CardClientUnitTest.kt | 1 - .../cardpayments/CardRequestParserUnitTest.kt | 23 ++-- ...DataVaultPaymentMethodTokensAPIUnitTest.kt | 4 +- CorePayments/build.gradle | 1 + .../android/corepayments/APIClientError.kt | 40 ++++--- .../paypal/android/corepayments/APIRequest.kt | 6 + .../CoreCoroutineExceptionHandler.kt | 5 + .../android/corepayments/Environment.kt | 2 +- .../paypal/android/corepayments/HttpMethod.kt | 6 + .../android/corepayments/HttpResponse.kt | 5 + .../android/corepayments/JSONObjectExt.kt | 16 --- .../android/corepayments/OrderErrorDetail.kt | 6 + .../android/corepayments/OrderStatus.kt | 4 + .../android/corepayments/PayPalSDKError.kt | 4 +- .../corepayments/PayPalSDKErrorCode.kt | 18 +++ .../android/corepayments/PaymentsJSON.kt | 5 + .../android/corepayments/ResourceLoader.kt | 3 +- .../paypal/android/corepayments/RestClient.kt | 5 + .../corepayments/SecureTokenServiceAPI.kt | 31 ------ .../android/corepayments/TrackingEventsAPI.kt | 2 +- .../analytics/AnalyticsEventData.kt | 2 +- .../analytics/AnalyticsService.kt | 5 + .../corepayments/analytics/DeviceData.kt | 2 +- .../corepayments/analytics/DeviceInspector.kt | 2 +- .../corepayments/api/EligibilityAPI.kt | 79 ------------- .../corepayments/api/models/Eligibility.kt | 12 -- .../graphql/{common => }/GraphQLClient.kt | 7 +- .../corepayments/graphql/GraphQLError.kt | 12 ++ .../corepayments/graphql/GraphQLExtension.kt | 12 ++ .../corepayments/graphql/GraphQLResponse.kt | 15 +++ .../corepayments/graphql/common/Error.kt | 6 - .../corepayments/graphql/common/Extension.kt | 6 - .../graphql/common/GraphQLResponse.kt | 12 -- .../models/FundingEligibilityIntent.kt | 5 - .../models/SupportedCountryCurrencyType.kt | 5 - .../models/SupportedPaymentMethodsType.kt | 5 - .../graphql_query_funding_eligibility.graphql | 33 ------ .../SecureTokenServiceAPIUnitTest.kt | 105 ------------------ .../api/EligibilityAPIUnitTest.kt | 95 ---------------- .../{common => }/GraphQLClientUnitTest.kt | 6 +- .../com/paypal/android/api/RetrofitClient.kt | 19 ---- .../paypal/android/api/model}/OrderIntent.kt | 2 +- .../api/services/SDKSampleServerAPI.kt | 29 +---- .../com/paypal/android/text/EditTextExt.kt | 9 -- .../paypal/android/text/ValueChangeWatcher.kt | 29 ----- .../android/ui/WireframeOptionDropDown.kt | 48 -------- .../ui/card/ApproveOrderSuccessView.kt | 2 +- .../paypal/android/ui/card/CardFragment.kt | 4 +- .../paypal/android/ui/card/CardViewModel.kt | 4 +- .../ui/card/validation/CardViewUiState.kt | 4 +- .../ui/card/validation/DateFormatter.kt | 29 ----- .../ui/createorder/CreateOrderFragment.kt | 3 +- .../ui/createorder/CreateOrderUiState.kt | 2 +- .../ui/createorder/CreateOrderViewModel.kt | 2 +- .../android/ui/paypalweb/PayPalWebFragment.kt | 2 +- .../android/ui/paypalweb/PayPalWebUiState.kt | 2 +- .../ui/paypalweb/PayPalWebViewModel.kt | 2 +- .../uishared/components/CardResultView.kt | 2 +- .../uishared/components/CompleteOrderForm.kt | 2 +- .../uishared/components/CreateOrderForm.kt | 2 +- .../CreateOrderWithVaultOptionForm.kt | 2 +- .../GetBillingAgreementTokenUseCase.kt | 47 -------- .../viewmodels/PayPalNativeViewModel.kt | 18 +-- .../fraudprotection/CoreConfigMagnesExt.kt | 2 +- .../PayPalNativeCheckoutClient.kt | 10 +- .../PayPalNativeCheckoutError.kt | 13 +-- .../PayPalDeepLinkUrlResult.kt | 3 +- .../PayPalWebCheckoutLifeCycleObserver.kt | 4 +- .../errors/PayPalWebCheckoutError.kt | 9 +- .../errors/PayPalWebCheckoutErrorCode.kt | 6 + .../android/paymentbuttons/PayPalButton.kt | 2 +- .../paymentbuttons/PayPalCreditButton.kt | 2 +- .../paymentbuttons/PaymentButtonShape.kt | 2 +- .../paymentbuttons/PaymentButtonSize.kt | 2 +- .../paymentbuttons/error/Exceptions.kt | 2 +- 88 files changed, 253 insertions(+), 729 deletions(-) rename CardPayments/src/main/java/com/paypal/android/cardpayments/{model => }/CardResult.kt (63%) delete mode 100644 CardPayments/src/main/java/com/paypal/android/cardpayments/OrderRequest.kt delete mode 100644 CorePayments/src/main/java/com/paypal/android/corepayments/JSONObjectExt.kt create mode 100644 CorePayments/src/main/java/com/paypal/android/corepayments/PayPalSDKErrorCode.kt delete mode 100644 CorePayments/src/main/java/com/paypal/android/corepayments/SecureTokenServiceAPI.kt delete mode 100644 CorePayments/src/main/java/com/paypal/android/corepayments/api/EligibilityAPI.kt delete mode 100644 CorePayments/src/main/java/com/paypal/android/corepayments/api/models/Eligibility.kt rename CorePayments/src/main/java/com/paypal/android/corepayments/graphql/{common => }/GraphQLClient.kt (94%) create mode 100644 CorePayments/src/main/java/com/paypal/android/corepayments/graphql/GraphQLError.kt create mode 100644 CorePayments/src/main/java/com/paypal/android/corepayments/graphql/GraphQLExtension.kt create mode 100644 CorePayments/src/main/java/com/paypal/android/corepayments/graphql/GraphQLResponse.kt delete mode 100644 CorePayments/src/main/java/com/paypal/android/corepayments/graphql/common/Error.kt delete mode 100644 CorePayments/src/main/java/com/paypal/android/corepayments/graphql/common/Extension.kt delete mode 100644 CorePayments/src/main/java/com/paypal/android/corepayments/graphql/common/GraphQLResponse.kt delete mode 100644 CorePayments/src/main/java/com/paypal/android/corepayments/graphql/fundingEligibility/models/FundingEligibilityIntent.kt delete mode 100644 CorePayments/src/main/java/com/paypal/android/corepayments/graphql/fundingEligibility/models/SupportedCountryCurrencyType.kt delete mode 100644 CorePayments/src/main/java/com/paypal/android/corepayments/graphql/fundingEligibility/models/SupportedPaymentMethodsType.kt delete mode 100644 CorePayments/src/main/res/raw/graphql_query_funding_eligibility.graphql delete mode 100644 CorePayments/src/test/java/com/paypal/android/corepayments/SecureTokenServiceAPIUnitTest.kt delete mode 100644 CorePayments/src/test/java/com/paypal/android/corepayments/api/EligibilityAPIUnitTest.kt rename CorePayments/src/test/java/com/paypal/android/corepayments/graphql/{common => }/GraphQLClientUnitTest.kt (96%) delete mode 100644 Demo/src/main/java/com/paypal/android/api/RetrofitClient.kt rename {CardPayments/src/main/java/com/paypal/android/cardpayments => Demo/src/main/java/com/paypal/android/api/model}/OrderIntent.kt (95%) delete mode 100644 Demo/src/main/java/com/paypal/android/text/EditTextExt.kt delete mode 100644 Demo/src/main/java/com/paypal/android/text/ValueChangeWatcher.kt delete mode 100644 Demo/src/main/java/com/paypal/android/ui/WireframeOptionDropDown.kt delete mode 100644 Demo/src/main/java/com/paypal/android/ui/card/validation/DateFormatter.kt delete mode 100644 Demo/src/main/java/com/paypal/android/usecase/GetBillingAgreementTokenUseCase.kt create mode 100644 PayPalWebPayments/src/main/java/com/paypal/android/paypalwebpayments/errors/PayPalWebCheckoutErrorCode.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b5ff08c5..ee1cb7894 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,21 @@ # PayPal Android SDK Release Notes +## unreleased + +* Breaking Changes + * CardPayments + * Make `Amount` class internal + * Make `ApproveOrderMetadata` class internal + * Make `AuthenticationResult` class internal + * Make `Payee` class internal + * Make `PaymentSource` class internal + * Make `PurchaseUnit` class internal + * Make `ThreeDSecureResult` class internal + * Make `Environment` enum associated values internal + * Remove `OrderRequest` class + * CorePayments + * Remove `open` modifier on `PayPalSDKError` + ## 0.0.13 (2023-08-22) * FraudDetection diff --git a/CardPayments/src/main/java/com/paypal/android/cardpayments/ApproveOrderListener.kt b/CardPayments/src/main/java/com/paypal/android/cardpayments/ApproveOrderListener.kt index 9686fd6d4..1aea03cbc 100644 --- a/CardPayments/src/main/java/com/paypal/android/cardpayments/ApproveOrderListener.kt +++ b/CardPayments/src/main/java/com/paypal/android/cardpayments/ApproveOrderListener.kt @@ -1,7 +1,6 @@ package com.paypal.android.cardpayments import androidx.annotation.MainThread -import com.paypal.android.cardpayments.model.CardResult import com.paypal.android.corepayments.PayPalSDKError /** diff --git a/CardPayments/src/main/java/com/paypal/android/cardpayments/ApproveOrderMetadata.kt b/CardPayments/src/main/java/com/paypal/android/cardpayments/ApproveOrderMetadata.kt index 12dfedbe0..f705110ac 100644 --- a/CardPayments/src/main/java/com/paypal/android/cardpayments/ApproveOrderMetadata.kt +++ b/CardPayments/src/main/java/com/paypal/android/cardpayments/ApproveOrderMetadata.kt @@ -4,7 +4,7 @@ import com.paypal.android.cardpayments.model.PaymentSource import com.paypal.android.corepayments.PaymentsJSON import org.json.JSONObject -data class ApproveOrderMetadata(val orderId: String, val paymentSource: PaymentSource?) { +internal data class ApproveOrderMetadata(val orderId: String, val paymentSource: PaymentSource?) { companion object { diff --git a/CardPayments/src/main/java/com/paypal/android/cardpayments/CardClient.kt b/CardPayments/src/main/java/com/paypal/android/cardpayments/CardClient.kt index 1ace6702f..d113dbc97 100644 --- a/CardPayments/src/main/java/com/paypal/android/cardpayments/CardClient.kt +++ b/CardPayments/src/main/java/com/paypal/android/cardpayments/CardClient.kt @@ -8,7 +8,6 @@ import com.braintreepayments.api.BrowserSwitchOptions import com.braintreepayments.api.BrowserSwitchResult import com.braintreepayments.api.BrowserSwitchStatus import com.paypal.android.cardpayments.api.CheckoutOrdersAPI -import com.paypal.android.cardpayments.model.CardResult import com.paypal.android.corepayments.CoreConfig import com.paypal.android.corepayments.CoreCoroutineExceptionHandler import com.paypal.android.corepayments.PayPalSDKError diff --git a/CardPayments/src/main/java/com/paypal/android/cardpayments/model/CardResult.kt b/CardPayments/src/main/java/com/paypal/android/cardpayments/CardResult.kt similarity index 63% rename from CardPayments/src/main/java/com/paypal/android/cardpayments/model/CardResult.kt rename to CardPayments/src/main/java/com/paypal/android/cardpayments/CardResult.kt index 8243a156b..c1e1be6fe 100644 --- a/CardPayments/src/main/java/com/paypal/android/cardpayments/model/CardResult.kt +++ b/CardPayments/src/main/java/com/paypal/android/cardpayments/CardResult.kt @@ -1,11 +1,17 @@ -package com.paypal.android.cardpayments.model +package com.paypal.android.cardpayments import android.net.Uri /** * A result returned by [CardClient] when an order was successfully approved with a [Card]. + * + * @property [orderId] associated order ID. */ data class CardResult( val orderId: String, + + /** + * @suppress + */ val deepLinkUrl: Uri? = null ) diff --git a/CardPayments/src/main/java/com/paypal/android/cardpayments/DataVaultPaymentMethodTokensAPI.kt b/CardPayments/src/main/java/com/paypal/android/cardpayments/DataVaultPaymentMethodTokensAPI.kt index 2340189b4..7433af129 100644 --- a/CardPayments/src/main/java/com/paypal/android/cardpayments/DataVaultPaymentMethodTokensAPI.kt +++ b/CardPayments/src/main/java/com/paypal/android/cardpayments/DataVaultPaymentMethodTokensAPI.kt @@ -4,7 +4,7 @@ import android.content.Context import com.paypal.android.corepayments.CoreConfig import com.paypal.android.corepayments.PayPalSDKError import com.paypal.android.corepayments.ResourceLoader -import com.paypal.android.corepayments.graphql.common.GraphQLClient +import com.paypal.android.corepayments.graphql.GraphQLClient import org.json.JSONObject internal class DataVaultPaymentMethodTokensAPI internal constructor( diff --git a/CardPayments/src/main/java/com/paypal/android/cardpayments/OrderRequest.kt b/CardPayments/src/main/java/com/paypal/android/cardpayments/OrderRequest.kt deleted file mode 100644 index 70a1149d1..000000000 --- a/CardPayments/src/main/java/com/paypal/android/cardpayments/OrderRequest.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.paypal.android.cardpayments - -import com.paypal.android.cardpayments.model.PurchaseUnit - -data class OrderRequest(val intent: OrderIntent, val purchaseUnits: List?) diff --git a/CardPayments/src/main/java/com/paypal/android/cardpayments/model/Amount.kt b/CardPayments/src/main/java/com/paypal/android/cardpayments/model/Amount.kt index 6f56fbf69..e95ed1e33 100644 --- a/CardPayments/src/main/java/com/paypal/android/cardpayments/model/Amount.kt +++ b/CardPayments/src/main/java/com/paypal/android/cardpayments/model/Amount.kt @@ -2,7 +2,7 @@ package com.paypal.android.cardpayments.model import com.paypal.android.corepayments.PaymentsJSON -data class Amount( +internal data class Amount( val currencyCode: String?, val value: String? ) { diff --git a/CardPayments/src/main/java/com/paypal/android/cardpayments/model/AuthenticationResult.kt b/CardPayments/src/main/java/com/paypal/android/cardpayments/model/AuthenticationResult.kt index cdd4d5db1..b4e4237b9 100644 --- a/CardPayments/src/main/java/com/paypal/android/cardpayments/model/AuthenticationResult.kt +++ b/CardPayments/src/main/java/com/paypal/android/cardpayments/model/AuthenticationResult.kt @@ -4,7 +4,7 @@ import com.paypal.android.cardpayments.threedsecure.ThreeDSecureResult import com.paypal.android.corepayments.PaymentsJSON import org.json.JSONObject -data class AuthenticationResult( +internal data class AuthenticationResult( val liabilityShift: String?, val threeDSecure: ThreeDSecureResult? = null ) { diff --git a/CardPayments/src/main/java/com/paypal/android/cardpayments/model/Payee.kt b/CardPayments/src/main/java/com/paypal/android/cardpayments/model/Payee.kt index fc0ade447..6d8f00d6d 100644 --- a/CardPayments/src/main/java/com/paypal/android/cardpayments/model/Payee.kt +++ b/CardPayments/src/main/java/com/paypal/android/cardpayments/model/Payee.kt @@ -2,6 +2,6 @@ package com.paypal.android.cardpayments.model import com.paypal.android.corepayments.PaymentsJSON -data class Payee(val emailAddress: String) { +internal data class Payee(val emailAddress: String) { internal constructor(json: PaymentsJSON) : this(json.optString("email_address") ?: "") } diff --git a/CardPayments/src/main/java/com/paypal/android/cardpayments/model/PaymentSource.kt b/CardPayments/src/main/java/com/paypal/android/cardpayments/model/PaymentSource.kt index 422355f8c..9cb0b34a9 100644 --- a/CardPayments/src/main/java/com/paypal/android/cardpayments/model/PaymentSource.kt +++ b/CardPayments/src/main/java/com/paypal/android/cardpayments/model/PaymentSource.kt @@ -3,7 +3,7 @@ package com.paypal.android.cardpayments.model import com.paypal.android.corepayments.PaymentsJSON import org.json.JSONObject -data class PaymentSource( +internal data class PaymentSource( val lastDigits: String, val brand: String, val type: String? = null, diff --git a/CardPayments/src/main/java/com/paypal/android/cardpayments/model/PurchaseUnit.kt b/CardPayments/src/main/java/com/paypal/android/cardpayments/model/PurchaseUnit.kt index e8ea27785..3ed1b1a6a 100644 --- a/CardPayments/src/main/java/com/paypal/android/cardpayments/model/PurchaseUnit.kt +++ b/CardPayments/src/main/java/com/paypal/android/cardpayments/model/PurchaseUnit.kt @@ -6,7 +6,7 @@ import com.paypal.android.corepayments.PaymentsJSON * A purchase unit for an order. If an order takes multiple purchase units, * each one must contain a reference id. */ -data class PurchaseUnit( +internal data class PurchaseUnit( val referenceId: String?, val amount: Amount? = null, val payee: Payee? = null diff --git a/CardPayments/src/main/java/com/paypal/android/cardpayments/threedsecure/ThreeDSecureResult.kt b/CardPayments/src/main/java/com/paypal/android/cardpayments/threedsecure/ThreeDSecureResult.kt index a5e8c6d7a..626634ef8 100644 --- a/CardPayments/src/main/java/com/paypal/android/cardpayments/threedsecure/ThreeDSecureResult.kt +++ b/CardPayments/src/main/java/com/paypal/android/cardpayments/threedsecure/ThreeDSecureResult.kt @@ -3,7 +3,7 @@ package com.paypal.android.cardpayments.threedsecure import com.paypal.android.corepayments.PaymentsJSON import org.json.JSONObject -data class ThreeDSecureResult( +internal data class ThreeDSecureResult( val enrollmentStatus: String? = null, val authenticationStatus: String? = null ) { diff --git a/CardPayments/src/test/java/com/paypal/android/cardpayments/CardClientUnitTest.kt b/CardPayments/src/test/java/com/paypal/android/cardpayments/CardClientUnitTest.kt index 19cbaffa8..adcc1af97 100644 --- a/CardPayments/src/test/java/com/paypal/android/cardpayments/CardClientUnitTest.kt +++ b/CardPayments/src/test/java/com/paypal/android/cardpayments/CardClientUnitTest.kt @@ -11,7 +11,6 @@ import com.braintreepayments.api.BrowserSwitchResult import com.braintreepayments.api.BrowserSwitchStatus import com.paypal.android.cardpayments.api.CheckoutOrdersAPI import com.paypal.android.cardpayments.api.ConfirmPaymentSourceResponse -import com.paypal.android.cardpayments.model.CardResult import com.paypal.android.cardpayments.model.PaymentSource import com.paypal.android.corepayments.OrderStatus import com.paypal.android.corepayments.PayPalSDKError diff --git a/CardPayments/src/test/java/com/paypal/android/cardpayments/CardRequestParserUnitTest.kt b/CardPayments/src/test/java/com/paypal/android/cardpayments/CardRequestParserUnitTest.kt index 76a164bc2..7f42bd57f 100644 --- a/CardPayments/src/test/java/com/paypal/android/cardpayments/CardRequestParserUnitTest.kt +++ b/CardPayments/src/test/java/com/paypal/android/cardpayments/CardRequestParserUnitTest.kt @@ -1,7 +1,7 @@ package com.paypal.android.cardpayments -import com.paypal.android.corepayments.Code import com.paypal.android.corepayments.HttpResponse +import com.paypal.android.corepayments.PayPalSDKErrorCode import io.mockk.every import io.mockk.mockk import org.junit.Assert @@ -44,7 +44,7 @@ class CardRequestParserUnitTest { private val status: Int, private val body: String, private val message: String, - private val resultCode: Code + private val resultCode: PayPalSDKErrorCode ) { companion object { @@ -56,19 +56,22 @@ class CardRequestParserUnitTest { HttpResponse.STATUS_UNKNOWN_HOST, "json_body", "An error occurred due to an invalid HTTP response. Contact developer.paypal.com/support.", - Code.UNKNOWN_HOST), + PayPalSDKErrorCode.UNKNOWN_HOST + ), arrayOf( false, HttpResponse.STATUS_UNDETERMINED, "json_body", "An unknown error occurred. Contact developer.paypal.com/support.", - Code.UNKNOWN), + PayPalSDKErrorCode.UNKNOWN + ), arrayOf( false, HttpResponse.SERVER_ERROR, "json_body", "A server error occurred. Contact developer.paypal.com/support.", - Code.SERVER_RESPONSE_ERROR), + PayPalSDKErrorCode.SERVER_RESPONSE_ERROR + ), arrayOf( false, HttpURLConnection.HTTP_OK, @@ -86,7 +89,8 @@ class CardRequestParserUnitTest { """.trimIndent(), "error message -> [Issue: ISSUE_KEY_TITLE.\n" + "Error description: issue description message]", - Code.CHECKOUT_ERROR) + PayPalSDKErrorCode.CHECKOUT_ERROR + ) ) } @@ -107,7 +111,12 @@ class CardRequestParserUnitTest { val sut = CardResponseParser() val error = sut.parseError(httpResponse) - if (status != HttpURLConnection.HTTP_OK) Assert.assertEquals(resultCode.ordinal, error?.code) + if (status != HttpURLConnection.HTTP_OK) { + Assert.assertEquals( + resultCode.ordinal, + error?.code + ) + } Assert.assertEquals(correlationId, error?.correlationId) Assert.assertEquals(message, error?.errorDescription) } diff --git a/CardPayments/src/test/java/com/paypal/android/cardpayments/DataVaultPaymentMethodTokensAPIUnitTest.kt b/CardPayments/src/test/java/com/paypal/android/cardpayments/DataVaultPaymentMethodTokensAPIUnitTest.kt index 823909847..b9098f98a 100644 --- a/CardPayments/src/test/java/com/paypal/android/cardpayments/DataVaultPaymentMethodTokensAPIUnitTest.kt +++ b/CardPayments/src/test/java/com/paypal/android/cardpayments/DataVaultPaymentMethodTokensAPIUnitTest.kt @@ -6,8 +6,8 @@ import com.paypal.android.corepayments.Address import com.paypal.android.corepayments.CoreConfig import com.paypal.android.corepayments.Environment import com.paypal.android.corepayments.ResourceLoader -import com.paypal.android.corepayments.graphql.common.GraphQLClient -import com.paypal.android.corepayments.graphql.common.GraphQLResponse +import com.paypal.android.corepayments.graphql.GraphQLClient +import com.paypal.android.corepayments.graphql.GraphQLResponse import io.mockk.coEvery import io.mockk.coVerify import io.mockk.mockk diff --git a/CorePayments/build.gradle b/CorePayments/build.gradle index 7cef39dec..89f6f96e7 100644 --- a/CorePayments/build.gradle +++ b/CorePayments/build.gradle @@ -50,6 +50,7 @@ android { all { // workaround for spying on java.net.URL in Http module // Ref: https://mockk.io/doc/md/jdk16-access-exceptions.html + jvmArgs("--add-opens", "java.base/java.io=ALL-UNNAMED") jvmArgs("--add-opens", "java.base/java.net=ALL-UNNAMED") } } diff --git a/CorePayments/src/main/java/com/paypal/android/corepayments/APIClientError.kt b/CorePayments/src/main/java/com/paypal/android/corepayments/APIClientError.kt index c601a57ba..990e24541 100644 --- a/CorePayments/src/main/java/com/paypal/android/corepayments/APIClientError.kt +++ b/CorePayments/src/main/java/com/paypal/android/corepayments/APIClientError.kt @@ -1,17 +1,24 @@ package com.paypal.android.corepayments +import androidx.annotation.RestrictTo +import java.lang.Exception + +/** + * @suppress + */ +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) object APIClientError { // 0. An unknown error occurred. fun unknownError(correlationId: String?) = PayPalSDKError( - code = Code.UNKNOWN.ordinal, + code = PayPalSDKErrorCode.UNKNOWN.ordinal, errorDescription = "An unknown error occurred. Contact developer.paypal.com/support.", correlationId = correlationId ) // 1. Error parsing HTTP response data. fun dataParsingError(correlationId: String?) = PayPalSDKError( - code = Code.DATA_PARSING_ERROR.ordinal, + code = PayPalSDKErrorCode.DATA_PARSING_ERROR.ordinal, errorDescription = "An error occurred parsing HTTP response data." + " Contact developer.paypal.com/support.", correlationId = correlationId @@ -19,27 +26,27 @@ object APIClientError { // 2. Unknown Host from network. fun unknownHost(correlationId: String?) = PayPalSDKError( - code = Code.UNKNOWN_HOST.ordinal, + code = PayPalSDKErrorCode.UNKNOWN_HOST.ordinal, errorDescription = "An error occurred due to an invalid HTTP response. Contact developer.paypal.com/support.", correlationId = correlationId ) // 3. Missing HTTP response data. fun noResponseData(correlationId: String?) = PayPalSDKError( - code = Code.NO_RESPONSE_DATA.ordinal, + code = PayPalSDKErrorCode.NO_RESPONSE_DATA.ordinal, errorDescription = "An error occurred due to missing HTTP response data. Contact developer.paypal.com/support.", correlationId = correlationId ) // 4. There was an error constructing the URLRequest. val invalidUrlRequest = PayPalSDKError( - code = Code.INVALID_URL_REQUEST.ordinal, + code = PayPalSDKErrorCode.INVALID_URL_REQUEST.ordinal, errorDescription = "An error occurred constructing an HTTP request. Contact developer.paypal.com/support." ) // 5. The server's response body returned an error message. fun serverResponseError(correlationId: String?) = PayPalSDKError( - code = Code.SERVER_RESPONSE_ERROR.ordinal, + code = PayPalSDKErrorCode.SERVER_RESPONSE_ERROR.ordinal, errorDescription = "A server error occurred. Contact developer.paypal.com/support.", correlationId = correlationId ) @@ -54,24 +61,23 @@ object APIClientError { val payPalCheckoutError: (description: String) -> PayPalSDKError = { description -> PayPalSDKError( - code = Code.CHECKOUT_ERROR.ordinal, + code = PayPalSDKErrorCode.CHECKOUT_ERROR.ordinal, errorDescription = description ) } + val payPalNativeCheckoutError: (description: String, reason: Exception) -> PayPalSDKError = + { description, reason -> + PayPalSDKError( + code = PayPalSDKErrorCode.NATIVE_CHECKOUT_ERROR.ordinal, + errorDescription = description, + reason = reason + ) + } + fun clientIDNotFoundError(code: Int, correlationId: String?) = PayPalSDKError( code = code, errorDescription = "Error fetching clientId. Contact developer.paypal.com/support.", correlationId = correlationId ) } - -enum class Code { - UNKNOWN, - DATA_PARSING_ERROR, - UNKNOWN_HOST, - NO_RESPONSE_DATA, - INVALID_URL_REQUEST, - SERVER_RESPONSE_ERROR, - CHECKOUT_ERROR -} diff --git a/CorePayments/src/main/java/com/paypal/android/corepayments/APIRequest.kt b/CorePayments/src/main/java/com/paypal/android/corepayments/APIRequest.kt index e89924a41..23b97fee3 100644 --- a/CorePayments/src/main/java/com/paypal/android/corepayments/APIRequest.kt +++ b/CorePayments/src/main/java/com/paypal/android/corepayments/APIRequest.kt @@ -1,3 +1,9 @@ package com.paypal.android.corepayments +import androidx.annotation.RestrictTo + +/** + * @suppress + */ +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) data class APIRequest(val path: String, val method: HttpMethod, val body: String? = null) diff --git a/CorePayments/src/main/java/com/paypal/android/corepayments/CoreCoroutineExceptionHandler.kt b/CorePayments/src/main/java/com/paypal/android/corepayments/CoreCoroutineExceptionHandler.kt index b820ac4de..1b8b3ed22 100644 --- a/CorePayments/src/main/java/com/paypal/android/corepayments/CoreCoroutineExceptionHandler.kt +++ b/CorePayments/src/main/java/com/paypal/android/corepayments/CoreCoroutineExceptionHandler.kt @@ -1,9 +1,14 @@ package com.paypal.android.corepayments +import androidx.annotation.RestrictTo import kotlinx.coroutines.CoroutineExceptionHandler import kotlin.coroutines.AbstractCoroutineContextElement import kotlin.coroutines.CoroutineContext +/** + * @suppress + */ +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) class CoreCoroutineExceptionHandler(private val handler: (PayPalSDKError) -> Unit) : AbstractCoroutineContextElement(CoroutineExceptionHandler), CoroutineExceptionHandler { diff --git a/CorePayments/src/main/java/com/paypal/android/corepayments/Environment.kt b/CorePayments/src/main/java/com/paypal/android/corepayments/Environment.kt index 6d21783e8..f84f63cef 100644 --- a/CorePayments/src/main/java/com/paypal/android/corepayments/Environment.kt +++ b/CorePayments/src/main/java/com/paypal/android/corepayments/Environment.kt @@ -1,6 +1,6 @@ package com.paypal.android.corepayments -enum class Environment(val url: String, val graphQLEndpoint: String) { +enum class Environment(internal val url: String, internal val graphQLEndpoint: String) { LIVE( "https://api.paypal.com", "https://www.paypal.com" diff --git a/CorePayments/src/main/java/com/paypal/android/corepayments/HttpMethod.kt b/CorePayments/src/main/java/com/paypal/android/corepayments/HttpMethod.kt index 85d6f8470..59716fc70 100644 --- a/CorePayments/src/main/java/com/paypal/android/corepayments/HttpMethod.kt +++ b/CorePayments/src/main/java/com/paypal/android/corepayments/HttpMethod.kt @@ -1,5 +1,11 @@ package com.paypal.android.corepayments +import androidx.annotation.RestrictTo + +/** + * @suppress + */ +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) enum class HttpMethod { GET, POST } diff --git a/CorePayments/src/main/java/com/paypal/android/corepayments/HttpResponse.kt b/CorePayments/src/main/java/com/paypal/android/corepayments/HttpResponse.kt index f8781ba17..a2bd669db 100644 --- a/CorePayments/src/main/java/com/paypal/android/corepayments/HttpResponse.kt +++ b/CorePayments/src/main/java/com/paypal/android/corepayments/HttpResponse.kt @@ -1,7 +1,12 @@ package com.paypal.android.corepayments +import androidx.annotation.RestrictTo import java.net.HttpURLConnection +/** + * @suppress + */ +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) data class HttpResponse( val status: Int, val headers: Map = emptyMap(), diff --git a/CorePayments/src/main/java/com/paypal/android/corepayments/JSONObjectExt.kt b/CorePayments/src/main/java/com/paypal/android/corepayments/JSONObjectExt.kt deleted file mode 100644 index 0f91d35ff..000000000 --- a/CorePayments/src/main/java/com/paypal/android/corepayments/JSONObjectExt.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.paypal.android.corepayments - -import org.json.JSONObject - -fun JSONObject.optBooleanAtKeyPath(keyPath: String, fallback: Boolean = false): Boolean { - val keys = keyPath.split(".").toMutableList() - if (keys.isNotEmpty()) { - var targetObject: JSONObject = this - while (keys.size > 1) { - val key = keys.removeFirst() - targetObject = targetObject.optJSONObject(key) ?: JSONObject() - } - return targetObject.optBoolean(keys[0], fallback) - } - return fallback -} diff --git a/CorePayments/src/main/java/com/paypal/android/corepayments/OrderErrorDetail.kt b/CorePayments/src/main/java/com/paypal/android/corepayments/OrderErrorDetail.kt index 59209b10c..0680b76ec 100644 --- a/CorePayments/src/main/java/com/paypal/android/corepayments/OrderErrorDetail.kt +++ b/CorePayments/src/main/java/com/paypal/android/corepayments/OrderErrorDetail.kt @@ -1,5 +1,11 @@ package com.paypal.android.corepayments +import androidx.annotation.RestrictTo + +/** + * @suppress + */ +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) data class OrderErrorDetail( val issue: String, val description: String diff --git a/CorePayments/src/main/java/com/paypal/android/corepayments/OrderStatus.kt b/CorePayments/src/main/java/com/paypal/android/corepayments/OrderStatus.kt index edfb1af94..7b510cdaa 100644 --- a/CorePayments/src/main/java/com/paypal/android/corepayments/OrderStatus.kt +++ b/CorePayments/src/main/java/com/paypal/android/corepayments/OrderStatus.kt @@ -1,8 +1,12 @@ package com.paypal.android.corepayments +import androidx.annotation.RestrictTo + /** * The status of an order. + * @suppress */ +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) enum class OrderStatus { /** diff --git a/CorePayments/src/main/java/com/paypal/android/corepayments/PayPalSDKError.kt b/CorePayments/src/main/java/com/paypal/android/corepayments/PayPalSDKError.kt index 499731700..9bc4bab9d 100644 --- a/CorePayments/src/main/java/com/paypal/android/corepayments/PayPalSDKError.kt +++ b/CorePayments/src/main/java/com/paypal/android/corepayments/PayPalSDKError.kt @@ -1,9 +1,11 @@ package com.paypal.android.corepayments +import androidx.annotation.RestrictTo + /** * Class used to describe PayPal errors when they occur. */ -open class PayPalSDKError( +class PayPalSDKError @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) constructor( val code: Int, val errorDescription: String, val correlationId: String? = null, diff --git a/CorePayments/src/main/java/com/paypal/android/corepayments/PayPalSDKErrorCode.kt b/CorePayments/src/main/java/com/paypal/android/corepayments/PayPalSDKErrorCode.kt new file mode 100644 index 000000000..ffe900d8a --- /dev/null +++ b/CorePayments/src/main/java/com/paypal/android/corepayments/PayPalSDKErrorCode.kt @@ -0,0 +1,18 @@ +package com.paypal.android.corepayments + +import androidx.annotation.RestrictTo + +/** + * @suppress + */ +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) +enum class PayPalSDKErrorCode { + UNKNOWN, + DATA_PARSING_ERROR, + UNKNOWN_HOST, + NO_RESPONSE_DATA, + INVALID_URL_REQUEST, + SERVER_RESPONSE_ERROR, + CHECKOUT_ERROR, + NATIVE_CHECKOUT_ERROR +} diff --git a/CorePayments/src/main/java/com/paypal/android/corepayments/PaymentsJSON.kt b/CorePayments/src/main/java/com/paypal/android/corepayments/PaymentsJSON.kt index 4d1ec8f0d..dfcd2ebca 100644 --- a/CorePayments/src/main/java/com/paypal/android/corepayments/PaymentsJSON.kt +++ b/CorePayments/src/main/java/com/paypal/android/corepayments/PaymentsJSON.kt @@ -1,9 +1,14 @@ package com.paypal.android.corepayments +import androidx.annotation.RestrictTo import org.json.JSONArray import org.json.JSONException import org.json.JSONObject +/** + * @suppress + */ +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) class PaymentsJSON(val json: JSONObject) { @Throws(JSONException::class) diff --git a/CorePayments/src/main/java/com/paypal/android/corepayments/ResourceLoader.kt b/CorePayments/src/main/java/com/paypal/android/corepayments/ResourceLoader.kt index 8bcd17f35..b469dc9a0 100644 --- a/CorePayments/src/main/java/com/paypal/android/corepayments/ResourceLoader.kt +++ b/CorePayments/src/main/java/com/paypal/android/corepayments/ResourceLoader.kt @@ -10,8 +10,9 @@ import java.io.IOException /** * Convenience class to simplify interaction with Android resource APIs. + * @suppress */ -@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX) +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) class ResourceLoader { /** diff --git a/CorePayments/src/main/java/com/paypal/android/corepayments/RestClient.kt b/CorePayments/src/main/java/com/paypal/android/corepayments/RestClient.kt index f2ac21d41..b70095cc9 100644 --- a/CorePayments/src/main/java/com/paypal/android/corepayments/RestClient.kt +++ b/CorePayments/src/main/java/com/paypal/android/corepayments/RestClient.kt @@ -1,8 +1,13 @@ package com.paypal.android.corepayments +import androidx.annotation.RestrictTo import java.net.URL import java.util.Locale +/** + * @suppress + */ +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) class RestClient internal constructor( private val configuration: CoreConfig, private val http: Http = Http(), diff --git a/CorePayments/src/main/java/com/paypal/android/corepayments/SecureTokenServiceAPI.kt b/CorePayments/src/main/java/com/paypal/android/corepayments/SecureTokenServiceAPI.kt deleted file mode 100644 index 8609f219f..000000000 --- a/CorePayments/src/main/java/com/paypal/android/corepayments/SecureTokenServiceAPI.kt +++ /dev/null @@ -1,31 +0,0 @@ -package com.paypal.android.corepayments - -class SecureTokenServiceAPI internal constructor( - private val restClient: RestClient, -) { - constructor(configuration: CoreConfig) : this(RestClient(configuration)) - - @Throws(PayPalSDKError::class) - suspend fun getClientId(): String { - val apiRequest = APIRequest("v1/oauth2/token", HttpMethod.GET) - val response = restClient.send(apiRequest) - val correlationId = response.headers["Paypal-Debug-Id"] - if (response.isSuccessful) { - return parseClientId(response.body, correlationId) - } - throw APIClientError.serverResponseError(correlationId) - } - - @Throws(PayPalSDKError::class) - private fun parseClientId(responseBody: String?, correlationId: String?): String { - if (responseBody.isNullOrBlank()) { - throw APIClientError.noResponseData(correlationId) - } - val json = PaymentsJSON(responseBody) - val clientId = json.optString("client_id") - if (clientId.isNullOrBlank()) { - throw APIClientError.dataParsingError(correlationId) - } - return clientId - } -} diff --git a/CorePayments/src/main/java/com/paypal/android/corepayments/TrackingEventsAPI.kt b/CorePayments/src/main/java/com/paypal/android/corepayments/TrackingEventsAPI.kt index 439d435da..29f7e3d9b 100644 --- a/CorePayments/src/main/java/com/paypal/android/corepayments/TrackingEventsAPI.kt +++ b/CorePayments/src/main/java/com/paypal/android/corepayments/TrackingEventsAPI.kt @@ -4,7 +4,7 @@ import com.paypal.android.corepayments.analytics.AnalyticsEventData import com.paypal.android.corepayments.analytics.DeviceData import org.json.JSONObject -class TrackingEventsAPI internal constructor( +internal class TrackingEventsAPI constructor( private val coreConfig: CoreConfig, private val restClient: RestClient ) { diff --git a/CorePayments/src/main/java/com/paypal/android/corepayments/analytics/AnalyticsEventData.kt b/CorePayments/src/main/java/com/paypal/android/corepayments/analytics/AnalyticsEventData.kt index 3068487e5..0c29546b0 100644 --- a/CorePayments/src/main/java/com/paypal/android/corepayments/analytics/AnalyticsEventData.kt +++ b/CorePayments/src/main/java/com/paypal/android/corepayments/analytics/AnalyticsEventData.kt @@ -1,7 +1,7 @@ package com.paypal.android.corepayments.analytics // Ref: https://blog.klipse.tech/databook/2022/06/22/separate-code-from-data.html -data class AnalyticsEventData( +internal data class AnalyticsEventData( val environment: String, val eventName: String, val timestamp: Long, diff --git a/CorePayments/src/main/java/com/paypal/android/corepayments/analytics/AnalyticsService.kt b/CorePayments/src/main/java/com/paypal/android/corepayments/analytics/AnalyticsService.kt index 5a2b74dc3..f5ab8c580 100644 --- a/CorePayments/src/main/java/com/paypal/android/corepayments/analytics/AnalyticsService.kt +++ b/CorePayments/src/main/java/com/paypal/android/corepayments/analytics/AnalyticsService.kt @@ -2,6 +2,7 @@ package com.paypal.android.corepayments.analytics import android.content.Context import android.util.Log +import androidx.annotation.RestrictTo import androidx.annotation.VisibleForTesting import com.paypal.android.corepayments.CoreConfig import com.paypal.android.corepayments.Environment @@ -12,6 +13,10 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.async +/** + * @suppress + */ +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) class AnalyticsService internal constructor( private val deviceInspector: DeviceInspector, private val environment: Environment, diff --git a/CorePayments/src/main/java/com/paypal/android/corepayments/analytics/DeviceData.kt b/CorePayments/src/main/java/com/paypal/android/corepayments/analytics/DeviceData.kt index 0d6a377b6..fc93e55aa 100644 --- a/CorePayments/src/main/java/com/paypal/android/corepayments/analytics/DeviceData.kt +++ b/CorePayments/src/main/java/com/paypal/android/corepayments/analytics/DeviceData.kt @@ -1,6 +1,6 @@ package com.paypal.android.corepayments.analytics -data class DeviceData( +internal data class DeviceData( val appId: String, val appName: String, val clientOS: String, diff --git a/CorePayments/src/main/java/com/paypal/android/corepayments/analytics/DeviceInspector.kt b/CorePayments/src/main/java/com/paypal/android/corepayments/analytics/DeviceInspector.kt index d83135774..9a89808a3 100644 --- a/CorePayments/src/main/java/com/paypal/android/corepayments/analytics/DeviceInspector.kt +++ b/CorePayments/src/main/java/com/paypal/android/corepayments/analytics/DeviceInspector.kt @@ -7,7 +7,7 @@ import androidx.annotation.VisibleForTesting import com.paypal.android.corepayments.BuildConfig @Suppress("LongParameterList") -class DeviceInspector @VisibleForTesting internal constructor( +internal class DeviceInspector @VisibleForTesting constructor( private val clientSDKVersion: String, private val sdkInt: Int, private val deviceManufacturer: String, diff --git a/CorePayments/src/main/java/com/paypal/android/corepayments/api/EligibilityAPI.kt b/CorePayments/src/main/java/com/paypal/android/corepayments/api/EligibilityAPI.kt deleted file mode 100644 index 4b3b09ad8..000000000 --- a/CorePayments/src/main/java/com/paypal/android/corepayments/api/EligibilityAPI.kt +++ /dev/null @@ -1,79 +0,0 @@ -package com.paypal.android.corepayments.api - -import android.content.Context -import com.paypal.android.corepayments.CoreConfig -import com.paypal.android.corepayments.PayPalSDKError -import com.paypal.android.corepayments.R -import com.paypal.android.corepayments.ResourceLoader -import com.paypal.android.corepayments.api.models.Eligibility -import com.paypal.android.corepayments.graphql.common.GraphQLClient -import com.paypal.android.corepayments.graphql.fundingEligibility.models.FundingEligibilityIntent -import com.paypal.android.corepayments.graphql.fundingEligibility.models.SupportedCountryCurrencyType -import com.paypal.android.corepayments.graphql.fundingEligibility.models.SupportedPaymentMethodsType -import com.paypal.android.corepayments.optBooleanAtKeyPath -import org.json.JSONArray -import org.json.JSONObject - -/** - * API that checks merchants eligibility for different payment methods. - */ -internal class EligibilityAPI internal constructor( - private val config: CoreConfig, - private val graphQLClient: GraphQLClient, - private val resourceLoader: ResourceLoader -) { - companion object { - const val VARIABLE_CLIENT_ID = "clientId" - const val VARIABLE_INTENT = "intent" - const val VARIABLE_CURRENCY = "currency" - const val VARIABLE_ENABLE_FUNDING = "enableFunding" - } - - /** - * EligibilityAPI constructor. - * @param config configuration parameters for eligibility API - */ - constructor(config: CoreConfig) : - this(config, GraphQLClient(config), ResourceLoader()) - - /** - * Checks if merchant is eligible for a set of payment methods - * @param context Android context - * @return [Eligibility] for payment methods - * @throws PayPalSDKError if something went wrong in the API call - */ - suspend fun checkEligibility(context: Context): Eligibility { - val query = resourceLoader.loadRawResource(context, R.raw.graphql_query_funding_eligibility) - val enableFundingMethods = listOf(SupportedPaymentMethodsType.VENMO.name) - val variables = JSONObject() - .put(VARIABLE_CLIENT_ID, config.clientId) - .put(VARIABLE_INTENT, FundingEligibilityIntent.CAPTURE.name) - .put(VARIABLE_CURRENCY, SupportedCountryCurrencyType.USD.name) - .put(VARIABLE_ENABLE_FUNDING, JSONArray(enableFundingMethods)) - - val graphQLRequest = JSONObject() - .put("query", query) - .put("variables", variables) - val graphQLResponse = graphQLClient.send(graphQLRequest) - if (graphQLResponse.data != null) { - val fundingEligibility = - graphQLResponse.data.optJSONObject("fundingEligibility") ?: JSONObject() - - return fundingEligibility.run { - Eligibility( - isCreditCardEligible = optBooleanAtKeyPath("venmo.eligible"), - isPayLaterEligible = optBooleanAtKeyPath("card.eligible"), - isPaypalCreditEligible = optBooleanAtKeyPath("paypal.eligible"), - isPaypalEligible = optBooleanAtKeyPath("paylater.eligible"), - isVenmoEligible = optBooleanAtKeyPath("credit.eligible"), - ) - } - } else { - throw PayPalSDKError( - 0, - "Error in checking eligibility: ${graphQLResponse.errors}", - graphQLResponse.correlationId - ) - } - } -} diff --git a/CorePayments/src/main/java/com/paypal/android/corepayments/api/models/Eligibility.kt b/CorePayments/src/main/java/com/paypal/android/corepayments/api/models/Eligibility.kt deleted file mode 100644 index cac274d79..000000000 --- a/CorePayments/src/main/java/com/paypal/android/corepayments/api/models/Eligibility.kt +++ /dev/null @@ -1,12 +0,0 @@ -package com.paypal.android.corepayments.api.models - -/** - * Class representing eligibility for a set of payment methods - */ -internal data class Eligibility( - val isVenmoEligible: Boolean, - val isPaypalEligible: Boolean, - val isPaypalCreditEligible: Boolean, - val isPayLaterEligible: Boolean, - val isCreditCardEligible: Boolean -) diff --git a/CorePayments/src/main/java/com/paypal/android/corepayments/graphql/common/GraphQLClient.kt b/CorePayments/src/main/java/com/paypal/android/corepayments/graphql/GraphQLClient.kt similarity index 94% rename from CorePayments/src/main/java/com/paypal/android/corepayments/graphql/common/GraphQLClient.kt rename to CorePayments/src/main/java/com/paypal/android/corepayments/graphql/GraphQLClient.kt index d55c3669f..1fba576ac 100644 --- a/CorePayments/src/main/java/com/paypal/android/corepayments/graphql/common/GraphQLClient.kt +++ b/CorePayments/src/main/java/com/paypal/android/corepayments/graphql/GraphQLClient.kt @@ -1,4 +1,4 @@ -package com.paypal.android.corepayments.graphql.common +package com.paypal.android.corepayments.graphql import androidx.annotation.RestrictTo import com.paypal.android.corepayments.APIClientError @@ -10,7 +10,10 @@ import org.json.JSONObject import java.net.HttpURLConnection import java.net.URL -@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX) +/** + * @suppress + */ +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) class GraphQLClient internal constructor( coreConfig: CoreConfig, private val http: Http = Http(), diff --git a/CorePayments/src/main/java/com/paypal/android/corepayments/graphql/GraphQLError.kt b/CorePayments/src/main/java/com/paypal/android/corepayments/graphql/GraphQLError.kt new file mode 100644 index 000000000..972ecb73d --- /dev/null +++ b/CorePayments/src/main/java/com/paypal/android/corepayments/graphql/GraphQLError.kt @@ -0,0 +1,12 @@ +package com.paypal.android.corepayments.graphql + +import androidx.annotation.RestrictTo + +/** + * @suppress + */ +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) +data class GraphQLError( + val message: String, + val extensions: List? = null +) diff --git a/CorePayments/src/main/java/com/paypal/android/corepayments/graphql/GraphQLExtension.kt b/CorePayments/src/main/java/com/paypal/android/corepayments/graphql/GraphQLExtension.kt new file mode 100644 index 000000000..f330ae250 --- /dev/null +++ b/CorePayments/src/main/java/com/paypal/android/corepayments/graphql/GraphQLExtension.kt @@ -0,0 +1,12 @@ +package com.paypal.android.corepayments.graphql + +import androidx.annotation.RestrictTo + +/** + * @suppress + */ +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) +data class GraphQLExtension( + val correlationId: String, + val code: String? = null +) diff --git a/CorePayments/src/main/java/com/paypal/android/corepayments/graphql/GraphQLResponse.kt b/CorePayments/src/main/java/com/paypal/android/corepayments/graphql/GraphQLResponse.kt new file mode 100644 index 000000000..2b314c513 --- /dev/null +++ b/CorePayments/src/main/java/com/paypal/android/corepayments/graphql/GraphQLResponse.kt @@ -0,0 +1,15 @@ +package com.paypal.android.corepayments.graphql + +import androidx.annotation.RestrictTo +import org.json.JSONObject + +/** + * @suppress + */ +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) +data class GraphQLResponse( + val data: JSONObject? = null, + val extensions: List? = null, + val errors: List? = null, + val correlationId: String? = null +) diff --git a/CorePayments/src/main/java/com/paypal/android/corepayments/graphql/common/Error.kt b/CorePayments/src/main/java/com/paypal/android/corepayments/graphql/common/Error.kt deleted file mode 100644 index f610a12c2..000000000 --- a/CorePayments/src/main/java/com/paypal/android/corepayments/graphql/common/Error.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.paypal.android.corepayments.graphql.common - -data class Error( - val message: String, - val extensions: List? = null -) diff --git a/CorePayments/src/main/java/com/paypal/android/corepayments/graphql/common/Extension.kt b/CorePayments/src/main/java/com/paypal/android/corepayments/graphql/common/Extension.kt deleted file mode 100644 index 06dd451b0..000000000 --- a/CorePayments/src/main/java/com/paypal/android/corepayments/graphql/common/Extension.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.paypal.android.corepayments.graphql.common - -data class Extension( - val correlationId: String, - val code: String? = null -) diff --git a/CorePayments/src/main/java/com/paypal/android/corepayments/graphql/common/GraphQLResponse.kt b/CorePayments/src/main/java/com/paypal/android/corepayments/graphql/common/GraphQLResponse.kt deleted file mode 100644 index 6c29dca64..000000000 --- a/CorePayments/src/main/java/com/paypal/android/corepayments/graphql/common/GraphQLResponse.kt +++ /dev/null @@ -1,12 +0,0 @@ -package com.paypal.android.corepayments.graphql.common - -import androidx.annotation.RestrictTo -import org.json.JSONObject - -@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX) -data class GraphQLResponse( - val data: JSONObject? = null, - val extensions: List? = null, - val errors: List? = null, - val correlationId: String? = null -) diff --git a/CorePayments/src/main/java/com/paypal/android/corepayments/graphql/fundingEligibility/models/FundingEligibilityIntent.kt b/CorePayments/src/main/java/com/paypal/android/corepayments/graphql/fundingEligibility/models/FundingEligibilityIntent.kt deleted file mode 100644 index 887daa153..000000000 --- a/CorePayments/src/main/java/com/paypal/android/corepayments/graphql/fundingEligibility/models/FundingEligibilityIntent.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.paypal.android.corepayments.graphql.fundingEligibility.models - -internal enum class FundingEligibilityIntent { - SALE, CAPTURE, AUTHORIZE, ORDER, TOKENIZE, SUBSCRIPTION -} diff --git a/CorePayments/src/main/java/com/paypal/android/corepayments/graphql/fundingEligibility/models/SupportedCountryCurrencyType.kt b/CorePayments/src/main/java/com/paypal/android/corepayments/graphql/fundingEligibility/models/SupportedCountryCurrencyType.kt deleted file mode 100644 index 0bb462d65..000000000 --- a/CorePayments/src/main/java/com/paypal/android/corepayments/graphql/fundingEligibility/models/SupportedCountryCurrencyType.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.paypal.android.corepayments.graphql.fundingEligibility.models - -internal enum class SupportedCountryCurrencyType { - USD -} diff --git a/CorePayments/src/main/java/com/paypal/android/corepayments/graphql/fundingEligibility/models/SupportedPaymentMethodsType.kt b/CorePayments/src/main/java/com/paypal/android/corepayments/graphql/fundingEligibility/models/SupportedPaymentMethodsType.kt deleted file mode 100644 index 87735c973..000000000 --- a/CorePayments/src/main/java/com/paypal/android/corepayments/graphql/fundingEligibility/models/SupportedPaymentMethodsType.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.paypal.android.corepayments.graphql.fundingEligibility.models - -internal enum class SupportedPaymentMethodsType { - VENMO, CREDIT, PAYLATER -} diff --git a/CorePayments/src/main/res/raw/graphql_query_funding_eligibility.graphql b/CorePayments/src/main/res/raw/graphql_query_funding_eligibility.graphql deleted file mode 100644 index bf0e6d7b6..000000000 --- a/CorePayments/src/main/res/raw/graphql_query_funding_eligibility.graphql +++ /dev/null @@ -1,33 +0,0 @@ -query GetFundingEligibility( - $clientId: String!, - $currency: SupportedCountryCurrencies!, - $intent: FundingEligibilityIntent!, - $enableFunding: [SupportedPaymentMethodsType]! -) { - fundingEligibility( - clientId: $clientId, - currency: $currency, - intent: $intent, - enableFunding: $enableFunding - ) { - paypal { - eligible - reasons - } - credit { - eligible - reasons - } - paylater { - eligible - reasons - } - card { - eligible - } - venmo { - eligible - reasons - } - } -} diff --git a/CorePayments/src/test/java/com/paypal/android/corepayments/SecureTokenServiceAPIUnitTest.kt b/CorePayments/src/test/java/com/paypal/android/corepayments/SecureTokenServiceAPIUnitTest.kt deleted file mode 100644 index c085e58f2..000000000 --- a/CorePayments/src/test/java/com/paypal/android/corepayments/SecureTokenServiceAPIUnitTest.kt +++ /dev/null @@ -1,105 +0,0 @@ -package com.paypal.android.corepayments - -import io.mockk.coEvery -import io.mockk.mockk -import io.mockk.slot -import junit.framework.TestCase.assertEquals -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.test.runTest -import org.json.JSONObject -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import org.robolectric.RobolectricTestRunner - -@ExperimentalCoroutinesApi -@RunWith(RobolectricTestRunner::class) -class SecureTokenServiceAPIUnitTest { - - private val restClient = mockk() - private val httpResponseHeaders = mapOf( - "Paypal-Debug-Id" to "sample-correlation-id" - ) - - private val clientIdSuccessResponse by lazy { - val clientIdBody = JSONObject() - .put("client_id", "sample-client-id") - .toString() - HttpResponse(200, httpResponseHeaders, clientIdBody) - } - - private lateinit var sut: SecureTokenServiceAPI - - @Before - fun beforeEach() { - sut = SecureTokenServiceAPI(restClient) - } - - @Test - fun `getClientId() sends oauth api request when value not in cache`() = - runTest { - val apiRequestSlot = slot() - coEvery { restClient.send(capture(apiRequestSlot)) } returns clientIdSuccessResponse - - sut.getClientId() - - val apiRequest = apiRequestSlot.captured - assertEquals(HttpMethod.GET, apiRequest.method) - assertEquals("v1/oauth2/token", apiRequest.path) - } - - @Test - fun `getClientId() returns client id from JSON`() = runTest { - coEvery { restClient.send(any()) } returns clientIdSuccessResponse - - val result = sut.getClientId() - assertEquals("sample-client-id", result) - } - - @Test - fun `getClientId() throws no response data error when http response has no body`() = runTest { - val noBodyHttpResponse = HttpResponse(200, httpResponseHeaders) - coEvery { restClient.send(any()) } returns noBodyHttpResponse - - var capturedError: PayPalSDKError? = null - try { - sut.getClientId() - } catch (e: PayPalSDKError) { - capturedError = e - } - assertEquals(Code.NO_RESPONSE_DATA.ordinal, capturedError?.code) - assertEquals("sample-correlation-id", capturedError?.correlationId) - } - - @Test - fun `getClientId() throws data parsing error when http response is missing client id`() = - runTest { - val missingClientIdResponse = HttpResponse(200, httpResponseHeaders, "{}") - coEvery { restClient.send(any()) } returns missingClientIdResponse - - var capturedError: PayPalSDKError? = null - try { - sut.getClientId() - } catch (e: PayPalSDKError) { - capturedError = e - } - assertEquals(Code.DATA_PARSING_ERROR.ordinal, capturedError?.code) - assertEquals("sample-correlation-id", capturedError?.correlationId) - } - - @Test - fun `getClientId() throws server response error when http response is unsuccessful`() = - runTest { - val failedServerResponse = HttpResponse(500, httpResponseHeaders) - coEvery { restClient.send(any()) } returns failedServerResponse - - var capturedError: PayPalSDKError? = null - try { - sut.getClientId() - } catch (e: PayPalSDKError) { - capturedError = e - } - assertEquals(Code.SERVER_RESPONSE_ERROR.ordinal, capturedError?.code) - assertEquals("sample-correlation-id", capturedError?.correlationId) - } -} diff --git a/CorePayments/src/test/java/com/paypal/android/corepayments/api/EligibilityAPIUnitTest.kt b/CorePayments/src/test/java/com/paypal/android/corepayments/api/EligibilityAPIUnitTest.kt deleted file mode 100644 index c888429a4..000000000 --- a/CorePayments/src/test/java/com/paypal/android/corepayments/api/EligibilityAPIUnitTest.kt +++ /dev/null @@ -1,95 +0,0 @@ -package com.paypal.android.corepayments.api - -import android.app.Application -import androidx.test.core.app.ApplicationProvider -import com.paypal.android.corepayments.CoreConfig -import com.paypal.android.corepayments.Environment -import com.paypal.android.corepayments.R -import com.paypal.android.corepayments.ResourceLoader -import com.paypal.android.corepayments.graphql.common.GraphQLClient -import com.paypal.android.corepayments.graphql.common.GraphQLResponse -import io.mockk.coEvery -import io.mockk.coVerify -import io.mockk.mockk -import io.mockk.slot -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.test.runTest -import org.json.JSONObject -import org.junit.Assert.assertTrue -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import org.robolectric.RobolectricTestRunner -import org.skyscreamer.jsonassert.JSONAssert - -@ExperimentalCoroutinesApi -@RunWith(RobolectricTestRunner::class) -class EligibilityAPIUnitTest { - - private val coreConfig = CoreConfig("fake-client-id", Environment.SANDBOX) - - private val resourceLoader = ResourceLoader() - private val context = ApplicationProvider.getApplicationContext() - - private lateinit var graphQLClient: GraphQLClient - private lateinit var sut: EligibilityAPI - - @Before - fun beforeEach() { - graphQLClient = mockk(relaxed = true) - } - - @Test - fun checkEligibility_sendsGraphQLRequest() = runTest { - sut = EligibilityAPI(coreConfig, graphQLClient, resourceLoader) - sut.checkEligibility(context) - - val requestBodySlot = slot() - coVerify { graphQLClient.send(capture(requestBodySlot)) } - val actualRequestBody = requestBodySlot.captured - - val expectedQuery = - resourceLoader.loadRawResource(context, R.raw.graphql_query_funding_eligibility) - // language=JSON - val expectedRequestBody = """ - { - "query": "$expectedQuery", - "variables": { - "clientId": "fake-client-id", - "intent": "CAPTURE", - "currency": "USD", - "enableFunding": ["VENMO"] - } - } - """ - - JSONAssert.assertEquals(JSONObject(expectedRequestBody), actualRequestBody, true) - } - - @Test - fun checkEligibility_parsesGraphQLResponse() = runTest { - // language=JSON - val data = """ - { - "fundingEligibility": { - "venmo": { "eligible": true }, - "card": { "eligible": true }, - "paypal": { "eligible": true }, - "paylater": { "eligible": true }, - "credit": { "eligible": true } - } - } - """ - val graphQLResponse = GraphQLResponse(JSONObject(data)) - coEvery { graphQLClient.send(any()) } returns graphQLResponse - - sut = EligibilityAPI(coreConfig, graphQLClient, resourceLoader) - val result = sut.checkEligibility(context) - - assertTrue(result.isCreditCardEligible) - assertTrue(result.isVenmoEligible) - assertTrue(result.isPayLaterEligible) - assertTrue(result.isPaypalCreditEligible) - assertTrue(result.isPaypalEligible) - } -} diff --git a/CorePayments/src/test/java/com/paypal/android/corepayments/graphql/common/GraphQLClientUnitTest.kt b/CorePayments/src/test/java/com/paypal/android/corepayments/graphql/GraphQLClientUnitTest.kt similarity index 96% rename from CorePayments/src/test/java/com/paypal/android/corepayments/graphql/common/GraphQLClientUnitTest.kt rename to CorePayments/src/test/java/com/paypal/android/corepayments/graphql/GraphQLClientUnitTest.kt index 26fc75b25..b6cd0f27a 100644 --- a/CorePayments/src/test/java/com/paypal/android/corepayments/graphql/common/GraphQLClientUnitTest.kt +++ b/CorePayments/src/test/java/com/paypal/android/corepayments/graphql/GraphQLClientUnitTest.kt @@ -1,6 +1,5 @@ -package com.paypal.android.corepayments.graphql.common +package com.paypal.android.corepayments.graphql -import com.paypal.android.corepayments.Code import com.paypal.android.corepayments.CoreConfig import com.paypal.android.corepayments.Environment import com.paypal.android.corepayments.Http @@ -8,6 +7,7 @@ import com.paypal.android.corepayments.HttpMethod import com.paypal.android.corepayments.HttpRequest import com.paypal.android.corepayments.HttpResponse import com.paypal.android.corepayments.PayPalSDKError +import com.paypal.android.corepayments.PayPalSDKErrorCode import io.mockk.CapturingSlot import io.mockk.coEvery import io.mockk.coVerify @@ -146,7 +146,7 @@ internal class GraphQLClientUnitTest { try { sut.send(graphQLRequestBody) } catch (e: PayPalSDKError) { - assertEquals(Code.NO_RESPONSE_DATA.ordinal, e.code) + assertEquals(PayPalSDKErrorCode.NO_RESPONSE_DATA.ordinal, e.code) val expectedErrorMessage = "An error occurred due to missing HTTP response data. Contact developer.paypal.com/support." assertEquals(expectedErrorMessage, e.errorDescription) diff --git a/Demo/src/main/java/com/paypal/android/api/RetrofitClient.kt b/Demo/src/main/java/com/paypal/android/api/RetrofitClient.kt deleted file mode 100644 index 71c273f92..000000000 --- a/Demo/src/main/java/com/paypal/android/api/RetrofitClient.kt +++ /dev/null @@ -1,19 +0,0 @@ -package com.paypal.android.api - -import retrofit2.Retrofit -import retrofit2.converter.gson.GsonConverterFactory - -object RetrofitClient { - // Dev https://ppcp-sample-merchant-sand.herokuapp.com - // Sandbox https://api.sandbox.paypal.com - // Live https://api.paypal.com - private const val BASE_URL = "https://ppcp-sample-merchant-sand.herokuapp.com" - - val instance: Retrofit - get() { - return Retrofit.Builder() - .baseUrl(BASE_URL) - .addConverterFactory(GsonConverterFactory.create()) - .build() - } -} diff --git a/CardPayments/src/main/java/com/paypal/android/cardpayments/OrderIntent.kt b/Demo/src/main/java/com/paypal/android/api/model/OrderIntent.kt similarity index 95% rename from CardPayments/src/main/java/com/paypal/android/cardpayments/OrderIntent.kt rename to Demo/src/main/java/com/paypal/android/api/model/OrderIntent.kt index ab737edb5..69d3f1cee 100644 --- a/CardPayments/src/main/java/com/paypal/android/cardpayments/OrderIntent.kt +++ b/Demo/src/main/java/com/paypal/android/api/model/OrderIntent.kt @@ -1,4 +1,4 @@ -package com.paypal.android.cardpayments +package com.paypal.android.api.model /** * The intent to either capture payment immediately or authorize a payment for an order after order creation diff --git a/Demo/src/main/java/com/paypal/android/api/services/SDKSampleServerAPI.kt b/Demo/src/main/java/com/paypal/android/api/services/SDKSampleServerAPI.kt index 7464188e0..bb904f333 100644 --- a/Demo/src/main/java/com/paypal/android/api/services/SDKSampleServerAPI.kt +++ b/Demo/src/main/java/com/paypal/android/api/services/SDKSampleServerAPI.kt @@ -5,7 +5,7 @@ import com.google.gson.JsonParser import com.paypal.android.api.model.ClientId import com.paypal.android.api.model.CreateOrderRequest import com.paypal.android.api.model.Order -import com.paypal.android.cardpayments.OrderIntent +import com.paypal.android.api.model.OrderIntent import com.paypal.android.usecase.UpdateOrderUseCase import com.paypal.checkout.order.OrderRequest import okhttp3.OkHttpClient @@ -128,25 +128,6 @@ class SDKSampleServerAPI { suspend fun fetchClientId(merchantIntegration: MerchantIntegration = SELECTED_MERCHANT_INTEGRATION) = DEFAULT_CLIENT_ID ?: findService(merchantIntegration).fetchClientId().value - suspend fun createOrder( - orderRequest: CreateOrderRequest, - merchantIntegration: MerchantIntegration = SELECTED_MERCHANT_INTEGRATION - ): Order = DEFAULT_ORDER_ID?.let { - Order(it, "CREATED") - } ?: findService(merchantIntegration).createOrder(orderRequest) - - suspend fun createOrder( - orderRequest: JSONObject, - merchantIntegration: MerchantIntegration = SELECTED_MERCHANT_INTEGRATION - ): Order { - if (DEFAULT_ORDER_ID != null) { - return Order(DEFAULT_ORDER_ID, "CREATED") - } - - val body = JsonParser.parseString(orderRequest.toString()) as JsonObject - return findService(merchantIntegration).createOrder(body) - } - suspend fun createOrder( orderRequest: OrderRequest, merchantIntegration: MerchantIntegration = SELECTED_MERCHANT_INTEGRATION @@ -191,14 +172,6 @@ class SDKSampleServerAPI { return parseOrder(JSONObject(response.string())) } - suspend fun getOrder( - orderId: String, - merchantIntegration: MerchantIntegration = SELECTED_MERCHANT_INTEGRATION - ): Order { - val response = findService(merchantIntegration).getOrder(orderId) - return parseOrder(JSONObject(response.string())) - } - suspend fun createSetupToken( jsonObject: JsonObject, merchantIntegration: MerchantIntegration = SELECTED_MERCHANT_INTEGRATION diff --git a/Demo/src/main/java/com/paypal/android/text/EditTextExt.kt b/Demo/src/main/java/com/paypal/android/text/EditTextExt.kt deleted file mode 100644 index 68cb4fcd1..000000000 --- a/Demo/src/main/java/com/paypal/android/text/EditTextExt.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.paypal.android.text - -import android.widget.EditText - -var EditText.onValueChange: ((oldValue: String, newValue: String) -> Unit)? - get() = null - set(callback) { - callback?.let { addTextChangedListener(ValueChangeWatcher(it)) } - } diff --git a/Demo/src/main/java/com/paypal/android/text/ValueChangeWatcher.kt b/Demo/src/main/java/com/paypal/android/text/ValueChangeWatcher.kt deleted file mode 100644 index 72fc52e5c..000000000 --- a/Demo/src/main/java/com/paypal/android/text/ValueChangeWatcher.kt +++ /dev/null @@ -1,29 +0,0 @@ -package com.paypal.android.text - -import android.text.Editable -import android.text.TextWatcher - -open class ValueChangeWatcher(private val onValueChange: ((oldValue: String, newValue: String) -> Unit)) : - TextWatcher { - - private var oldValue: String = "" - - override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) { - // no-op - } - - override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) { - // no-op - } - - override fun afterTextChanged(p0: Editable?) { - if (p0 != null) { - val newValue = p0.toString() - if (oldValue != newValue) { - val old = oldValue - this.oldValue = newValue - onValueChange(old, newValue) - } - } - } -} diff --git a/Demo/src/main/java/com/paypal/android/ui/WireframeOptionDropDown.kt b/Demo/src/main/java/com/paypal/android/ui/WireframeOptionDropDown.kt deleted file mode 100644 index f172092fa..000000000 --- a/Demo/src/main/java/com/paypal/android/ui/WireframeOptionDropDown.kt +++ /dev/null @@ -1,48 +0,0 @@ -package com.paypal.android.ui - -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.material3.DropdownMenuItem -import androidx.compose.material3.ExperimentalMaterial3Api -import androidx.compose.material3.ExposedDropdownMenuBox -import androidx.compose.material3.ExposedDropdownMenuDefaults -import androidx.compose.material3.OutlinedTextField -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier - -@ExperimentalMaterial3Api -@Composable -fun WireframeOptionDropDown( - hint: String, - value: String, - options: List, - expanded: Boolean, - modifier: Modifier, - onExpandedChange: (Boolean) -> Unit, - onValueChange: (String) -> Unit -) { - // Ref: https://alexzh.com/jetpack-compose-dropdownmenu/ - ExposedDropdownMenuBox( - expanded = expanded, - onExpandedChange = onExpandedChange, - modifier = modifier - ) { - OutlinedTextField( - value = value, - label = { Text(hint) }, - readOnly = true, - onValueChange = {}, - trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded = expanded) }, - modifier = Modifier - .fillMaxWidth() - .menuAnchor() - ) - ExposedDropdownMenu(expanded = expanded, onDismissRequest = {}) { - options.forEach { item -> - DropdownMenuItem(text = { Text(text = item) }, onClick = { - onValueChange(item) - }) - } - } - } -} diff --git a/Demo/src/main/java/com/paypal/android/ui/card/ApproveOrderSuccessView.kt b/Demo/src/main/java/com/paypal/android/ui/card/ApproveOrderSuccessView.kt index 7e8e3ed4f..c632bf3d6 100644 --- a/Demo/src/main/java/com/paypal/android/ui/card/ApproveOrderSuccessView.kt +++ b/Demo/src/main/java/com/paypal/android/ui/card/ApproveOrderSuccessView.kt @@ -10,7 +10,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp -import com.paypal.android.cardpayments.model.CardResult +import com.paypal.android.cardpayments.CardResult import com.paypal.android.uishared.components.CardResultView @Composable diff --git a/Demo/src/main/java/com/paypal/android/ui/card/CardFragment.kt b/Demo/src/main/java/com/paypal/android/ui/card/CardFragment.kt index f7e33ef47..5ae469df8 100644 --- a/Demo/src/main/java/com/paypal/android/ui/card/CardFragment.kt +++ b/Demo/src/main/java/com/paypal/android/ui/card/CardFragment.kt @@ -39,8 +39,8 @@ import com.paypal.android.cardpayments.ApproveOrderListener import com.paypal.android.cardpayments.Card import com.paypal.android.cardpayments.CardClient import com.paypal.android.cardpayments.CardRequest -import com.paypal.android.cardpayments.OrderIntent -import com.paypal.android.cardpayments.model.CardResult +import com.paypal.android.api.model.OrderIntent +import com.paypal.android.cardpayments.CardResult import com.paypal.android.cardpayments.threedsecure.SCA import com.paypal.android.corepayments.CoreConfig import com.paypal.android.corepayments.PayPalSDKError diff --git a/Demo/src/main/java/com/paypal/android/ui/card/CardViewModel.kt b/Demo/src/main/java/com/paypal/android/ui/card/CardViewModel.kt index 7a858b55e..de51c50a5 100644 --- a/Demo/src/main/java/com/paypal/android/ui/card/CardViewModel.kt +++ b/Demo/src/main/java/com/paypal/android/ui/card/CardViewModel.kt @@ -2,8 +2,8 @@ package com.paypal.android.ui.card import androidx.lifecycle.ViewModel import com.paypal.android.api.model.Order -import com.paypal.android.cardpayments.OrderIntent -import com.paypal.android.cardpayments.model.CardResult +import com.paypal.android.api.model.OrderIntent +import com.paypal.android.cardpayments.CardResult import com.paypal.android.models.TestCard import com.paypal.android.ui.card.validation.CardViewUiState import kotlinx.coroutines.flow.MutableStateFlow diff --git a/Demo/src/main/java/com/paypal/android/ui/card/validation/CardViewUiState.kt b/Demo/src/main/java/com/paypal/android/ui/card/validation/CardViewUiState.kt index 916fb445c..bbb19c71a 100644 --- a/Demo/src/main/java/com/paypal/android/ui/card/validation/CardViewUiState.kt +++ b/Demo/src/main/java/com/paypal/android/ui/card/validation/CardViewUiState.kt @@ -2,8 +2,8 @@ package com.paypal.android.ui.card.validation import androidx.compose.runtime.Immutable import com.paypal.android.api.model.Order -import com.paypal.android.cardpayments.OrderIntent -import com.paypal.android.cardpayments.model.CardResult +import com.paypal.android.api.model.OrderIntent +import com.paypal.android.cardpayments.CardResult @Immutable data class CardViewUiState( diff --git a/Demo/src/main/java/com/paypal/android/ui/card/validation/DateFormatter.kt b/Demo/src/main/java/com/paypal/android/ui/card/validation/DateFormatter.kt deleted file mode 100644 index 33ae0acf6..000000000 --- a/Demo/src/main/java/com/paypal/android/ui/card/validation/DateFormatter.kt +++ /dev/null @@ -1,29 +0,0 @@ -package com.paypal.android.ui.card.validation - -object DateFormatter { - - /** - * Formats a month and year string for UI. - * Example: "1226" -> "12/26" - * - * @param newDateString - date to format - * @param previousDateString - previous value that was entered into the date field. This value - * is needed to handle the deletion of characters. - */ - @Suppress("MagicNumber") - fun formatExpirationDate( - newDateString: String, - previousDateString: String? - ): String { - if (newDateString.endsWith("/")) return newDateString - return if (newDateString.length > (previousDateString ?: "").length) { - when (newDateString.length) { - 2 -> "$newDateString/" - 3 -> newDateString.substring(0, 2) + "/" + newDateString.substring(2, 3) - else -> newDateString - } - } else { - newDateString - } - } -} diff --git a/Demo/src/main/java/com/paypal/android/ui/createorder/CreateOrderFragment.kt b/Demo/src/main/java/com/paypal/android/ui/createorder/CreateOrderFragment.kt index 09f6ac246..ef293b1c4 100644 --- a/Demo/src/main/java/com/paypal/android/ui/createorder/CreateOrderFragment.kt +++ b/Demo/src/main/java/com/paypal/android/ui/createorder/CreateOrderFragment.kt @@ -77,7 +77,7 @@ class CreateOrderFragment : Fragment() { // TODO: remove once Feature enum is converted to an inner class of FeaturesFragment // continue on to feature - when (val feature = args.feature) { + when (args.feature) { Feature.PAYPAL_NATIVE -> { navigate( CreateOrderFragmentDirections.actionCreateOrderFragmentToPayPalNativeFragment( @@ -85,6 +85,7 @@ class CreateOrderFragment : Fragment() { ) ) } + else -> {} } } diff --git a/Demo/src/main/java/com/paypal/android/ui/createorder/CreateOrderUiState.kt b/Demo/src/main/java/com/paypal/android/ui/createorder/CreateOrderUiState.kt index 2a706f864..9c1906c72 100644 --- a/Demo/src/main/java/com/paypal/android/ui/createorder/CreateOrderUiState.kt +++ b/Demo/src/main/java/com/paypal/android/ui/createorder/CreateOrderUiState.kt @@ -1,6 +1,6 @@ package com.paypal.android.ui.createorder -import com.paypal.android.cardpayments.OrderIntent +import com.paypal.android.api.model.OrderIntent data class CreateOrderUiState( val intentOption: OrderIntent = OrderIntent.AUTHORIZE, diff --git a/Demo/src/main/java/com/paypal/android/ui/createorder/CreateOrderViewModel.kt b/Demo/src/main/java/com/paypal/android/ui/createorder/CreateOrderViewModel.kt index eff440069..99fc4cc08 100644 --- a/Demo/src/main/java/com/paypal/android/ui/createorder/CreateOrderViewModel.kt +++ b/Demo/src/main/java/com/paypal/android/ui/createorder/CreateOrderViewModel.kt @@ -1,7 +1,7 @@ package com.paypal.android.ui.createorder import androidx.lifecycle.ViewModel -import com.paypal.android.cardpayments.OrderIntent +import com.paypal.android.api.model.OrderIntent import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.update diff --git a/Demo/src/main/java/com/paypal/android/ui/paypalweb/PayPalWebFragment.kt b/Demo/src/main/java/com/paypal/android/ui/paypalweb/PayPalWebFragment.kt index 51ca1ebff..b7df5fdc0 100644 --- a/Demo/src/main/java/com/paypal/android/ui/paypalweb/PayPalWebFragment.kt +++ b/Demo/src/main/java/com/paypal/android/ui/paypalweb/PayPalWebFragment.kt @@ -28,8 +28,8 @@ import androidx.fragment.app.viewModels import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.lifecycleScope import com.paypal.android.R +import com.paypal.android.api.model.OrderIntent import com.paypal.android.api.services.SDKSampleServerAPI -import com.paypal.android.cardpayments.OrderIntent import com.paypal.android.corepayments.APIClientError import com.paypal.android.corepayments.CoreConfig import com.paypal.android.corepayments.PayPalSDKError diff --git a/Demo/src/main/java/com/paypal/android/ui/paypalweb/PayPalWebUiState.kt b/Demo/src/main/java/com/paypal/android/ui/paypalweb/PayPalWebUiState.kt index 937556d2f..d164c576d 100644 --- a/Demo/src/main/java/com/paypal/android/ui/paypalweb/PayPalWebUiState.kt +++ b/Demo/src/main/java/com/paypal/android/ui/paypalweb/PayPalWebUiState.kt @@ -1,7 +1,7 @@ package com.paypal.android.ui.paypalweb import com.paypal.android.api.model.Order -import com.paypal.android.cardpayments.OrderIntent +import com.paypal.android.api.model.OrderIntent import com.paypal.android.corepayments.PayPalSDKError import com.paypal.android.paypalwebpayments.PayPalWebCheckoutFundingSource import com.paypal.android.paypalwebpayments.PayPalWebCheckoutResult diff --git a/Demo/src/main/java/com/paypal/android/ui/paypalweb/PayPalWebViewModel.kt b/Demo/src/main/java/com/paypal/android/ui/paypalweb/PayPalWebViewModel.kt index 4aded6020..fb121ccac 100644 --- a/Demo/src/main/java/com/paypal/android/ui/paypalweb/PayPalWebViewModel.kt +++ b/Demo/src/main/java/com/paypal/android/ui/paypalweb/PayPalWebViewModel.kt @@ -2,7 +2,7 @@ package com.paypal.android.ui.paypalweb import androidx.lifecycle.ViewModel import com.paypal.android.api.model.Order -import com.paypal.android.cardpayments.OrderIntent +import com.paypal.android.api.model.OrderIntent import com.paypal.android.corepayments.PayPalSDKError import com.paypal.android.paypalwebpayments.PayPalWebCheckoutFundingSource import com.paypal.android.paypalwebpayments.PayPalWebCheckoutResult diff --git a/Demo/src/main/java/com/paypal/android/uishared/components/CardResultView.kt b/Demo/src/main/java/com/paypal/android/uishared/components/CardResultView.kt index d344d8dab..bb4ade106 100644 --- a/Demo/src/main/java/com/paypal/android/uishared/components/CardResultView.kt +++ b/Demo/src/main/java/com/paypal/android/uishared/components/CardResultView.kt @@ -13,7 +13,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp -import com.paypal.android.cardpayments.model.CardResult +import com.paypal.android.cardpayments.CardResult @Composable fun CardResultView( diff --git a/Demo/src/main/java/com/paypal/android/uishared/components/CompleteOrderForm.kt b/Demo/src/main/java/com/paypal/android/uishared/components/CompleteOrderForm.kt index cb0ea1059..abb798ec9 100644 --- a/Demo/src/main/java/com/paypal/android/uishared/components/CompleteOrderForm.kt +++ b/Demo/src/main/java/com/paypal/android/uishared/components/CompleteOrderForm.kt @@ -11,7 +11,7 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp -import com.paypal.android.cardpayments.OrderIntent +import com.paypal.android.api.model.OrderIntent import com.paypal.android.ui.WireframeButton @Composable diff --git a/Demo/src/main/java/com/paypal/android/uishared/components/CreateOrderForm.kt b/Demo/src/main/java/com/paypal/android/uishared/components/CreateOrderForm.kt index f795f084e..016a82401 100644 --- a/Demo/src/main/java/com/paypal/android/uishared/components/CreateOrderForm.kt +++ b/Demo/src/main/java/com/paypal/android/uishared/components/CreateOrderForm.kt @@ -16,7 +16,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.paypal.android.R -import com.paypal.android.cardpayments.OrderIntent +import com.paypal.android.api.model.OrderIntent import com.paypal.android.ui.OptionList import com.paypal.android.ui.WireframeButton diff --git a/Demo/src/main/java/com/paypal/android/uishared/components/CreateOrderWithVaultOptionForm.kt b/Demo/src/main/java/com/paypal/android/uishared/components/CreateOrderWithVaultOptionForm.kt index 2005a3f30..081bff970 100644 --- a/Demo/src/main/java/com/paypal/android/uishared/components/CreateOrderWithVaultOptionForm.kt +++ b/Demo/src/main/java/com/paypal/android/uishared/components/CreateOrderWithVaultOptionForm.kt @@ -24,7 +24,7 @@ import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.paypal.android.R -import com.paypal.android.cardpayments.OrderIntent +import com.paypal.android.api.model.OrderIntent import com.paypal.android.ui.OptionList import com.paypal.android.ui.WireframeButton diff --git a/Demo/src/main/java/com/paypal/android/usecase/GetBillingAgreementTokenUseCase.kt b/Demo/src/main/java/com/paypal/android/usecase/GetBillingAgreementTokenUseCase.kt deleted file mode 100644 index 966d5e96e..000000000 --- a/Demo/src/main/java/com/paypal/android/usecase/GetBillingAgreementTokenUseCase.kt +++ /dev/null @@ -1,47 +0,0 @@ -package com.paypal.android.usecase - -import com.paypal.android.api.model.Order -import com.paypal.android.api.services.SDKSampleServerAPI -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.withContext -import org.json.JSONObject -import javax.inject.Inject - -class GetBillingAgreementTokenUseCase - @Inject constructor(private val sdkSampleServerAPI: SDKSampleServerAPI) { - - suspend operator fun invoke(): Order = withContext(Dispatchers.IO) { - sdkSampleServerAPI.createOrder(JSONObject(BA_TOKEN_BODY)) - } - - companion object { - private const val BA_TOKEN_BODY = """ - { - "intent": "CAPTURE", - "purchase_units": [ - { - - "amount": { - "currency_code": "USD", - "value": "95.00" - } - } - ], - "payment_source": { - "paypal": { - "attributes": { - "vault": { - "confirm_payment_token": "ON_ORDER_COMPLETION", - "usage_type": "MERCHANT" - } - } - } - }, - "application_context": { - "return_url": "https://example.com/returnUrl", - "cancel_url": "https://example.com/cancelUrl" - } - } - """ - } -} diff --git a/Demo/src/main/java/com/paypal/android/viewmodels/PayPalNativeViewModel.kt b/Demo/src/main/java/com/paypal/android/viewmodels/PayPalNativeViewModel.kt index 182a92147..dc240938f 100644 --- a/Demo/src/main/java/com/paypal/android/viewmodels/PayPalNativeViewModel.kt +++ b/Demo/src/main/java/com/paypal/android/viewmodels/PayPalNativeViewModel.kt @@ -59,17 +59,21 @@ class PayPalNativeViewModel @Inject constructor( override fun onPayPalCheckoutSuccess(result: PayPalNativeCheckoutResult) { result.apply { - internalState.postValue(NativeCheckoutViewState.CheckoutComplete( - payerId, - orderId - )) + internalState.postValue( + NativeCheckoutViewState.CheckoutComplete( + payerId, + orderId + ) + ) } } override fun onPayPalCheckoutFailure(error: PayPalSDKError) { - val errorState = when (error) { - is PayPalNativeCheckoutError -> NativeCheckoutViewState.CheckoutError(error = error.errorInfo) - else -> NativeCheckoutViewState.CheckoutError(message = error.errorDescription) + val nxoError = error.cause as? PayPalNativeCheckoutError + val errorState = if (nxoError != null) { + NativeCheckoutViewState.CheckoutError(error = nxoError.errorInfo) + } else { + NativeCheckoutViewState.CheckoutError(message = error.errorDescription) } internalState.postValue(errorState) } diff --git a/FraudProtection/src/main/java/com/paypal/android/fraudprotection/CoreConfigMagnesExt.kt b/FraudProtection/src/main/java/com/paypal/android/fraudprotection/CoreConfigMagnesExt.kt index ab4c0ecf3..bb3566503 100644 --- a/FraudProtection/src/main/java/com/paypal/android/fraudprotection/CoreConfigMagnesExt.kt +++ b/FraudProtection/src/main/java/com/paypal/android/fraudprotection/CoreConfigMagnesExt.kt @@ -3,7 +3,7 @@ package com.paypal.android.fraudprotection import com.paypal.android.corepayments.CoreConfig import lib.android.paypal.com.magnessdk.Environment -val CoreConfig.magnesEnvironment: Environment +internal val CoreConfig.magnesEnvironment: Environment get() = when (environment) { com.paypal.android.corepayments.Environment.LIVE -> Environment.LIVE com.paypal.android.corepayments.Environment.SANDBOX -> Environment.SANDBOX diff --git a/PayPalNativePayments/src/main/java/com/paypal/android/paypalnativepayments/PayPalNativeCheckoutClient.kt b/PayPalNativePayments/src/main/java/com/paypal/android/paypalnativepayments/PayPalNativeCheckoutClient.kt index 4b4674967..d6d0a9cc4 100644 --- a/PayPalNativePayments/src/main/java/com/paypal/android/paypalnativepayments/PayPalNativeCheckoutClient.kt +++ b/PayPalNativePayments/src/main/java/com/paypal/android/paypalnativepayments/PayPalNativeCheckoutClient.kt @@ -120,13 +120,9 @@ class PayPalNativeCheckoutClient internal constructor( notifyOnCancel() }, onError = OnError { errorInfo -> - notifyOnFailure( - PayPalNativeCheckoutError( - 0, - errorInfo.reason, - errorInfo = errorInfo - ) - ) + val description = errorInfo.reason + val reason = PayPalNativeCheckoutError(errorInfo) + notifyOnFailure(APIClientError.payPalNativeCheckoutError(description, reason)) }, onShippingChange = OnShippingChange { shippingChangeData, shippingChangeActions -> notifyOnShippingChange(shippingChangeData, shippingChangeActions) diff --git a/PayPalNativePayments/src/main/java/com/paypal/android/paypalnativepayments/PayPalNativeCheckoutError.kt b/PayPalNativePayments/src/main/java/com/paypal/android/paypalnativepayments/PayPalNativeCheckoutError.kt index 5ca139f25..ac0b14583 100644 --- a/PayPalNativePayments/src/main/java/com/paypal/android/paypalnativepayments/PayPalNativeCheckoutError.kt +++ b/PayPalNativePayments/src/main/java/com/paypal/android/paypalnativepayments/PayPalNativeCheckoutError.kt @@ -1,11 +1,10 @@ package com.paypal.android.paypalnativepayments -import com.paypal.android.corepayments.PayPalSDKError import com.paypal.checkout.error.ErrorInfo +import java.lang.Exception -class PayPalNativeCheckoutError( - code: Int, - errorDescription: String, - correlationId: String? = null, - val errorInfo: ErrorInfo -) : PayPalSDKError(code, errorDescription, correlationId) +/** + * Wrapper error type for native checkout error. + */ +data class PayPalNativeCheckoutError internal constructor(val errorInfo: ErrorInfo) : + Exception("PayPal Native Checkout Error") diff --git a/PayPalWebPayments/src/main/java/com/paypal/android/paypalwebpayments/PayPalDeepLinkUrlResult.kt b/PayPalWebPayments/src/main/java/com/paypal/android/paypalwebpayments/PayPalDeepLinkUrlResult.kt index 9b7145d12..a11e086ee 100644 --- a/PayPalWebPayments/src/main/java/com/paypal/android/paypalwebpayments/PayPalDeepLinkUrlResult.kt +++ b/PayPalWebPayments/src/main/java/com/paypal/android/paypalwebpayments/PayPalDeepLinkUrlResult.kt @@ -1,10 +1,9 @@ package com.paypal.android.paypalwebpayments import android.net.Uri -import androidx.annotation.NonNull import org.json.JSONObject -class PayPalDeepLinkUrlResult internal constructor(@NonNull uri: Uri, @NonNull metadata: JSONObject) { +internal class PayPalDeepLinkUrlResult constructor(uri: Uri, metadata: JSONObject) { val payerId: String? = uri.getQueryParameter("PayerID") val intent: String? = uri.getQueryParameter("intent") val opType: String? = uri.getQueryParameter("opType") diff --git a/PayPalWebPayments/src/main/java/com/paypal/android/paypalwebpayments/PayPalWebCheckoutLifeCycleObserver.kt b/PayPalWebPayments/src/main/java/com/paypal/android/paypalwebpayments/PayPalWebCheckoutLifeCycleObserver.kt index cb807b53a..a6f81e10c 100644 --- a/PayPalWebPayments/src/main/java/com/paypal/android/paypalwebpayments/PayPalWebCheckoutLifeCycleObserver.kt +++ b/PayPalWebPayments/src/main/java/com/paypal/android/paypalwebpayments/PayPalWebCheckoutLifeCycleObserver.kt @@ -4,7 +4,9 @@ import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleObserver import androidx.lifecycle.OnLifecycleEvent -class PayPalWebCheckoutLifeCycleObserver(private val payPalClient: PayPalWebCheckoutClient) : LifecycleObserver { +internal class PayPalWebCheckoutLifeCycleObserver( + private val payPalClient: PayPalWebCheckoutClient +) : LifecycleObserver { @OnLifecycleEvent(Lifecycle.Event.ON_RESUME) fun resume() { payPalClient.handleBrowserSwitchResult() diff --git a/PayPalWebPayments/src/main/java/com/paypal/android/paypalwebpayments/errors/PayPalWebCheckoutError.kt b/PayPalWebPayments/src/main/java/com/paypal/android/paypalwebpayments/errors/PayPalWebCheckoutError.kt index 535bbed45..7edf5d25f 100644 --- a/PayPalWebPayments/src/main/java/com/paypal/android/paypalwebpayments/errors/PayPalWebCheckoutError.kt +++ b/PayPalWebPayments/src/main/java/com/paypal/android/paypalwebpayments/errors/PayPalWebCheckoutError.kt @@ -6,18 +6,13 @@ internal object PayPalWebCheckoutError { // 0. An unknown error occurred. val unknownError = PayPalSDKError( - code = Code.UNKNOWN.ordinal, + code = PayPalWebCheckoutErrorCode.UNKNOWN.ordinal, errorDescription = "An unknown error occurred. Contact developer.paypal.com/support." ) // 1. Result did not contain the expected data. val malformedResultError = PayPalSDKError( - code = Code.MALFORMED_RESULT.ordinal, + code = PayPalWebCheckoutErrorCode.MALFORMED_RESULT.ordinal, errorDescription = "Result did not contain the expected data. Payer ID or Order ID is null." ) } - -internal enum class Code { - UNKNOWN, - MALFORMED_RESULT -} diff --git a/PayPalWebPayments/src/main/java/com/paypal/android/paypalwebpayments/errors/PayPalWebCheckoutErrorCode.kt b/PayPalWebPayments/src/main/java/com/paypal/android/paypalwebpayments/errors/PayPalWebCheckoutErrorCode.kt new file mode 100644 index 000000000..991a56ad3 --- /dev/null +++ b/PayPalWebPayments/src/main/java/com/paypal/android/paypalwebpayments/errors/PayPalWebCheckoutErrorCode.kt @@ -0,0 +1,6 @@ +package com.paypal.android.paypalwebpayments.errors + +internal enum class PayPalWebCheckoutErrorCode { + UNKNOWN, + MALFORMED_RESULT +} diff --git a/PaymentButtons/src/main/java/com/paypal/android/paymentbuttons/PayPalButton.kt b/PaymentButtons/src/main/java/com/paypal/android/paymentbuttons/PayPalButton.kt index 67acfef1a..59b83e364 100644 --- a/PaymentButtons/src/main/java/com/paypal/android/paymentbuttons/PayPalButton.kt +++ b/PaymentButtons/src/main/java/com/paypal/android/paymentbuttons/PayPalButton.kt @@ -5,7 +5,7 @@ import android.content.res.TypedArray import android.util.AttributeSet import android.view.View import androidx.core.content.res.use -import com.paypal.android.paypalnativepayments.paymentbutton.error.createFormattedIllegalArgumentException +import com.paypal.android.paymentbuttons.error.createFormattedIllegalArgumentException import com.paypal.android.ui.R /** diff --git a/PaymentButtons/src/main/java/com/paypal/android/paymentbuttons/PayPalCreditButton.kt b/PaymentButtons/src/main/java/com/paypal/android/paymentbuttons/PayPalCreditButton.kt index 02d38d978..d835578f3 100644 --- a/PaymentButtons/src/main/java/com/paypal/android/paymentbuttons/PayPalCreditButton.kt +++ b/PaymentButtons/src/main/java/com/paypal/android/paymentbuttons/PayPalCreditButton.kt @@ -4,7 +4,7 @@ import android.content.Context import android.content.res.TypedArray import android.util.AttributeSet import androidx.core.content.res.use -import com.paypal.android.paypalnativepayments.paymentbutton.error.createFormattedIllegalArgumentException +import com.paypal.android.paymentbuttons.error.createFormattedIllegalArgumentException import com.paypal.android.ui.R import com.paypal.android.paymentbuttons.PayPalCreditButtonColor.BLACK import com.paypal.android.paymentbuttons.PayPalCreditButtonColor.DARK_BLUE diff --git a/PaymentButtons/src/main/java/com/paypal/android/paymentbuttons/PaymentButtonShape.kt b/PaymentButtons/src/main/java/com/paypal/android/paymentbuttons/PaymentButtonShape.kt index 73e391bc7..2ba06f8ef 100644 --- a/PaymentButtons/src/main/java/com/paypal/android/paymentbuttons/PaymentButtonShape.kt +++ b/PaymentButtons/src/main/java/com/paypal/android/paymentbuttons/PaymentButtonShape.kt @@ -1,6 +1,6 @@ package com.paypal.android.paymentbuttons -import com.paypal.android.paypalnativepayments.paymentbutton.error.createFormattedIllegalArgumentException +import com.paypal.android.paymentbuttons.error.createFormattedIllegalArgumentException /** * Defines the shapes available for payment buttons. If no shape is provided then the default diff --git a/PaymentButtons/src/main/java/com/paypal/android/paymentbuttons/PaymentButtonSize.kt b/PaymentButtons/src/main/java/com/paypal/android/paymentbuttons/PaymentButtonSize.kt index de7508c9e..825eaf4c1 100644 --- a/PaymentButtons/src/main/java/com/paypal/android/paymentbuttons/PaymentButtonSize.kt +++ b/PaymentButtons/src/main/java/com/paypal/android/paymentbuttons/PaymentButtonSize.kt @@ -1,6 +1,6 @@ package com.paypal.android.paymentbuttons -import com.paypal.android.paypalnativepayments.paymentbutton.error.createFormattedIllegalArgumentException +import com.paypal.android.paymentbuttons.error.createFormattedIllegalArgumentException import com.paypal.android.ui.R /** diff --git a/PaymentButtons/src/main/java/com/paypal/android/paymentbuttons/error/Exceptions.kt b/PaymentButtons/src/main/java/com/paypal/android/paymentbuttons/error/Exceptions.kt index 69b9dd0e9..bcba35a00 100644 --- a/PaymentButtons/src/main/java/com/paypal/android/paymentbuttons/error/Exceptions.kt +++ b/PaymentButtons/src/main/java/com/paypal/android/paymentbuttons/error/Exceptions.kt @@ -1,4 +1,4 @@ -package com.paypal.android.paypalnativepayments.paymentbutton.error +package com.paypal.android.paymentbuttons.error internal fun createFormattedIllegalArgumentException(enumName: String, enumValues: Int): IllegalArgumentException { val exceptionMessage = "Attempted to create a $enumName with an invalid index. Please use an" +