FILTER BY TAG

Basic C/C++ Page Example

The following example shows the code required to send a Simple Order API request for credit card authorization and process the reply. The example uses name-value pairs. For a more complete example, see the sample code and sample store included in the package (see Sample Code). Using Name-Value Pairs, shows you how to create the code.
#include "cybersource.h" // Load the configuration settings const char CYBS_CONFIG_INI_FILE[] = "../cybs.ini"; pConfig = cybs_load_config( CYBS_CONFIG_INI_FILE ); // Set up the request by creating an empty CybsMap and add fields to it pRequest = cybs_create_map(); // We want to do credit card authorization in this example cybs_add( pRequest, "ccAuthService_run", "true" ); // Add required fields cybs_add( pRequest, "merchantID", "infodev" ); cybs_add( pRequest, "merchantReferenceCode", "MRC-14344" ); cybs_add( pRequest, "billTo_firstName", "Jane" ); cybs_add( pRequest, "billTo_lastName", "Smith" ); cybs_add( pRequest, "billTo_street1", "Charleston" ); cybs_add( pRequest, "billTo_city", "Mountain View" ); cybs_add( pRequest, "billTo_state", "CA" ); cybs_add( pRequest, "billTo_postalCode", "94043" ); cybs_add( pRequest, "billTo_country", "US" ); cybs_add( pRequest, "billTo_email", "[email protected]" ); cybs_add( pRequest, "card_accountNumber", "4111111111111111" ); cybs_add( pRequest, "card_expirationMonth", "12" ); cybs_add( pRequest, "card_expirationYear", "2010" ); cybs_add( pRequest, "purchaseTotals_currency", "USD" ); // This example has two items cybs_add( pRequest, "item_0_unitPrice", "12.34" ); cybs_add( pRequest, "item_1_unitPrice", "56.78" ); // Add optional fields here according to your business needs // Send request Create the reply structure and send the request pReply = cybs_create_map(); status = cybs_run_transaction(pConfig, pRequest, pReply); // Handle the reply. See Handling the Return Status.