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

Move Decoupling to GA #6857

Merged
merged 8 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from 7 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## XX.XX.XX - 2023-XX-XX

### PaymentSheet
* [ADDED][6857](https://github.com/stripe/stripe-android/pull/6857) You can now collect payment details before creating a PaymentIntent or SetupIntent. See [our docs](https://stripe.com/docs/payments/accept-a-payment-deferred?platform=android) for more info. This integration also allows you to [confirm the Intent on the server](https://stripe.com/docs/payments/finalize-payments-on-the-server?platform=android).

### PaymentSheet
* [ADDED][6583](https://github.com/stripe/stripe-android/pull/6583) Added top-level methods `rememberPaymentSheet()` and `rememberPaymentSheetFlowController()` for easier integration in Compose.
* [DEPRECATED][6583](https://github.com/stripe/stripe-android/pull/6583) `PaymentSheetContract` has been deprecated and will be removed in a future release. Use the `PaymentSheet` constructor or new `rememberPaymentSheet()` method instead.
Expand Down
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,5 @@ apiValidation {
"stripecardscan-example",
]
nonPublicMarkers.add("androidx.annotation.RestrictTo")
nonPublicMarkers.add("com.stripe.android.paymentsheet.ExperimentalPaymentSheetDecouplingApi")
nonPublicMarkers.add("dagger.internal.DaggerGenerated")
}
4 changes: 2 additions & 2 deletions paymentsheet-example/detekt-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<ID>LargeClass:PaymentSheetPlaygroundActivity.kt$PaymentSheetPlaygroundActivity : AppCompatActivity</ID>
<ID>LongMethod:AppearanceBottomSheetDialogFragment.kt$@Composable private fun Colors( currentAppearance: PaymentSheet.Appearance, updateAppearance: (PaymentSheet.Appearance) -> Unit, )</ID>
<ID>LongMethod:AppearanceBottomSheetDialogFragment.kt$@Composable private fun PrimaryButton( currentAppearance: PaymentSheet.Appearance, updateAppearance: (PaymentSheet.Appearance) -> Unit, )</ID>
<ID>LongMethod:PaymentSheetPlaygroundActivity.kt$PaymentSheetPlaygroundActivity$@OptIn(ExperimentalPaymentSheetDecouplingApi::class) override fun onCreate(savedInstanceState: Bundle?)</ID>
<ID>LongMethod:PaymentSheetPlaygroundActivity.kt$PaymentSheetPlaygroundActivity$override fun onCreate(savedInstanceState: Bundle?)</ID>
<ID>LongMethod:PaymentSheetPlaygroundActivity.kt$PaymentSheetPlaygroundActivity$private fun setToggles( initialization: String?, customer: String?, link: Boolean, googlePay: Boolean, currency: String?, merchantCountryCode: String, mode: String?, shippingAddress: String, setDefaultBillingAddress: Boolean, setAutomaticPaymentMethods: Boolean, setDelayedPaymentMethods: Boolean, attachDefaultBillingAddress: Boolean, collectName: String, collectEmail: String, collectPhone: String, collectAddress: String, )</ID>
<ID>LongMethod:PaymentSheetPlaygroundActivity.kt$PaymentSheetPlaygroundActivity$private fun startShippingAddressCollection()</ID>
<ID>LongMethod:PaymentSheetPlaygroundViewModel.kt$PaymentSheetPlaygroundViewModel$suspend fun getSavedToggleState(): SavedToggles</ID>
Expand All @@ -26,7 +26,7 @@
<ID>MagicNumber:DrawablePainter.kt$DrawablePainter$255</ID>
<ID>MagicNumber:Payment.kt$0.5f</ID>
<ID>MaxLineLength:PaymentSheetPlaygroundActivity.kt$PaymentSheetPlaygroundActivity$get() = viewBinding.allowsDelayedPaymentMethodsRadioGroup.checkedRadioButtonId == R.id.allowsDelayedPaymentMethods_on_button</ID>
<ID>MaximumLineLength:com.stripe.android.paymentsheet.example.playground.activity.PaymentSheetPlaygroundActivity.kt:147</ID>
<ID>MaximumLineLength:com.stripe.android.paymentsheet.example.playground.activity.PaymentSheetPlaygroundActivity.kt:146</ID>
<ID>PackageNaming:CompleteFlowActivity.kt$package com.stripe.android.paymentsheet.example.samples.ui.paymentsheet.complete_flow</ID>
<ID>PackageNaming:CompleteFlowViewModel.kt$package com.stripe.android.paymentsheet.example.samples.ui.paymentsheet.complete_flow</ID>
<ID>PackageNaming:CompleteFlowViewState.kt$package com.stripe.android.paymentsheet.example.samples.ui.paymentsheet.complete_flow</ID>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import com.google.android.material.snackbar.Snackbar
import com.stripe.android.PaymentConfiguration
import com.stripe.android.core.model.CountryCode
import com.stripe.android.core.model.CountryUtils
import com.stripe.android.paymentsheet.ExperimentalPaymentSheetDecouplingApi
import com.stripe.android.paymentsheet.PaymentSheet
import com.stripe.android.paymentsheet.PaymentSheetResult
import com.stripe.android.paymentsheet.addresselement.AddressDetails
Expand Down Expand Up @@ -186,7 +185,6 @@ class PaymentSheetPlaygroundActivity : AppCompatActivity() {
private lateinit var addressLauncher: AddressLauncher
private var shippingAddress: AddressDetails? = null

@OptIn(ExperimentalPaymentSheetDecouplingApi::class)
override fun onCreate(savedInstanceState: Bundle?) {
val shouldUseDarkMode = intent.extras?.get(FORCE_DARK_MODE_EXTRA) as Boolean?
if (shouldUseDarkMode != null) {
Expand Down Expand Up @@ -571,7 +569,6 @@ class PaymentSheetPlaygroundActivity : AppCompatActivity() {
viewBinding.paymentMethod.isClickable = false
}

@OptIn(ExperimentalPaymentSheetDecouplingApi::class)
private fun startCompleteCheckout() {
if (viewModel.initializationType.value == InitializationType.Normal) {
val clientSecret = viewModel.clientSecret.value ?: return
Expand Down Expand Up @@ -690,7 +687,6 @@ class PaymentSheetPlaygroundActivity : AppCompatActivity() {
)
}

@OptIn(ExperimentalPaymentSheetDecouplingApi::class)
private fun configureCustomCheckout() {
if (viewModel.initializationType.value == InitializationType.Normal) {
val clientSecret = viewModel.clientSecret.value ?: return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import com.stripe.android.PaymentConfiguration
import com.stripe.android.core.model.CountryCode
import com.stripe.android.paymentsheet.CreateIntentResult
import com.stripe.android.paymentsheet.DelicatePaymentSheetApi
import com.stripe.android.paymentsheet.ExperimentalPaymentSheetDecouplingApi
import com.stripe.android.paymentsheet.PaymentSheet
import com.stripe.android.paymentsheet.example.playground.model.CheckoutCurrency
import com.stripe.android.paymentsheet.example.playground.model.CheckoutCustomer
Expand Down Expand Up @@ -268,14 +267,13 @@ class PaymentSheetPlaygroundViewModel(
}
}

@OptIn(ExperimentalPaymentSheetDecouplingApi::class)
private fun createIntent(): CreateIntentResult {
// Note: This is not how you'd do this in a real application. Instead, your app would
// call your backend and create (and optionally confirm) a payment or setup intent.
return CreateIntentResult.Success(clientSecret = clientSecret.value!!)
}

@OptIn(ExperimentalPaymentSheetDecouplingApi::class, DelicatePaymentSheetApi::class)
@OptIn(DelicatePaymentSheetApi::class)
suspend fun createAndConfirmIntent(
paymentMethodId: String,
shouldSavePaymentMethod: Boolean,
Expand Down Expand Up @@ -308,7 +306,6 @@ class PaymentSheetPlaygroundViewModel(
}
}

@OptIn(ExperimentalPaymentSheetDecouplingApi::class)
private suspend fun createAndConfirmIntentInternal(
paymentMethodId: String,
shouldSavePaymentMethod: Boolean,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.stripe.android.paymentsheet.example.samples.model

import com.stripe.android.paymentsheet.ExperimentalPaymentSheetDecouplingApi
import com.stripe.android.paymentsheet.PaymentSheet
import com.stripe.android.paymentsheet.example.samples.networking.ExampleCheckoutResponse
import com.stripe.android.paymentsheet.example.samples.networking.ExampleUpdateResponse
Expand Down Expand Up @@ -74,7 +73,6 @@ internal fun CartState.updateWithResponse(
)
}

@OptIn(ExperimentalPaymentSheetDecouplingApi::class)
internal fun CartState.toIntentConfiguration(): PaymentSheet.IntentConfiguration {
return PaymentSheet.IntentConfiguration(
mode = PaymentSheet.IntentConfiguration.Mode.Payment(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import com.google.android.material.snackbar.Snackbar
import com.stripe.android.paymentsheet.ExperimentalPaymentSheetDecouplingApi
import com.stripe.android.paymentsheet.example.samples.model.toIntentConfiguration
import com.stripe.android.paymentsheet.example.samples.ui.shared.BuyButton
import com.stripe.android.paymentsheet.example.samples.ui.shared.CompletedPaymentAlertDialog
Expand All @@ -29,7 +28,6 @@ internal class ServerSideConfirmationCompleteFlowActivity : AppCompatActivity()

private val viewModel by viewModels<ServerSideConfirmationCompleteFlowViewModel>()

@OptIn(ExperimentalPaymentSheetDecouplingApi::class)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import com.github.kittinunf.fuel.core.requests.suspendable
import com.stripe.android.PaymentConfiguration
import com.stripe.android.model.PaymentMethod
import com.stripe.android.paymentsheet.CreateIntentResult
import com.stripe.android.paymentsheet.ExperimentalPaymentSheetDecouplingApi
import com.stripe.android.paymentsheet.PaymentSheetResult
import com.stripe.android.paymentsheet.example.samples.model.CartProduct
import com.stripe.android.paymentsheet.example.samples.model.CartState
Expand Down Expand Up @@ -68,7 +67,6 @@ internal class ServerSideConfirmationCompleteFlowViewModel(
}
}

@OptIn(ExperimentalPaymentSheetDecouplingApi::class)
suspend fun createAndConfirmIntent(
paymentMethod: PaymentMethod,
shouldSavePaymentMethod: Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.platform.LocalContext
import com.google.android.material.snackbar.Snackbar
import com.stripe.android.paymentsheet.ExperimentalPaymentSheetDecouplingApi
import com.stripe.android.paymentsheet.PaymentSheet
import com.stripe.android.paymentsheet.example.R
import com.stripe.android.paymentsheet.example.samples.model.toIntentConfiguration
Expand All @@ -38,7 +37,6 @@ internal class ServerSideConfirmationCustomFlowActivity : AppCompatActivity() {

private val viewModel by viewModels<ServerSideConfirmationCustomFlowViewModel>()

@OptIn(ExperimentalPaymentSheetDecouplingApi::class)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

Expand Down Expand Up @@ -102,7 +100,6 @@ internal class ServerSideConfirmationCustomFlowActivity : AppCompatActivity() {
}
}

@OptIn(ExperimentalPaymentSheetDecouplingApi::class)
@Composable
fun AttachFlowControllerToViewModel(
flowController: PaymentSheet.FlowController,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import com.github.kittinunf.fuel.core.requests.suspendable
import com.stripe.android.PaymentConfiguration
import com.stripe.android.model.PaymentMethod
import com.stripe.android.paymentsheet.CreateIntentResult
import com.stripe.android.paymentsheet.ExperimentalPaymentSheetDecouplingApi
import com.stripe.android.paymentsheet.PaymentSheetResult
import com.stripe.android.paymentsheet.example.samples.model.CartProduct
import com.stripe.android.paymentsheet.example.samples.model.CartState
Expand Down Expand Up @@ -90,7 +89,6 @@ internal class ServerSideConfirmationCustomFlowViewModel(
}
}

@OptIn(ExperimentalPaymentSheetDecouplingApi::class)
suspend fun createAndConfirmIntent(
paymentMethod: PaymentMethod,
shouldSavePaymentMethod: Boolean,
Expand Down
Loading