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

Merge master #1633

Merged
merged 8 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
54 changes: 54 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,59 @@
# Changelog

## 23.0.0 - 2023-08-16
* This release changes the pinned API version to `2023-08-16`. Please read the [API Upgrade Guide](https://stripe.com/docs/upgrades#2023-08-16) and carefully review the API changes before upgrading `stripe-java`.
* More information is available in the [stripe-java v23 migration guide](https://github.com/stripe/stripe-java/wiki/Migration-guide-for-v23)

"⚠️" symbol highlights breaking changes.

* [#1632](https://github.com/stripe/stripe-java/pull/1632) Update generated code
* ⚠️Remove support for values `custom_account_update` and `custom_account_verification` from enum `AccountLinkCreateParams.type`
* These values are not fully operational
* ⚠️Remove support for `available_on` on `BalanceTransactionListParams`
* Use of this parameter is discouraged. You may use [`.putExtraParam`](https://github.com/stripe/stripe-java/#parameters) if sending the parameter is still required.
* ⚠️Remove support for `alternate_statement_descriptors`, `destination`, and `dispute` on `Charge`
* Use of these fields is discouraged.
* Remove support for `shipping_rates` on `checkout.SessionCreateParams`
* ⚠️Remove support for `shipping_rates` on `checkout.SessionCreateParams`
* Please use `shipping_options` instead.
* ⚠️Remove support for `coupon` and `trial_from_plan` on `checkout.SessionCreateParams.subscription_data`
* Please [migrate to the Prices API](https://stripe.com/docs/billing/migration/migrating-prices), or use [`.putExtraParam`](https://github.com/stripe/stripe-java/#parameters) if sending the parameter is still required.
* ⚠️Remove support for value `card_present` from enums `CustomerListPaymentMethodsParams.type` and `PaymentMethodListParams.type`
* This value was not fully operational.
* ⚠️Remove support for `blik` on `Mandate.payment_method_details`, `PaymentMethodUpdateParams`, `SetupAttempt.payment_method_details`, `SetupIntent.payment_method_options`, `SetupIntentConfirmParams.payment_method_options`, `SetupIntentCreateParams.payment_method_options`, and `SetupIntentUpdateParams.payment_method_options`
* These fields were mistakenly released.
* ⚠️Remove support for `acss_debit`, `affirm`, `au_becs_debit`, `bacs_debit`, `cashapp`, `sepa_debit`, and `zip` on `PaymentMethodUpdateParams`
* These fields are empty.
* ⚠️Remove support for `country` on `PaymentMethod.link`
* This field was not fully operational.
* ⚠️Remove support for `recurring` on `PriceUpdateParams`
* This property should be set on create only.
* ⚠️Remove support for `attributes`, `caption`, and `deactivate_on` on `ProductCreateParams`, `ProductUpdateParams`, and `Product`
* These fields are not fully operational.
* Add support for new value `2023-08-16` on enum `WebhookEndpointCreateParams.api_version`
* [#1622](https://github.com/stripe/stripe-java/pull/1622) - StripeClient
* 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 an `update`.
* No static methods. Much easier mocking.
* Visit the [migration guide](https://github.com/stripe/stripe-java/wiki/Migration-guide-for-v23) to learn more.
* **Removals**
* ⚠️ `ApiResource.request()`, `requestStream()`, `requestCollection()`, `requestSearchResult()` methods removed.
* ⚠️ `StripeResponseGetter.oauthRequest(...)` was removed. OAuth requests are now performed via `StripeResponseGetter.request` with `ApiMode.OAuth`.
* ⚠️ Deprecated `ApiResource.className()` `singleClassUrl()`, `classUrl()`, `instanceUrl()`, `subresourceUrl()` methods removed.
* **Type changes**
* ⚠️ `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.
* ⚠️ `RequestOptions.getReadTimeout()`, `getConnectTimeout()`, `getMaxNetworkRetries()` now return `Integer` instead of `int`.
* **Renames**
* ⚠️ `addFullNameAliase` renamed to `addFullNameAlias` in `AccountCreateParams`, `AccountUpdateParams`, `PersonCollectionCreateParams`, `TokenCreateParams`, `PersonCollectionCreateParams`, `PersonUpdateParams`.
* ⚠️ `addLookupKeys` renamed to `addLookupKey` in `PriceListParams`
* **Behavior Changes**
* ⚠️ `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`.

## 22.32.0-beta.1 - 2023-08-10
* [#1624](https://github.com/stripe/stripe-java/pull/1624) Update generated code for beta
* Add support for `paypal` on `PaymentMethodConfigurationCreateParams`, `PaymentMethodConfigurationUpdateParams`, and `PaymentMethodConfiguration`
Expand Down
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v458
v446
29 changes: 16 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ StripeExample.java
import java.util.HashMap;
import java.util.Map;

import com.stripe.Stripe;
import com.stripe.StripeClient;
import com.stripe.exception.StripeException;
import com.stripe.model.Customer;
import com.stripe.net.RequestOptions;
Expand All @@ -76,8 +76,7 @@ import com.stripe.param.CustomerCreateParams;
public class StripeExample {

public static void main(String[] args) {
Stripe.apiKey = "sk_test_...";

StripeClient client = new StripeClient("sk_test_...");
CustomerCreateParams params =
CustomerCreateParams
.builder()
Expand All @@ -87,7 +86,7 @@ public class StripeExample {
.build();

try {
Customer customer = Customer.create(params);
Customer customer = client.customers().create(params);
System.out.println(customer);
} catch (StripeException e) {
e.printStackTrace();
Expand All @@ -112,9 +111,9 @@ RequestOptions requestOptions = RequestOptions.builder()
.setStripeAccount("acct_...")
.build();

Customer.list(null, requestOptions);
client.customers().list(requestOptions);

Customer.retrieve("cus_123456789", requestOptions);
client.customers().retrieve("cus_123456789", requestOptions);
```

### Configuring automatic retries
Expand All @@ -124,7 +123,9 @@ an intermittent network problem or other knowingly non-deterministic errors.
This can be enabled globally:

```java
Stripe.setMaxNetworkRetries(2);
StripeClient client = StripeClient.builder()
.setMaxNetworkRetries(2)
.build();
```

Or on a finer grain level using `RequestOptions`:
Expand All @@ -133,7 +134,7 @@ Or on a finer grain level using `RequestOptions`:
RequestOptions options = RequestOptions.builder()
.setMaxNetworkRetries(2)
.build();
Customer.create(params, options);
client.customers().create(params, options);
```

[Idempotency keys][idempotency-keys] are added to requests to guarantee that
Expand All @@ -144,8 +145,10 @@ retries are safe.
Connect and read timeouts can be configured globally:

```java
Stripe.setConnectTimeout(30 * 1000); // in milliseconds
Stripe.setReadTimeout(80 * 1000);
StripeClient client = StripeClient.builder()
.setConnectTimeout(30 * 1000); // in milliseconds
.setReadTimeout(80 * 1000);
.build();
```

Or on a finer grain level using `RequestOptions`:
Expand All @@ -155,7 +158,7 @@ RequestOptions options = RequestOptions.builder()
.setConnectTimeout(30 * 1000) // in milliseconds
.setReadTimeout(80 * 1000)
.build();
Customer.create(params, options);
client.customers().create(params, options);
```

Please take care to set conservative read timeouts. Some API requests can take
Expand Down Expand Up @@ -191,15 +194,15 @@ CustomerCreateParams params =
.putExtraParam("secret_parameter[secondary]", "secondary value")
.build();

Customer customer = customer.Create(params);
client.customers().create(params);
```

#### Properties

To retrieve undocumented properties from Stripe using Java you can use an option in the library to return the raw JSON object and return the property as a native type. An example of this is shown below:

```java
final Customer customer = Customer.retrieve("cus_1234");
final Customer customer = client.customers().retrieve("cus_1234");
Boolean featureEnabled =
customer.getRawJsonObject()
.getAsJsonPrimitive("secret_feature_enabled")
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/stripe/ApiVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

final class ApiVersion {
public static final String CURRENT = "2022-11-15";
public static final String PREVIEW_CURRENT = "2023-07-13.preview-v2";
public static final String PREVIEW_CURRENT = "2023-08-11.preview-v2";
}
4 changes: 1 addition & 3 deletions src/main/java/com/stripe/Stripe.java
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,7 @@ public static StripeResponse rawRequest(
throw new IllegalArgumentException(
"content is not allowed for non-POST requests. Please pass null and add request parameters to the query string of the URL.");
}
String url = ApiResource.fullUrl(Stripe.getApiBase(), options, relativeUrl);

return ApiResource.rawRequest(method, url, content, options);
return ApiResource.rawRequest(method, relativeUrl, content, options);
}

/** Deserializes StripeResponse returned by rawRequest into a similar class. */
Expand Down
Loading
Loading