- Changes to
PaymentSheetContract:- The class has been deprecated and will be removed in a future release. Use the
PaymentSheetconstructor or the newrememberPaymentSheet()method.
- The class has been deprecated and will be removed in a future release. Use the
- Changes to
PaymentLauncher:PaymentLauncher.rememberLauncher()has been deprecated and will be removed in a future release. Use the top-levelrememberPaymentLauncher()method instead.
- Changes to
GooglePayLauncher:GooglePayLauncher.rememberLauncher()has been deprecated and will be removed in a future release. Use the top-levelrememberGooglePayLauncher()method instead.
- Changes to
GooglePayPaymentMethodLauncher:GooglePayPaymentMethodLauncher.rememberLauncher()has been deprecated and will be removed in a future release. Use the top-levelrememberGooglePayPaymentMethodLauncher()method instead.
- Changes to
GooglePayLauncherContract:- The class has been deprecated and will be removed in a future release. Use
GooglePayLauncherdirectly.
- The class has been deprecated and will be removed in a future release. Use
- Changes to
GooglePayPaymentMethodLauncherContract:- The class has been deprecated and will be removed in a future release. Use
GooglePayPaymentMethodLauncherdirectly.
- The class has been deprecated and will be removed in a future release. Use
- Changes to
PaymentSheet.ConfigurationprimaryButtonColoris now deprecated. Please use the newAppearanceparameter instead:Appearance.colorsLight/colorsDark.primaryPrimaryButton.colorsLight/colorsDark.backgroundColor
- Changes to
CollectBankAccountLauncher- Required, dependent artifact
com.stripe.connectionshas been renamed tocom.stripe.financial-connections.
- Required, dependent artifact
- The following classes' packages are changed
com.stripe.android.AppInfo->com.stripe.android.core.AppInfocom.stripe.android.model.StripeFile->com.stripe.android.core.model.StripeFilecom.stripe.android.model.StripeFileParams->com.stripe.android.core.model.StripeFileParamscom.stripe.android.model.StripeFilePurpose->com.stripe.android.core.model.StripeFilePurposecom.stripe.android.exception.AuthenticationException->com.stripe.android.core.exception.AuthenticationExceptioncom.stripe.android.exception.PermissionException->com.stripe.android.core.exception.PermissionExceptioncom.stripe.android.exception.RateLimitException->com.stripe.android.core.exception.RateLimitException
- Changes to
StripeCardScan.Configuration- Setting custom scan values in
Configis no longer supported. Configuration values have been moved to theStripeCardScan.Configurationobject. If a value was removed that you need access to, please file an issue against this repository.
- Setting custom scan values in
- The following list of classes' package names are changed from
com.stripe.androidtocom.stripe.android.coreStripeModelStripeErrorStripeExceptionAPIExceptionAPIConnectionExceptionInvalidRequestException
- Changes to
PaymentSheet.Configuration- If you're modifying values in your
Configurationclass after instantiating it then you won't be able to build your project. You should create the object with the final values or use the newBuilder.
- If you're modifying values in your
- Changes to
StripeComponentActivityis now required for payment confirmation methods to make operations lifecycle-aware.authenticatePaymentandauthenticateSetuphave been removedcreateCardToken()now requiresCardParamsinstead ofCard
- Changes to
ConfirmPaymentIntentParamsreturnUrlhas been removed as a parameter onConfirmPaymentIntentParamsstatic creation methods. The SDK manages setting this value internally.extraParamsproperty has been removed. Static creation methods that accept this parameter have been removed.
- Changes to
ConfirmSetupIntentParamsreturnUrlhas been removed as a parameter onConfirmSetupIntentParamsstatic creation methods. The SDK manages setting this value internally.
- Changes to
Cardnumberandcvcproperties have been removed to reflect the Stripe APImetadatahas been removed to reflect that it is no longer returned to clients using a publishable keyCard.Builderhas been removedfromString()andfromJson()static methods have been removedtoPaymentMethodsParams(),toPaymentMethodParamsCard(),toBuilder(), and validation instance methods have been removed
- Changes to
PaymentMethodmetadatahas been removed to reflect that it is no longer returned to clients using a publishable keyPaymentMethod.Card.Builderhas been removed
- Changes to
PaymentIntentnextActionproperty has been removed. UsenextActionDatainstead.
- Changes to
PaymentMethodCreateParamsIdeal.Builder,Fpx.Builder, andSepaDebit.Builderhave been removed
- Changes to
Sourcemetadatahas been removed to reflect that it is no longer returned to clients using a publishable key
- Changes to
SourceParams- Most setter methods have been removed
extraParamsproperty has been removed
- Changes to
Customer- Remove
fromString()andfromJson() - Rename
CustomerSourcetoCustomerPaymentSourceand make a sealed class with typesCustomerBankAccount,CustomerCard, andCustomerSource
- Remove
- Changes to
CardBrand- Deprecated methods have been removed
- Changes to
CardInputWidgetcardandcardBuilderproperties have been removed; usecardParamsinstead
- Changes to
CardMultilineWidgetcardandcardBuilderproperties have been removed; usecardParamsinstead
- Changes to
CardNumberEditTextlengthMaxandcardNumberproperties have been removed
- Changes to
CvcEditTextcvcValueproperty has been removed
- Changes to
ExpiryDateEditTextvalidDateFieldsproperty has been removed
- Changes to
StripeEditTextcachedColorStateListproperty has been removed
- Other changes
GooglePayConfignow requires instantiatedPaymentConfigurationCardUtilsis nowinternalStripeTextUtilshas been removedStripe.confirmPaymentandStripe.confirmSetupIntentwill now use Custom Tabs by default when performing 3DS1 Authentication. If Custom Tabs are not available the SDK will launch the device browser to perform authentication.
- Changes to
CardInputWidgetandCardMultilineWidget- To enable 19-digit card support, [PaymentConfiguration.init] must be called before the card widgets are instantiated.
cardandcardBuilderare deprecated. UsecardParamsinstead.
- Changes to
CardNumberEditTextlengthMaxandcardNumberare deprecated
- Changes to
CvcEditTextcvcValueis deprecated
- Changes to
Cardnumberandcvcare deprecated and will be removed in a future release.Card.BuilderandtoBuilder()are deprecated; useCardParamsinstead.Card.fromString(),Card.fromJson(), andCard.create()are deprecated and will be removed in a future release.metadatais deprecated and no longer populated on the client. It must be fetched on your server using your secret key. If this is causing issues with your deployed app versions please reach out to Stripe Support. This field will be removed in a future SDK version.toPaymentMethodsParams()andtoPaymentMethodParamsCard()are deprecated; usePaymentMethodCreateParams.createCard()instead.validateCard(),validateNumber(),validateExpiryDate(),validateCVC(),validateExpMonth()are deprecated
- Changes to
CardBrand- Methods
fromCardNumber(),formatNumber(),groupNumber(),getSpacePositionsForCardNumber(),getMaxLengthWithSpacesForCardNumber(),getMaxLengthForCardNumber()are deprecated - Properties
defaultMaxLength,pattern, anddefaultSpacePositionsare deprecated
- Methods
- Changes to
CardUtilsgetPossibleCardBrand()andisValidCardNumberare deprecated
- Changes to
StripeTextUtilsremoveSpacesAndHyphens()is deprecated
- Changes to
SourceParamscreateCardToken()that accepts aCardparameter is deprecated. UsecreateCardToken()that accepts aCardParamsparameter instead.createCardTokenSynchronous()that accepts aCardparameter is deprecated. UsecreateCardTokenSynchronous()that accepts aCardParamsparameter instead.
- Changes to
Sourcemetadatais deprecated and no longer populated on the client. It must be fetched on your server using your secret key. If this is causing issues with your deployed app versions please reach out to Stripe Support. This field will be removed in a future SDK version.
- Changes to
PaymentMethodmetadatais deprecated and no longer populated on the client. It must be fetched on your server using your secret key. If this is causing issues with your deployed app versions please reach out to Stripe Support. This field will be removed in a future SDK version.
- Changes to
StripecreateCardParams()that accepts aCardparameter is deprecated. UsecreateCardParams()that accepts aCardParamsparameter instead.createToken()has been removed; usecreateCardToken()instead.
- The SDK now targets JVM 1.8
- The SDK now requires Android 5.0+ (API level 21+)
- Changes to
PaymentIntentPaymentIntent#captureMethodis now an enum,PaymentIntent.CaptureMethod// before if (paymentIntent.captureMethod == "automatic") { } else if (paymentIntent.captureMethod == "manual") { } // after when (paymentIntent.captureMethod) { PaymentIntent.CaptureMethod.Automatic -> {} PaymentIntent.CaptureMethod.Manual -> {} }
PaymentIntent#confirmationMethodis now an enum,PaymentIntent.ConfirmationMethod// before if (paymentIntent.confirmationMethod == "automatic") { } else if (paymentIntent.confirmationMethod == "manual") { } // after when (paymentIntent.confirmationMethod) { PaymentIntent.ConfirmationMethod.Automatic -> {} PaymentIntent.ConfirmationMethod.Manual -> {} }
- Changes to
PaymentMethodPaymentMethod.Card#brandis now aCardBrand// before when (paymentMethod.card?.brand) { "visa" -> {} "mastercard" -> {} else -> {} } // after when (paymentMethod.card?.brand) { CardBrand.Visa -> {} CardBrand.MasterCard -> {} else -> {} }
- Changes to
TokenToken.TokenTypeis renamed toToken.Typeand is now an enum// before when (token.type) { Token.TokenType.CARD -> {} Token.TokenType.BANK_ACCOUNT -> {} else -> {} } // after when (token.type) { Token.Type.Card -> {} Token.Type.BankAccount -> {} else -> {} }
- Changes to
PaymentSession- Remove
PaymentSession#ActivityPaymentSessionListener
- Remove
- Changes to
CustomerSessionCustomerSession's constructor no longer takes astripeAccountId; instead, instantiatePaymentConfigurationwith astripeAccountId// before PaymentConfiguration.init( context, "pk_test" ) CustomerSession.initCustomerSession( context ephemeralKeyProvider, "acct_1234" ) // after PaymentConfiguration.init( context, "pk_test", "acct_1234" ) CustomerSession.initCustomerSession( context ephemeralKeyProvider )
- Remove
CustomerSession#ActivityCustomerRetrievalListener,CustomerSession#ActivityPaymentMethodRetrievalListener,CustomerSession#ActivityPaymentMethodsRetrievalListener, andCustomerSession#ActivitySourceRetrievalListener
- Changes to
AddPaymentMethodActivity- When
PaymentConfigurationis instantiated with astripeAccountId, it will be used inAddPaymentMethodActivitywhen creating a payment methodPaymentConfiguration.init(context, "pk_test", "acct_1234")
AddPaymentMethodActivity.Resultis now a sealed class withSuccess,Failure, andCanceledsubclasses// before val result = AddPaymentMethodActivityStarter.Result.fromIntent( intent ) when { result != null -> result.paymentMethod else -> { // error happened or customer canceled } } // after val result = AddPaymentMethodActivityStarter.Result.fromIntent( intent ) when (result) { is AddPaymentMethodActivityStarter.Result.Success -> { result.paymentMethod } is AddPaymentMethodActivityStarter.Result.Failure -> { result.exception } is AddPaymentMethodActivityStarter.Result.Canceled -> { // customer canceled } }
- When
- Changes to
ShippingInfoWidgetsetOptionalFields()is nowoptionalFieldssetHiddenFields()is nowhiddenFieldsCustomizableShippingFieldis now an enum
- Changes to
SourceSource.SourceFlowhas been renamed toSource.Flowand is now an enumSource.SourceStatushas been renamed toSource.Statusand is now an enumSource.Usageis now an enumSourceCodeVerificationhas been moved toSource.CodeVerificationSourceOwnerhas been moved toSource.OwnerSourceReceiverhas been moved toSource.ReceiverSourceRedirecthas been moved toSource.Redirect
- Changes to
CustomerSourceCustomerSource#tokenizationMethodis now aTokenizationMethod?
- Changes to
SourceTypeModel.CardSourceTypeModel.Card.ThreeDSecureStatusis now an enum
- Changes to
BankAccount- public constructors have been removed
BankAccount#accountNumberhas been removedStripe#createBankAccountToken()no longer accepts aBankAccountinstance; instead, useBankAccountTokenParamsStripe#createBankAccountTokenSynchronous()no longer accepts aBankAccountinstance; instead, useBankAccountTokenParams
- Changes to
AccountParams- Remove
AccountParams.create()that takes a raw map; instead, usecreate()method that takes aAccountParams.BusinessTypeParams.IndividualorAccountParams.BusinessTypeParams.Company
- Remove
- Changes to
CardInputListenerFocusFieldis now an enum
- Changes to
StripeIntent-
redirectDatais now deprecated.If a
PaymentIntentorSetupIntentrequires a redirect to authenticate, this information will be innextActionData. However, as before, this action will be handled by the SDK inStripe.confirmPayment/Stripe.confirmSetupIntent.// before if (intent.redirectData != null) { // requires redirect } // after when (intent.nextActionData) { is StripeIntent.RedirectData.RedirectToUrl -> // requires redirect }
-
stripeSdkDatais now deprecated.If a
PaymentIntentorSetupIntentrequires 3DS1 or 3DS2 authentication, this information will be innextActionData. However, as before, this action will be handled by the SDK inStripe.confirmPayment/Stripe.confirmSetupIntent.// before if (intent.stripeSdkData != null) { // requires 3D Secure auth } // after when (intent.nextActionData) { is StripeIntent.RedirectData.SdkData -> // requires 3D Secure auth }
-
- Changes to Stripe Error localization
-
All Stripe Error messages are now localized based on the device locale.
For example, when retrieving a SetupIntent with a nonexistent
idwhen the device locale is set toLocale.JAPAN, the error message will now be localized.// before - English "No such setupintent: seti_invalid123" // after - Japanese "そのような setupintent はありません : seti_invalid123"
-
- Changes to Material Components
com.google.android.material:materialhas been updated tov1.1.0
- Changes to
PaymentSession- When instantiating a
PaymentSession()with anActivity, it must now be aComponentActivity(e.g.AppCompatActivityorFragmentActivity) PaymentSession#init()no longer takes asavedInstanceStateargument// before paymentSession.init(listener, savedInstancedState) // after paymentSession.init(listener)
PaymentSession#savePaymentSessionInstanceState()has been removed; state management is handled byPaymentSessionPaymentSession#onDestroy()has been removed; thelistenerinstance is now released automatically when the hostActivityorFragmentis destroyed- Remove
PaymentSessionData.paymentSessionData; this data will be returned viaPaymentSessionListener#onPaymentSessionDataChanged()
- When instantiating a
- Changes to
StripeSourceTypeModel- Rename to
SourceTypeModeland make a sealed class - Move
SourceCardDatasubclass toSourceTypeModel.Card - Move
SourceSepaDebitDatasubclass toSourceTypeModel.SepaDebit - Change type of
Source#sourceTypeModeltoSourceTypeModel?
- Rename to
- Changes to
Card.FundingType- Rename to
CardFundingand convert to anenum
- Rename to
- Changes to
StripeExceptionsubclassesInvalidRequestExceptionis nowfinal- Remove
InvalidRequestException'sparam,errorCode, anderrorDeclineCodeproperties; these can be accessed via thestripeErrorproperty// before invalidRequestException.param invalidRequestException.errorCode invalidRequestException.errorDeclineCode // after invalidRequestException.stripeError?.param invalidRequestException.stripeError?.code invalidRequestException.stripeError?.declineCode
RateLimitExceptionnow extendsStripeException
- Update 3DS2 styles
- Create
BaseStripe3DS2TextInputLayoutthat extendsWidget.MaterialComponents.TextInputLayout.OutlinedBox - Create
Stripe3DS2TextInputLayoutthat extendsBaseStripe3DS2TextInputLayout - Apply
Stripe3DS2TextInputLayouttoTextInputLayout - Create
BaseStripe3DS2EditTextwith parentWidget.MaterialComponents.TextInputEditText.OutlinedBox - Rename
Stripe3DS2EditTextThemetoStripe3DS2EditTextand change its parent toBaseStripe3DS2EditText - Apply
Stripe3DS2EditTexttoTextInputEditText
- Create
- Changes to
CardandSourceCardData- Change the type of
brandproperty fromString?toCardBrand - Remove
Card.CardBrand - Change the type of
tokenizationMethodproperty fromString?toTokenizationMethod?// before card.tokenizationMethod == "google_pay" // after card.tokenizationMethod == TokenizationMethod.GooglePay
- Change the type of
- Changes to
PaymentMethod- Change the type of
typeproperty fromString?toPaymentMethod.Type?// before paymentMethod.type == "card" // after paymentMethod.type == PaymentMethod.Type.Card
- Change the type of
- Changes to
SourceParamssetOwner()now takesOwnerParamsinstead ofMap// before sourceParams .setOwner(mapOf( "name" to "Jenny Rosen" )) // after sourceParams .setOwner(OwnerParams( name = "Jenny Rosen" ))
setRedirect()has been removed; usesetReturnUrl()instead// before sourceParams .setRedirect(mapOf("return_url" to "myapp://return")) // after sourceParams .setReturnUrl("myapp://return")
- Changes to
AccountParamsAccountParams.createAccountParams()is now deprecated; use the appropriateAccountParams.create()method.// before AccountParams.createAccountParams( true, AccountParams.BusinessType.Individual, mapOf( "address" to mapOf( "line1" to "123 Market St", "line2" to "#345", "city" to "San Francisco", "state" to "CA", "postal_code" to "94107", "country" to "US" ), "ssn_last_4" to "1234", "first_name" to "Jenny", "last_name" to "Rosen" ) ) // after AccountParams.create( true, AccountParams.BusinessTypeParams.Individual( address = Address( line1 = "123 Market St", line2 = "#345", city = "San Francisco", state = "CA", postal_code = "94107", country = "US" ), ssnLast4 = "1234", firstName = "Jenny", lastName = "Rosen" ) )
- Changes to
StripeEditTextStripeEditTextnow extendsTextInputEditTextinstead ofAppCompatEditText
- Changes to
CardInputWidget- The postal code field is now displayed by default
- The postal code input is not validated
StripeEditTextsubclasses (e.g.CardNumberEditText) used in this widget are now wrapped inTextInputLayout
- Changes to
CardMultilineWidget- The postal code field is now displayed by default
- The postal code field is now optional when displayed
- The postal code input is not validated
CardInputListener.onPostalCodeComplete()has been removed
- Changes to
Stripe- Bindings for API POST methods now take an optional
idempotencyKey. Read about Idempotent Requests for more details.// before stripe.createPaymentMethod( paymentMethodCreateParams, callback ) // after - without idempotency key stripe.createPaymentMethod( paymentMethodCreateParams, callback = callback ) // after - with idempotency key stripe.createPaymentMethod( paymentMethodCreateParams, idempotencyKey = idempotencyKey, callback = callback )
- Bindings for API POST methods now take an optional
- Changes to
PaymentMethodsActivityStarter.Result- The type of
paymentMethodhas been changed fromPaymentMethodtoPaymentMethod?(i.e. it is nullable)
- The type of
- Changes to
PaymentSession-
PaymentSessionnow takes thePaymentSessionConfiginstance through its constructor, instead ofinit()// before val paymentSession = PaymentSession(activity) paymentSession.init(listener, paymentSessionConfig) // after val paymentSession = PaymentSession(activity, paymentSessionConfig) paymentSession.init(listener)
-
By default, users will be asked for their postal code (i.e.
BillingAddressFields.PostalCode) when adding a new card payment method. -
PaymentSession#init()no longer takes ashouldPrefetchCustomerargument. If you need to specifyshouldPrefetchCustomer, usePaymentSessionConfig.Builder.setShouldPrefetchCustomer(). -
PaymentSession#presentPaymentMethodSelection(shouldRequirePostalCode, userSelectedPaymentMethodId)is deleted. If you need to specify billing details, usePaymentSessionConfig.Builder#setBillingAddressFields(). -
setShouldRequirePostalCode()has been removed fromAddPaymentMethodActivityStarter.ArgsandPaymentMethodsActivityStarter.Args. UsesetBillingAddressFields()instead. -
Shipping information validation and shipping methods creation logic when using
PaymentSessionhas been improved. Previously, this was accomplished by creating aBroadcastReceiverand registering it for a particularIntent. This has been greatly simplified by providingShippingInformationValidatorandShippingMethodsFactoryinterfaces that can be defined when creating thePaymentSessionConfig. See below for an example.-
Before, using
BroadcastReceiverclass PaymentSessionActivity : AppCompatActivity() { private lateinit var broadcastReceiver: BroadcastReceiver override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) val localBroadcastManager = LocalBroadcastManager.getInstance(this) broadcastReceiver = object : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { val shippingInformation = intent .getParcelableExtra<ShippingInformation>(EXTRA_SHIPPING_INFO_DATA) val shippingInfoProcessedIntent = Intent(EVENT_SHIPPING_INFO_PROCESSED) if (!isValidShippingInfo(shippingInformation)) { shippingInfoProcessedIntent.putExtra(EXTRA_IS_SHIPPING_INFO_VALID, false) } else { shippingInfoProcessedIntent .putExtra(EXTRA_IS_SHIPPING_INFO_VALID, true) .putParcelableArrayListExtra( EXTRA_VALID_SHIPPING_METHODS, SHIPPING_METHODS ) .putExtra( EXTRA_DEFAULT_SHIPPING_METHOD, SHIPPING_METHODS.last() ) } localBroadcastManager.sendBroadcast(shippingInfoProcessedIntent) } private fun isValidShippingInfo(shippingInfo: ShippingInformation?): Boolean { return shippingInfo?.address?.country == Locale.US.country } } localBroadcastManager.registerReceiver(broadcastReceiver, IntentFilter(EVENT_SHIPPING_INFO_SUBMITTED)) } override fun onDestroy() { LocalBroadcastManager.getInstance(this) .unregisterReceiver(broadcastReceiver) super.onDestroy() } private companion object { private val SHIPPING_METHODS = arrayListOf( ShippingMethod("UPS Ground", "ups-ground", 0, "USD", "Arrives in 3-5 days"), ShippingMethod("FedEx", "fedex", 599, "USD", "Arrives tomorrow") ) } }
-
After, using
ShippingInformationValidatorandShippingMethodsFactoryclass PaymentSessionActivity : AppCompatActivity() { private fun createPaymentSession(): PaymentSession { val customerSession = createCustomerSession() val paymentSession = PaymentSession(this) paymentSession.init( listener = createPaymentSessionListener(), paymentSessionConfig = createPaymentSessionConfig(), savedInstanceState = savedInstanceState ) return paymentSession } private fun createPaymentSessionConfig(): PaymentSessionConfig { PaymentSessionConfig.Builder() .setShippingInformationValidator(ShippingInformationValidator()) .setShippingMethodsFactory(ShippingMethodsFactory()) .build() } private class ShippingInformationValidator : PaymentSessionConfig.ShippingInformationValidator { override fun isValid( shippingInformation: ShippingInformation ): Boolean { return shippingInformation.address?.country == Locale.US.country } override fun getErrorMessage( shippingInformation: ShippingInformation ): String { return "The country must be US." } } private class ShippingMethodsFactory : PaymentSessionConfig.ShippingMethodsFactory { override fun create( shippingInformation: ShippingInformation ): List<ShippingMethod> { return listOf( ShippingMethod("UPS Ground", "ups-ground", 0, "USD", "Arrives in 3-5 days"), ShippingMethod("FedEx", "fedex", 599, "USD", "Arrives tomorrow") ) } } }
-
-
Related to the above,
PaymentFlowExtrasis deleted
-
-
Replace
Stripe#createTokenSynchronous(Card)withStripe#createCardTokenSynchronous(Card)// Java // before stripe.createTokenSynchronous(card); // after stripe.createCardTokenSynchronous(card);
// Kotlin // before stripe.createTokenSynchronous(card) // after stripe.createCardTokenSynchronous(card)
-
Replace
Card#getCVC()withCard#getCvc()// Java // before card.getCVC(); // after card.getCvc();
// Kotlin // before card.getCVC() // after card.cvc
-
Remove
AddPaymentMethodActivity#EXTRA_NEW_PAYMENT_METHOD, useAddPaymentMethodActivityStarter.Result.fromIntent()instead// Java // before private PaymentMethod getPaymentMethodFromIntent(@NonNull Intent intent) { return intent.getParcelableExtra<PaymentMethod>(AddPaymentMethodActivity.EXTRA_NEW_PAYMENT_METHOD); } // after private PaymentMethod getPaymentMethodFromIntent(@NonNull Intent intent) { final AddPaymentMethodActivityStarter.Result result = AddPaymentMethodActivityStarter.Result.fromIntent(intent) return result != null ? result.paymentMethod : null; }
// Kotlin // before private fun getPaymentMethodFromIntent(intent: Intent): PaymentMethod? { return intent.getParcelableExtra(AddPaymentMethodActivity.EXTRA_NEW_PAYMENT_METHOD) } // after private fun getPaymentMethodFromIntent(intent: Intent): PaymentMethod? { val result: AddPaymentMethodActivityStarter.Result? = AddPaymentMethodActivityStarter.Result.fromIntent(intent) return result?.paymentMethod }
-
Create overloaded
ShippingMethodconstructor with optionaldetailargument// Java // before ShippingMethod("FedEx", "fedex", null, 599, "USD"); ShippingMethod("FedEx", "fedex", "Arrives tomorrow", 599, "USD"); // after ShippingMethod("FedEx", "fedex", 599, "USD"); ShippingMethod("FedEx", "fedex", 599, "USD", "Arrives tomorrow");
// Kotlin // before ShippingMethod("FedEx", "fedex", null, 599, "USD") ShippingMethod("FedEx", "fedex", "Arrives tomorrow", 599, "USD") // after ShippingMethod("FedEx", "fedex", 599, "USD") ShippingMethod("FedEx", "fedex", 599, "USD", "Arrives tomorrow")
-
Payment Intent requests (i.e. requests to
/v1/payment_intents) now return localized error messages// Java // before @Test public void testErrorMessage() { Locale.setDefault(Locale.GERMANY); final Stripe stripe = createStripe(); final InvalidRequestException exception = assertThrows( InvalidRequestException.class, new ThrowingRunnable() { @Override public void run() throws Throwable { stripe.retrievePaymentIntentSynchronous("invalid"); } }); // Locale is Germany, error message is in English assertEquals( "No such payment_intent: invalid", exception.getStripeError().getMessage() ); } // after @Test public void testErrorMessage() { Locale.setDefault(Locale.GERMANY); final Stripe stripe = createStripe(); final InvalidRequestException exception = assertThrows( InvalidRequestException.class, new ThrowingRunnable() { @Override public void run() throws Throwable { stripe.retrievePaymentIntentSynchronous("invalid"); } }); // Locale is Germany, error message is in Germany assertEquals( "Keine solche payment_intent: invalid", exception.getStripeError().getMessage() ); }
- AndroidX is required. Please read the Migrating to AndroidX guide for more information. See #1478.
- The signatures of
PaymentConfiguration.init()andPaymentConfiguration.getInstance()have been changed. They now both take aContextinstance as the first argument. See #1479.// before PaymentConfiguration.init("publishable_key") PaymentConfiguration.getInstance() // after PaymentConfiguration.init(context, "publishable_key") PaymentConfiguration.getInstance(context)
- Remove
Stripemethods that accept a publishable key. Pass publishable key in theStripeconstructor.// Example // before val stripe = Stripe(context) stripe.createPaymentMethodSynchronous(params, "pk_test_demo123") // after val stripe = Stripe(context, "pk_test_demo123") stripe.createPaymentMethodSynchronous(params) Sourceis immutable. All setter methods have been removed. See #1480.TokenCallbackandSourceCallbackhave been removed. UseApiResultCallback<Token>andApiResultCallback<Source>instead. See #1481.StripeIntent#getStatus()has been removed. UseStripeIntent#getOutcome()instead.PaymentIntent#getSource()has been removed. UsePaymentIntent#getPaymentMethodId()instead.SetupIntent#getCustomerId()has been removed. This method was unintentionally added and always returnednull.- The
samplestoreapp has moved to stripe-samples/sample-store-android. - Remove
PaymentMethodsActivity.newIntent(). UsePaymentMethodsActivityStarter#startForResult()to startPaymentMethodsActivity. - Remove
PaymentMethodsActivity.EXTRA_SELECTED_PAYMENT. UsePaymentMethodsActivityStarter.Result#fromIntent(intent)to obtain the result ofPaymentMethodsActivity. - Remove
Stripe#createToken()withExecutorargument. Use Stripe#createCardToken() instead.
- You must call
PaymentConfiguration.init()before callingCustomerSession.initCustomerSession().PaymentConfiguration.init(PUBLISHABLE_KEY); CustomerSession.initCustomerSession(context, ephemeralKeyProvider);
-
The signature of
Stripe#retrievePaymentIntentSynchronous()has changed. It now takes a client_secretStringinstead of aPaymentIntentParamsinstance. See #1172.// before stripe.retrievePaymentIntentSynchronous( PaymentIntentParams.createRetrievePaymentIntentParams(clientSecret)); // after stripe.retrievePaymentIntentSynchronous(clientSecret);
-
PaymentIntentParamsis nowConfirmPaymentIntentParamsand its method names have been simplified. See #1172.// before PaymentIntentParams.createConfirmPaymentIntentWithPaymentMethodId( paymentMethodId, clientSecret, returnUrl); // after ConfirmPaymentIntentParams.createWithPaymentMethodId(paymentMethodId, clientSecret, returnUrl);
-
All
@StringDefconstants have been inlined in their respective@interface. Below is an example fromCard.FundingType. See #1173.// before @Retention(RetentionPolicy.SOURCE) @StringDef({ FUNDING_CREDIT, FUNDING_DEBIT, FUNDING_PREPAID, FUNDING_UNKNOWN }) public @interface FundingType { } public static final String FUNDING_CREDIT = "credit"; public static final String FUNDING_DEBIT = "debit"; public static final String FUNDING_PREPAID = "prepaid"; public static final String FUNDING_UNKNOWN = "unknown"; // after @Retention(RetentionPolicy.SOURCE) @StringDef({ FundingType.CREDIT, FundingType.DEBIT, FundingType.PREPAID, FundingType.UNKNOWN }) public @interface FundingType { String CREDIT = "credit"; String DEBIT = "debit"; String PREPAID = "prepaid"; String UNKNOWN = "unknown"; }
- The enum
PaymentIntent.Statusis nowStripeIntent.Status - The enum
PaymentIntent.NextActionTypeis nowStripeIntent.NextActionType
These changes should not impact Java integrations. For Kotlin integrations, please change your reference as shown in the example below.
// before
PaymentIntent.Status.Succeeded
// after
StripeIntent.Status.Succeeded-
CustomerSession's Listener interfaces'sonError()method now have a@NonNullerrorMessageargument// before new CustomerSession.CustomerRetrievalListener() { @Override public void onError(int errorCode, @Nullable String errorMessage, @Nullable StripeError stripeError) { } } // after new CustomerSession.CustomerRetrievalListener() { @Override public void onError(int errorCode, @NonNull String errorMessage, @Nullable StripeError stripeError) { } }
-
PaymentResultListenerhas been removed -
PaymentSession#completePayment()has been replaced withPaymentSession#onCompleted()// before private void chargePaymentMethod() { mPaymentSession.completePayment(new PaymentCompletionProvider() { @Override public void completePayment(@NonNull PaymentSessionData data, @NonNull PaymentResultListener listener) { // Make async request to your backend to charge the payment method. // Upon success, call: listener.onPaymentResult(PaymentResultListener.SUCCESS); } }); } // after private void chargePaymentMethod() { // Make async request to your backend to charge the payment method. // Upon success, call: mPaymentSession.onCompleted(); }
Cardmodel is now immutableCard#getType()is nowCard#getBrand()
- Standard UI components now use
PaymentMethodinstead ofSource- Setting a customer's default payment method is not available for PaymentMethod objects
CustomerSession#getPaymentMethods()andCustomerSession#attachPaymentMethod()have been addedPaymentSessionData#getSelectedPaymentMethodId()is nowPaymentSessionData#getPaymentMethod()and returns aPaymentMethod. See usage in the samplestore app's PaymentActivity.java.
- Remove the following unused methods from
PaymentConfigurationgetRequiredBillingAddressFields()setRequiredBillingAddressFields()getShouldUseSourcesForCards()setShouldUseSourcesForCards()
-
minSdkVersionis now 19 -
AccountParams.createAccountParams()requires aAccountParams#BusinessTypeparameter// before AccountParams.createAccountParams( true, createBusinessData() ); // after, AccountParams.BusinessType is required // for Individual entities AccountParams.createAccountParams( true, BusinessType.Individual, createBusinessData() ); // for Company entities AccountParams.createAccountParams( true, BusinessType.Company, createBusinessData() );
-
CustomerSession.initCustomerSession()now has aContextparameter. Related,CustomerSessionpublic instance methods no longer have aContextparameter.// before CustomerSession.initCustomerSession(ephemeralKeyProvider); CustomerSession.getInstance().setCustomerShippingInformation(this, listener); // after CustomerSession.initCustomerSession(this, ephemeralKeyProvider); CustomerSession.getInstance().setCustomerShippingInformation(listener);
-
PaymentIntenthas been updated to reflect API version 2019-02-11PaymentIntent.Status.RequiresSourceis nowPaymentIntent.Status.RequiresPaymentMethodPaymentIntent.Status.RequiresSourceActionis nowPaymentIntent.Status.RequiresActionPaymentIntent.NextActionType.AuthorizeWithUrlhas been removedPaymentIntent#getNextSourceAction()is nowPaymentIntent#getNextAction()PaymentIntent#getAuthorizationUrl()is nowPaymentIntent#getRedirectUrl()PaymentIntent#requiresAction()has been added as a conveniencePaymentIntent#getStatus()now returns aPaymentIntent.Statusenum value instead of aString
-
Addressis now immutable and its setters have been removed. UseAddress.Builderto create a newAddressobject.
- Remove Bitcoin source support because Stripe no longer processes Bitcoin payments
- Sources can no longer have a "BITCOIN" source type. These sources will now be interpreted as "UNKNOWN".
- You can no longer
createBitcoinParams. Please use a different payment method.
StripeApiHandlermethods can no longer be called directly.PaymentConfigurationnow stores your public key and is depended upon forCustomerSession.- Many Utils classes have been migrated to package-private access.
- Instantiation of a Stripe object can no longer throw an
AuthenticationException.- Any time you were instantiating a Stripe object in a try/catch block will be simplified.
now becomesStripe stripe; try { stripe = new Stripe(mContext, MY_PUBLISHABLE_KEY); } catch (AuthenticationException authEx) { // This never happens because you check your key. }
Stripe stripe = new Stripe(mContext, MY_PUBLISHABLE_KEY);
Stripe#setDefaultPublishableKey(String key)has similarly been changed, and no longer needs to be wrapped.- Both methods can still throw an
IllegalArgumentExceptionif an invalid key is used, but as a runtime exception, that does not need to be wrapped. AuthenticationExceptionwill now only be thrown if you attempt to create aTokenorSourcewith an invalid key.