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 @@ -5,6 +5,7 @@
- Removes the deprecated, unusable `add_credit_card` 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 `referral_customer.retrieve_easypost_stripe_api_key` 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.

## v10.7.0 (2026-06-25)

Expand Down
31 changes: 20 additions & 11 deletions easypost/constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,24 @@

# Internal constants (user's should not use these)
_TEST_FAILED_INTENTIONALLY_ERROR = "Test failed intentionally."
_CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_WORKFLOWS = [
"FedexAccount",
"FedexSmartpostAccount",
]
_CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH = [
"AmazonShippingAccount",
"UpsAccount",
"UpsMailInnovationsAccount",
"UpsSurepostAccount",
"UspsShipAccount",
]
_CARRIER_ACCOUNT_CREATE_ENDPOINT_TYPES = {
"/carrier_accounts/open": (
"FedexDefaultAccount",
"GofoWalletAccount",
"UpsDapAccount",
"UniUniWalletAccount",
"VehoWalletAccount",
),
"/carrier_accounts/register": (
"FedexAccount",
"FedexSmartpostAccount",
),
"/carrier_accounts/register_oauth": (
"AmazonShippingAccount",
"UpsAccount",
"UpsMailInnovationsAccount",
"UpsSurepostAccount",
"UspsShipAccount",
),
}
_FILTERS_KEY = "filters"
12 changes: 5 additions & 7 deletions easypost/services/carrier_account_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
)

from easypost.constant import (
_CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH,
_CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_WORKFLOWS,
_CARRIER_ACCOUNT_CREATE_ENDPOINT_TYPES,
MISSING_PARAMETER_ERROR,
)
from easypost.easypost_object import convert_to_easypost_object
Expand All @@ -31,7 +30,7 @@ def create(self, **params) -> CarrierAccount:
raise MissingParameterError(MISSING_PARAMETER_ERROR.format("type"))

url = self._select_carrier_account_creation_endpoint(carrier_account_type=carrier_account_type)
if carrier_account_type in _CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH:
if url == "/carrier_accounts/register_oauth":
wrapped_params = {"carrier_account_oauth_registrations": params}
else:
wrapped_params = {self._snakecase_name(self._model_class): params}
Expand Down Expand Up @@ -64,9 +63,8 @@ def types(self) -> list[dict[str, Any]]:

def _select_carrier_account_creation_endpoint(self, carrier_account_type: Optional[Any]) -> str:
"""Determines which API endpoint to use for the creation call."""
if carrier_account_type in _CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_WORKFLOWS:
return "/carrier_accounts/register"
elif carrier_account_type in _CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH:
return "/carrier_accounts/register_oauth"
for endpoint, carrier_account_types in _CARRIER_ACCOUNT_CREATE_ENDPOINT_TYPES.items():
if carrier_account_type in carrier_account_types:
return endpoint

return "/carrier_accounts"

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.

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

Loading
Loading