-
Notifications
You must be signed in to change notification settings - Fork 659
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
Add minimal user key auth support to PaymentSheet #4481
Conversation
return ConfirmPaymentIntentParams( | ||
clientSecret = clientSecret, | ||
paymentMethodId = paymentMethodId, | ||
paymentMethodOptions = PaymentMethodOptionsParams.Card(moto = true), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -105,6 +105,9 @@ data class ApiRequest internal constructor( | |||
internal val idempotencyKey: String? = null | |||
) : Parcelable { | |||
|
|||
internal val apiKeyIsUserKey: Boolean | |||
get() = apiKey.startsWith("uk_") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -64,6 +65,13 @@ internal sealed class RequestHeadersFactory { | |||
HEADER_AUTHORIZATION to "Bearer ${options.apiKey}" | |||
).plus( | |||
stripeClientUserAgentHeaderFactory.create(appInfo) | |||
).plus( | |||
if (options.apiKeyIsUserKey) { | |||
val isLiveMode = Os.getenv("Stripe-Livemode") != "false" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -186,11 +187,25 @@ internal class StripeApiRepository @JvmOverloads internal constructor( | |||
confirmPaymentIntentParams: ConfirmPaymentIntentParams, | |||
options: ApiRequest.Options, | |||
expandFields: List<String> | |||
): PaymentIntent? { | |||
return confirmPaymentIntentInternal( | |||
confirmPaymentIntentParams = confirmPaymentIntentParams.maybeForDashboard(options), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
confirmPaymentIntentParams.toParamMap(), | ||
confirmPaymentIntentParams.toParamMap() | ||
// Omit client_secret with user key auth. | ||
.let { if (options.apiKeyIsUserKey) it.minus(PARAM_CLIENT_SECRET) else it }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
payments-core/src/main/java/com/stripe/android/networking/StripeApiRepository.kt
Outdated
Show resolved
Hide resolved
@@ -1137,6 +1160,9 @@ internal class StripeApiRepository @JvmOverloads internal constructor( | |||
parser: PaymentMethodPreferenceJsonParser<T>, | |||
analyticsEvent: PaymentAnalyticsEvent | |||
): T? { | |||
// Unsupported for user key sessions. | |||
if (options.apiKeyIsUserKey) return null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary
Add
uk
support to PaymentSheet similar to what currently exists in the iOS SDK:Motivation
Parity with iOS SDK.
Testing