Difference between revisions of "API/Services/PurchaseProduct"

From Emersion
Jump to: navigation, search
(Purchase Product)
m (added createimmediateinvoice notes)
 
(2 intermediate revisions by 2 users not shown)
Line 2: Line 2:
  
 
'''Purpose'''
 
'''Purpose'''
This method is used to create a product purchase on behalf of an existing client.
+
This method is used to create a product purchase on behalf of an existing client. This call supports creating pending cardline items for charging to next invoice.
 +
For Products of type Credit, please enter a negative quantity.
  
 
'''Inputs'''
 
'''Inputs'''
  <soapenv:Header/>
+
<nowiki>
 +
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:emersion:api" xmlns:urn1="urn:emersion:types">
 +
  <soapenv:Header/>
 
   <soapenv:Body>
 
   <soapenv:Body>
       <ser:PurchaseProducts>
+
       <urn:PurchaseProducts>
         <ser:AccountID>9999999</ser:AccountID>
+
         <urn:AccountID>?</urn:AccountID>
         <ser:ShoppingCart>
+
         <urn:ShoppingCart>
 
             <!--1 to 999 repetitions:-->
 
             <!--1 to 999 repetitions:-->
             <ser:PurchaseItem>
+
             <urn1:PurchaseItem>
               <ser:ProductID>9999999</ser:ProductID>
+
               <urn1:ProductID>?</urn1:ProductID>
               <ser:Quantity>9</ser:Quantity>
+
               <urn1:Quantity>?</urn1:Quantity>
               <!--Optional:-->
+
               <urn1:ExTaxPrice>?</urn1:ExTaxPrice>
               <ser:ExTaxPrice>99</ser:ExTaxPrice>
+
               <urn1:Tax>?</urn1:Tax>
               <!--Optional:-->
+
               <urn1:Note_Details>?</urn1:Note_Details>
               <ser:Tax>9</ser:Tax>
+
               <urn1:Note_Customer_Visible>?</urn1:Note_Customer_Visible>
              <!-Optional:->
+
            </urn1:PurchaseItem>
              <ser:Note_Details>Customer Note</ser:Note_Details>
+
        </urn:ShoppingCart>
              <!-Optional:->
+
        <urn:DeliveryAddress>
               <ser:Note_Customer_Visible>1</ser:Note_Customer_Visible>
+
            <urn1:PrimaryAddressID>?</urn1:PrimaryAddressID>
            </ser:PurchaseItem>
+
            <urn1:Address ID="?">
        </ser:ShoppingCart>
+
               <urn1:IsPrimary>?</urn1:IsPrimary>
        <!--Optional:-->
+
              <urn1:Details/>
        <ser:DeliveryAddress>
+
              <urn1:NearestCrossStreet>?</urn1:NearestCrossStreet>
            <!--Optional:-->
+
              <urn1:Country>?</urn1:Country>
            <ser:PrimaryAddressID></ser:PrimaryAddressID>
+
              <urn1:FormattedAddress>?</urn1:FormattedAddress>
            <ser:PrimaryAddressPostCode>9999</ser:PrimaryAddressPostCode>
+
              <urn1:IsValidated>?</urn1:IsValidated>
            <ser:PrimaryAddressSuburb>Dummy</ser:PrimaryAddressSuburb>
+
              <urn1:Type>?</urn1:Type>
            <ser:PrimaryAddressStreetName>Dummy</ser:PrimaryAddressStreetName>
+
              <urn1:DateFrom>?</urn1:DateFrom>
            <ser:PrimaryAddressStreetTypeID>999</ser:PrimaryAddressStreetTypeID>
+
              <urn1:DateTo>?</urn1:DateTo>
            <ser:PrimaryAddressLotNumber>999</ser:PrimaryAddressLotNumber>
+
              <urn1:GnafPid ID="?">?</urn1:GnafPid>
            <ser:PrimaryAddressUnitNumber>999</ser:PrimaryAddressUnitNumber>
+
              <urn1:DPID>?</urn1:DPID>
            <ser:PrimaryAddressState>999</ser:PrimaryAddressState>
+
              <urn1:Barcode>?</urn1:Barcode>
            <ser:PrimaryAddressLevel>999</ser:PrimaryAddressLevel>
