Ayhan, It took me about five minutes to create the account, obtain an access key, a developer's key; and I was off and running! Thanks for the code!
<cfsavecontent variable="AV">
<cfoutput ><?xml version="1.0"?>
<AccessRequest xml:lang="en-US">
<AccessLicenseNumber>YOUR LICENSE NUMBER</AccessLicenseNumber>
<UserId>USERID</UserId>
<Password>PASSWORD</Password>
</AccessRequest>
<?xml version="1.0"?>
<AddressValidationRequest xml:lang="en-US">
<Request>
<TransactionReference>
<XpciVersion>1.0001</XpciVersion>
</TransactionReference>
<RequestAction>AV</RequestAction>
</Request>
<Address>
<City>#form.city#</City>
<StateProvinceCode>#form.state#</StateProvinceCode>
<PostalCode>#form.zip#</PostalCode>
</Address>
</AddressValidationRequest></cfoutput>
</cfsavecontent>
<!-- Parsing -->
<cfhttp url="https://www.ups.com/ups.app/xml/AV" port="443" method="POST" throwonerror="yes">
<cfhttpparam name="requestAV" type="XML" value="#AV#">
</cfhttp>
<cfset VerifyAddress = XmlParse(CFHTTP.FileContent)>
<!--First find out if the address is okay. -->
<cfif VerifyAddress.AddressValidationResponse.AddressValidationResult.Quality.xmlText is not 1>
<!--If the address info was bad this part will run. Use below part if you like you will use it to give customer some option to help them find right information. -->
bad address
<select name="SCZ">
<cfoutput>
<cfloop from="1" to="#ArrayLen(VerifyAddress.AddressValidationResponse.AddressValidationResult)#" index="i">
<cfset makeit[i]=structnew()>
<cfset makeit[i].city=VerifyAddress.AddressValidationResponse.AddressValidationResult[i].Address.City.xmlText>
<cfset makeit[i].state=VerifyAddress.AddressValidationResponse.AddressValidationResult[i].Address.StateProvinceCode.xmlText>
<cfset makeit[i].zip=VerifyAddress.AddressValidationResponse.AddressValidationResult[i].PostalCodeHighEnd.xmlText>
<option value="#i#">#makeit[i].city#, #makeit[i].state# #makeit[i].zip#</option>
</cfloop>
</cfoutput>
</select>
<cfelse>
no problem with address
</cfif>
Ayhan, It took me about five minutes to create the account, obtain an access key, a developer's key; and I was off and running! Thanks for the code!
How do we obtain a license number? I have a UPS sign-in account, is that the same thing?
You Rock!, Thanks for posting this. Its the only open piece of code I found that does this.