Created
November 27, 2012 16:48
-
-
Save objectivehtml/4155411 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public function checkout_complete($auth, $template = NULL, $return = NULL) | |
| { | |
| /* | |
| NOTES: regarding an active session | |
| 1. logging in customer requires an active session. if run from a cul-de-sac payment gateway, the user won't be logged-in when they leave the gateway | |
| 2. Process discounts & inventory. Does this requires an active session. If so the session needs to be relaunched to handle this. | |
| so...use checkout_complete_offsite | |
| */ | |
| $auth = array_merge( | |
| array( | |
| 'processing' => FALSE, | |
| 'authorized' => FALSE, | |
| 'declined' => FALSE, | |
| 'failed' => TRUE, | |
| 'error_message' => '', | |
| 'transaction_id' => '', | |
| ), | |
| $auth | |
| ); | |
| $this->EE->cartthrob->cart->update_order(array_merge($auth, array('auth' => $auth))); | |
| $order_id = $this->EE->cartthrob->cart->order('order_id'); | |
| $this->EE->session->set_flashdata($auth); | |
| //since we use the authorized variables as tag conditionals in submitted_order_info, | |
| //we won't throw any errors from here on out | |
| $this->EE->form_builder->set_show_errors(FALSE); | |
| if (isset($_POST['ERR'])) | |
| { | |
| unset($_POST['ERR']); | |
| } | |
| // checking to see if this is already complete to keep from getting multiple emails or other processing duplication errors. | |
| $this->EE->load->model('order_model'); | |
| if ($this->EE->cartthrob->store->config('save_orders')) | |
| { | |
| $order_status = FALSE; | |
| $statuses = array( | |
| 'authorized', | |
| 'completed', | |
| 'processing', | |
| 'reversed', | |
| 'refunded', | |
| 'voided', | |
| 'expired', | |
| 'canceled', | |
| 'failed', | |
| 'declined', | |
| 'offsite' | |
| ); | |
| foreach($statuses as $index) | |
| { | |
| if(isset($auth[$index]) && $auth[$index] === TRUE) | |
| { | |
| $order_status = $index; | |
| } | |
| } | |
| $this->set_order_meta($order_id, $order_status, $this->EE->cartthrob->store->config('orders_default_status'), element('transaction_id', $auth),element('error_message', $auth), array() ); | |
| } | |
| $order_status = $this->EE->order_model->get_order_status($order_id); | |
| if ($order_status === 'authorized' || $order_status === 'completed') | |
| { | |
| if ($this->EE->cartthrob->cart->order('subscription_update_id')) | |
| { | |
| $this->apply('subscriptions', 'subscriptions_start', $auth); | |
| $this->apply('subscriptions', 'subscriptions_complete', $auth); | |
| } | |
| $this->EE->cartthrob->cart->save(); | |
| #$this->EE->cartthrob->cart->clear()->clear_totals(); | |
| $this->EE->form_builder->set_success_callback(array($this->EE->cartthrob, 'action_complete')) | |
| ->action_complete(TRUE); | |
| return NULL; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment