-
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
ShippingMethod
constructor with optionaldetail
argument// 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 aContext
instance as the first argument. See #1479.// before PaymentConfiguration.init("publishable_key") PaymentConfiguration.getInstance() // after PaymentConfiguration.init(context, "publishable_key") PaymentConfiguration.getInstance(context)
- Remove
Stripe
methods that accept a publishable key. Pass publishable key in theStripe
constructor.// Example // before val stripe = Stripe(context) stripe.createPaymentMethodSynchronous(params, "pk_test_demo123") // after val stripe = Stripe(context, "pk_test_demo123") stripe.createPaymentMethodSynchronous(params)
Source
is immutable. All setter methods have been removed. See #1480.TokenCallback
andSourceCallback
have 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
samplestore
app 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()
withExecutor
argument. Use Stripe#createToken(Card, ApiResultCallback) 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_secretString
instead of aPaymentIntentParams
instance. See #1172.// before stripe.retrievePaymentIntentSynchronous( PaymentIntentParams.createRetrievePaymentIntentParams(clientSecret)); // after stripe.retrievePaymentIntentSynchronous(clientSecret);
-
PaymentIntentParams
is nowConfirmPaymentIntentParams
and its method names have been simplified. See #1172.// before PaymentIntentParams.createConfirmPaymentIntentWithPaymentMethodId( paymentMethodId, clientSecret, returnUrl); // after ConfirmPaymentIntentParams.createWithPaymentMethodId(paymentMethodId, clientSecret, returnUrl);
-
All
@StringDef
constants 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.Status
is nowStripeIntent.Status
- The enum
PaymentIntent.NextActionType
is 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@NonNull
errorMessage
argument// 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) { } }
-
PaymentResultListener
has 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(); }
Card
model is now immutableCard#getType()
is nowCard#getBrand()
- Standard UI components now use
PaymentMethod
instead 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
PaymentConfiguration
getRequiredBillingAddressFields()
setRequiredBillingAddressFields()
getShouldUseSourcesForCards()
setShouldUseSourcesForCards()
-
minSdkVersion
is now 19 -
AccountParams.createAccountParams()
requires aAccountParams#BusinessType
parameter// 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 aContext
parameter. Related,CustomerSession
public instance methods no longer have aContext
parameter.// before CustomerSession.initCustomerSession(ephemeralKeyProvider); CustomerSession.getInstance().setCustomerShippingInformation(this, listener); // after CustomerSession.initCustomerSession(this, ephemeralKeyProvider); CustomerSession.getInstance().setCustomerShippingInformation(listener);
-
PaymentIntent
has been updated to reflect API version 2019-02-11PaymentIntent.Status.RequiresSource
is nowPaymentIntent.Status.RequiresPaymentMethod
PaymentIntent.Status.RequiresSourceAction
is nowPaymentIntent.Status.RequiresAction
PaymentIntent.NextActionType.AuthorizeWithUrl
has been removedPaymentIntent#getNextSourceAction()
is nowPaymentIntent#getNextAction()
PaymentIntent#getAuthorizationUrl()
is nowPaymentIntent#getRedirectUrl()
PaymentIntent#requiresAction()
has been added as a conveniencePaymentIntent#getStatus()
now returns aPaymentIntent.Status
enum value instead of aString
-
Address
is now immutable and its setters have been removed. UseAddress.Builder
to create a newAddress
object.
- 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.
StripeApiHandler
methods can no longer be called directly.PaymentConfiguration
now 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
IllegalArgumentException
if an invalid key is used, but as a runtime exception, that does not need to be wrapped. AuthenticationException
will now only be thrown if you attempt to create aToken
orSource
with an invalid key.