Skip to content
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Removes the deprecated, unusable `addCreditCardToUser` function
- Stripe has disabled the ability to pass plain credit card details over the wire and now requires using [Stripe.js/Elements/Checkout](https://support.stripe.com/questions/card-tokenization-restrictions-using-publishable-keys). Follow the [Decentralized (EasyPost-Manage Billing) Guide](https://docs.easypost.com/guides/get-started-with-forge/easypost-managed-billing-guide#referralcustomer-billing-management) for more details on the new flow to use.
- Makes `referralCustomer.retrieveEasypostStripeApiKey` public to help facilitate adding credit cards using Stripe.js
- Adds support for `FedexDefaultAccount`, `GofoWalletAccount`, `UpsDapAccount`, `UniUniWalletAccount`, and `VehoWalletAccount` by properly routing carrier-account create requests to the `/carrier_accounts/open` endpoint.

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

Expand Down
16 changes: 10 additions & 6 deletions src/main/java/com/easypost/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.easypost.exception.APIException;
import com.easypost.http.HashMapSerializer;
Expand All @@ -15,6 +16,7 @@
import com.easypost.model.Webhook;
import com.easypost.model.WebhookDeserializer;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.gson.FieldNamingPolicy;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
Expand Down Expand Up @@ -61,12 +63,14 @@ public abstract static class ErrorCodes {
}

public abstract static class CarrierAccountTypes {
public static final List<String> CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_WORKFLOW = ImmutableList.of(
"FedexAccount", "FedexSmartpostAccount");

public static final List<String> CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH = ImmutableList.of(
"AmazonShippingAccount", "UpsAccount", "UpsMailInnovationsAccount", "UpsSurepostAccount",
"UspsShipAccount");
public static final Map<String, List<String>> CARRIER_ACCOUNT_CREATE_ENDPOINT_TYPES = ImmutableMap.of(
"carrier_accounts/open", ImmutableList.of(
"FedexDefaultAccount", "GofoWalletAccount", "UpsDapAccount", "UniUniWalletAccount",
"VehoWalletAccount"),
"carrier_accounts/register", ImmutableList.of("FedexAccount", "FedexSmartpostAccount"),
"carrier_accounts/register_oauth", ImmutableList.of(
"AmazonShippingAccount", "UpsAccount", "UpsMailInnovationsAccount", "UpsSurepostAccount",
"UspsShipAccount"));
}

public abstract static class Http {
Expand Down
34 changes: 17 additions & 17 deletions src/main/java/com/easypost/service/CarrierAccountService.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,14 @@ public class CarrierAccountService {
*/
public CarrierAccount create(final Map<String, Object> params) throws EasyPostException {
String type = (String) params.get("type");
Map<String, Object> wrappedParams = new HashMap<String, Object>();
wrappedParams.put(selectTopLayerKey(type), params);
if (type == null) {
throw new MissingParameterError(
String.format(Constants.ErrorMessages.MISSING_REQUIRED_PARAMETER, "carrier account type"));
}

String endpoint = selectCarrierAccountCreationEndpoint(type);
Map<String, Object> wrappedParams = new HashMap<String, Object>();
wrappedParams.put(selectTopLayerKey(endpoint), params);

return Requestor.request(RequestMethod.POST, endpoint, wrappedParams, CarrierAccount.class, client);
}
Expand Down Expand Up @@ -116,30 +121,25 @@ public void delete(String id) throws EasyPostException {
* @return The endpoint for the carrier account creation request.
*/
private static String selectCarrierAccountCreationEndpoint(final String carrierAccountType) {
if (Constants.CarrierAccountTypes.CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_WORKFLOW.contains(carrierAccountType)) {
return "carrier_accounts/register";
} else if (Constants.CarrierAccountTypes.CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH.contains(carrierAccountType)) {
return "carrier_accounts/register_oauth";
} else {
return "carrier_accounts";
for (Map.Entry<String, List<String>> entry : Constants.CarrierAccountTypes.CARRIER_ACCOUNT_CREATE_ENDPOINT_TYPES
.entrySet()) {
if (entry.getValue().contains(carrierAccountType)) {
return entry.getKey();
}
}

return "carrier_accounts";
}

/**
* Select the top-layer key for the carrier account creation/update request based on the
* carrier type.
*
* @param carrierAccountType The type of carrier account to create.
* @param carrierAccountEndpoint The endpoint of carrier account to create.
* @return The top-layer key for the carrier account creation/update request.
* @throws MissingParameterError when the request fails.
*/
private static String selectTopLayerKey(final String carrierAccountType) throws MissingParameterError {
if (carrierAccountType == null) {
throw new MissingParameterError(
String.format(Constants.ErrorMessages.MISSING_REQUIRED_PARAMETER, "carrier account type"));
}

if (Constants.CarrierAccountTypes.CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH.contains(carrierAccountType)) {
private static String selectTopLayerKey(final String carrierAccountEndpoint) {
if ("carrier_accounts/register_oauth".equals(carrierAccountEndpoint)) {
return "carrier_account_oauth_registrations";
} else {
return "carrier_account";
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading