Sample Code {#ID-00001406}
==========================

The client contains sample scripts and sample PHP pages that you can use to test the client.

Basic PHP Page Example {#ID-00001408}
=====================================

The example below shows the primary code required to send a Simple Order API request for credit card authorization. The example uses name-value pairs. For a more complete example, see the sample program and sample PHP pages included in the package (see [Sample Code](/docs/cybs/en-us/client-sdk/developer/all/so/client-sdk-so/c_PHP_Client/c_Sample_Code4.md "")). [Using Name-Value Pairs](/docs/cybs/en-us/client-sdk/developer/all/so/client-sdk-so/c_PHP_Client/c_Using_Name-Value_Pairs3.md "") shows you how to create the code.

```
// Load the configuration settings
$config = cybs_load_config( 'cybs.ini' );
// set up the request by creating an array and adding fields to it
$request = array();
// We want to do credit card authorization in this example
$request['ccAuthService_run'] = "true";
// Add required fields
$request['merchantID'] = 'infodev';
$request['merchantReferenceCode'] = 'MRC-14344';
$request['billTo_firstName'] = 'Jane';
$request['billTo_lastName'] = 'Smith';
$request['billTo_street1'] = '1295 Charleston Road';
$request['billTo_city'] = 'Mountain View';
$request['billTo_state'] = 'CA';
$request['billTo_postalCode'] = '94043';
$request['billTo_country'] = 'US';
$request['billTo_email'] = 'jsmith@example.com';
$request['card_accountNumber'] = '4111111111111111';
$request['card_expirationMonth'] = '12';
$request['card_expirationYear'] = '2010';
$request['purchaseTotals_currency'] = 'USD';
// This example has two items
$request['item_0_unitPrice'] = '12.34';
$request['item_1_unitPrice'] = '56.78';
// Add optional fields here according to your business needs
// Send request
$reply = array();
$status = cybs_run_transaction( $config, $request, $reply );
// Handle the reply. See Handling the Return Status
```

Sample Scripts {#ID-0000142a}
=============================

The client contains two sample scripts, one for using name-value pairs and one for using XML. See [Testing the Client,](/docs/cybs/en-us/client-sdk/developer/all/so/client-sdk-so/c_PHP_Client/c_Installing_and_Testing_the_Client3/c_Testing_the_Client3.md "") or see the README file for more information about using the `authCaptureSample.php` script to test the client.

* Name-value pairs: See `authCaptureSample.php` in \&lt;installation directory\&gt;`/samples/nvp`.
* XML: We suggest that you examine the name-value pair sample code listed above before implementing your code to process XML requests.

For the XML sample code, see `authSample.php` in \&lt;installation directory\&gt;`/samples/xml`. Also see the `auth.xml` XML document that the script uses.

Sample PHP Pages {#ID-0000143a}
===============================

The client download package also includes sample PHP pages in the *\&lt;installation directory\&gt;* `/samples/store` directory.

| File               | Description                                                                                   |
|:-------------------|:----------------------------------------------------------------------------------------------|
| `util.php`         | Used by the other PHP pages in the directory.                                                 |
| `checkout.php`     | Displays the contents of the shopping basket and prompts for address and payment information. |
| `checkout2.php`    | Authorizes the order and displays the result.                                                 |
| `store_footer.php` | Footer used in the checkout pages.                                                            |
| `store_header.php` | Header used in the checkout pages.                                                            |
[Files in sampleStore Directory]

Use the Sample PHP Pages {#ID-0000146b}
=======================================

If you have files in your web server's root directory that have the same name as the files listed in [Files in sampleStore Directory](/docs/cybs/en-us/client-sdk/developer/all/so/client-sdk-so/c_PHP_Client/c_Sample_Code4/c_Sample_PHP_Pages.md#ID-0000143a_ID-0000143e "") back up those files. You will be copying the sample store files into the root directory in the next step. For Apache, the root directory is the one specified by `DocumentRoot` in `httpd.conf`.

1. Copy all of the files in the *\&lt;installation directory\&gt;* `/samples/store` directory into your web server's root directory.

2. Modify the `cybs.ini` file as appropriate. For more information, see [Configuring Client Settings](/docs/cybs/en-us/client-sdk/developer/all/so/client-sdk-so/c_PHP_Client/c_Installing_and_Testing_the_Client3/c_Configuring_Client_Settings1.md "").

   #### ADDITIONAL INFORMATION

   > Use absolute paths for the directories in the ` cybs.ini ` file that you use with the sample store, for example: ` keysDirectory `=` c:\keys `.  
   > If you encounter problems getting the sample PHP pages to work, you might need to locate your ` cybs.ini ` file outside of the root directory.

3. Open the `checkout.php` file in a text editor and locate the `cybs_load_config() `function.

4. Make sure that the parameter for the `cybs.ini` file passed to the function includes the absolute path. For example, make sure the line reads: `$config = cybs_load_config( 'c:\cybs.ini' );`

   #### ADDITIONAL INFORMATION

   not this line: `$config = cybs_load_config( 'cybs.ini' );`

5. Restart your web server.

   #### ADDITIONAL INFORMATION

   If you are using Microsoft Internet Information Services (IIS), you might need to restart your computer for IIS to pick up the new server path.

6. Open a web browser and type the following URL: http://\&lt;your web server name or IP address\&gt;/\&lt;virtual directory if applicable\&gt;/checkout.php

