Making headway on the gateway classes.
git-svn-id: http://svn.cleancode.org/svn/pickles@93 4d10bc64-7434-11dc-a737-d2d0f8310089
This commit is contained in:
parent
c33c72e5af
commit
0816ee2fd3
4 changed files with 707 additions and 51 deletions
|
@ -28,7 +28,641 @@
|
|||
* Authorize.Net Advanced Integrated Method (AIM) Gateway
|
||||
*/
|
||||
class Gateway_AuthorizeNet_AIM extends Gateway_Common {
|
||||
|
||||
public function process() {
|
||||
|
||||
// Once the user is customer and their addresses are added, perform the authenticate.net logic
|
||||
$debugging = 1; // Display additional information to track down problems
|
||||
$testing = 1; // Set the testing flag so that transactions are not live
|
||||
$error_retries = 2; // Number of transactions to post if soft errors occur
|
||||
|
||||
$auth_net_url = "https://test.authorize.net/gateway/transact.dll";
|
||||
// Uncomment the line ABOVE for test accounts or BELOW for live merchant accounts
|
||||
// $auth_net_url = "https://secure.authorize.net/gateway/transact.dll";
|
||||
|
||||
$authnet_values = array(
|
||||
'x_login' => $this->config->gateway->authorizenet_aim->test->login,
|
||||
'x_version' => '3.1',
|
||||
'x_delim_char' => '|',
|
||||
'x_delim_data' => 'TRUE',
|
||||
'x_type' => 'AUTH_CAPTURE',
|
||||
'x_method' => 'CC',
|
||||
'x_tran_key' => $this->config->gateway->authorizenet_aim->test->transaction_key,
|
||||
'x_relay_response' => 'FALSE',
|
||||
|
||||
'x_card_num' => '4242424242424242',
|
||||
'x_exp_date' => $this->expiration_month . $this->expiration_year,
|
||||
'x_description' => 'Menopause Solutions',
|
||||
'x_amount' => $this->total_amount,
|
||||
|
||||
'x_company' => $this->billing_company,
|
||||
'x_first_name' => $this->billing_first_name,
|
||||
'x_last_name' => $this->billing_last_name,
|
||||
'x_address' => $this->billing_address1,
|
||||
'x_city' => $this->billing_city,
|
||||
'x_state' => $this->billing_state,
|
||||
'x_zip' => $this->billing_zip_code,
|
||||
'x_country' => $this->billing_country,
|
||||
'x_email' => $this->billing_email,
|
||||
'x_phone' => $this->billing_phone,
|
||||
'x_fax' => $this->billing_fax,
|
||||
|
||||
'x_ship_to_company' => $this->shipping_company,
|
||||
'x_ship_to_first_name' => $this->shipping_first_name,
|
||||
'x_ship_to_last_name' => $this->shipping_last_name,
|
||||
'x_ship_to_address' => $this->shipping_address1,
|
||||
'x_ship_to_city' => $this->shipping_city,
|
||||
'x_ship_to_state' => $this->shipping_state,
|
||||
'x_ship_to_zip' => $this->shipping_zip_code,
|
||||
'x_ship_to_country' => $this->shipping_country,
|
||||
|
||||
// 'x_tax' => '',
|
||||
// 'x_freight' => '',
|
||||
|
||||
// 'x_invoice_num' => '',
|
||||
// 'se_session_token' => '',
|
||||
);
|
||||
|
||||
$fields = '';
|
||||
foreach ($authnet_values as $key => $value) {
|
||||
$fields .= "{$key}=" . urlencode($value) . '&';
|
||||
}
|
||||
|
||||
// Post the transaction to Authorize.net
|
||||
$ch = curl_init("https://test.authorize.net/gateway/transact.dll");
|
||||
// Uncomment the line ABOVE for test accounts or BELOW for live merchant accounts
|
||||
// $ch = curl_init("https://secure.authorize.net/gateway/transact.dll");
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0); // set to 0 to eliminate header info from response
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1)
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, rtrim( $fields, "& " )); // use HTTP POST to send form data
|
||||
// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // uncomment this line if you get no gateway response. ###
|
||||
$response = curl_exec($ch); //execute post and get results
|
||||
curl_close ($ch);
|
||||
|
||||
$h = substr_count($response, '|');
|
||||
$h++;
|
||||
|
||||
for($j = 1; $j <= $h; $j++) {
|
||||
$p = strpos($response, '|');
|
||||
|
||||
if ($p === false) {
|
||||
|
||||
echo "<tr>";
|
||||
echo "<td class=\"e\">";
|
||||
|
||||
// x_delim_char is obviously not found in the last go-around
|
||||
|
||||
if($j>=69){
|
||||
|
||||
echo "Merchant-defined (".$j."): ";
|
||||
echo ": ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $response;
|
||||
echo "<br>";
|
||||
|
||||
} else {
|
||||
|
||||
echo $j;
|
||||
echo ": ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $response;
|
||||
echo "<br>";
|
||||
|
||||
}
|
||||
|
||||
|
||||
echo "</td>";
|
||||
echo "</tr>";
|
||||
|
||||
}else{
|
||||
|
||||
$p++;
|
||||
|
||||
// We found the x_delim_char and accounted for it . . . now do something with it
|
||||
|
||||
// get one portion of the response at a time
|
||||
$pstr = substr($response, 0, $p);
|
||||
|
||||
// this prepares the text and returns one value of the submitted
|
||||
// and processed name/value pairs at a time
|
||||
// for AIM-specific interpretations of the responses
|
||||
// please consult the AIM Guide and look up
|
||||
// the section called Gateway Response API
|
||||
$pstr_trimmed = substr($pstr, 0, -1); // removes "|" at the end
|
||||
|
||||
if($pstr_trimmed==""){
|
||||
$pstr_trimmed="NO VALUE RETURNED";
|
||||
}
|
||||
|
||||
|
||||
echo "<tr>";
|
||||
echo "<td class=\"e\">";
|
||||
|
||||
switch($j){
|
||||
|
||||
case 1:
|
||||
echo "Response Code: ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
$fval="";
|
||||
if($pstr_trimmed=="1"){
|
||||
$fval="Approved";
|
||||
}elseif($pstr_trimmed=="2"){
|
||||
$fval="Declined";
|
||||
}elseif($pstr_trimmed=="3"){
|
||||
$fval="Error";
|
||||
}
|
||||
|
||||
echo $fval;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 2:
|
||||
echo "Response Subcode: ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 3:
|
||||
echo "Response Reason Code: ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 4:
|
||||
echo "Response Reason Text: ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 5:
|
||||
echo "Approval Code: ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 6:
|
||||
echo "AVS Result Code: ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 7:
|
||||
echo "Transaction ID: ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 8:
|
||||
echo "Invoice Number (x_invoice_num): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 9:
|
||||
echo "Description (x_description): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 10:
|
||||
echo "Amount (x_amount): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 11:
|
||||
echo "Method (x_method): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 12:
|
||||
echo "Transaction Type (x_type): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 13:
|
||||
echo "Customer ID (x_cust_id): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 14:
|
||||
echo "Cardholder First Name (x_first_name): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 15:
|
||||
echo "Cardholder Last Name (x_last_name): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 16:
|
||||
echo "Company (x_company): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 17:
|
||||
echo "Billing Address (x_address): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 18:
|
||||
echo "City (x_city): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 19:
|
||||
echo "State (x_state): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 20:
|
||||
echo "ZIP (x_zip): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 21:
|
||||
echo "Country (x_country): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 22:
|
||||
echo "Phone (x_phone): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 23:
|
||||
echo "Fax (x_fax): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 24:
|
||||
echo "E-Mail Address (x_email): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 25:
|
||||
echo "Ship to First Name (x_ship_to_first_name): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 26:
|
||||
echo "Ship to Last Name (x_ship_to_last_name): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 27:
|
||||
echo "Ship to Company (x_ship_to_company): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 28:
|
||||
echo "Ship to Address (x_ship_to_address): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 29:
|
||||
echo "Ship to City (x_ship_to_city): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 30:
|
||||
echo "Ship to State (x_ship_to_state): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 31:
|
||||
echo "Ship to ZIP (x_ship_to_zip): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 32:
|
||||
echo "Ship to Country (x_ship_to_country): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 33:
|
||||
echo "Tax Amount (x_tax): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 34:
|
||||
echo "Duty Amount (x_duty): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 35:
|
||||
echo "Freight Amount (x_freight): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 36:
|
||||
echo "Tax Exempt Flag (x_tax_exempt): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 37:
|
||||
echo "PO Number (x_po_num): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 38:
|
||||
echo "MD5 Hash: ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 39:
|
||||
echo "Card Code Response: ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
$fval="";
|
||||
if($pstr_trimmed=="M"){
|
||||
$fval="M = Match";
|
||||
}elseif($pstr_trimmed=="N"){
|
||||
$fval="N = No Match";
|
||||
}elseif($pstr_trimmed=="P"){
|
||||
$fval="P = Not Processed";
|
||||
}elseif($pstr_trimmed=="S"){
|
||||
$fval="S = Should have been present";
|
||||
}elseif($pstr_trimmed=="U"){
|
||||
$fval="U = Issuer unable to process request";
|
||||
}else{
|
||||
$fval="NO VALUE RETURNED";
|
||||
}
|
||||
|
||||
echo $fval;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
case 40:
|
||||
case 41:
|
||||
case 42:
|
||||
case 43:
|
||||
case 44:
|
||||
case 45:
|
||||
case 46:
|
||||
case 47:
|
||||
case 48:
|
||||
case 49:
|
||||
case 50:
|
||||
case 51:
|
||||
case 52:
|
||||
case 53:
|
||||
case 54:
|
||||
case 55:
|
||||
case 55:
|
||||
case 56:
|
||||
case 57:
|
||||
case 58:
|
||||
case 59:
|
||||
case 60:
|
||||
case 61:
|
||||
case 62:
|
||||
case 63:
|
||||
case 64:
|
||||
case 65:
|
||||
case 66:
|
||||
case 67:
|
||||
case 68:
|
||||
echo "Reserved (".$j."): ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
if($j>=69){
|
||||
|
||||
echo "Merchant-defined (".$j."): ";
|
||||
echo ": ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
|
||||
} else {
|
||||
|
||||
echo $j;
|
||||
echo ": ";
|
||||
|
||||
echo "</td>";
|
||||
echo "<td class=\"v\">";
|
||||
|
||||
echo $pstr_trimmed;
|
||||
echo "<br>";
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
echo "</td>";
|
||||
echo "</tr>";
|
||||
|
||||
// remove the part that we identified and work with the rest of the string
|
||||
$response = substr($response, $p);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo "</table>";
|
||||
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -30,7 +30,23 @@
|
|||
* This is the class that each gateway class should be extending from.
|
||||
*/
|
||||
abstract class Gateway_Common extends Object {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* Runs the parent's constructor and adds the module to the object.
|
||||
*/
|
||||
public function __construct(Config $config, Error $error) {
|
||||
parent::__construct();
|
||||
|
||||
$this->config = $config;
|
||||
$this->error = $error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract processing function that is overloaded within the loaded gateway
|
||||
*/
|
||||
public abstract function process();
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -27,11 +27,13 @@ class store_checkout extends store {
|
|||
}
|
||||
else {
|
||||
$shipping_address_id = $this->db->insert('addresses', $shipping_address);
|
||||
$shipping_address = $this->db->getRow("SELECT * FROM addresses WHERE address_id = '{$shipping_address_id}';");
|
||||
}
|
||||
|
||||
// Adds the billing information into the database
|
||||
if ($_REQUEST['billing_same_as_shipping'] == 'on') {
|
||||
if (isset($_REQUEST['billing_same_as_shipping']) && $_REQUEST['billing_same_as_shipping'] == 'on') {
|
||||
$billing_address_id = $shipping_address_id;
|
||||
$billing_address = $shipping_address;
|
||||
}
|
||||
else {
|
||||
$billing_address = array(
|
||||
|
@ -56,6 +58,7 @@ class store_checkout extends store {
|
|||
}
|
||||
else {
|
||||
$billing_address_id = $this->db->insert('addresses', $billing_address);
|
||||
$billing_address = $this->db->getRow("SELECT * FROM addresses WHERE address_id = '{$billing_address_id}';");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,59 +81,60 @@ class store_checkout extends store {
|
|||
exit("There was an error - @todo make a more formal error for when the customer account cannot be created");
|
||||
}
|
||||
else {
|
||||
// Once the user is customer and their addresses are added, perform the authenticate.net logic
|
||||
$debugging = 1; // Display additional information to track down problems
|
||||
$testing = 1; // Set the testing flag so that transactions are not live
|
||||
$error_retries = 2; // Number of transactions to post if soft errors occur
|
||||
$gateway = new Gateway_AuthorizeNet_AIM($this->config, $this->error);
|
||||
|
||||
$auth_net_login_id = "CHANGE THIS";
|
||||
$auth_net_tran_key = "CHANGE THIS";
|
||||
$auth_net_url = "https://test.authorize.net/gateway/transact.dll";
|
||||
// Uncomment the line ABOVE for test accounts or BELOW for live merchant accounts
|
||||
// $auth_net_url = "https://secure.authorize.net/gateway/transact.dll";
|
||||
$cart = $_SESSION['cart'];
|
||||
$total_amount = $cart['subtotal'] + $cart['shipping'];
|
||||
|
||||
$authnet_values = array(
|
||||
'x_login' => $auth_net_login_id,
|
||||
'x_version' => '3.1',
|
||||
'x_delim_char' => '|',
|
||||
'x_delim_data' => 'TRUE',
|
||||
'x_type' => 'AUTH_CAPTURE',
|
||||
'x_method' => 'CC',
|
||||
'x_tran_key' => $auth_net_tran_key,
|
||||
'x_relay_response' => 'FALSE',
|
||||
'x_card_num' => '4242424242424242',
|
||||
'x_exp_date' => '1209',
|
||||
'x_description' => 'Recycled Toner Cartridges',
|
||||
'x_amount' => '12.23',
|
||||
'x_first_name' => 'Charles D.',
|
||||
'x_last_name' => 'Gaulle',
|
||||
'x_address' => '342 N. Main Street #150',
|
||||
'x_city' => 'Ft. Worth',
|
||||
'x_state' => 'TX',
|
||||
'x_zip' => '12345',
|
||||
'CustomerBirthMonth' => 'Customer Birth Month: 12',
|
||||
'CustomerBirthDay' => 'Customer Birth Day: 1',
|
||||
'CustomerBirthYear' => 'Customer Birth Year: 1959',
|
||||
'SpecialCode' => 'Promotion: Spring Sale',
|
||||
);
|
||||
if ($total_amount > 0) {
|
||||
|
||||
$fields = '';
|
||||
foreach ($authnet_values as $key => $value) {
|
||||
$fields .= "{$key}=" . urlencode($value) . '&';
|
||||
// Payment information
|
||||
$gateway->total_amount = $total_amount;
|
||||
//$gateway->card_type = '',
|
||||
$gateway->card_number = $_REQUEST['cc_number'];
|
||||
$gateway->expiration_month = $_REQUEST['cc_expiration']['month'];
|
||||
$gateway->expiration_year = $_REQUEST['cc_expiration']['year'];
|
||||
|
||||
if (isset($_REQUEST['ccv2'])) {
|
||||
$gateway->cvv2 = $_REQUEST['ccv2'];
|
||||
}
|
||||
|
||||
// Billing information
|
||||
$gateway->billing_company = $billing_address['company'];
|
||||
$gateway->billing_first_name = $billing_address['first_name'];
|
||||
$gateway->billing_last_name = $billing_address['last_name'];
|
||||
$gateway->billing_address1 = $billing_address['address1'];
|
||||
$gateway->billing_address2 = $billing_address['address2'];
|
||||
$gateway->billing_city = $billing_address['city'];
|
||||
$gateway->billing_state = $billing_address['state'];
|
||||
$gateway->billing_zip_code = $billing_address['zip_code'];
|
||||
$gateway->billing_country = $billing_address['country'];
|
||||
$gateway->billing_email = $billing_address['email'];
|
||||
$gateway->billing_phone = $billing_address['phone'];
|
||||
$gateway->billing_fax = $billing_address['fax'];
|
||||
|
||||
$gateway->shipping_company = $shipping_address['company'];
|
||||
$gateway->shipping_first_name = $shipping_address['first_name'];
|
||||
$gateway->shipping_last_name = $shipping_address['last_name'];
|
||||
$gateway->shipping_address1 = $shipping_address['address1'];
|
||||
$gateway->shipping_address2 = $shipping_address['address2'];
|
||||
$gateway->shipping_city = $shipping_address['city'];
|
||||
$gateway->shipping_state = $shipping_address['state'];
|
||||
$gateway->shipping_zip_code = $shipping_address['zip_code'];
|
||||
$gateway->shipping_country = $shipping_address['country'];
|
||||
$gateway->shipping_email = $shipping_address['email'];
|
||||
$gateway->shipping_phone = $shipping_address['phone'];
|
||||
$gateway->shipping_fax = $shipping_address['fax'];
|
||||
|
||||
/*
|
||||
$gateway->tax = '';
|
||||
$gateway->freight = '';
|
||||
$gateway->order_number = '';
|
||||
$gateway->session_number = '';
|
||||
*/
|
||||
|
||||
$gateway->process();
|
||||
}
|
||||
|
||||
// Post the transaction to Authorize.net
|
||||
$ch = curl_init("https://test.authorize.net/gateway/transact.dll");
|
||||
// Uncomment the line ABOVE for test accounts or BELOW for live merchant accounts
|
||||
// $ch = curl_init("https://secure.authorize.net/gateway/transact.dll");
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0); // set to 0 to eliminate header info from response
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1)
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, rtrim( $fields, "& " )); // use HTTP POST to send form data
|
||||
// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // uncomment this line if you get no gateway response. ###
|
||||
$resp = curl_exec($ch); //execute post and get results
|
||||
curl_close ($ch);
|
||||
|
||||
echo $resp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,9 @@ define('DISPLAY_SMARTY', 'Smarty');
|
|||
* @return boolean Return value of require_once() or false (default)
|
||||
*/
|
||||
function __autoload($class) {
|
||||
$filename = str_replace('_', '/', $class) . '.php';
|
||||
|
||||
// @todo Not sure this will come up, but right now core classes can only be nested a single directory deep (e.g. /classes/Display/Smarty.php)
|
||||
$filename = preg_replace('/_/', '/', $class, 1) . '.php';
|
||||
|
||||
$class_file = PICKLES_PATH . 'classes/' . $filename;
|
||||
$module_file = PICKLES_PATH . 'common/modules/' . $filename;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue