Skip to content
Draft
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## Next Release

- Sends card details in the request body instead of the URL query string when `referralCustomer.addCreditCardToUser` creates a Stripe token

## v8.8.0 (2026-06-25)

- Adds `params` to `requestPin` ensuring users can pass `easypost_details` to the call
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
Expand Down Expand Up @@ -163,7 +164,7 @@
throw new ExternalApiError(String.format(Constants.ErrorMessages.EXTERNAL_API_CALL_FAILED, "Stripe"));
}

return createEasypostCreditCard(referralApiKey, stripeToken, priority.toString().toLowerCase());

Check warning on line 167 in src/main/java/com/easypost/service/ReferralCustomerService.java

View workflow job for this annotation

GitHub Actions / coverage

[StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)

Check warning on line 167 in src/main/java/com/easypost/service/ReferralCustomerService.java

View workflow job for this annotation

GitHub Actions / build (19)

[StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)

Check warning on line 167 in src/main/java/com/easypost/service/ReferralCustomerService.java

View workflow job for this annotation

GitHub Actions / build (22)

[StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)

Check warning on line 167 in src/main/java/com/easypost/service/ReferralCustomerService.java

View workflow job for this annotation

GitHub Actions / build (10)

[StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)

Check warning on line 167 in src/main/java/com/easypost/service/ReferralCustomerService.java

View workflow job for this annotation

GitHub Actions / build (23)

[StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)

Check warning on line 167 in src/main/java/com/easypost/service/ReferralCustomerService.java

View workflow job for this annotation

GitHub Actions / build (25)

[StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)

Check warning on line 167 in src/main/java/com/easypost/service/ReferralCustomerService.java

View workflow job for this annotation

GitHub Actions / build (24)

[StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)

Check warning on line 167 in src/main/java/com/easypost/service/ReferralCustomerService.java

View workflow job for this annotation

GitHub Actions / build (20)

[StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)

Check warning on line 167 in src/main/java/com/easypost/service/ReferralCustomerService.java

View workflow job for this annotation

GitHub Actions / build (21)

[StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)

Check warning on line 167 in src/main/java/com/easypost/service/ReferralCustomerService.java

View workflow job for this annotation

GitHub Actions / build (8)

[StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)

Check warning on line 167 in src/main/java/com/easypost/service/ReferralCustomerService.java

View workflow job for this annotation

GitHub Actions / build (12)

[StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)

Check warning on line 167 in src/main/java/com/easypost/service/ReferralCustomerService.java

View workflow job for this annotation

GitHub Actions / build (15)

[StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)

Check warning on line 167 in src/main/java/com/easypost/service/ReferralCustomerService.java

View workflow job for this annotation

GitHub Actions / build (9)

[StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)

Check warning on line 167 in src/main/java/com/easypost/service/ReferralCustomerService.java

View workflow job for this annotation

GitHub Actions / build (18)

[StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)

Check warning on line 167 in src/main/java/com/easypost/service/ReferralCustomerService.java

View workflow job for this annotation

GitHub Actions / build (17)

[StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)

Check warning on line 167 in src/main/java/com/easypost/service/ReferralCustomerService.java

View workflow job for this annotation

GitHub Actions / build (14)

[StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)

Check warning on line 167 in src/main/java/com/easypost/service/ReferralCustomerService.java

View workflow job for this annotation

GitHub Actions / build (11)

[StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)

Check warning on line 167 in src/main/java/com/easypost/service/ReferralCustomerService.java

View workflow job for this annotation

GitHub Actions / build (16)

[StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)

Check warning on line 167 in src/main/java/com/easypost/service/ReferralCustomerService.java

View workflow job for this annotation

GitHub Actions / build (13)

[StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)
}

/**
Expand All @@ -181,7 +182,7 @@
Map<String, Object> params = new HashMap<>();
Map<String, Object> creditCardParams = new HashMap<>();
creditCardParams.put("payment_method_id", paymentMethodId);
creditCardParams.put("priority", priority.toString().toLowerCase());

Check warning on line 185 in src/main/java/com/easypost/service/ReferralCustomerService.java

View workflow job for this annotation

GitHub Actions / coverage

[StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)

Check warning on line 185 in src/main/java/com/easypost/service/ReferralCustomerService.java

View workflow job for this annotation

GitHub Actions / build (19)

[StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)

Check warning on line 185 in src/main/java/com/easypost/service/ReferralCustomerService.java

View workflow job for this annotation

GitHub Actions / build (22)

[StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)

Check warning on line 185 in src/main/java/com/easypost/service/ReferralCustomerService.java

View workflow job for this annotation

GitHub Actions / build (10)

[StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)

Check warning on line 185 in src/main/java/com/easypost/service/ReferralCustomerService.java

View workflow job for this annotation

GitHub Actions / build (23)

[StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)

Check warning on line 185 in src/main/java/com/easypost/service/ReferralCustomerService.java

View workflow job for this annotation

GitHub Actions / build (25)

[StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)

Check warning on line 185 in src/main/java/com/easypost/service/ReferralCustomerService.java

View workflow job for this annotation

GitHub Actions / build (24)

[StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)

Check warning on line 185 in src/main/java/com/easypost/service/ReferralCustomerService.java

View workflow job for this annotation

GitHub Actions / build (20)

[StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)

Check warning on line 185 in src/main/java/com/easypost/service/ReferralCustomerService.java

View workflow job for this annotation

GitHub Actions / build (21)

[StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)

Check warning on line 185 in src/main/java/com/easypost/service/ReferralCustomerService.java

View workflow job for this annotation

GitHub Actions / build (8)

[StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)

Check warning on line 185 in src/main/java/com/easypost/service/ReferralCustomerService.java

View workflow job for this annotation

GitHub Actions / build (12)

[StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)

Check warning on line 185 in src/main/java/com/easypost/service/ReferralCustomerService.java

View workflow job for this annotation

GitHub Actions / build (15)

[StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)

Check warning on line 185 in src/main/java/com/easypost/service/ReferralCustomerService.java

View workflow job for this annotation

GitHub Actions / build (9)

[StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)

Check warning on line 185 in src/main/java/com/easypost/service/ReferralCustomerService.java

View workflow job for this annotation

GitHub Actions / build (18)

[StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)

Check warning on line 185 in src/main/java/com/easypost/service/ReferralCustomerService.java

View workflow job for this annotation

GitHub Actions / build (17)

[StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)

Check warning on line 185 in src/main/java/com/easypost/service/ReferralCustomerService.java

View workflow job for this annotation

GitHub Actions / build (14)

[StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)

Check warning on line 185 in src/main/java/com/easypost/service/ReferralCustomerService.java

View workflow job for this annotation

GitHub Actions / build (11)

[StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)

Check warning on line 185 in src/main/java/com/easypost/service/ReferralCustomerService.java

View workflow job for this annotation

GitHub Actions / build (16)

[StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)

Check warning on line 185 in src/main/java/com/easypost/service/ReferralCustomerService.java

View workflow job for this annotation

GitHub Actions / build (13)

[StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)
params.put("credit_card", creditCardParams);

EasyPostClient referralClient = new EasyPostClient(referralApiKey);
Expand Down Expand Up @@ -257,8 +258,10 @@
params.put("exp_year", String.valueOf(expirationYear));
params.put("cvc", cvc);

String encodedURL = InternalUtilities.getEncodedURL(params, "card");
URL stripeUrl = new URL("https://api.stripe.com/v1/tokens?" + encodedURL);
// Card details must travel in the form-encoded request body, never in the URL,
// so they cannot end up in access logs, proxy logs, or Referer headers.
String encodedBody = InternalUtilities.getEncodedURL(params, "card");
URL stripeUrl = new URL("https://api.stripe.com/v1/tokens");

HttpURLConnection conn;
if (EasyPost._vcrUrlFunction != null) {
Expand All @@ -272,6 +275,10 @@
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setDoOutput(true);

try (OutputStream outputStream = conn.getOutputStream()) {
outputStream.write(encodedBody.getBytes(StandardCharsets.UTF_8));
}

StringBuilder response;

try (BufferedReader br = new BufferedReader(
Expand Down
Loading