Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate StripeIntent.redirectData #2497

Merged
merged 19 commits into from
May 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -438,14 +438,13 @@ internal class StripePaymentController internal constructor(
)
)

val redirectData = stripeIntent.redirectData
beginWebAuth(
host,
getRequestCode(stripeIntent),
stripeIntent.clientSecret.orEmpty(),
redirectData?.url.toString(),
nextActionData.url.toString(),
requestOptions.stripeAccount,
redirectData?.returnUrl,
nextActionData.returnUrl,
enableLogging = enableLogging
)
}
Expand Down Expand Up @@ -510,9 +509,6 @@ internal class StripePaymentController internal constructor(
config.stripe3ds2Config.uiCustomization.uiCustomization
)

val redirectData = stripeIntent.redirectData
val returnUrl = redirectData?.returnUrl

val areqParams = transaction.authenticationRequestParameters
val timeout = config.stripe3ds2Config.timeout
val authParams = Stripe3ds2AuthParams(
Expand All @@ -524,7 +520,9 @@ internal class StripePaymentController internal constructor(
areqParams.sdkEphemeralPublicKey,
areqParams.messageVersion,
timeout,
returnUrl
// We do not currently have a fallback url
// TODO(smaskell-stripe): Investigate more robust error handling
returnUrl = null
)
stripeRepository.start3ds2Auth(
authParams,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,12 @@ data class PaymentIntent internal constructor(
}

/**
* @deprecated use {@link #nextActionData} instead
*
* The URL you must redirect your customer to in order to authenticate the payment.
*/
@Deprecated("use {@link #nextActionData}",
replaceWith = ReplaceWith("(nextActionData as? StripeIntent.NextActionData.RedirectToUrl)?.url"))
val redirectUrl: Uri?
get() {
return redirectData?.url
Expand All @@ -164,6 +168,8 @@ data class PaymentIntent internal constructor(
else -> null
}

@Deprecated("use {@link #nextActionData}",
replaceWith = ReplaceWith("nextActionData as? StripeIntent.NextActionData.RedirectToUrl"))
override val redirectData: StripeIntent.RedirectData?
get() = when (nextActionData) {
is StripeIntent.NextActionData.RedirectToUrl ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,17 @@ data class SetupIntent internal constructor(
else -> null
}

@Deprecated("use {@link #nextActionData}",
replaceWith = ReplaceWith("nextActionData as? StripeIntent.NextActionData.RedirectToUrl"))
override val redirectData: StripeIntent.RedirectData?
get() = when (nextActionData) {
is StripeIntent.NextActionData.RedirectToUrl ->
StripeIntent.RedirectData(nextActionData.url, nextActionData.returnUrl)
else -> null
}

@Deprecated("use {@link #nextActionData}",
replaceWith = ReplaceWith("(nextActionData as? StripeIntent.NextActionData.RedirectToUrl)?.url"))
val redirectUrl: Uri?
get() {
return redirectData?.url
Expand Down
31 changes: 29 additions & 2 deletions stripe/src/main/java/com/stripe/android/model/StripeIntent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,26 @@ interface StripeIntent : StripeModel {
val nextActionType: NextActionType?

/**
* @deprecated use {@link #nextActionData} instead
*
* Contains instructions for authenticating by redirecting your customer to another page
* or application.
*/
@Deprecated("use {@link #nextActionData}",
replaceWith = ReplaceWith("nextActionData as? StripeIntent.NextActionData.RedirectToUrl"))
val redirectData: RedirectData?

val clientSecret: String?

/**
* @deprecated use {@link #nextActionData} instead
*
* When confirming a PaymentIntent with the Stripe SDK, the Stripe SDK depends on this property
* to invoke authentication flows. The shape of the contents is subject to change and is only
* intended to be used by the Stripe SDK.
*/
@Deprecated("use {@link #nextActionData}",
replaceWith = ReplaceWith("nextActionData as? StripeIntent.NextAction.SdkData"))
replaceWith = ReplaceWith("nextActionData as? StripeIntent.NextActionData.SdkData"))
val stripeSdkData: SdkData?

val status: Status?
Expand Down Expand Up @@ -144,21 +150,26 @@ interface StripeIntent : StripeModel {
}

/**
* @deprecated use {@link StripeIntent.NextActionData.SdkData} instead
*
* When confirming a [PaymentIntent] or [SetupIntent] with the Stripe SDK, the Stripe SDK
* depends on this property to invoke authentication flows. The shape of the contents is subject
* to change and is only intended to be used by the Stripe SDK.
*/
@Deprecated("use {@link StripeIntent.NextActionData.SdkData}")
@Deprecated("use [StripeIntent.NextActionData.SdkData]")
data class SdkData internal constructor(
val is3ds1: Boolean,
val is3ds2: Boolean,
internal val data: NextActionData.SdkData
)

/**
* @deprecated use {@link StripeIntent.NextActionData.RedirectToUrl} instead
*
* Contains instructions for authenticating by redirecting your customer to another
* page or application.
*/
@Deprecated("use {@link StripeIntent.NextActionData.RedirectToUrl}")
smaskell-stripe marked this conversation as resolved.
Show resolved Hide resolved
@Parcelize
data class RedirectData internal constructor(
/**
Expand Down Expand Up @@ -209,12 +220,28 @@ interface StripeIntent : StripeModel {
val number: String? = null
) : NextActionData()

/**
* Contains instructions for authenticating by redirecting your customer to another
* page or application.
*/
@Parcelize
data class RedirectToUrl(
/**
* The URL you must redirect your customer to in order to authenticate.
*/
val url: Uri,
/**
* If the customer does not exit their browser while authenticating, they will be redirected
* to this specified URL after completion.
*/
val returnUrl: String?
) : NextActionData()

/**
* When confirming a [PaymentIntent] or [SetupIntent] with the Stripe SDK, the Stripe SDK
* depends on this property to invoke authentication flows. The shape of the contents is subject
* to change and is only intended to be used by the Stripe SDK.
*/
sealed class SdkData : NextActionData() {
@Parcelize
data class Use3DS1(
Expand Down