+
              <urn1:ExternalReferences>
            <ser:PrimaryAddressLevelTypeID>999</ser:PrimaryAddressLevelTypeID>
+
                  <!--Zero or more repetitions:-->
            <ser:PrimaryAddressUnitTypeID>999</ser:PrimaryAddressUnitTypeID>
+
                  <urn1:ExternalReference Type="?">?</urn1:ExternalReference>
            <ser:PrimaryAddressPOBoxNumber>999</ser:PrimaryAddressPOBoxNumber>
+
              </urn1:ExternalReferences>
            <ser:PrimaryAddressSiteName>Dummy</ser:PrimaryAddressSiteName>
+
              <urn1:UploadSource>?</urn1:UploadSource>
             <ser:PrimaryAddressStreetTypeSuffixID>999</ser:PrimaryAddressStreetTypeSuffixID>
+
              <urn1:UploadSourceRef>?</urn1:UploadSourceRef>
         </ser:DeliveryAddress>
+
              <urn1:ImportIdentifier>?</urn1:ImportIdentifier>
       </ser:PurchaseProducts>
+
              <urn1:LastUpdated>?</urn1:LastUpdated>
 +
             </urn1:Address>
 +
        </urn:DeliveryAddress>
 +
         <urn:CreateImmediateInvoice>?</urn:CreateImmediateInvoice>
 +
       </urn:PurchaseProducts>
 
   </soapenv:Body>
 
   </soapenv:Body>
 +
</soapenv:Envelope>
 +
</nowiki>
  
 
'''Important notes'''
 
'''Important notes'''
- ProductID needs to be the ID of the Product in the Emersion system
+
* ''ProductID'' needs to be the ID of the Product in the Emersion system
- Quantity has to be non-zero and an integer
+
* ''Quantity'' has to be non-zero and an integer
- ExTaxPrice and Tax are floating point numbers however tax is optional – a sale can be tax free.
+
* ''ExTaxPrice'' and Tax are floating point numbers however tax is optional – a sale can be tax free.
 +
* ''CreateImmediateInvoice'' defaults to 1 (and therefore attempts to create an immediate invoice if no Pending invoices exist).
  
 
'''Example Validation Error'''
 
'''Example Validation Error'''
Line 80: Line 90:
 
* Could not find Account ID!
 
* Could not find Account ID!
  
* You do not have permission to modify this Account!
+
* You do not have permission to modify this Account
  
 
* No items have been provided to purchase in transaction.
 
* No items have been provided to purchase in transaction.

Latest revision as of 17:32, 2 May 2019

Purchase Product

Purpose This method is used to create a product purchase on behalf of an existing client. This call supports creating pending cardline items for charging to next invoice. For Products of type Credit, please enter a negative quantity.

Inputs

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:emersion:api" xmlns:urn1="urn:emersion:types">
   <soapenv:Header/>
   <soapenv:Body>
      <urn:PurchaseProducts>
         <urn:AccountID>?</urn:AccountID>
         <urn:ShoppingCart>
            <!--1 to 999 repetitions:-->
            <urn1:PurchaseItem>
               <urn1:ProductID>?</urn1:ProductID>
               <urn1:Quantity>?</urn1:Quantity>
               <urn1:ExTaxPrice>?</urn1:ExTaxPrice>
               <urn1:Tax>?</urn1:Tax>
               <urn1:Note_Details>?</urn1:Note_Details>
               <urn1:Note_Customer_Visible>?</urn1:Note_Customer_Visible>
            </urn1:PurchaseItem>
         </urn:ShoppingCart>
         <urn:DeliveryAddress>
            <urn1:PrimaryAddressID>?</urn1:PrimaryAddressID>
            <urn1:Address ID="?">
               <urn1:IsPrimary>?</urn1:IsPrimary>
               <urn1:Details/>
               <urn1:NearestCrossStreet>?</urn1:NearestCrossStreet>
               <urn1:Country>?</urn1:Country>
               <urn1:FormattedAddress>?</urn1:FormattedAddress>
               <urn1:IsValidated>?</urn1:IsValidated>
               <urn1:Type>?</urn1:Type>
               <urn1:DateFrom>?</urn1:DateFrom>
               <urn1:DateTo>?</urn1:DateTo>
               <urn1:GnafPid ID="?">?</urn1:GnafPid>
               <urn1:DPID>?</urn1:DPID>
               <urn1:Barcode>?</urn1:Barcode>
               <urn1:ExternalReferences>
                  <!--Zero or more repetitions:-->
                  <urn1:ExternalReference Type="?">?</urn1:ExternalReference>
               </urn1:ExternalReferences>
               <urn1:UploadSource>?</urn1:UploadSource>
               <urn1:UploadSourceRef>?</urn1:UploadSourceRef>
               <urn1:ImportIdentifier>?</urn1:ImportIdentifier>
               <urn1:LastUpdated>?</urn1:LastUpdated>
            </urn1:Address>
         </urn:DeliveryAddress>
         <urn:CreateImmediateInvoice>?</urn:CreateImmediateInvoice>
      </urn:PurchaseProducts>
   </soapenv:Body>
