*
* Note: To send requests to the live gateway, either define this:
* define("AUTHORIZENET_SANDBOX", false);
- * -- OR --
+ * -- OR --
* $sale = new AuthorizeNetAIM;
* $sale->setSandbox(false);
*
* @link http://www.authorize.net/support/AIM_guide.pdf AIM Guide
*/
-
+
/**
* Builds and sends an AuthorizeNet AIM Request.
*
*/
class AuthorizeNetAIM extends AuthorizeNetRequest
{
-
- const LIVE_URL = 'https://secure.authorize.net/gateway/transact.dll';
+ const LIVE_URL = 'http://ws6.gaslightmedia.com/AuthorizeNetRelay/glmAuthNetRelay/AuthNetRelayProduction.php';
+ //const LIVE_URL = 'https://secure.authorize.net/gateway/transact.dll';
const SANDBOX_URL = 'https://test.authorize.net/gateway/transact.dll';
-
+
/**
- * Holds all the x_* name/values that will be posted in the request.
+ * Holds all the x_* name/values that will be posted in the request.
* Default values are provided for best practice fields.
*/
protected $_x_post_fields = array(
- "version" => "3.1",
+ "version" => "3.1",
"delim_char" => ",",
"delim_data" => "TRUE",
"relay_response" => "FALSE",
"encap_char" => "|",
);
-
+
/**
* Only used if merchant wants to send multiple line items about the charge.
*/
private $_additional_line_items = array();
-
+
/**
* Only used if merchant wants to send custom fields.
*/
private $_custom_fields = array();
-
+
/**
* Checks to make sure a field is actually in the API before setting.
* Set to false to skip this check.
*/
public $verify_x_fields = true;
-
+
/**
* A list of all fields in the AIM API.
* Used to warn user if they try to set a field not offered in the API.
"split_tender_id","state","tax","tax_exempt","test_request","tran_key",
"trans_id","type","version","zip"
);
-
+
/**
- * Do an AUTH_CAPTURE transaction.
- *
+ * Do an AUTH_CAPTURE transaction.
+ *
* Required "x_" fields: card_num, exp_date, amount
*
* @param string $amount The dollar amount to charge
$this->type = "AUTH_CAPTURE";
return $this->_sendRequest();
}
-
+
/**
* Do a PRIOR_AUTH_CAPTURE transaction.
*
$this->type = "VOID";
return $this->_sendRequest();
}
-
+
/**
* Do a CAPTURE_ONLY transaction.
*
$this->type = "CAPTURE_ONLY";
return $this->_sendRequest();
}
-
+
/**
* Do a CREDIT transaction.
*
$this->type = "CREDIT";
return $this->_sendRequest();
}
-
+
/**
* Alternative syntax for setting x_ fields.
*
* @param string $name
* @param string $value
*/
- public function __set($name, $value)
+ public function __set($name, $value)
{
$this->setField($name, $value);
}
-
+
/**
* Quickly set multiple fields.
*
$this->setField($key, $value);
}
}
-
+
/**
* Quickly set multiple custom fields.
*
$this->setCustomField($key, $value);
}
}
-
+
/**
* Add a line item.
- *
+ *
* @param string $item_id
* @param string $item_name
* @param string $item_description
}
$this->_additional_line_items[] = $line_item;
}
-
+
/**
* Use ECHECK as payment type.
*/
)
);
}
-
+
/**
* Set an individual name/value pair. This will append x_ to the name
* before posting.
$this->_x_post_fields[$name] = $value;
}
}
-
+
/**
* Set a custom field. Note: the x_ prefix will not be added to
* your custom field if you use this method.
{
$this->_custom_fields[$name] = $value;
}
-
+
/**
* Unset an x_ field.
*
{
unset($this->_x_post_fields[$name]);
}
-
+
/**
*
*
* @param string $response
- *
+ *
* @return AuthorizeNetAIM_Response
*/
protected function _handleResponse($response)
{
return new AuthorizeNetAIM_Response($response, $this->_x_post_fields['delim_char'], $this->_x_post_fields['encap_char'], $this->_custom_fields);
}
-
+
/**
* @return string
*/
{
return ($this->_sandbox ? self::SANDBOX_URL : self::LIVE_URL);
}
-
+
/**
* Converts the x_post_fields array into a string suitable for posting.
*/
public function __construct($response, $delimiter, $encap_char, $custom_fields)
{
if ($response) {
-
+
// Split Array
$this->response = $response;
if ($encap_char) {
} else {
$this->_response_array = explode($delimiter, $response);
}
-
+
/**
* If AuthorizeNet doesn't return a delimited response.
*/
$this->error_message = "Unrecognized response from AuthorizeNet: $response";
return;
}
-
-
-
+
+
+
// Set all fields
$this->response_code = $this->_response_array[0];
$this->response_subcode = $this->_response_array[1];
$this->split_tender_id = $this->_response_array[52];
$this->requested_amount = $this->_response_array[53];
$this->balance_on_card = $this->_response_array[54];
-
+
$this->approved = ($this->response_code == self::APPROVED);
$this->declined = ($this->response_code == self::DECLINED);
$this->error = ($this->response_code == self::ERROR);
$this->held = ($this->response_code == self::HELD);
-
+
// Set custom fields
if ($count = count($custom_fields)) {
$custom_fields_response = array_slice($this->_response_array, -$count, $count);
$i++;
}
}
-
+
if ($this->error) {
$this->error_message = "AuthorizeNet Error:
Response Code: ".$this->response_code."
class AuthorizeNetDPM extends AuthorizeNetSIM_Form
{
- const LIVE_URL = 'https://secure.authorize.net/gateway/transact.dll';
+ const LIVE_URL = 'http://ws6.gaslightmedia.com/AuthorizeNetRelay/glmAuthNetRelay/AuthNetRelayProduction.php';
+ //const LIVE_URL = 'https://secure.authorize.net/gateway/transact.dll';
const SANDBOX_URL = 'https://test.authorize.net/gateway/transact.dll';
/**
*/
public static function directPostDemo($url, $api_login_id, $transaction_key, $amount = "0.00", $md5_setting = "")
{
-
+
// Step 1: Show checkout form to customer.
if (!count($_POST) && !count($_GET))
{
echo AuthorizeNetDPM::getCreditCardForm($amount, $fp_sequence, $url, $api_login_id, $transaction_key);
}
// Step 2: Handle AuthorizeNet Transaction Result & return snippet.
- elseif (count($_POST))
+ elseif (count($_POST))
{
$response = new AuthorizeNetSIM($api_login_id, $md5_setting);
- if ($response->isAuthorizeNet())
+ if ($response->isAuthorizeNet())
{
- if ($response->approved)
+ if ($response->approved)
{
// Do your processing here.
- $redirect_url = $url . '?response_code=1&transaction_id=' . $response->transaction_id;
+ $redirect_url = $url . '?response_code=1&transaction_id=' . $response->transaction_id;
}
else
{
}
}
}
-
+
/**
* A snippet to send to AuthorizeNet to redirect the user back to the
* merchant's server. Use this on your relay response page.
</script>
</head><body><noscript><meta http-equiv=\"refresh\" content=\"1;url={$redirect_url}\"></noscript></body></html>";
}
-
+
/**
* Generate a sample form for use in a demo Direct Post implementation.
*
);
$hidden_fields = $sim->getHiddenFieldString();
$post_url = ($test_mode ? self::SANDBOX_URL : self::LIVE_URL);
-
+
$form = '
<style>
fieldset {
return $form;
}
-}
\ No newline at end of file
+}