Tag Archives: shipping

USPS Web Tools

I was trying to add the USPS API into osCommerce. I received the following error when adding this shipping module:

RateV3 is not a valid API name for this protocol

This is because when you create an account for the Web Tools at USPS you only have access to their test server. The USPS test server can only use RateV2, so test using this code below, then request to be switched to use the production server. Then you can use RateV3 on the production server and the USPS module for osCommerce will work.


$request1 = <<< XMLREQUEST
<RateV2Request USERID="xxxxxxxxxxxxx">
<Package ID="0">
<Container>Flat Rate Box</Container>

$request = "http://testing.shippingapis.com/ShippingAPITest.dll?API=RateV2&XML=" . rawurlencode($request1);

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $request);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SLL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

$response = curl_exec($ch);