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

stripe-java v23 release #1622

Merged
merged 5 commits into from
Aug 16, 2023
Merged

stripe-java v23 release #1622

merged 5 commits into from
Aug 16, 2023

Conversation

richardm-stripe
Copy link
Contributor

@richardm-stripe richardm-stripe commented Aug 1, 2023

Changelog

StripeClient

StripeClient and the new service-based pattern is introduced. StripeClient has multiple benefits over existing resource-based patterns:

  1. Allows to have multiple clients with different connection options (different API keys).
  2. All operations can be performed in a single HTTP call.
    // Before: creating funding instructions takes two HTTP calls
    Customer customer = Customer.retrieve("cus_123"); // HTTP call 1
    customer.createFundingInstructions(..); // HTTP call 2
    
    // After: creating funding instructions is a single HTTP call
    StripeClient client = new StripeClient();
    client.customers().createFundingInstructions("cus_123", ...); // HTTP call 1
  3. StripeClient is easier to mock for testing as all methods are instance methods.

Migration

To migrate from resource-based to service-based pattern:

  1. Initialize a StripeClient instance.
    // Before
    Stripe.apiKey = "sk_test_123"
    
    // After
    StripeClient client = new StripeClient("sk_test_123");
  2. Convert static resource method calls to StripeClient calls:
    // Before
    Customer customer = Customer.retrieve("cus_123");
    
    // After
    client.customers().retrieve("cus_123");
  3. Convert instance resource method calls to StripeClient calls. Params 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");

Breaking changes

Breaking changes that arose during code generation of the library that we postponed for the next major version. For changes to the Stripe products, read more at https://stripe.com/docs/upgrades#2023-08-16.

"⚠️" symbol highlights breaking changes.

  • ⚠️ addFullNameAliase renamed to addFullNameAlias in AccountCreateParams, AccountUpdateParams, PersonCollectionCreateParams, TokenCreateParams, PersonCollectionCreateParams, PersonUpdateParams.

  • ⚠️ addLookupKeys renamed to addLookupKey in PriceListParams

  • ⚠️ RequestOptions.getReadTimeout(), getConnectTimeout(), getMaxNetworkRetries() now return Integer instead of int.

  • ⚠️ RequestOptions.getDefault() does not apply global configuration options from Stripe class, all fields are initialized to null.

  • ⚠️ RequestOptionsBuilder does not apply global configuration options from Stripe class, all fields are initialized to null.

  • ⚠️ StripeResponseGetter.oauthRequest(...) was removed. OAuth requests are now performed via StripeResponseGetter.request with ApiMode.OAuth.

  • ⚠️ StripeResponseGetter.request(...), streamRequest(...) signatures changed.

    • BaseAddress parameter added.
    • url renamed to path and is a relative to the base address
    • apiMode parameter added to control how request is sent and response is handled, V1 and OAuth are supported values.
  • ⚠️ Deprecated ApiResource.className() singleClassUrl(), classUrl(), instanceUrl(), subresourceUrl() methods removed.

  • ⚠️ ApiResource.request(), requestStream(), requestCollection(), requestSearchResult() methods removed.

@pakrym-stripe pakrym-stripe changed the title stripe-java v42 release stripe-java v23 release Aug 16, 2023
@pakrym-stripe pakrym-stripe merged commit cc8bed2 into master Aug 16, 2023
28 checks passed
@richardm-stripe richardm-stripe deleted the sdk-release/next-major branch August 16, 2023 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants