-
-
Save c0debreaker/0de24919db3c2e2b0b99 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function requestUPSRate($origin_zipcode, $dest_zip, $country_code, $carton_length, $carton_width, $carton_height, $number_of_packages, $weight_per_carton, $units_per_carton, $qty) { | |
$access = "XXXXXXXXXXX"; // Access License | |
$userid = "someuser"; | |
$passwd = "p@ssw0rd!"; | |
$wsdl = "ups/RateWS.wsdl"; | |
$operation = "ProcessRate"; | |
$endpointurl = 'https://wwwcie.ups.com/webservices/Rate'; | |
$mode = array | |
( | |
'soap_version' => 'SOAP_1_1', // use soap 1.1 client | |
'trace' => 1 | |
); | |
// initialize soap client | |
ini_set("soap.wsdl_cache_enabled", "0"); | |
$soapUpsClient = new SoapClient($wsdl , $mode); | |
//set endpoint url | |
$soapUpsClient->__setLocation($endpointurl); | |
//create soap header | |
$usernameToken['Username'] = $userid; | |
$usernameToken['Password'] = $passwd; | |
$serviceAccessLicense['AccessLicenseNumber'] = $access; | |
$upss['UsernameToken'] = $usernameToken; | |
$upss['ServiceAccessToken'] = $serviceAccessLicense; | |
$header = new SoapHeader('http://www.ups.com/XMLSchema/XOLTWS/UPSS/v1.0','UPSSecurity',$upss); | |
$soapUpsClient->__setSoapHeaders($header); | |
return $soapUpsClient->__soapCall($operation, array(processRate($origin_zipcode, $dest_zip, $country_code, $carton_length, $carton_width, $carton_height, $number_of_packages, $weight_per_carton, $units_per_carton, $qty))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment