Screen: ShopSite > Orders

Automatic XML Orders Download

Note:

The information on this page applies to Orders only. For information on automated XML uploads and downloads of Products or Pages, see Database Automated XML Upload/Download.

You can use a merchant-supplied program to automatically download a store’s orders as an XML-formatted text file. This help page describes the programmatic interface; the XML DTD is described on Orders Download XML Format.

Your orders download program must send a request to a ShopSite Authorization CGI program (authorize.cgi) and provide authentication to receive a token that can authorize a request to a ShopSite Download CGI program (db_xml.cgi) to start the download. To keep order information secure, the ShopSite CGI program must be invoked through a secure connection (https). If the connection is not secure, customer credit card information will not be included in the download.

The db_xml.cgi program can accept these optional parameters:

While it is possible to use startorder and endorder or startdate and enddate to download a specific set of orders, you do not have to use both the start and end value. You could, for example, use startdate without enddate to download all the orders that have come in since the last time you downloaded orders.

The db_xml.cgi will output the following line, followed by the XML order information:

Content-type: application/x-www-form-urlencoded\n\n

Example Program

This example program functions as though the client has already entered the appropriate information on the Application screen of the back office and relies heavily on the sample OAuth source code provided here.

From the back office:

Generated by the OAuth sample code:

This example uses a non-secure connection to request order information, starting with order number 1962. Because the CGI directory on the server requires authentication, the program first requests a token from ShopSite, passing the authentication keys set up on the Application screen in the back office. It then passes the token as authentication for the order information request. This program does not process the XML, so it does not test the response values (Success or Failure).

if ((msg_socket = getconnection("mystore.com",80)) == -1)
{
  printf("Big trouble, no socket connection\n");
  exit(1);
}

    /* create the HTTP header for authentication request */
sprintf(send_msg,
  "POST /cgi-bin/ss/authorize.cgi HTTP/1.1\n"
  "Host: mystore.com:80\r\n"
  "Content-Type: application/x-www-form-urlencoded"
  "grant_type=authorization_code&code=MTQxMDZ8ZGViYmllfDJ8&client_credentials=QjlEMzI5OUI6ODAwMjZiYzc=&signature=rfw0k21l9YdXl0r240Uw+3aa9A4=");
    /* send the HTTP header for authentication request */
resource = send(msg_socket, send_msg, strlen(send_msg),0);

    /* create the HTTP header for download */
sprintf(send_msg,
  "POST /cgi-bin/ss/db_xml.cgi?startorder=1962 HTTP/1.1\n"
  "Host: mystore.com:80\r\n"
  "Content-Type: application/x-www-form-urlencoded"
  “clientApp=1&dbname=orders&version=11.0&token=MTMwMjA5NjAyOHxkZWJiaWV8MnxCYWlsZXl8MjU2fA==&timestamp=1302101084&nonce=503bb763&signature=LXIUwI9RSLqzd19GpOJnbO0hTQg=”);

    /* send the HTTP header for download */
count = send(msg_socket, send_msg, strlen(send_msg),0);

    /* loop to receive order info */
while (count = recv(msg_socket, buf, 2048, 0))
{
  buf[count] = '\0';
  printf("%s",buf); /* since just testing write the order info to the screen */

    /* Here is where you would create a buffer /*
    /* containing all the order info */
    /* and then process that information */
}

close(msg_socket);

The getconnection() function creates a socket link to the specified host on port 80. Once the socket connection has been established the program will "send" the HTTP header that specifies the CGI to be invoked along with any parameters (in this case startorder=1962 for the starting order to download), the Host and the Authorization which is needed because the CGI is in a oAuth protected web server directory.


ShopSite Help and Resource Center
Last updated: March 01, 2010
Give Feedback


ShopSite Shopping Cart Software