Skip to content

Commit

Permalink
Support for APIs in the new API version 2024-09-30.acacia (#1880)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya-stripe authored Oct 1, 2024
1 parent fd2e2e3 commit 81feaf1
Show file tree
Hide file tree
Showing 143 changed files with 9,385 additions and 708 deletions.
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,9 @@
},
"java.configuration.updateBuildConfiguration": "automatic",
// LSP was ooming and it recommended this change
"java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx2G -Xms100m -Xlog:disable"
"java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx2G -Xms100m -Xlog:disable",
"java.test.config": {
"vmargs": [ "-Dstripe.disallowGlobalResponseGetterFallback=true"]

}
}
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1267
v1268
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,31 @@ If your beta feature requires a `Stripe-Version` header to be sent, set the `Str
Stripe.addBetaVersion("feature_beta", "v3");
```

### Custom requests

If you would like to send a request to an undocumented API (for example you are in a private beta), or if you prefer to bypass the method definitions in the library and specify your request details directly, you can use the `rawRequest` method on `StripeClient`.

```java
// Create a RawRequestOptions object, allowing you to set per-request
// configuration options like additional headers.
Map<String, String> stripeVersionHeader = new HashMap<>();
stripeVersionHeader.put("Stripe-Version", "2022-11-15; feature_beta=v3");
RawRequestOptions options =
RawRequestOptions.builder()
.setAdditionalHeaders(stripeVersionHeader)
.build();

// Make the request using the Stripe.rawRequest() method.
StripeClient client = new StripeClient("sk_test_...");
final StripeResponse response =
client.rawRequest(
ApiResource.RequestMethod.POST, "/v1/beta_endpoint", "param=123", options);

// (Optional) response.body() is a string. You can call
// Stripe.deserialize() to get a StripeObject.
StripeObject obj = client.deserialize(response.body());
```

## Support

New features and bug fixes are released on the latest major version of the Stripe Java client library. If you are on an older major version, we recommend that you upgrade to the latest in order to use the new features and bug fixes including those for security vulnerabilities. Older major versions of the package will continue to be available for use, but will not be receiving any updates.
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 @@ -2,5 +2,5 @@
package com.stripe;

final class ApiVersion {
public static final String CURRENT = "2024-06-20";
public static final String CURRENT = "2024-09-30.acacia";
}
19 changes: 16 additions & 3 deletions src/main/java/com/stripe/Stripe.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,27 @@ public abstract class Stripe {
public static final String CONNECT_API_BASE = "https://connect.stripe.com";
public static final String LIVE_API_BASE = "https://api.stripe.com";
public static final String UPLOAD_API_BASE = "https://files.stripe.com";
public static final String METER_EVENTS_API_BASE = "https://meter-events.stripe.com";
public static final String VERSION = "26.12.0";

public static volatile String apiKey;
public static volatile String clientId;
public static volatile boolean enableTelemetry = true;
public static volatile String partnerId;

// Note that URLConnection reserves the value of 0 to mean "infinite
// timeout", so we use -1 here to represent an unset value which should
// fall back to a default.
private static volatile int connectTimeout = -1;
private static volatile int readTimeout = -1;

private static volatile int maxNetworkRetries = 0;
private static volatile int maxNetworkRetries = 2;

private static volatile String apiBase = LIVE_API_BASE;
private static volatile String connectBase = CONNECT_API_BASE;
private static volatile String uploadBase = UPLOAD_API_BASE;
private static volatile String meterEventsBase = METER_EVENTS_API_BASE;
private static volatile Proxy connectionProxy = null;
private static volatile PasswordAuthentication proxyCredential = null;

private static volatile Map<String, String> appInfo = null;

/**
Expand Down Expand Up @@ -72,6 +72,18 @@ public static String getUploadBase() {
return uploadBase;
}

/**
* (FOR TESTING ONLY) If you'd like your events requests to hit your own (mocked) server, you can
* set this up here by overriding the base api URL.
*/
public static void overrideMeterEventsBase(final String overriddenMeterEventsBase) {
meterEventsBase = overriddenMeterEventsBase;
}

public static String getMeterEventsBase() {
return meterEventsBase;
}

/**
* Set proxy to tunnel all Stripe connections.
*
Expand All @@ -94,6 +106,7 @@ public static int getConnectTimeout() {
if (connectTimeout == -1) {
return DEFAULT_CONNECT_TIMEOUT;
}

return connectTimeout;
}

Expand Down
Loading

0 comments on commit 81feaf1

Please sign in to comment.