How the API Fits In


Using the API

Using the API in the store demo application was a simple process. In fact, a total of thirty-one lines of 'C' code was all that was necessary to call the API.

The steps that are done in the application are as follows:

  1. Initialize the input structure.
  2. Assign the Host Service Name, Merchant Name, and Merchant Password to the input structure. These values are read from the global configuration physical file (MGLOBALP).
  3. Assign the Order ID to the input structure.
  4. Assign the Customer Name, Address, City, State/Province, Zip/Postal Code, and Country to the input structure. These values are pulled directly from the Check Out screen.
  5. Assign the Order / Charge Amount to the input structure. This is calculated from the items ordered and the shipping and handling charges.
  6. Assign Credit Card Number, Card Expiration Month, Card Expiration Year to the input structure. These values are pulled directly from the Check Out screen.
  7. Allocate a buffer for the output structure. The buffer was allocated to be large enough to hold the output structure plus 512 additional bytes for the Return Comment.
  8. Assign Bytes Provided in the output structure to the size of the allocated buffer
  9. Assign the Bytes Available and Return Comment Length in the output structure to zero.
  10. Call the API. Pass to it the Remote Host, Remote Port, and Transmit Method, along with the input and output structures. The Remote Host, Remote Port, and Transmit Method are all read from the global configuration physical file (MGLOBALP).
    See the Using the Merchant/400 API in an ILE Program or an OPM Program for more information on calling the API.
  11. Check the return code.