Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UPS Shipping API - ShipmentConfirmRequest Error

Tags:

php

xml

api

ups

Hello I am creating a wordpress website for a client using WooCommerce. The site is complete but the client wants the ability to create shipments from the shop_order page. I have most of this figured out, the problem is my XML request to the UPS API. I have checked and recheck, and I cant seem to find the error:

<ShipmentConfirmResponse><Response><ResponseStatusCode>0</ResponseStatusCode><ResponseStatusDescription>Failure</ResponseStatusDescription><Error><ErrorSeverity>Hard</ErrorSeverity><ErrorCode>10002</ErrorCode><ErrorDescription>The XML document is well formed but the document is not valid</ErrorDescription></Error></Response></ShipmentConfirmResponse>

Below is my xml mark up with sensitive info hidden.

<?xml version="1.0" ?>
<AccessRequest xml:lang='en-US'>
    <AccessLicenseNumber>******</AccessLicenseNumber>
    <UserId>********</UserId>
    <Password>********</Password>
</AccessRequest>
    <?xml version="1.0" ?>
    <ShipConfirmRequest xml:lang='en-US'>
    <Request>
    <TransactionReference>
        <CustomerContext>Customer Context</CustomerContext>
        <XpciVersion>1.0</XpciVersion>
    </TransactionReference>
     <RequestAction>ShipConfirm</RequestAction>
     <RequestOption>validate</RequestOption>
 </Request>
 <Shipment>
     <Shipper>
        <ShipperNumber>*******</ShipperNumber>
         <Name>Canyon Werks, LLC</Name>
         <Address>
             <AddressLine>2941 Brookspark Drive</AddressLine>
            <AddressLine></AddressLine>
            <City>North Las Vegas</City>
            <StateProvinceCode>NV</StateProvinceCode>
            <PostalCode>89030</PostalCode>
            <CountryCode>US</CountryCode>
        </Address>
        <Phone>
            <Number>7022552222</Number>
        </Phone>
    </Shipper>
    <ShipTo>
        <Name>Justin Walker</Name>
        <Address>
            <AddressLine>2675 Windmill Pkwy</AddressLine>
            <AddressLine>3024</AddressLine>
            <City>Henderson</City>
            <StateProvinceCode>NV</StateProvinceCode>
            <PostalCode>89074</PostalCode>
            <CountryCode>US</CountryCode>
        </Address>
        <Phone>
            <Number>7024609485</Number>
        </Phone>
    </ShipTo>
    <ShipFrom>
        <Name>Canyon Werks, LLC</Name>
        <Address>
            <AddressLine>2941 Brookspark Drive</AddressLine>
            <AddressLine></AddressLine>
            <City>North Las Vegas</City>
            <StateProvinceCode>NV</StateProvinceCode>
            <PostalCode>89030</PostalCode>
            <CountryCode>US</CountryCode>
        </Address>
        <Phone>
            <Number>7022552222</Number>
        </Phone>
    </ShipFrom>
    <PaymentInformation>
        <ShipmentCharge>
            <Type>01</Type>
            <BillShipper>
                <AccountNumber>*******</AccountNumber>
            </BillShipper>
        </ShipmentCharge>
    </PaymentInformation>
    <Service>
        <Code>03</Code>
    </Service>
    <Package>
        <Packaging>
            <Code>02</Code>
            <Description>Customer Supplied</Description>
        </Packaging>
        <Dimensions>
            <UnitOfMeasurement>
                <Code>IN</Code>
            </UnitOfMeasurement>
            <Length>16</Length>
            <Width>12</Width>
            <Height>6</Height>
        </Dimensions>
        <PackageWeight>
            <UnitOfMeasurement>
                <Code>LBS</Code>
            </UnitOfMeasurement>
            <Weight>6.07</Weight>
        </PackageWeight>
    </Package>
</Shipment>
<LabelSpecification>
    <LabelImageFormat>
        <Code>GIF</Code>
    </LabelImageFormat>
</LabelSpecification>
</ShipConfirmRequest>

I am almost there on this, but I am stuck at this road block. If anyone can shed some light into this it would be much appreciated.

like image 297
Jusmark123 Avatar asked Nov 29 '13 22:11

Jusmark123


People also ask

What does shipper error mean on UPS?

The error “the shippers shipper number cannot be used for this shipment” typically means the UPS account has been suspended - usually due to billing details expiring. Please contact UPS at 1-800-742-5877 and work with them to reactivate the shipper account.

What is UPS Shipping API?

The Shipping Application Programming Interface (API) allows you to integrate UPS shipping functionality directly into your website or enterprise system. Your customers will enjoy the depth of UPS services and capabilities, while your business becomes more efficient with improved processes.

How do I connect to UPS API?

Step 1: Sign up for a ups.com® profile or Log-in now. Step 2: Select an API. Step 3: Download the API documentation. Step 4: Request an access key.

Why do I get a missing invalid shipper number error when attempting to use the Shipping API?

Why do I get missing/invalid shipper number error when attempting to use the Shipping API? You may have received this error for a number of reasons. However, more than likely it's because your shipper number (Account Number) from the Shipping API was not added to your ups.com profile.


1 Answers

It was the service code container it must be included in the package container. I had it before it. Took me quite a while to figure out this dumb mistake on my part.

Before:

...
<Service>
    <Code>03</Code>
</Service>
<Package>
    ...

After:

...
<Package>
    <Service>
        <Code>03</Code>
    </Service>
    ...

Thanks for the help, and yes UPS requires a strange XML format.

like image 70
Jusmark123 Avatar answered Sep 30 '22 21:09

Jusmark123