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:
- Initialize the input structure.
- 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).
- Assign the Order ID to the input
structure.
- 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.
- Assign the Order / Charge Amount
to the input structure. This is calculated from the items ordered and the
shipping and handling charges.
- Assign Credit Card Number,
Card Expiration Month, Card
Expiration Year to the input structure. These values are pulled directly
from the Check Out screen.
- 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.
- Assign Bytes Provided in the
output structure to the size of the allocated buffer
- Assign the Bytes Available
and Return Comment Length in the
output structure to zero.
- 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.
- Check the return code.
- If WWW_MAPIERR_SUCCESS is returned, get the Result
Code from the output structure and store it with the order.
- Otherwise, redisplay the Check Out Screen with an error message that
contains the Return Comment from
the output structure.