Pushing Orders to FarApp

FarApp Order API

FarApp supports a SOAP-like interface for posting orders. If you need to post orders directly to FarApp, we can provide a listener to receive XML orders and then relay them as required. A URL and credentials will be provided during the setup process.

XML documents should be submitted with an HTTP POST to the URL provided, and the documents must be submitted as the HTTP body (not as a keyword-argument).

Posting-Document (XML)

The following is an example XML posting document (note that many of the fields are optional):

<?xml version="1.0" encoding="UTF-8"?>
<OrderList FarAppAccountName="{CLIENTACCOUNT}" Storefront="{STOREFRONT}" Key="{API-KEY}" Version="{VERSION}">
	<Order>
		<OrderNumber>{ORDERNUMBER}</OrderNumber>
		<Time>{ISOORDERTIMESTAMP}</Time> <!-- Order Date/Time in ISO format (yyyy-mm-ddThh:mm:ssZ) -->
		<Currency>USD</Currency> <!--Optional-->
		<BuyerAddressInfo>
			<Name>
				<First>{FIRSTNAME}</First> <!-- Use either Full, or First and Last -->
				<Last>{LASTNAME}</Last>
				<Full>{FULLNAME}</Full>
			</Name>
			<Company>{COMPANY}</Company>
			<Address1>{ADDRESS1}</Address1>
			<Address2>{ADDRESS2}</Address2>
			<City>{CITY}</City>
			<StateProvince>{STATEPROVINCE}</StateProvince>
			<Country>{COUNTRY}</Country>
			<PostalCode>{POSTALCODE}</PostalCode>
			<Phone>{PHONE}</Phone>
			<Email>{EMAIL}</Email>
		</BuyerAddressInfo>
		<ShipToAddressInfo>
			<Name>
				<First>{FIRSTNAME}</First>
				<Last>{LASTNAME}</Last>
				<Full>{FULLNAME}</Full>
			</Name>
			<Company>{COMPANY}</Company>
			<Address1>{ADDRESS1}</Address1>
			<Address2>{ADDRESS2}</Address2>
			<Address3>{ADDRESS3}</Address3>
			<City>{CITY}</City>
			<StateProvince>{STATEPROVINCE}</StateProvince>
			<Country>{COUNTRY}</Country>
			<PostalCode>{PostalCode}</PostalCode>
			<Phone>{PHONE}</Phone>
			<Email>{EMAIL}</Email>
		</ShipToAddressInfo>
		<ShipMethod>{SHIPMETHOD}</ShipMethod>
		<PaymentMethod>{PAYMENTMETHOD}</PaymentMethod>
		<CreditCard> <!-- ONLY Allowed via secure transports -->
			<CCType>{CCType}</CCType>
			<CCNO>{CCNO}</CCNO> <!-- For PCI Compliance, please don't send full credit card number -->
			<CCExp>{CCExp}</CCExp>
		</CreditCard>
		<OrderItems>
			<Item> <!-- Repeat for each order line -->
				<LineNo>{LINENUMBER}</LineNo>
				<ProductID>{PRODUCTID}</ProductID> <!--Must contain the Product ID/SKU/Item-Code value that matches the back-end Item-->
				<Quantity>{QUANTITY}</Quantity>
				<UnitPrice>{UNITPRICE}</UnitPrice>
				<Description>{ITEMDESCRIPTION}</Description>
				<ItemNotes>{ITEMNOTES}</ItemNotes>
				<CustomFields>
					<CustomNode1 {Name whatever you want}>{CUSTOMVAL1}</CustomNode1>
					<CustomNode2 {Name whatever you want}>{CUSTOMVAL2}</CustomNode2>
					<AnotherField {Name whatever you want}>{CUSTOMVAL}</AnotherField>
				</CustomFields>
			</Item>
		</OrderItems>
		<OrderNotes>{ORDERNOTES}</OrderNotes>
		<Totals>
			<Subtotal>{ORDERITEMTOTAL}</Subtotal>
			<ShippingTotal>{SHIPPINGTOTAL}</ShippingTotal>
			<ShippingTaxTotal >{SHIPPINGTAXTOTAL}</ShippingTaxTotal>
			<DiscountTotal>{DISCOUNTTOTAL}</DiscountTotal>
			<CouponTotal>{COUPONTOTAL}</CouponTotal>
			<TaxTotal>{TAXTOTAL}</TaxTotal>
			<OrderTotal>{ORDERTOTAL}</OrderTotal>
		</Totals>
<CustomFields>
<CustomNode1 {Name whatever you want}>{CUSTOMVAL1}</CustomNode1>
<CustomNode2 {Name whatever you want}>{CUSTOMVAL2}</CustomNode2>
<AnotherField {Name whatever you want}>{CUSTOMVAL}</AnotherField> </CustomFields> </Order> </OrderList>

PHP Order-Posting Sample Code

function requestPost($url, $data) {
        set_time_limit(60);
        $output = array();

        // Open the cURL session
        $curlSession = curl_init();

        curl_setopt ($curlSession, CURLOPT_URL, $url);
        curl_setopt ($curlSession, CURLOPT_HEADER, 0);
        curl_setopt ($curlSession, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
        curl_setopt ($curlSession, CURLOPT_POST, 1);
        curl_setopt ($curlSession, CURLOPT_POSTFIELDS, $data);
        curl_setopt($curlSession, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curlSession, CURLOPT_TIMEOUT,60);
        curl_setopt($curlSession, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($curlSession, CURLOPT_SSL_VERIFYHOST, 1);

        $response = curl_exec($curlSession);
        if (curl_error($curlSession)){
        }

        curl_close ($curlSession);

        return $response;
}

$url = 'https://adv.farapp.com/secure_StorefrontOrderListener/YOUR_ACCOUNT_TOKEN_HERE;

$response = requestPost($url, $data);

echo $response;
 

Comments

  • Avatar
    paul WATTS

    Very useful, thank you.