</soapenv:Envelope>

Important notes

  • ProductID needs to be the ID of the Product in the Emersion system
  • Quantity has to be non-zero and an integer
  • ExTaxPrice and Tax are floating point numbers however tax is optional – a sale can be tax free.
  • CreateImmediateInvoice defaults to 1 (and therefore attempts to create an immediate invoice if no Pending invoices exist).

Example Validation Error

  <SOAP-ENV:Body>
     <SOAP-ENV:Fault>
        <faultcode>SOAP-ENV:Client</faultcode>
        <faultstring>Validation Error</faultstring>
        <faultactor>http://emersion.com.au/Services</faultactor>
        <detail>Invalid or Missing Account ID</detail>
     </SOAP-ENV:Fault>
  </SOAP-ENV:Body>

Output

 <SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://emersion.com.au/ServiceObjects">
            <SOAP-ENV:Body>
                <ns1:PurchaseProductResponse>
                       <ns1:AccountID>399301</ns1:AccountID>
                        <ns1:InvoiceID/>
                         <ns1:Cardlines/>
            </ns1:PurchaseProductResponse>
         </SOAP-ENV:Body>
 </SOAP-ENV:Envelope>


Error Strings

  • Invalid or Missing Account ID
  • Could not find Account ID!
  • You do not have permission to modify this Account
  • No items have been provided to purchase in transaction.
  • Cart item missing mandatory ProductID
  • Cart item missing mandatory quantity
  • Product purchase failed with an exception: '.$e->getMessage());

The following errors can only occur if a Delivery Address is provided.

  • Provided Primary Address ID does not exist in system
  • Primary Address ID should be Integer
  • Missing Primary Address Post Code from Delivery Address
  • Post Code should consist of 4 digits
  • Post Code should contain digits only
  • Missing Primary Address Suburb from Delivery Address
  • Missing Primary Address Street Name from Delivery Address
  • Missing Primary Address Street Name from Delivery Address
  • Missing Primary Address Street Type ID from Delivery Address
  • Invalid Value for Street Type ID (means that Street Type ID does not exist in the system)
  • Street Type ID should be Integer
  • Missing Primary Address Lot Number from Delivery Address
  • Missing Primary Address Unit Number from Delivery Address
  • Missing Primary Address State from Delivery Address
  • Invalid Value for State (means that State ID does not exist in the system)
  • State should be Integer
  • Missing Primary Address Level from Delivery Address
  • Missing Primary Address Level Type ID from Delivery Address
  • Invalid Value for Level Type ID (means that Level Type ID does not exist in the system)
  • Level Type ID should be Integer
  • Missing Primary Address Unit Type ID from Delivery Address
  • Invalid Value for Unit Type ID (means that Unit Type ID does not exist in the system)
  • Unit Type ID should be Integer
  • Missing Primary Address P.O. Box Number from Delivery Address
  • Missing Primary Address Site Name from Delivery Address
  • Missing Primary Address Street Type Suffix ID from Delivery Address
  • Invalid Value for Street Type Suffix ID (means that Street Type Suffix ID does not exist in the system)
  • Street Type Suffix ID should be Integer