addProduct

This method creates a new product record and returns a ProductRefNum

Description

The addProduct method creates a new product record. If successful, a ProductRefNum will be returned. The ProductRefNum is a gateway assigned product identifier. This product identifier should be stored and is needed for updating and deleting products. The product database is an optional feature and may not be supported by all merchants. The merchant should check their gateway package to determine if this feature is available to them.

See also updateProduct, deleteProduct

Syntax

string addProduct ( ueSecurityToken, Product)

Arguments

Type Name Description
ueSecurityToken Token Merchant security token: used to identify merchant and retrieve the custom fields.
Product Product Object contain product details

Return Value

| Type | Description | | ---- | ---- | ----------- | string | Returns a ProductRefNum. |

Exceptions

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

Code Message Advice
41001 Unable to create product database Merchant does not have a product database. The feature not be enabled for merchant. Contact customer service and make sure product database feature is enabled.

Examples

PHP

For directions on how to set up the WSDL link, create "$token" and "$client", go to PHP Soap How-to.

    <?php

    try {

    $Product = array(
        "ProductID" => "0-13-508011-8",
        "SKU" =>"135080118",
        "UPC" => "9780135080115",
        "Category" => "Books:Math",
        "Enabled" => true,
        "Name" => "Elementary Differential Equations",
        "Description" => "Rainville, Bedient and Bedient (Eight Edition)",
        "Weight" => 1.0,
        "ShipWeight" => 1.1,
        "Price" => 112.00,
        "ListPrice" =>  128.00,
        "WholesalePrice"=> 100.00,
        "DateAvailable" => "2009-12-01",
        "Manufacturer" => "Prentice Hall",
        "Type" => "Unknown",
        "MinQuantity" =>0,
        "ImageURL" => "http://acme.com/prodimg/123123.jpg",
        "URL" => "http:/acme.com/prod/123123.html"
     );


    $ProductRefNum = $client->addProduct($token, $Product);

      print_r($res);
    }

    catch(SoapFault $e) {

      echo $e->getMessage();

    }

    ?>

VB

    Dim product As newtek.Product = New newtek.Product
            product.ProductID = "0-13-508011-8"
            product.SKU = "135080118"
            product.UPC = "9780135080115"
            product.Category = "Books:Math"

            Dim inventory(0 To 1) As newtek.ProductInventory
            inventory(0) = New newtek.ProductInventory()
            inventory(0).InventoryLocation = "Los angeles"
            inventory(0).QtyOnHand = "10"
            inventory(0).QtyOnOrder = "5"
            inventory(0).DateAvailable = "2010-08-20"

            product.Inventory = inventory

            Dim priceTier(0 To 1) As newtek.PriceTier
            priceTier(0) = New newtek.PriceTier()
            priceTier(0).Qty = "2"
            priceTier(0).Price = "100"

            product.PriceTiers = priceTier

            product.TaxClass = "your_tax_class"
            product.Enabled = True
            product.Name = "Elementary Differential Equations"
            product.Description = "Rainville, Bedient and Bedient (Eight Edition)"
            product.Weight = 1.0
            product.ShipWeight = 1.1
            product.Price = 112.0
            product.ListPrice = 128.0
            product.WholesalePrice = 100.0
            product.DateAvailable = "2010-08-01"
            product.Manufacturer = "Prentice Hail"
            product.MinQuantity = "0"

            Dim refNum As String

            refNum = client.addProduct(token, product)
            MsgBox(refNum)

.NET C

                newtek.Product product = new newtek.Product();
                product.ProductID = "0-13-508011-8";
                product.SKU = "135080118";
                product.UPC = "9780135080115";
                product.Category = "Books:Math";

                newtek.ProductInventory[] inventory = new newtek.ProductInventory[1];
                inventory[0] = new newtek.ProductInventory();
                inventory[0].InventoryLocation = "Los angeles";
                inventory[0].QtyOnHand = "10";
                inventory[0].QtyOnOrder = "5";
                inventory[0].DateAvailable = "2010-08-20";

                product.Inventory = inventory;

                newtek.PriceTier[] priceTier = new newtek.PriceTier[1];
                priceTier[0] = new newtek.PriceTier();
                priceTier[0].Qty = "2";
                priceTier[0].Price = "100";

                product.PriceTiers = priceTier;

                product.TaxClass = "your_tax_class";
                product.Enabled = true;
                product.Name = "Elementary Differential Equations";
                product.Description = "Rainville, Bedient and Bedient (Eight Edition)";
                product.Weight = 1.0;
                product.ShipWeight = 1.1;
                product.Price = 112.00;
                product.ListPrice = 128.00;
                product.WholesalePrice = 100.00;
                product.DateAvailable = "2010-08-01";
                product.Manufacturer = "Prentice Hail";
                product.MinQuantity = "0";

                string refNum;

                try
                {
                    refNum = client.addProduct(token, product);
                    MessageBox.Show(string.Concat(refNum));
                }
                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:addProduct>
<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">6336749834eabc43b70de5bc20fe037b6517b8d4</HashValue>
<Seed xsi:type="xsd:string">1667362908-test</Seed>
<Type xsi:type="xsd:string">sha1</Type>
</PinHash>
<SourceKey xsi:type="xsd:string">_B4P7C4K2w2ZCQQQXRqrxDj6agrS2NIT</SourceKey>
</Token>
<Product xsi:type="ns1:Product">
<ProductID xsi:type="xsd:string">2345678</ProductID>
<SKU xsi:type="xsd:string">909090</SKU>
<UPC xsi:type="xsd:string">789789</UPC>
<Category xsi:type="xsd:string">liqour</Category>
<Enabled xsi:type="xsd:boolean">true</Enabled>
<Name xsi:type="xsd:string">sailor jerry</Name>
<Description xsi:type="xsd:string">spice rum bottle</Description>
<Model xsi:type="xsd:string">bottle</Model>
<Weight xsi:type="xsd:double">7.7</Weight>
<ShipWeight xsi:type="xsd:double">11.7</ShipWeight>
<Price xsi:type="xsd:double">40</Price>
<WholesalePrice xsi:type="xsd:double">60</WholesalePrice>
<ListPrice xsi:type="xsd:double">20</ListPrice>
<Manufacturer xsi:type="xsd:string">Chase</Manufacturer>
<PhysicalGood xsi:type="xsd:boolean">true</PhysicalGood>
<MinQuantity xsi:type="xsd:integer">18</MinQuantity>
<ImageURL xsi:type="xsd:string">www.candyland.com</ImageURL>
<URL xsi:type="xsd:string">www.candyland.com</URL>
<Inventory SOAP-ENC:arrayType="ns1:ProductInventory[1]" xsi:type="ns1:ProductInventoryArray">
<item xsi:type="ns1:ProductInventory">
<InventoryLocation xsi:type="xsd:string">compton</InventoryLocation>
<QtyOnHand xsi:type="xsd:string">30</QtyOnHand>
<QtyOnOrder xsi:type="xsd:string">10</QtyOnOrder>
<DateAvailable xsi:type="xsd:string">461</DateAvailable>
</item>
</Inventory>
<PriceTiers SOAP-ENC:arrayType="ns1:PriceTier[2]" xsi:type="ns1:PriceTierArray">
<item xsi:type="ns1:PriceTier">
<Qty xsi:type="xsd:string">10</Qty>
<Price xsi:type="xsd:string">25</Price>
</item>
<item xsi:type="ns1:PriceTier">
<Qty xsi:type="xsd:string">20</Qty>
<Price xsi:type="xsd:string">15</Price>
</item>
</PriceTiers>
</Product>
</ns1:addProduct>
</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: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:addProductResponse>
<ProductRefNum xsi:type="xsd:string">9001001937</ProductRefNum>
</ns1:addProductResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>