Setting up Usps Returns Account with easy post api

247 views Asked by At

I have a php application in which we are using USPS prepaid account with easy post api which works fine but now client says we need to add a USPS returns account now i am not sure how to do it here is a code sample that USPS have emailed...

curl -X POST https://api.easypost.com/v2/carrier_accounts \
  -u <Production API Key>: \
  -d 'carrier_account[type]=UspsReturnsAccount' \
  -d 'carrier_account[description]=<Your Description>' \
  -d 'carrier_account[reference]=<Your Reference>' \
  -d 'carrier_account[credentials][company_name]=John Doe' \
  -d 'carrier_account[credentials][address_street]=345 California Street, 10th Floor' \
  -d 'carrier_account[credentials][address_city]=San Francisco' \
  -d 'carrier_account[credentials][address_state]=CA' \
  -d 'carrier_account[credentials][address_zip]=94104' \
  -d 'carrier_account[credentials][phone]=415-123-4567' \
  -d 'carrier_account[credentials][email][email protected]'

how to implement with the easypost api i have no clue any help would be much appreciated..

1

There are 1 answers

1
Logan Simonsen On

this is an EasyPost carrier account type that isn't listed (yet) on your EasyPost dashboard by default, so it can only be added with an API call to this endpoint https://www.easypost.com/docs/api#create-a-carrier-account

If PHP is your preferred language and you are using the EasyPost PHP client library, they offer an example of how to add a carrier account using that library https://www.easypost.com/docs/api/php#carrier-accounts-create-codesample

You just need to match the credential structure that they gave you. So it should look something like this:

    require_once("path/to/lib/easypost.php");
\EasyPost\EasyPost::setApiKey("<YOUR_PRODUCTION_API_KEY>");

$ca = \EasyPost\CarrierAccount::create(array(
  'type' => "UspsReturnsAccount",
  'description' => "my-description",
  'reference' => "my-reference",
  'credentials' => array(
    'company_name' => "A1A1A1",
    'address_street' => "123 STREET",
    'address_city' => "CITY",
    'address_state' => "AL",
    'address_zip' => "12345",
    'phone' => "1234567890",
    'email' => "[email protected]"
  )
));

NOTE: This is a special type of USPS account through EasyPost and it is not required for regular USPS shipping in general. After you create this account, you need to email [email protected] to get your USPS returns account configured for proper billing support.