-
Notifications
You must be signed in to change notification settings - Fork 367
Migration guide for v23
Ramya Rao edited this page Apr 8, 2025
·
11 revisions
- This release changes the pinned API version to
2023-08-16
. Please read the API Upgrade Guide and carefully review the API changes before upgradingstripe-java
.
"
Introduces StripeClient
and the service-based pattern, a new interface for calling the Stripe API with many benefits over the existing resource-based paradigm:
- No global config: you can simultaneously use multiple clients with different configuration options (such as API keys)
- No extra API calls. All API endpoints can be accessed with a single method call. You don't have to call
retrieve
before doing anupdate
. - No static methods. Much easier mocking.
While there are no plans yet to completely remove the previous resource-based call pattern, it will be deprecated soon and new API endpoints will be supported only in the new pattern. We strongly recommend migrating to the new service-based pattern as you begin to use new APIs. This will help you avoid mixing the two patterns in your integration, which can lead to confusion as you maintain your code.
To migrate from resource-based to service-based pattern:
- Initialize a
StripeClient
instance.// Before Stripe.apiKey = "sk_test_123" // After StripeClient client = new StripeClient("sk_test_123");
- Convert static resource method calls to
StripeClient
calls:// Before Customer customer = Customer.retrieve("cus_123"); // After client.customers().retrieve("cus_123");
- Convert instance resource method calls to
StripeClient
calls.XxxParams
classes will, in most cases, stay the same as you used for resource-based calls.// Before Customer customer = Customer.retrive("cus_123"); customer.delete(); // After client.customers().delete("cus_123"); // After client.customers().delete(customer.id); PaymentMethod pm = client.customers().retrievePaymentMethod(customer.id, "pm_123");
- Convert
XxxCollection
method calls to toStripeClient
calls. In these casesXxxParams
classes will change fromXxxCollectionParams
toXxxPrams
. Note:StripeClient
always returnsStripeCollection<Xxx>
instead ofXxxCollection
and all methods that were available onXxxCollection
are accessible thoughtStripeClient
.// Before Account resource = Account.retrieve("acct_xxxxxxxxxxxxx"); CapabilityCollection capabilities = resource.capabilities(); CapabilityCollectionRetrieveParams params = CapabilityCollectionRetrieveParams.builder() .addExpand("account") .build(); capabilities.retrieve("cap_123", params, null); // After CapabilityRetrieveParams params = CapabilityRetrieveParams.builder() .addExpand("account") .build(); client.accounts().capabilities().retrieve("acct_xxxxxxxxxxxxx", "cap_123", params);
- Convert nested resource operations to
StripeClient
calls:// Before Customer resource = Customer.retrieve("cus_xxxxxxxxxxxxx"); CustomerBalanceTransactionCollection collection = resource.balanceTransactions(); // After StripeCollection<CustomerBalanceTransaction> customer = client. customers().balanceTransactions().list("cus_xxxxxxxxxxxxx");
⚠️ StripeResponseGetter.request(...)
,streamRequest(...)
signatures changed.-
BaseAddress
parameter added. -
url
renamed topath
and is a relative to the base address -
apiMode
parameter added to control how request is sent and response is handled,V1
andOAuth
are supported values.
-
⚠️ RequestOptions.getReadTimeout()
,getConnectTimeout()
,getMaxNetworkRetries()
now returnInteger
instead ofint
.
⚠️ Remove support for valuescustom_account_update
andcustom_account_verification
from enumAccountLinkCreateParams.type
- These values are not fully operational. Please use
account_update
andaccount_onboarding
instead (see API reference).
- These values are not fully operational. Please use
⚠️ Remove support foravailable_on
onBalanceTransactionListParams
- Use of this parameter is discouraged. You may use
.putExtraParam
if sending the parameter is still required.
- Use of this parameter is discouraged. You may use
⚠️ Remove support foralternate_statement_descriptors
,destination
, anddispute
onCharge
- Use of these fields is discouraged.
⚠️ Remove support forshipping_rates
oncheckout.SessionCreateParams
⚠️ Remove support forshipping_rates
oncheckout.SessionCreateParams
- Please use
shipping_options
instead.
- Please use
⚠️ Remove support forcoupon
andtrial_from_plan
oncheckout.SessionCreateParams.subscription_data
- Please migrate to the Prices API, or use
.putExtraParam
if sending the parameter is still required.
- Please migrate to the Prices API, or use
⚠️ Remove support for valuecard_present
from enumsCustomerListPaymentMethodsParams.type
andPaymentMethodListParams.type
- This value was not fully operational.
⚠️ Remove support forblik
onMandate.payment_method_details
,PaymentMethodUpdateParams
,SetupAttempt.payment_method_details
,SetupIntent.payment_method_options
,SetupIntentConfirmParams.payment_method_options
,SetupIntentCreateParams.payment_method_options
, andSetupIntentUpdateParams.payment_method_options
- These fields were mistakenly released.
⚠️ Remove support foracss_debit
,affirm
,au_becs_debit
,bacs_debit
,cashapp
,sepa_debit
, andzip
onPaymentMethodUpdateParams
- These fields are empty.
⚠️ Remove support forcountry
onPaymentMethod.link
- This field was not fully operational.
⚠️ Remove support forrecurring
onPriceUpdateParams
- This property should be set on create only.
⚠️ Remove support forattributes
,caption
, anddeactivate_on
onProductCreateParams
,ProductUpdateParams
, andProduct
- These fields are not fully operational.
⚠️ addFullNameAliase
renamed toaddFullNameAlias
inAccountCreateParams
,AccountUpdateParams
,PersonCollectionCreateParams
,TokenCreateParams
,PersonCollectionCreateParams
,PersonUpdateParams
.⚠️ addLookupKeys
renamed toaddLookupKey
inPriceListParams
-
Behavior Changes
⚠️ RequestOptions.getDefault()
does not apply global configuration options fromStripe
class, all fields are initialized tonull
.⚠️ RequestOptionsBuilder
does not apply global configuration options fromStripe
class, all fields are initialized tonull
.
⚠️ ApiResource.request()
,requestStream()
,requestCollection()
,requestSearchResult()
methods removed. *⚠️ StripeResponseGetter.oauthRequest(...)
was removed. OAuth requests are now performed viaStripeResponseGetter.request
withApiMode.OAuth
. *⚠️ DeprecatedApiResource.className()
singleClassUrl()
,classUrl()
,instanceUrl()
,subresourceUrl()
methods removed.