Skip to content

[Do not merge] Updated stripeclient snippets in Readme.md #2016

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public class StripeExample {
.build();

try {
Customer customer = client.customers().create(params);
Customer customer = client.v1().customers().create(params);
System.out.println(customer);
} catch (StripeException e) {
e.printStackTrace();
Expand All @@ -112,7 +112,7 @@ Once the legacy pattern is deprecated, new API endpoints will only be accessible

### Per-request Configuration

All of the request methods accept an optional `RequestOptions` object. This is
All the request methods accept an optional `RequestOptions` object. This is
used if you want to set an [idempotency key][idempotency-keys], if you are
using [Stripe Connect][connect-auth], or if you want to pass the secret API
key on each method.
Expand All @@ -124,9 +124,9 @@ RequestOptions requestOptions = RequestOptions.builder()
.setStripeAccount("acct_...")
.build();

client.customers().list(requestOptions);
client.v1().customers().list(requestOptions);

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

### Configuring automatic retries
Expand All @@ -147,7 +147,7 @@ Or on a finer grain level using `RequestOptions`:
RequestOptions options = RequestOptions.builder()
.setMaxNetworkRetries(2)
.build();
client.customers().create(params, options);
client.v1().customers().create(params, options);
```

[Idempotency keys][idempotency-keys] are added to requests to guarantee that
Expand All @@ -171,7 +171,7 @@ RequestOptions options = RequestOptions.builder()
.setConnectTimeout(30 * 1000) // in milliseconds
.setReadTimeout(80 * 1000)
.build();
client.customers().create(params, options);
client.v1().customers().create(params, options);
```

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

client.customers().create(params);
client.v1().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 = client.customers().retrieve("cus_1234");
final Customer customer = client.v1().customers().retrieve("cus_1234");
Boolean featureEnabled =
customer.getRawJsonObject()
.getAsJsonPrimitive("secret_feature_enabled")
Expand Down