Login   Register  
PHP Classes
elePHPant
Icontem

File: TFPaymentExample.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Geoff Foley  >  TransFirst Payment Class  >  TFPaymentExample.php  >  Download  
File: TFPaymentExample.php
Role: Example script
Content type: text/plain
Description: Example usage
Class: TransFirst Payment Class
Process payments using the Transfirst ePay API
Author: By
Last change:
Date: 2009-09-14 12:45
Size: 2,234 bytes
 

Contents

Class file image Download
<?php
// Load the transfirst_payment class
require('transfirst_payment_class.php'); //  If you're using the 'classloader.php' module you could omit this line
$tf_payment = new transfirst_payment();

// Of course, in a production environment, you would NOT call both of these methods at the same time.
// ccVerify is simply for verification of the card, while ccSettle is for actual purchase transactions.

// Example of the ccVerify method
$tf_payment->ccVerify($_POST['cc_number'], $_POST['cc_exp_mo'], $_POST['cc_exp_yr'], $_POST['bill_address_1'], $_POST['bill_zip']);

// Example of how to build the array needed for the ccSettle method
$settleDataArray = array(orderNum => $_POST['order_id'],
                        
transactionAmount => $_POST['order_total'],
                        
cardAccountNum => $_POST['cc_number'],
                        
expirationDate => $_POST['cc_exp_mo'].$_POST['cc_exp_yr'],
                        
cardHolderZip => $_POST['bill_zip'],
                        
cardHolderName => $_POST['bill_f_name']." ".$_POST['bill_l_name'],
                        
cardHolderAddress => $_POST['bill_address_1'],
                        
cardHolderCity => $_POST['bill_city'],
                        
cardHolderState => $_POST['bill_state'],
                        
cardHolderEmail => $_POST['bill_email'],
                        
cardHolderPhone => $_POST['bill_phone'],
                        
customerNum => $_POST['order_id'],
                        
CVV2 => $_POST['cc_cvv'],
                        
TaxIndicator => $_POST['tax_indicator'],
                        
TotalTaxAmount => $_POST['tax_amt']);
// The ccSettle method
$tf_payment->ccSettle($settleDataArray);

// Here are examples of some of the more important properties to check
$tf_trans_status     $tf_payment->getVars("tf_trans_status");
$tf_ext_trans_status $tf_payment->getVars("tf_ext_trans_status");
$tf_trans_refno      $tf_payment->getVars("tf_trans_refno");
$tf_avs_code         $tf_payment->getVars("avs_response_code");

// If the response code is not 00 (approved)
if ($tf_trans_status != '00') {
    
// Put your code here to deal with failed transactions
} else {
    
// Put your code here to deal with successful transactions
}
?>