Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
- class Chout extends CI_Controller
- {
- function Chout()
- {
- parent::__construct();
- $this->load->model('cart_model');
- }
- function page_data()
- {
- $data['title'] = 'Prep N\' Pop';
- $data['header'] = '
- <div id="header" /></div>';
- $data['css'] = "
- <link href=\"".$this->config->item('base_url').$this->config->item('css')."\" rel=\"stylesheet\" type=\"text/css\" />
- <script type=\"text/javascript\" src=\"".$this->config->item('base_url')."assets/js/jquery-1.6.2.min.js\"></script>
- <script type=\"text/javascript\" src=\"".$this->config->item('base_url')."assets/js/ch_core.js\"></script>";
- $data['heading'] = '
- <div id="heading" />Prep N\' Pop</div>';
- return $data;
- }
- function index()
- {
- $this->load->view('checkout', $this->page_data());
- }
- function show_cart(){
- $this->load->view('chcart');
- }
- function update_cart(){
- $this->cart_model->validate_update_cart();
- redirect('chout');
- }
- function empty_cart(){
- $this->cart->destroy();
- redirect('pnp');
- }
- function process_sale(){
- $root = realpath($_SERVER["DOCUMENT_ROOT"]);
- require_once("$root/newsite/assets/anet_php_sdk/config.php");
- if ($METHOD_TO_USE == "AIM") {
- $transaction = new AuthorizeNetAIM;
- $transaction->setSandbox(AUTHORIZENET_SANDBOX);
- $transaction->setFields(
- array(
- 'amount' => $amount,
- 'card_num' => $_POST['x_card_num'],
- 'exp_date' => $_POST['x_exp_date'],
- 'first_name' => $_POST['x_first_name'],
- 'last_name' => $_POST['x_last_name'],
- 'address' => $_POST['x_address'],
- 'city' => $_POST['x_city'],
- 'state' => $_POST['x_state'],
- 'country' => $_POST['x_country'],
- 'zip' => $_POST['x_zip'],
- 'email' => $_POST['x_email'],
- 'card_code' => $_POST['x_card_code'],
- )
- );
- $response = $transaction->authorizeAndCapture();
- if ($response->approved) {
- // Transaction approved! Do your logic here.
- header('Location: thank_you_page.php?transaction_id=' . $response->transaction_id);
- } else {
- header('Location: error_page.php?response_reason_code='.$response->response_reason_code.'&response_code='.$response->response_code.'&response_reason_text=' .$response->response_reason_text);
- }
- } elseif (count($_POST)) {
- $response = new AuthorizeNetSIM;
- if ($response->isAuthorizeNet()) {
- if ($response->approved) {
- // Transaction approved! Do your logic here.
- // Redirect the user back to your site.
- $return_url = $site_root . 'thank_you_page.php?transaction_id=' .$response->transaction_id;
- } else {
- // There was a problem. Do your logic here.
- // Redirect the user back to your site.
- $return_url = $site_root . 'error_page.php?response_reason_code='.$response->response_reason_code.'&response_code='.$response->response_code.'&response_reason_text=' .$response->response_reason_text;
- }
- echo AuthorizeNetDPM::getRelayResponseSnippet($return_url);
- } else {
- echo "MD5 Hash failed. Check to make sure your MD5 Setting matches the one in config.php";
- }
- }
- }
- function thank_you(){
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement