Difference between revisions of "API/Services/PurchaseProduct"
From Emersion
								
												
				 (→Purchase Product)  | 
				m (added createimmediateinvoice notes)  | 
				||
| (6 intermediate revisions by 4 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'''  | ||
| − | + |  <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>  | |
| − | + |       <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:Body>  | ||
| + | </soapenv:Envelope>  | ||
| + | </nowiki>  | ||
'''Important notes'''  | '''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'''  | '''Example Validation Error'''  | ||
| Line 54: | Line 84: | ||
| − | '''Error   | + | '''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  | |
Latest revision as of 18: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