Skip to content

Commit

Permalink
Cleanup before GA Release (#190)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
sshropshire authored Sep 20, 2023
1 parent 51f5e4d commit 73615bc
Show file tree
Hide file tree
Showing 88 changed files with 253 additions and 729 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
)
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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?
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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") ?: "")
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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,
Expand All @@ -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
)
)
}

Expand All @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions CorePayments/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,45 +1,52 @@
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
)

// 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
)
Expand All @@ -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
}
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -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 {

Expand Down
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package com.paypal.android.corepayments

import androidx.annotation.RestrictTo

/**
* @suppress
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
enum class HttpMethod {
GET, POST
}
Original file line number Diff line number Diff line change
@@ -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<String, String> = emptyMap(),
Expand Down

This file was deleted.

Loading

0 comments on commit 73615bc

Please sign in to comment.