Skip to content

Commit 82dee14

Browse files
committed
Merge branch 'master' into DEVSDK-3012
2 parents 4b075e2 + 409eb1e commit 82dee14

17 files changed

Lines changed: 336 additions & 29 deletions

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 31.4.1 - 2026-03-06
4+
* [#2168](https://github.com/stripe/stripe-java/pull/2168) Support serializing Stripe objects with ApiResource.GSON
5+
* `ApiResource.GSON` now supports serializing Stripe objects back into compatible JSON
6+
* [#2165](https://github.com/stripe/stripe-java/pull/2165) Add AI Agent information to UserAgent
7+
38
## 31.4.0 - 2026-02-25
49
This release changes the pinned API version to `2026-02-25.clover`.
510

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
# Stripe Java client library
22

3-
[![Maven Central](https://img.shields.io/badge/maven--central-v31.4.0-blue)](https://mvnrepository.com/artifact/com.stripe/stripe-java)
3+
[![Maven Central](https://img.shields.io/badge/maven--central-v31.4.1-blue)](https://mvnrepository.com/artifact/com.stripe/stripe-java)
44
[![JavaDoc](http://img.shields.io/badge/javadoc-reference-blue.svg)](https://stripe.dev/stripe-java)
55
[![Build Status](https://github.com/stripe/stripe-java/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/stripe/stripe-java/actions?query=branch%3Amaster)
66

7+
> [!TIP]
8+
> Want to chat live with Stripe engineers? Join us on our [Discord server](https://stripe.com/go/discord/java).
9+
710
The official [Stripe][stripe] Java client library.
811

912
## Installation
@@ -23,7 +26,7 @@ We support LTS versions of the JDK. Currently, that's Java versions:
2326
Add this dependency to your project's build file:
2427

2528
```groovy
26-
implementation "com.stripe:stripe-java:31.4.0"
29+
implementation "com.stripe:stripe-java:31.4.1"
2730
```
2831

2932
### Maven users
@@ -34,7 +37,7 @@ Add this dependency to your project's POM:
3437
<dependency>
3538
<groupId>com.stripe</groupId>
3639
<artifactId>stripe-java</artifactId>
37-
<version>31.4.0</version>
40+
<version>31.4.1</version>
3841
</dependency>
3942
```
4043

@@ -43,8 +46,8 @@ Add this dependency to your project's POM:
4346
If you are not using Gradle or Maven, you will need to manually install the following JARs:
4447

4548
1. The Stripe JAR:
46-
- Download the latest release version from [Maven Central](https://repo1.maven.org/maven2/com/stripe/stripe-java/31.4.0/stripe-java-31.4.0.jar)
47-
- Current release version: 31.4.0
49+
- Download the latest release version from [Maven Central](https://repo1.maven.org/maven2/com/stripe/stripe-java/31.4.1/stripe-java-31.4.1.jar)
50+
- Current release version: 31.4.1
4851

4952
2. Google Gson:
5053
- The Stripe JAR builds and tests with Gson version 2.10.1

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
31.4.0
1+
31.4.1

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ jar {
100100
"Implementation-Vendor": VENDOR_NAME,
101101
"Bundle-SymbolicName": POM_ARTIFACT_ID,
102102
"Export-Package": "com.stripe.*",
103-
"Automatic-Module-Name": "stripe.java")
103+
"Automatic-Module-Name": "com.stripe")
104104

105105
archiveVersion = VERSION_NAME
106106
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
GROUP=com.stripe
2-
VERSION_NAME=31.4.0
2+
VERSION_NAME=31.4.1
33

44
POM_URL=https://github.com/stripe/stripe-java
55
POM_SCM_URL=git@github.com:stripe/stripe-java.git

src/main/java/com/stripe/Stripe.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public abstract class Stripe {
1414
public static final String LIVE_API_BASE = "https://api.stripe.com";
1515
public static final String UPLOAD_API_BASE = "https://files.stripe.com";
1616
public static final String METER_EVENTS_API_BASE = "https://meter-events.stripe.com";
17-
public static final String VERSION = "31.4.0";
17+
public static final String VERSION = "31.4.1";
1818

1919
public static volatile String apiKey;
2020
public static volatile String clientId;

src/main/java/com/stripe/model/BalanceTransactionSourceTypeAdapterFactory.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
2525
}
2626
final String discriminator = "object";
2727
final TypeAdapter<JsonElement> jsonElementAdapter = gson.getAdapter(JsonElement.class);
28-
final TypeAdapter<com.stripe.model.BalanceTransactionSource> balanceTransactionSourceAdapter =
29-
gson.getDelegateAdapter(
30-
this, TypeToken.get(com.stripe.model.BalanceTransactionSource.class));
3128
final TypeAdapter<com.stripe.model.ApplicationFee> applicationFeeAdapter =
3229
gson.getDelegateAdapter(this, TypeToken.get(com.stripe.model.ApplicationFee.class));
3330
final TypeAdapter<com.stripe.model.Charge> chargeAdapter =
@@ -68,7 +65,13 @@ public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
6865
new TypeAdapter<BalanceTransactionSource>() {
6966
@Override
7067
public void write(JsonWriter out, BalanceTransactionSource value) throws IOException {
71-
balanceTransactionSourceAdapter.write(out, value);
68+
@SuppressWarnings("unchecked")
69+
TypeAdapter<BalanceTransactionSource> adapter =
70+
(TypeAdapter<BalanceTransactionSource>)
71+
gson.getDelegateAdapter(
72+
BalanceTransactionSourceTypeAdapterFactory.this,
73+
TypeToken.get(value.getClass()));
74+
adapter.write(out, value);
7275
}
7376

7477
@Override

src/main/java/com/stripe/model/ExternalAccountTypeAdapterFactory.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
2828
}
2929
final String discriminator = "object";
3030
final TypeAdapter<JsonElement> jsonElementAdapter = gson.getAdapter(JsonElement.class);
31-
final TypeAdapter<com.stripe.model.ExternalAccount> externalAccountAdapter =
32-
gson.getDelegateAdapter(this, TypeToken.get(com.stripe.model.ExternalAccount.class));
3331
final TypeAdapter<com.stripe.model.BankAccount> bankAccountAdapter =
3432
gson.getDelegateAdapter(this, TypeToken.get(com.stripe.model.BankAccount.class));
3533
final TypeAdapter<com.stripe.model.Card> cardAdapter =
@@ -39,7 +37,12 @@ public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
3937
new TypeAdapter<ExternalAccount>() {
4038
@Override
4139
public void write(JsonWriter out, ExternalAccount value) throws IOException {
42-
externalAccountAdapter.write(out, value);
40+
@SuppressWarnings("unchecked")
41+
TypeAdapter<ExternalAccount> adapter =
42+
(TypeAdapter<ExternalAccount>)
43+
gson.getDelegateAdapter(
44+
ExternalAccountTypeAdapterFactory.this, TypeToken.get(value.getClass()));
45+
adapter.write(out, value);
4346
}
4447

4548
@Override

src/main/java/com/stripe/model/PaymentSourceTypeAdapterFactory.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
2525
}
2626
final String discriminator = "object";
2727
final TypeAdapter<JsonElement> jsonElementAdapter = gson.getAdapter(JsonElement.class);
28-
final TypeAdapter<com.stripe.model.PaymentSource> paymentSourceAdapter =
29-
gson.getDelegateAdapter(this, TypeToken.get(com.stripe.model.PaymentSource.class));
3028
final TypeAdapter<com.stripe.model.Account> accountAdapter =
3129
gson.getDelegateAdapter(this, TypeToken.get(com.stripe.model.Account.class));
3230
final TypeAdapter<com.stripe.model.BankAccount> bankAccountAdapter =
@@ -40,7 +38,12 @@ public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
4038
new TypeAdapter<PaymentSource>() {
4139
@Override
4240
public void write(JsonWriter out, PaymentSource value) throws IOException {
43-
paymentSourceAdapter.write(out, value);
41+
@SuppressWarnings("unchecked")
42+
TypeAdapter<PaymentSource> adapter =
43+
(TypeAdapter<PaymentSource>)
44+
gson.getDelegateAdapter(
45+
PaymentSourceTypeAdapterFactory.this, TypeToken.get(value.getClass()));
46+
adapter.write(out, value);
4447
}
4548

4649
@Override
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.stripe.model;
2+
3+
import com.google.gson.TypeAdapter;
4+
import com.google.gson.stream.JsonReader;
5+
import com.google.gson.stream.JsonToken;
6+
import com.google.gson.stream.JsonWriter;
7+
import java.io.IOException;
8+
9+
public class StringInt64TypeAdapter extends TypeAdapter<Long> {
10+
/** Serializes Long values as JSON strings and deserializes string-encoded integers. */
11+
@Override
12+
public void write(JsonWriter out, Long value) throws IOException {
13+
if (value == null) {
14+
out.nullValue();
15+
return;
16+
}
17+
18+
out.value(value.toString());
19+
}
20+
21+
@Override
22+
public Long read(JsonReader in) throws IOException {
23+
JsonToken token = in.peek();
24+
if (token == JsonToken.NULL) {
25+
in.nextNull();
26+
return null;
27+
}
28+
29+
return Long.valueOf(in.nextString());
30+
}
31+
}

0 commit comments

Comments
 (0)