#native_company# #native_desc#

CyberCash Page 3

By Nathan Cassano
on December 24, 2000

Web site Integration
Now that you are familiar the CyberCash API the next stage is to
integrate CyberCash into your web site. When you receive an authorization request there are
several tasks that need to be done.
  1. Verify the input variables
  2. Send an authorization request to CyberCash
  3. Log to a database the order request and the CyberCash authorization status
  4. If the authorization status is successful proceed to fulfill the goods or services requested
  5. Else display an error and exit
  6. Present the customer with an order receipt
Below is an example of an authorization wrapper function. This takes care of CyberClass interfacing,
database logging (done with MySQL) and error handling.



CyberClass authorization wrapper function

// SQL table definition used in insert order logs into

CREATE TABLE cc_order_log (

order_id CHAR(16),

amount CHAR(12),

order_desc tinytext,

trans_time datetime,

card_name CHAR(100),

card_address CHAR(100),

card_city CHAR(30),

card_state CHAR(30),

card_zip CHAR(15),

card_country CHAR(30),

part_card_num CHAR(6),

mstatus CHAR(20),

merr_code CHAR(10),

merr_msg tinytext,

merch_txn CHAR(12),

ref_code CHAR(14)




function cyberauth($order){ 

/* Make the cyberclass instance */ 

$transaction = new cyberclass('/etc/merchant_conf'); 

/* Make the credit card authorization request */

$cybercash_result $transaction->SendCC2_1Server('mauthonly',$order); 

$part_card_num substr($order['card-number'], 02) . 


strlen($order['card-number']) - 44); 

/* Make copy of order */ 

$db $order

/* Run addslashes() on data */ 


$key key($db)){ 

$db[$key] = addslashes($db[$key]); 


$dbMErrCode addslashes($cybercash_result[MErrCode]); 

$dbMErrMsg addslashes($cybercash_result[MErrMsg]); 

/* Log the transaction results */ 

$insert "INSERT INTO cc_order_log VALUES ('{$order['order-id']}',

















if(mysql("your_db"$insert) == false){

mail('[email protected]'

'Cyberauth Database Log Error',''$insert); 


if($cybercash_result['MStatus'] == "success"){ 

/* Success */ 

$return_result['success'] = true


/* Failure */

$return_result['success'] = false

$return_result['message'] = 

"There was an error processing your credit card

    transaction. {$cybercash_result['MErrCode']} - 


}elseif($cybercash_result['MStatus'] == "success-duplicate"){ 

/* Repeat */

$return_result['success'] = false

$return_result['message'] = 

"There was an error processing your credit card

    transaction. The transaction you created is a 

    duplication of a previous transaction."


/* Unknown Error */ 

$return_result['success'] = false

$return_result['message'] = 

"There was an unknown error while processing the

    credit card transaction."


/* Return results */

$return_result['order-id'] = $order_id

$return_result['part-card-number'] = $part_card_num

$return_result['card-type'] = $cybercash_result['card-type']; 

$return_result['merchtxn'] = $cybercash_result['merchtxn']; 

$return_result['refcode'] = $cybercash_result['refcode']; 

return $return_result



To setup and use the cyberauth function create the cc_order_log table in your database by
running the given SQL create table command. The cyberauth script is an example and can be
adjusted to work with any database. Adjust other various items in the script such as the path
to the merchant_conf file, the database and email notification.