Exemple #1
0
 /**
  * Display a form which posts to authorize.net's server
  */
 public function paymentForm(\Jazzee\Entity\Applicant $applicant, $amount)
 {
     if (\is_a($this->_controller, 'ApplyPageController')) {
         $time = time();
         $fpSequence = $applicant->getId() . $time;
         $form = new \Foundation\Form();
         $form->newHiddenElement('x_show_form', 'PAYMENT_FORM');
         $form->newHiddenElement('x_amount', $amount);
         $form->newHiddenElement('x_test_request', $this->_controller->getConfig()->getStatus() == 'PRODUCTION' ? 0 : 1);
         $form->newHiddenElement('x_fp_sequence', $fpSequence);
         $form->newHiddenElement('x_fp_hash', \AuthorizeNetSIM_Form::getFingerprint($this->_paymentType->getVar('gatewayId'), $this->_paymentType->getVar('gatewayKey'), $amount, $fpSequence, $time));
         $form->newHiddenElement('x_fp_timestamp', $time);
         $form->newHiddenElement('x_relay_response', "TRUE");
         $form->newHiddenElement('x_relay_url', $this->_controller->getServerPath() . $this->_controller->getActionPath() . '/../../../../../transaction/' . \urlencode(get_class($this)));
         $form->newHiddenElement('x_cancel_url', $this->_controller->getServerPath() . $this->_controller->getActionPath());
         $form->newHiddenElement('redirect_url', $this->_controller->getServerPath() . $this->_controller->getActionPath());
         $form->newHiddenElement('x_login', $this->_paymentType->getVar('gatewayId'));
         $form->newHiddenElement('x_cust_id', $applicant->getId());
         $form->newHiddenElement('x_customer_ip', $_SERVER['REMOTE_ADDR']);
         $form->newHiddenElement('x_email', $applicant->getEmail());
         $form->newHiddenElement('x_email_customer', 0);
         $form->newHiddenElement('x_description', $this->_paymentType->getVar('description'));
         $form->setAction($this->_paymentType->getVar('testAccount') ? \AuthorizeNetDPM::SANDBOX_URL : \AuthorizeNetDPM::LIVE_URL);
         $field = $form->newField();
         $field->setLegend($this->_paymentType->getName());
         $field->setInstructions("<p>Clicking the 'Pay with Credit Card' button will redirect you to a secure payment page.  Once you have completed your transaction you will be returned to the application.<strong>Application Fee:</strong> &#36;{$amount}</p>");
         $form->newButton('submit', 'Pay with Credit Card');
     } else {
         $form = parent::paymentForm($applicant, $amount);
     }
     return $form;
 }
 public function _process($params)
 {
     $fp_sequence = $params['reference'];
     $time = time();
     $fingerprint = AuthorizeNetSIM_Form::getFingerprint($this->settings['api_login_id'], $this->settings['transaction_key'], $params['amount'], $fp_sequence, $time);
     $data = array('x_amount' => $params['amount'], 'x_delim_data' => 'FALSE', 'x_fp_sequence' => $fp_sequence, 'x_fp_hash' => $fingerprint, 'x_fp_timestamp' => $time, 'x_relay_response' => 'TRUE', 'x_relay_url' => $params['return_url'], 'x_login' => $this->settings['api_login_id'], 'x_show_form' => 'PAYMENT_FORM');
     $sim = new AuthorizeNetSIM_Form($data);
     $post_url = $this->settings['test_mode'] ? self::PROCESS_URL_TEST : self::PROCESS_URL;
     Merchant::redirect_post($post_url, $sim->getHiddenFieldString());
 }
    function authorizenetPayment()
    {
        $payconfig = $this->payconfig;
        $authTestmode = $payconfig->authTestmode;
        $authAPILogin = $payconfig->authAPILogin;
        $authTransKey = $payconfig->authTransKey;
        $details = $this->details;
        $amount = $details['amount'];
        $taxrate = $details['taxrate'];
        $totamt = (double) ($amount + $amount * ($taxrate / 100));
        //the total amount is calculated as authorize.net does not support tax parameter.
        $orderid = $details['orderid'];
        $itemname = $details['itemname'];
        $item_num = $details['item_num'];
        $invoiceNo = $details['invoiceNo'];
        $user = JFactory::getUser($details['user_id']);
        $link_status = JRoute::_(JURI::base() . 'index.php?option=com_jblance&task=membership.returnafterpayment&gateway=authorizenet');
        $this->authorizenet_url = $authTestmode ? 'https://test.authorize.net/gateway/transact.dll' : 'https://secure.authorize.net/gateway/transact.dll';
        require_once JPATH_SITE . '/components/com_jblance/gateways/includes/authorizenet/AuthorizeNetSIM.php';
        $fp_timestamp = time();
        $fp_sequence = $invoiceNo;
        // Enter an invoice or other unique number.
        $fingerprint = AuthorizeNetSIM_Form::getFingerprint($authAPILogin, $authTransKey, $totamt, $fp_sequence, $fp_timestamp);
        $this->add_field('x_login', $authAPILogin);
        $this->add_field('x_fp_hash', $fingerprint);
        $this->add_field('x_description', $itemname);
        //this is where the user is returned after payment.
        $this->add_field('x_cust_id', $user->username);
        $this->add_field('x_first_name', $user->name);
        $this->add_field('x_email', $user->email);
        // this is were POST data is sent
        $this->add_field('x_email_customer', true);
        $this->add_field('x_amount', $totamt);
        $this->add_field('x_invoice_num', $invoiceNo);
        $this->add_field('x_tax', $taxrate);
        $this->add_field('x_fp_timestamp', $fp_timestamp);
        $this->add_field('x_fp_sequence', $fp_sequence);
        $this->add_field('x_version', '3.1');
        $this->add_field('x_show_form', 'payment_form');
        $this->add_field('x_test_request', false);
        $this->add_field('x_method', 'cc');
        $this->add_field('x_receipt_link_method', 'POST');
        $this->add_field('x_receipt_link_text', 'Return to Merchant Site');
        $this->add_field('x_receipt_link_url', $link_status);
        $this->submit_authorizenet_post();
        // auto submit the fields to authorizenet
        ?>
	<script>
		document.authorizenet_form.submit();
	</script>
	<?php 
    }
 public function _process($params)
 {
     $fp_sequence = $params['reference'];
     $time = time();
     $fingerprint = AuthorizeNetSIM_Form::getFingerprint($this->settings['api_login_id'], $this->settings['transaction_key'], $params['amount'], $fp_sequence, $time);
     $data = array('x_amount' => $params['amount'], 'x_delim_data' => 'FALSE', 'x_fp_sequence' => $fp_sequence, 'x_fp_hash' => $fingerprint, 'x_fp_timestamp' => $time, 'x_invoice_num' => $params['reference'], 'x_relay_response' => 'TRUE', 'x_relay_url' => $params['return_url'], 'x_login' => $this->settings['api_login_id'], 'x_show_form' => 'PAYMENT_FORM', 'x_customer_ip' => $this->CI->input->ip_address());
     // set extra billing details if we have them
     if (isset($params['card_name'])) {
         $names = explode(' ', $params['card_name'], 2);
         $data['x_first_name'] = $names[0];
         $data['x_last_name'] = isset($names[1]) ? $names[1] : '';
     }
     if (isset($params['address']) and isset($params['address2'])) {
         $params['address'] = trim($params['address'] . " \n" . $params['address2']);
     }
     foreach (array('x_company' => 'company', 'x_address' => 'address', 'x_city' => 'city', 'x_state' => 'region', 'x_zip' => 'postcode', 'x_country' => 'country', 'x_phone' => 'phone', 'x_email' => 'email') as $key => $field) {
         if (isset($params[$field])) {
             $data[$key] = $params[$field];
         }
     }
     $sim = new AuthorizeNetSIM_Form($data);
     $post_url = $this->settings['test_mode'] ? self::PROCESS_URL_TEST : self::PROCESS_URL;
     Merchant::redirect_post($post_url, $sim->getHiddenFieldString());
 }
Exemple #5
0
<?php

require_once 'anet_php_sdk/AuthorizeNet.php';
// Include the SDK you downloaded in Step 2
$api_login_id = '37nUJ4v3tWp';
$transaction_key = '22fC8P6d2s7VJmf6';
$amount = "5.99";
$fp_timestamp = time();
$fp_sequence = "123" . time();
// Enter an invoice or other unique number.
$fingerprint = AuthorizeNetSIM_Form::getFingerprint($api_login_id, $transaction_key, $amount, $fp_sequence, $fp_timestamp);
?>

<form method='post' action="https://test.authorize.net/gateway/transact.dll">
<input type='hidden' name="x_login" value="<?php 
echo $api_login_id;
?>
" />
<input type='hidden' name="x_fp_hash" value="<?php 
echo $fingerprint;
?>
" />
<input type='hidden' name="x_amount" value="<?php 
echo $amount;
?>
" />
<input type='hidden' name="x_fp_timestamp" value="<?php 
echo $fp_timestamp;
?>
" />
<input type='hidden' name="x_fp_sequence" value="<?php 
    function setup_authnet_sim_form()
    {
        global $event_details;
        $event_id = $event_details['ID'];
        if (is_null($event_id)) {
            return false;
        }
        $regis_id = $this->erm->get_regis_id();
        $post_ID = $this->erm->get_regis_post_id();
        $this->ecm->setup_event_details($event_id);
        $_totals = $this->erm->calculate_cart_totals();
        $gateway_info = $this->erm->get_gateway_info();
        $gateway_id = $this->erm->get_payment_profile_id();
        $this->epl->load_file('libraries/gateways/authnet/AuthorizeNet.php');
        $api_login_id = $gateway_info['_epl_user'];
        $transaction_key = $gateway_info['_epl_pwd'];
        //$amount = number_format( $_totals['money_totals']['grand_total'], 2, '.', '' );
        $amount = number_format(epl_get_balance_due(), 2, '.', '');
        $description = $event_details['post_title'] . ', Qty: ' . $_totals['_att_quantity']['total'][$event_details['ID']];
        $fp_timestamp = time();
        $fp_sequence = $regis_id . time();
        // Enter an invoice or other unique number.
        $fingerprint = AuthorizeNetSIM_Form::getFingerprint($api_login_id, $transaction_key, $amount, $fp_sequence, $fp_timestamp);
        $return_url = get_permalink($post_ID);
        $relay_url = add_query_arg(array('epl_action' => '_authnet_sim_process'), epl_get_shortcode_page_permalink());
        $first_name = epl_get_attendee_form_value('ticket_buyer', 'first_name');
        $last_name = epl_get_attendee_form_value('ticket_buyer', 'last_name');
        $address = epl_get_attendee_form_value('ticket_buyer', 'address');
        $city = epl_get_attendee_form_value('ticket_buyer', 'city');
        $state = epl_get_attendee_form_value('ticket_buyer', 'state');
        $zip = epl_get_attendee_form_value('ticket_buyer', 'zip');
        $email = epl_get_attendee_form_value('ticket_buyer', 'email');
        //type=hidden doesn't work.  using a hidden wrapper div
        $this->redirect_form_data = <<<EOT
<div style="display:none">

            <input type='text' name="x_login" value="{$api_login_id}" />
            <input type='text' name="x_fp_hash" value="{$fingerprint}" />
            <input type='text' name="x_amount" value="{$amount}" />
            <input type='text' name="x_fp_timestamp" value="{$fp_timestamp}" />
            <input type='text' name="x_fp_sequence" value="{$fp_sequence}" />
            <input type='text' name="x_description" value="{$description}" />
            <input type='text' name="x_version" value="3.1" />
            <input type='text' name="x_show_form" value="PAYMENT_FORM" />
            <input type='text' name="x_test_request" value="false" />
            <input type='text' name="x_method" value="cc" />


            <input type='text' name="x_invoice_num" value="{$regis_id}" />
            <input type='text' name="x_first_name" value="{$first_name}" />
            <input type='text' name="x_last_name" value="{$last_name}" />
            <input type='text' name="x_address" value="{$address}" />
            <input type='text' name="x_city" value="{$city}" />
            <input type='text' name="x_state" value="{$state}" />
            <input type='text' name="x_zip" value="{$zip}" />
            <input type='text' name="x_email" value="{$email}" />

            <input type='text' name="e_ID" value="{$event_id}" />
            <input type='text' name="p_ID" value="{$post_ID}" />
            <input type='text' name="r_ID" value="{$regis_id}" />
            <input type='text' name="g_ID" value="{$gateway_id}" />

            <input type='text' name="x_receipt_link_method" value="POST" />
          <input type='text' name="x_receipt_link_text" value="PLEASE CLICK HERE TO FINISH YOUR REGISTRATION" />
          <input type='text' name="x_receipt_link_URL" value="{$relay_url}" />
              

</div>


EOT;
        /*
        *                         <input type='text' name="x_relay_response" value="TRUE">
         <input type='text' name="x_relay_url" value="$relay_url">
        *
        */
    }
 public function authorizePay($api_login_id, $transaction_key, $amount, $fp_sequence, $fp_timestamp)
 {
     require_once 'anet_php_sdk/AuthorizeNet.php';
     $fingerprint = AuthorizeNetSIM_Form::getFingerprint($api_login_id, $transaction_key, $amount, $fp_sequence, $fp_timestamp);
     return $fingerprint;
 }
<?php

require_once $controller->getConst('PLUGIN_DIR') . 'anet_php_sdk/AuthorizeNet.php';
$transaction_key = $tpl['arr']['transkey'];
$url = PJ_TEST_MODE ? 'https://test.authorize.net/gateway/transact.dll' : 'https://secure.authorize.net/gateway/transact.dll';
$x_login = $tpl['arr']['x_login'];
$x_amount = number_format($tpl['arr']['x_amount'], 2, '.', '');
$x_description = $tpl['arr']['x_description'];
$x_fp_sequence = md5(uniqid(rand(), true));
$x_fp_timestamp = time() + (int) $tpl['arr']['timezone'];
$fingerprint = AuthorizeNetSIM_Form::getFingerprint($x_login, $transaction_key, $x_amount, $x_fp_sequence, $x_fp_timestamp);
?>
<form method="post" action="<?php 
echo $url;
?>
" style="display: inline" name="<?php 
echo $tpl['arr']['name'];
?>
" id="<?php 
echo $tpl['arr']['id'];
?>
" target="<?php 
echo @$tpl['arr']['target'];
?>
">
	<input type="hidden" name="x_login" value="<?php 
echo $x_login;
?>
" />
	<input type="hidden" name="x_amount" value="<?php 
echo $x_amount;