adjustInventory

This method adjusts the inventory for a product

Description

This method can be used to either adjust or set the inventory for a product. The product to update inventory for is selected by the ProductRefNum parameter which is assigned by the gateway when the product was added. Inventory levels for multiple warehouses (inventory locations) may be set at the same time. The Inventory parameter is an array of ProductInventory objects containing the new qty levels or adjustments to current levels. Warehouses that are not sent in the array are left as is. Quantities sent as simple numbers will replace the existing quantities. If a "+" or "-" is sent before the number, the existing quantity will be either increased or decreased.

For example:

Starting Inventory
InventoryLocation QtyOnHand QtyOnOrder
Los Angeles 5 200
Washington DC 10 0
New York 123 10
Chicago 24 0
Array of ProductInventory
InventoryLocation QtyOnHand QtyOnOrder DateAvailable
Los Angeles +100 -100 8/10/2010
Washington DC 0 19 6/30/2010
New York -13 10 8/10/2010
Ending Inventory
InventoryLocation QtyOnHand QtyOnOrder
Los Angeles 105 100
Washington DC 0 19
New York 110 10
Chicago 24 0

See also updateProduct

Syntax

ProductInventory, adjustInventory ( uesecuritytoken, ProductRefNum, ProductInventory)

Arguments

Type Name Description
ueSecurityToken Token Merchant security token: used to identify merchant and retrieve the custom fields.
string ProductRefNum Product reference number (gateway assigned)
ProductInventory Inventory Array of ProductInventory objects containing qty or adjustments for each warehouse/inventory location

Return Value

Type Description
ProductInventory Returns an array of ProductInventory objects containing the adjusted inventory levels.

Exceptions

The following exceptions (errors) are applicable to this method.

Code Message Advice
41002 Product Not Found Product specified by ProductRefNum was not found. Make sure the number stored is not truncated or rounded.
41003 Error saving product A database fault was encountered while saving product record. Try operation again or contact support

Examples

VB

    Dim refNum As String
            refNum = "9001169811"

            Dim inventory(0 To 1) As newtek.ProductInventory
            inventory(0) = New newtek.ProductInventory()

            inventory(0).QtyOnHand = "+100"
            inventory(0).DateAvailable = "2010-08-12"

            Dim response() As newtek.ProductInventory
            response = client.adjustInventory(token, refNum, inventory)
            MsgBox(response.Length)

.NET C

                string RefNum = "900116985";

                newtek.ProductInventory[] inventory = new newtek.ProductInventory[1];
                inventory[0] = new newtek.ProductInventory();

                inventory[0].QtyOnHand = "+100";
                inventory[0].DateAvailable = "2010-08-12";

                try
                {
                    newtek.ProductInventory[] response = client.adjustInventory(token, RefNum, inventory);
                    MessageBox.Show(string.Concat(response.Length));
                }
                catch (Exception err)
                {
                    MessageBox.Show(err.Message);
                }

XML

Request:

    <?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:ns1="urn:newtek"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
    SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <SOAP-ENV:Body>
    <ns1:adjustInventory>
    <Token xsi:type="ns1:ueSecurityToken">
    <ClientIP xsi:type="xsd:string">123.123.123.123</ClientIP>
    <PinHash xsi:type="ns1:ueHash">
    <HashValue xsi:type="xsd:string">4e510e34e0e9a2ea067608e7a3298eeb453b3d0b</HashValue>
    <Seed xsi:type="xsd:string">11699233146-test</Seed>
    <Type xsi:type="xsd:string">sha1</Type>
    </PinHash>
    <SourceKey xsi:type="xsd:string">_B4P7C4K2w2ZCQQQXRqrxDj6agrS2NIT</SourceKey>
    </Token>
    <ProductRefNum xsi:type="xsd:string">9001001994</ProductRefNum>
    <Inventory SOAP-ENC:arrayType="ns1:ProductInventory[1]" xsi:type="ns1:ProductInventoryArray">
    <item xsi:type="ns1:ProductInventory">
    <InventoryLocation xsi:type="xsd:string">La Mirada</InventoryLocation>
    <QtyOnHand xsi:type="xsd:string">50</QtyOnHand>
    <QtyOnOrder xsi:type="xsd:string">50</QtyOnOrder>
    <DateAvailable xsi:type="xsd:string">2016-01-01</DateAvailable>
    </item>
    </Inventory>
    </ns1:adjustInventory>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

Response:

    <?xml version="1.0" encoding="utf-8"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:ns1="urn:newtek"
    xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <SOAP-ENV:Body>
    <ns1:adjustInventoryResponse>
    <adjustInventoryReturn SOAP-ENC:arrayType="ns1:ProductInventory[1]"
    xsi:type="ns1:ProductInventoryArray">
    <item xsi:type="ns1:ProductInventory">
    <InventoryLocation xsi:type="xsd:string">La Mirada</InventoryLocation>
    <QtyOnHand xsi:type="xsd:string">50</QtyOnHand>
    <QtyOnOrder xsi:type="xsd:string">50</QtyOnOrder>
    <DateAvailable xsi:type="xsd:string">2016-01-01</DateAvailable>
    </item>
    </adjustInventoryReturn>
    </ns1:adjustInventoryResponse>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>