public function _process($params)
 {
     $transaction = new AuthorizeNetAIM($this->settings['api_login_id'], $this->settings['transaction_key']);
     $transaction->amount = $params['amount'];
     $transaction->card_num = $params['card_no'];
     $transaction->exp_date = $params['exp_month'] . $params['exp_year'];
     $transaction->card_code = $params['csc'];
     $transaction->invoice_num = $params['reference'];
     $transaction->customer_ip = $this->CI->input->ip_address();
     $transaction->setSandbox((bool) $this->settings['test_mode']);
     // set extra billing details if we have them
     if (isset($params['card_name'])) {
         $names = explode(' ', $params['card_name'], 2);
         $transaction->first_name = $names[0];
         $transaction->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('company' => 'company', 'address' => 'address', 'city' => 'city', 'state' => 'region', 'zip' => 'postcode', 'country' => 'country', 'phone' => 'phone', 'email' => 'email') as $key => $field) {
         if (isset($params[$field])) {
             $transaction->{$key} = $params[$field];
         }
     }
     $response = $transaction->authorizeAndCapture();
     if ($response->approved) {
         return new Merchant_response('authorized', $response->response_reason_text, $response->transaction_id, (double) $response->amount);
     } elseif ($response->declined) {
         return new Merchant_response('declined', $response->response_reason_text);
     } else {
         return new Merchant_response('failed', $response->response_reason_text);
     }
 }
 /**
  * [action_form] generates the form to pay at paypal
  */
 public function action_pay()
 {
     $this->auto_render = FALSE;
     $id_order = $this->request->param('id');
     //retrieve info for the item in DB
     $order = new Model_Order();
     $order = $order->where('id_order', '=', $id_order)->where('status', '=', Model_Order::STATUS_CREATED)->limit(1)->find();
     if ($order->loaded()) {
         // include class vendor
         require Kohana::find_file('vendor/authorize/', 'autoload');
         define('AUTHORIZENET_API_LOGIN_ID', Core::config('payment.authorize_login'));
         define('AUTHORIZENET_TRANSACTION_KEY', Core::config('payment.authorize_key'));
         define('AUTHORIZENET_SANDBOX', Core::config('payment.authorize_sandbox'));
         $sale = new AuthorizeNetAIM();
         $sale->amount = $order->amount;
         $sale->card_num = Core::post('card-number');
         $sale->exp_date = Core::post('expiry-month') . '/' . Core::post('expiry-year');
         $response = $sale->authorizeAndCapture();
         if ($response->approved) {
             $order->confirm_payment('authorize', $response->transaction_id);
             //redirect him to his ads
             Alert::set(Alert::SUCCESS, __('Thanks for your payment!') . ' ' . $response->transaction_id);
             $this->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'orders')));
         } else {
             Alert::set(Alert::INFO, $response->error_message);
             $this->redirect(Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order)));
         }
     } else {
         Alert::set(Alert::INFO, __('Order could not be loaded'));
         $this->redirect(Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order)));
     }
 }
Exemplo n.º 3
0
 function action($data = array(), $post = array(), $id)
 {
     $ci =& get_instance();
     $ci->load->library('session');
     if (isset($this->ini['sandbox']) && isset($this->ini['api_login_id']) && isset($this->ini['transaction_key']) && isset($post['card_num']) && isset($post['exp_date'])) {
         require dirname(__FILE__) . '/lib/shared/AuthorizeNetRequest.php';
         require dirname(__FILE__) . '/lib/shared/AuthorizeNetTypes.php';
         require dirname(__FILE__) . '/lib/shared/AuthorizeNetXMLResponse.php';
         require dirname(__FILE__) . '/lib/shared/AuthorizeNetResponse.php';
         require dirname(__FILE__) . '/lib/AuthorizeNetAIM.php';
         define("AUTHORIZENET_API_LOGIN_ID", $this->ini['api_login_id']);
         define("AUTHORIZENET_TRANSACTION_KEY", $this->ini['transaction_key']);
         define("AUTHORIZENET_SANDBOX", $this->ini['sandbox']);
         $sale = new AuthorizeNetAIM();
         $sale->amount = number_format($data['amount'], 2);
         $sale->card_num = $post['card_num'];
         $sale->exp_date = $post['exp_date'];
         $response = $sale->authorizeAndCapture();
         if ($response->approved) {
             $ci =& get_instance();
             $ci->load->model('order_m');
             $order = $ci->order_m->getOrderNumber($data['item_number']);
             if (count($order) > 0) {
                 $update['status'] = 'completed';
                 $updatehis['order_id'] = $order->id;
                 $updatehis['label'] = 'order_status';
                 $updatehis['content'] = json_encode(array($order->order_number => 'completed'));
                 $updatehis['date'] = date('Y-m-d H:i:s');
                 $ci->order_m->_table_name = 'orders';
                 if ($ci->order_m->save($update, $order->id)) {
                     $ci->order_m->_table_name = 'orders_histories';
                     $ci->order_m->save($updatehis);
                     $ci->load->helper('cms');
                     $user = $ci->session->userdata('user');
                     //params shortcode email.
                     $params = array('username' => $user['username'], 'email' => $user['email'], 'date' => date('Y-m-d H:i:s'), 'shop' => getSiteName(config_item('site_name')), 'shop_url' => site_url(), 'total' => number_format($data['amount'], 2), 'order_number' => $data['item_number'], 'status' => 'completed');
                     //config email.
                     $config = array('mailtype' => 'html');
                     $subject = configEmail('sub_order_status', $params);
                     $message = configEmail('order_status', $params);
                     $ci->load->library('email', $config);
                     $ci->email->from(getEmail(config_item('admin_email')), getSiteName(config_item('site_name')));
                     $ci->email->to($user['email']);
                     $ci->email->subject($subject);
                     $ci->email->message($message);
                     $ci->email->send();
                 }
             }
             $ci->session->set_flashdata('msg', 'Thanks you for payment!');
             if (isset($this->ini['message'])) {
                 $ci->session->set_flashdata('message', $this->ini['message']);
             }
         } else {
             $ci->session->set_flashdata('error', 'Your payment not success!');
         }
     }
     redirect(site_url('payment/confirm'));
 }
Exemplo n.º 4
0
 public function processPayment(\AuthorizeNetAIM $transaction, array $paymentDetails)
 {
     $transaction->amount = $paymentDetails['amount'];
     $transaction->card_num = $paymentDetails['card_num'];
     $transaction->exp_date = $paymentDetails['exp_date'];
     $response = $transaction->authorizeAndCapture();
     if ($response->approved) {
         return $this->savePayment($response->transaction_id);
     }
     throw new \Exception($response->error_message);
 }
Exemplo n.º 5
0
 public function testGetUnsettledTransactionList()
 {
     $sale = new AuthorizeNetAIM();
     $amount = rand(1, 100);
     $response = $sale->authorizeAndCapture($amount, '4012888818888', '04/17');
     $this->assertTrue($response->approved);
     $request = new AuthorizeNetTD();
     $response = $request->getUnsettledTransactionList();
     $this->assertTrue($response->isOk());
     $this->assertTrue($response->xml->transactions->count() >= 1);
 }
Exemplo n.º 6
0
 /**
  * Payment process and create subscription
  * @author Gaurav
  */
 public function process()
 {
     $this->layout = false;
     /*$request = new AuthorizeNetTD;
     		$transactionId = "2234120548";
     		$response = $request->getTransactionDetails($transactionId);
     		pr($response);
     		exit;
     		echo $response->xml->transaction->transactionStatus;
     
     		exit;*/
     $transaction = new AuthorizeNetAIM();
     $transaction->setSandbox(AUTHORIZENET_SANDBOX);
     $transaction->setFields(array('amount' => $this->request->data['BusinessOwner']['memberShipPrice'], 'card_num' => $this->request->data['BusinessOwner']['CC_Number'], 'exp_date' => $this->request->data['BusinessOwner']['expiration'], 'card_code' => $this->request->data['BusinessOwner']['cvv']));
     $response = $transaction->authorizeAndCapture();
     //pr($response);exit;
     if (isset($response->declined) && $response->declined == "1") {
         $errMsg = $response->response_reason_text;
         $errMsg .= "Please try again later.";
         $this->Session->setFlash(__($errMsg), 'flash_bad');
         $this->redirect(array('controller' => 'users', 'action' => 'payment'));
     }
     if (isset($response->error) && $response->error == "1") {
         $errMsg = $response->response_reason_text;
         $errMsg .= "Please try again later.";
         $this->Session->setFlash(__($errMsg), 'flash_bad');
         $this->redirect(array('controller' => 'users', 'action' => 'payment'));
     }
     if (isset($response->approved) && $response->approved == "1") {
         /*             * ***********Create Subscription****************** */
         /* $subscription = new AuthorizeNet_Subscription;
                       $subscription->name = 'Api Subscription';
                       $subscription->intervalLength = "1";
                       $subscription->intervalUnit = "months";
                       $subscription->startDate = date('Y-m-d',time());
                       $subscription->totalOccurrences = "999";
                       $subscription->amount = '50';
                       $subscription->creditCardCardNumber = $this->request->data['BusinessOwner']['CC_Number'];
                       $subscription->creditCardExpirationDate = $this->request->data['BusinessOwner']['expiration'];
                       $subscription->creditCardCardCode = $this->request->data['BusinessOwner']['cvv'];
                       $subscription->billToFirstName = 'A3';
                       $subscription->billToLastName = 'Logics';
         
                       $request = new AuthorizeNetARB;
                       $response = $request->createSubscription($subscription);
                       $subscription_id = $response->getSubscriptionId(); */
         $errMsg = "Payment Successful";
         $this->Session->setFlash(__($errMsg), 'flash_good');
         /*             * ***********Create Subscripton******************* */
         $this->redirect(array('controller' => 'users', 'action' => 'payment'));
     }
 }
 public function testGetTransactionDetails()
 {
     $sale = new AuthorizeNetAIM();
     $amount = rand(1, 100);
     $response = $sale->authorizeAndCapture($amount, '4012888818888', '04/17');
     $this->assertTrue($response->approved);
     $transId = $response->transaction_id;
     $request = new AuthorizeNetTD();
     $response = $request->getTransactionDetails($transId);
     $this->assertTrue($response->isOk());
     $this->assertEquals($transId, (string) $response->xml->transaction->transId);
     $this->assertEquals($amount, (string) $response->xml->transaction->authAmount);
     $this->assertEquals("Visa", (string) $response->xml->transaction->payment->creditCard->cardType);
 }
Exemplo n.º 8
0
 public function _process($params)
 {
     $transaction = new AuthorizeNetAIM($this->settings['api_login_id'], $this->settings['transaction_key']);
     $transaction->amount = $params['amount'];
     $transaction->card_num = $params['card_no'];
     $transaction->exp_date = $params['exp_month'] . $params['exp_year'];
     $transaction->card_code = $params['csc'];
     $transaction->invoice_num = $params['reference'];
     $transaction->setSandbox((bool) $this->settings['test_mode']);
     $response = $transaction->authorizeAndCapture();
     if ($response->approved) {
         return new Merchant_response('authorized', $response->response_reason_text, $response->transaction_id, (double) $response->amount);
     } elseif ($response->declined) {
         return new Merchant_response('declined', $response->response_reason_text);
     } else {
         return new Merchant_response('failed', $response->response_reason_text);
     }
 }
 public function process(&$payment, $action)
 {
     if (!$this->validate_billing_information($payment)) {
         wp_redirect(esc_url_raw($payment->get_checkout_url()));
         die;
     }
     if ('pending' != $payment->get_status()) {
         die;
     }
     $payment->clear_errors();
     if (!class_exists('AuthorizeNetAIM')) {
         require_once WPBDP_PATH . 'vendors/anet_php_sdk/AuthorizeNet.php';
     }
     if ($payment->has_item_type('recurring_fee')) {
         // TODO: round fees not within 7-365 days (or make non-recurring).
         return $this->process_recurring($payment);
     }
     $data = $payment->get_data('billing-information');
     $aim = new AuthorizeNetAIM(wpbdp_get_option('authorize-net-login-id'), wpbdp_get_option('authorize-net-transaction-key'));
     if (wpbdp_get_option('payments-test-mode')) {
         $aim->setSandbox(true);
     } else {
         $aim->setSandbox(false);
     }
     // Order info.
     $aim->setFields(array('amount' => $payment->get_total(), 'description' => $payment->get_short_description(), 'invoice_num' => $payment->get_id()));
     // Card info.
     $aim->setFields(array('card_num' => $data['cc_number'], 'exp_date' => $data['cc_exp_month'] . substr($data['cc_exp_year'], 0, 2), 'card_code' => $data['cc_cvc']));
     // Billing addres info.
     $aim->setFields(array('first_name' => $data['first_name'], 'last_name' => $data['last_name'], 'address' => $data['address_line1'], 'city' => $data['address_city'], 'state' => $data['address_state'], 'country' => $data['address_country'], 'zip' => $data['zipcode']));
     // TODO: maybe add zip, phone, email and cust_id
     $aim->setCustomField('payment_id', $payment->get_id());
     $aim->setCustomField('listing_id', $payment->get_listing_id());
     $response = $aim->authorizeAndCapture();
     if ($response->approved) {
         $payment->set_status(WPBDP_Payment::STATUS_COMPLETED, WPBDP_Payment::HANDLER_GATEWAY);
     } elseif ($response->error) {
         $payment->set_data('validation-errors', array(sprintf(_x('The payment gateway didn\'t accept your credit card or billing information. The following reason was given: "%s".', 'authorize-net', 'WPBDM'), '(' . $response->response_reason_code . ') ' . rtrim($response->response_reason_text, '.'))));
     } elseif ($response->held) {
         $payment->add_error(sprintf(_x('Your payment is being held for review by the payment gateway. The following reason was given: "%s".', 'authorize-net', 'WPBDM'), '(' . $response->response_reason_code . ') ' . rtrim($response->response_reason_text, '.')));
     } else {
         $payment->add_error(sprintf(_x('Payment was rejected. The following reason was given: "%s".', 'authorize-net', 'WPBDM'), '(' . $response->response_reason_code . ') ' . rtrim($response->response_reason_text, '.')));
         $payment->set_status(WPBDP_Payment::STATUS_REJECTED, WPBDP_Payment::HANDLER_GATEWAY);
     }
     $payment->save();
     wp_redirect(esc_url_raw($payment->get_redirect_url()));
     die;
 }
Exemplo n.º 10
0
 /**
  * {@inheritDoc}
  */
 public function setField($name, $value)
 {
     // the _all_aim_fields is private so we cannot check that.
     try {
         parent::setField($name, $value);
     } catch (\AuthorizeNetException $e) {
         if ($this->ignore_not_x_fields) {
             return;
         }
         throw $e;
     }
 }
Exemplo n.º 11
0
 /**
  * Do AIM payment.
  */
 public function executeAuthorizeNetAIM()
 {
     include_once AB_PATH . '/lib/payment/authorize.net/autoload.php';
     $response = null;
     $userData = new AB_UserBookingData($this->getParameter('form_id'));
     if ($userData->load()) {
         define("AUTHORIZENET_API_LOGIN_ID", get_option('ab_authorizenet_api_login_id'));
         define("AUTHORIZENET_TRANSACTION_KEY", get_option('ab_authorizenet_transaction_key'));
         define("AUTHORIZENET_SANDBOX", (bool) get_option('ab_authorizenet_sandbox'));
         $price = $userData->getFinalServicePrice() * $userData->get('number_of_persons');
         $sale = new AuthorizeNetAIM();
         $sale->amount = $price;
         $sale->card_num = $this->getParameter('ab_card_number');
         $sale->card_code = $this->getParameter('ab_card_code');
         $sale->exp_date = $this->getParameter('ab_card_month') . '/' . $this->getParameter('ab_card_year');
         $sale->first_name = $userData->get('name');
         $sale->email = $userData->get('email');
         $sale->phone = $userData->get('phone');
         $response = $sale->authorizeAndCapture();
         if ($response->approved) {
             /** @var AB_Appointment $appointment */
             $appointment = $userData->save();
             $customer_appointment = new AB_CustomerAppointment();
             $customer_appointment->loadBy(array('appointment_id' => $appointment->get('id'), 'customer_id' => $userData->getCustomerId()));
             $payment = new AB_Payment();
             $payment->set('total', $price);
             $payment->set('type', 'authorizeNet');
             $payment->set('customer_appointment_id', $customer_appointment->get('id'));
             $payment->set('created', current_time('mysql'));
             $payment->save();
             $response = array('state' => 'success');
         } else {
             $response = array('status' => 'error', 'error' => $response->response_reason_text);
         }
     } else {
         $response = array('status' => 'error', 'error' => __('Session error.', 'bookly'));
     }
     wp_send_json($response);
 }
Exemplo n.º 12
0
 public function process_payment($order_id)
 {
     error_reporting(0);
     $order = $this->api->getOrderByID($order_id);
     $this->load_config();
     $sandbox = true;
     if ($this->m_config['AUTHORIZENET_SANDBOX']) {
         $sandbox = false;
     }
     $amount = $order->gross * 100;
     $currency = $order->currency;
     $cardnumber = str_replace(" ", "", $_POST['credit_card_number']);
     $cardname = $_POST['credit_card_name'];
     $cardtype = $_POST['credit_card_type'];
     $cvnnumber = $_POST['credit_card_cvn'];
     $expdate = $_POST['credit_card_exp_month'] . $_POST['credit_card_exp_year'];
     // API credentials only need to be defined once
     define("AUTHORIZENET_API_LOGIN_ID", $this->m_config['AUTHORIZENET_API_LOGIN_ID']);
     define("AUTHORIZENET_TRANSACTION_KEY", $this->m_config['AUTHORIZENET_TRANSACTION_KEY']);
     define("AUTHORIZENET_SANDBOX", $sandbox);
     $sale = new AuthorizeNetAIM();
     $sale->amount = $amount;
     $sale->card_num = $cardnumber;
     $sale->exp_date = $expdate;
     if ($this->m_config['transaction_method'] == 'authorization') {
         $response = $sale->authorizeOnly();
     } elseif ($this->m_config['transaction_method'] == 'capture') {
         $response = $sale->authorizeAndCapture();
     }
     if ($response->approved) {
         $order->paid();
         echo "<h2>Your payment was successfully processed. Thank you!</h2>";
         echo "Success! Transaction ID:" . $response->transaction_id;
     } else {
         echo "<h2>Your card was declined.</h2>";
     }
 }
Exemplo n.º 13
0
 public function processTransaction($data)
 {
     $log = Logger::getInstance();
     $log->LogDebug("process transaction authorize - ");
     //creditCard,$order,$customer
     $customer = (object) array();
     $customer->first_name = $data->reservationData->userData->first_name;
     $customer->last_name = $data->reservationData->userData->last_name;
     $customer->address = $data->reservationData->userData->address;
     $customer->city = $data->reservationData->userData->city;
     $customer->state = $data->reservationData->userData->state_name;
     $customer->country = $data->reservationData->userData->country;
     $customer->email = $data->reservationData->userData->email;
     $order = array('description' => JText::_('LNG_ORDER_DESC') . ' ' . $data->reservationData->hotel->hotel_name . '(' . $data->reservationData->userData->start_date . '-' . $data->reservationData->userData->end_date . ')', 'invoice_num' => $data->confirmation_id);
     $result = new stdClass();
     $result->card_name = JRequest::getVar("card_name", null);
     $result->card_number = JRequest::getVar("card_number", null);
     $result->card_expiration_year = JRequest::getVar("card_expiration_year", null);
     $result->card_expiration_month = JRequest::getVar("card_expiration_month", null);
     $result->card_security_code = JRequest::getVar("card_security_code", null);
     $result->amount = $data->cost > 0 ? $data->cost : $data->total;
     $creditCard = array('exp_date' => $result->card_expiration_month . "" . substr($result->card_expiration_year, -2), 'card_num' => $result->card_number, 'amount' => $result->amount);
     $sale = new AuthorizeNetAIM($this->AUTHORIZENET_API_LOGIN_ID, $this->AUTHORIZENET_TRANSACTION_KEY);
     if ($this->AUTHORIZENET_SANDBOX == 'false') {
         $sale->setSandbox(false);
     } else {
         $sale->setSandbox(true);
     }
     $sale->setFields($creditCard);
     $sale->setFields($order);
     $sale->setFields($customer);
     $response = $sale->authorizeAndCapture();
     $log->LogDebug("process response authorize -  " . serialize($response));
     if (isset($response->approved) && $response->approved == 1) {
         $result->status = PAYMENT_SUCCESS;
         $result->payment_status = PAYMENT_STATUS_PAID;
     } else {
         $result->status = PAYMENT_ERROR;
         $result->payment_status = PAYMENT_STATUS_FAILURE;
         $result->error_message = $response->error_message;
     }
     $result->transaction_id = 0;
     $result->payment_date = date("Y-m-d");
     $result->response_code = $response->approved;
     $result->confirmation_id = $data->confirmation_id;
     $result->processor_type = $this->type;
     return $result;
 }
Exemplo n.º 14
0
 public function processTransaction($data)
 {
     //creditCard,$order,$customer
     $customer = (object) array();
     $customer->first_name = "George";
     $customer->last_name = "Bara";
     $this->amount = $data->amount;
     $this->itemName = $data->service . " " . $data->description;
     $this->itemNumber = $data->id;
     $order = array('description' => $data->service . " " . $data->description, 'invoice_num' => $data->id);
     $result = new stdClass();
     $result->card_name = JRequest::getVar("card_name", null);
     $result->card_number = JRequest::getVar("card_number", null);
     $result->card_expiration_year = JRequest::getVar("card_expiration_year", null);
     $result->card_expiration_month = JRequest::getVar("card_expiration_month", null);
     $result->card_security_code = JRequest::getVar("card_security_code", null);
     $result->amount = $data->amount;
     $creditCard = array('exp_date' => $result->card_expiration_month . "" . substr($result->card_expiration_year, -2), 'card_num' => $result->card_number, 'amount' => $result->amount);
     $authorize = new AuthorizeNetAIM($this->apiLoginId, $this->transactionKey);
     if ($this->mode == "test") {
         $authorize->setSandbox(true);
     } else {
         $authorize->setSandbox(false);
     }
     $authorize->setFields($creditCard);
     $authorize->setFields($order);
     $authorize->setFields($customer);
     $response = $authorize->authorizeAndCapture();
     dump($response);
     if (isset($response->approved) && $response->approved == 1) {
         $result->status = PAYMENT_SUCCESS;
         $result->payment_status = PAYMENT_STATUS_PAID;
     } else {
         $result->status = PAYMENT_ERROR;
         $result->payment_status = PAYMENT_STATUS_FAILURE;
         $result->error_message = $response->error_message;
     }
     $result->transaction_id = $response->transaction_id;
     $result->payment_date = date("Y-m-d");
     $result->response_code = $response->approved;
     $result->order_id = $data->id;
     $result->processor_type = $this->type;
     return $result;
 }
Exemplo n.º 15
0
function authorizepayment($REQUEST)
{
    if (!checkCreditCard($REQUEST['x_card_num'], $REQUEST['card_type'], $ccerror, $ccerrortext)) {
        $_SESSION['donate_msg'] = 'Please enter a valid credit card number.';
        return false;
    } else {
        $transaction = new AuthorizeNetAIM();
        $transaction->setSandbox(AUTHORIZENET_SANDBOX);
        $transaction->setFields(array('amount' => $REQUEST['amount'], 'card_num' => $REQUEST['x_card_num'], 'exp_date' => $REQUEST['exp_month'] . '/' . $REQUEST['exp_year'], 'first_name' => $REQUEST['first_name'], 'last_name' => $REQUEST['last_name'], 'address' => $REQUEST['address'], 'city' => $REQUEST['city'], 'state' => $REQUEST['state'], 'country' => $REQUEST['country'], 'zip' => $REQUEST['zip'], 'email' => $REQUEST['email']));
        $transaction->setCustomField("Donation Form", $REQUEST["form_id"]);
        $transaction->setCustomField("Donation Type", $REQUEST["donation_type"]);
        $transaction->addLineItem("Donation", "Donation to '" . get_bloginfo("name") . "'", "Donation to '" . get_bloginfo("name") . "' using the form: " . $REQUEST["form_id"], 1, $REQUEST['amount'], false);
        $response = $transaction->authorizeAndCapture();
        if ($response->approved) {
            $_SESSION['donate_msg'] = $response->response_reason_text;
            return true;
        } else {
            $_SESSION['donate_msg'] = $response->response_reason_text;
            return false;
        }
    }
}
Exemplo n.º 16
0
<?php

session_start();
if ($_POST) {
    require_once 'AuthorizeNet.php';
    define("AUTHORIZENET_API_LOGIN_ID", "86jrDx8naX49");
    define("AUTHORIZENET_TRANSACTION_KEY", "8x88td44D8PFgeS5");
    define("AUTHORIZENET_SANDBOX", true);
    $sale = new AuthorizeNetAIM();
    //check deal quantity availability
    require_once $_SERVER['DOCUMENT_ROOT'] . "/system/includes/transaction.php";
    $USERID = $_SESSION['userid'];
    //check whether deal is expired or closed
    is_deal_expired($_POST['couponid']);
    check_max_deal_purchase($_POST['couponid'], $_POST["friendname"], $_POST["friendemail"], $_POST['qty'], $USERID);
    check_deal_quantity($_POST['couponid'], $_POST["friendname"], $_POST["friendemail"], $_POST['qty']);
    $USERID = $userid = $_SESSION['userid'];
    if ($_POST['ref_amt2'] > 0) {
        $user = "******";
        $userSet = mysql_query($user);
        while ($r = mysql_fetch_array($userSet)) {
            $account_balance = round($r['referral_earned_amount'], 2);
        }
        $deductable_ref_amt = round($_POST['ref_amt2'], 2);
        //referral amount validation
        if ($deductable_ref_amt > $account_balance) {
            $cid = $_POST['couponid'];
            if ($_POST["friendname"] != '' && $_POST["friendemail"] != '') {
                set_response_mes(-1, "Insufficient referral amount in your account.");
                url_redirect(DOCROOT . "purchase.html?cid=" . $cid . "&type=gift");
            } else {
Exemplo n.º 17
0
function espresso_process_aim($payment_data)
{
    extract($payment_data);
    global $wpdb, $org_options;
    require_once 'AuthorizeNet.php';
    $authnet_aim_settings = get_option('event_espresso_authnet_aim_settings');
    $authnet_aim_login_id = $authnet_aim_settings['authnet_aim_login_id'];
    $authnet_aim_transaction_key = $authnet_aim_settings['authnet_aim_transaction_key'];
    // Enable test mode if needed
    //4007000000027  <-- test successful visa
    //4222222222222  <-- test failure card number
    if ($authnet_aim_settings['use_sandbox']) {
        define("AUTHORIZENET_SANDBOX", true);
        define("AUTHORIZENET_LOG_FILE", true);
    } else {
        define("AUTHORIZENET_SANDBOX", false);
    }
    //start transaction
    $transaction = new AuthorizeNetAIM($authnet_aim_login_id, $authnet_aim_transaction_key);
    echo '<!--Event Espresso Authorize.net AIM Gateway Version ' . $transaction->gateway_version . '-->';
    $transaction->amount = $_POST['amount'];
    $transaction->card_num = $_POST['card_num'];
    $transaction->exp_date = $_POST['exp_date'];
    $transaction->card_code = $_POST['ccv_code'];
    $transaction->first_name = $_POST['first_name'];
    $transaction->last_name = $_POST['last_name'];
    $transaction->email = $_POST['email'];
    $transaction->address = $_POST['address'];
    $transaction->city = $_POST['city'];
    $transaction->state = $_POST['state'];
    $transaction->zip = $_POST['zip'];
    $transaction->cust_id = $_POST['x_cust_id'];
    $transaction->invoice_num = $_POST['invoice_num'];
    if ($authnet_aim_settings['test_transactions']) {
        $transaction->test_request = "true";
    }
    $payment_data['txn_type'] = 'authorize.net AIM';
    $payment_data['payment_status'] = 'Incomplete';
    $payment_data['txn_id'] = 0;
    $payment_data['txn_details'] = 'No response from authorize.net';
    $payment_data = apply_filters('filter_hook_espresso_prepare_event_link', $payment_data);
    $payment_data = apply_filters('filter_hook_espresso_get_total_cost', $payment_data);
    //Capture response
    $response = $transaction->authorizeAndCapture();
    if (!empty($response)) {
        if ($authnet_aim_settings['use_sandbox']) {
            $payment_data['txn_id'] = $response->invoice_number;
        } else {
            $payment_data['txn_id'] = $response->transaction_id;
        }
        $payment_data['txn_details'] = serialize($response);
        if ($response->approved) {
            $payment_data['payment_status'] = 'Completed';
            ?>
			<h2><?php 
            _e('Thank You!', 'event_espresso');
            ?>
</h2>
			<p><?php 
            _e('Your transaction has been processed.', 'event_espresso');
            ?>
</p>
			<p><?php 
            __('Transaction ID:', 'event_espresso') . $response->transaction_id;
            ?>
</p>
			<?php 
        } else {
            print $response->error_message;
            $payment_data['payment_status'] = 'Payment Declined';
        }
    } else {
        ?>
		<p><?php 
        _e('There was no response from Authorize.net.', 'event_espresso');
        ?>
</p>
		<?php 
    }
    add_action('action_hook_espresso_email_after_payment', 'espresso_email_after_payment');
    return $payment_data;
}
Exemplo n.º 18
0
 $amount_to_pay = $res['price'];
 if ($res['promo_price'] > 0) {
     $amount_to_pay = $res['promo_price'];
 }
 $amount_to_pay = is_numeric($amount_to_pay) ? normalPrettyPrice($amount_to_pay) : '';
 $amount_to_pay = unPrettyPrice($amount_to_pay);
 $payment_description .= isset($res['title']) ? $res['title'] : '';
 /*dump($amount_to_pay);
 	dump($payment_description);*/
 if (isset($_POST['x_card_num'])) {
     define("AUTHORIZENET_API_LOGIN_ID", $autho_api_id);
     define("AUTHORIZENET_TRANSACTION_KEY", $autho_key);
     define("AUTHORIZENET_SANDBOX", $mode_autho == "sandbox" ? true : false);
     //define("TEST_REQUEST", $mode_autho=="sandbox"?"FALSE":"TRUE");
     require_once 'anet_php_sdk/AuthorizeNet.php';
     $transaction = new AuthorizeNetAIM();
     $transaction->setSandbox(AUTHORIZENET_SANDBOX);
     $params = array('description' => $payment_description, 'amount' => $amount_to_pay, 'card_num' => $_POST['x_card_num'], 'exp_date' => $_POST['expiration_month'] . "/" . $_POST['expiration_yr'], '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'], 'card_code' => $_POST['cvv']);
     $transaction->setFields($params);
     $response = $transaction->authorizeAndCapture();
     if ($response->approved) {
         $resp_transaction = $response->transaction_id;
         $params = array('merchant_id' => Yii::app()->functions->getMerchantID(), 'sms_package_id' => $package_id, 'payment_type' => $payment_code, 'package_price' => $amount_to_pay, 'sms_limit' => isset($res['sms_limit']) ? $res['sms_limit'] : '', 'date_created' => date('c'), 'ip_address' => $_SERVER['REMOTE_ADDR'], 'payment_gateway_response' => json_encode($response), 'status' => "paid", 'payment_reference' => $resp_transaction);
         if ($db_ext->insertData("{{sms_package_trans}}", $params)) {
             header('Location: ' . Yii::app()->request->baseUrl . "/merchant/smsReceipt/id/" . Yii::app()->db->getLastInsertID());
         } else {
             $error = Yii::t("default", "ERROR: Cannot insert record.");
         }
     } else {
         $error = $response->response_reason_text;
     }
Exemplo n.º 19
0
 public function testInvalidCredentials()
 {
     if (MERCHANT_LIVE_API_LOGIN_ID) {
         // Post a response to live server using invalid credentials.
         $sale = new AuthorizeNetAIM('a', 'a');
         $sale->setSandbox(false);
         $sale->setFields(array('amount' => rand(1, 1000), 'card_num' => '6011000000000012', 'exp_date' => '0415'));
         $response = $sale->authorizeAndCapture();
         $this->assertTrue($response->error);
         $this->assertEquals("13", $response->response_reason_code);
     }
 }
Exemplo n.º 20
0
 /**
  * process a AIM transaction with authorize.net
  *
  * @return  Boolean,Int false on failure
  */
 public function anet_AIM()
 {
     // DEV RETURN TRUE
     return true;
     unset($this->_responses['last']);
     unset($this->_responses['TransactionResponse']);
     unset($this->_responses['CustomerProfileResponse']);
     unset($this->_responses['PaymentProfileResponse']);
     $anet = new AuthorizeNetAIM();
     $anet->amount = $this->amounts['total']->formatted;
     $anet->card_num = $this->info->card_num;
     $anet->card_code = $this->info->card_code;
     $anet->exp_date = $this->info->exp_date;
     $anet->description = $this->info->description;
     $anet->first_name = $this->info->first_name;
     $anet->last_name = $this->info->last_name;
     $anet->address = $this->info->address;
     $anet->city = $this->info->city;
     $anet->state = $this->info->state;
     $anet->zip = $this->info->zip;
     $anet->cust_id = $this->info->CustomerID;
     $anet->customer_ip = $this->info->customer_ip;
     $anet->trans_id = $this->old_trans_id;
     $anet->email = $this->info->email;
     if ($this->info->card_num) {
         $this->PymtRefCrdCd = substr($this->info->card_num, -4);
     }
     $anet->duplicate_window = AUTHORIZENET_DUPLICATE_WINDOW;
     if ($this->amounts['total']->rounded < 0) {
         $anet->amount = -$this->amounts['total']->rounded;
         $this->_responses['last'] = $anet->credit();
     } elseif ($this->amounts['total']->rounded > 0) {
         $this->_responses['last'] = $anet->authorizeAndCapture();
     } else {
         return 1;
     }
     if ($this->_responses['last']->approved) {
         $this->_responses['TransactionResponse'] = $this->_responses['last'];
         $this->_responses['last'] = $this->_responses['TransactionResponse'];
         $this->PymtRefCd = $this->_responses['TransactionResponse']->transaction_id;
         $this->PymtRefCrdCd = substr($this->_responses['TransactionResponse']->account_number, -4);
         $this->card_type = $this->_responses['TransactionResponse']->card_type;
         return true;
     } else {
         if ($this->debug) {
             ri($anet);
         }
         return false;
     }
 }
Exemplo n.º 21
0
<?php

require_once 'AuthorizeNet.php';
// Make sure this path is correct.
$transaction = new AuthorizeNetAIM('9p5nJ37UvTZX', '4V4h8M6h87UsM353');
$transaction->amount = '9.99';
$transaction->card_num = '4007000000027';
$transaction->exp_date = '10/16';
$response = $transaction->authorizeAndCapture();
if ($response->approved) {
    echo "<h1>Success! The test credit card has been charged!</h1>";
    echo "Transaction ID: " . $response->transaction_id;
} else {
    echo $response->error_message;
}
function authorizenet_capture_meta_box_action($order_id, $items)
{
    if (isset($items['_authorizenet_capture_charge']) && 1 == $items['_authorizenet_capture_charge']) {
        global $woocommerce;
        $wc_order = new WC_Order($order_id);
        $trx_id = get_post_meta($order_id, '_transaction_id', true);
        $amount = $wc_order->order_total;
        if (class_exists('WC_Authorizenet_Gateway')) {
            $authorizemetpg = new WC_Authorizenet_Gateway();
        }
        $capture = new AuthorizeNetAIM();
        $capturetrx = $capture->priorAuthCapture($trx_id, $amount);
        if (1 == $capturetrx->approved) {
            $wc_order->add_order_note(__($capturetrx->response_reason_text . 'on' . date("d-m-Y h:i:s e") . 'with Transaction ID = ' . $capturetrx->transaction_id . ' using ' . strtoupper($capturetrx->transaction_type) . ' and authorization code ' . $capturetrx->authorization_code, 'woocommerce'));
            update_post_meta($order_id, '_authorizenet_charge_status', 'charge_auth_captured_later');
        } else {
            $wc_order->add_order_note(__($capturetrx->response_reason_text . '-' . $capturetrx->error_message . ' on ' . date("d-m-Y h:i:s e") . ' using ' . strtoupper($capturetrx->transaction_type), 'woocommerce'));
        }
    }
}
Exemplo n.º 23
0
 private static function get_aim($local_api_settings = array())
 {
     self::include_api();
     $api_settings = self::get_api_settings($local_api_settings);
     $is_sandbox = $api_settings['mode'] == "test";
     $aim = new AuthorizeNetAIM($api_settings['login_id'], $api_settings['transaction_key']);
     $aim->setSandbox($is_sandbox);
     return $aim;
 }
Exemplo n.º 24
0
 public function executeProcessSale()
 {
     $this->setLayout(false);
     $this->result = false;
     $request = $this->getRequest();
     $request->setParameter('x_exp_date', $this->getRequestParameter("exp_month") . "/" . $this->getRequestParameter("exp_year"));
     $request->setParameter("exp_month", "");
     $request->setParameter("exp_year", "");
     if ($this->getRequestParameter("submitted")) {
         if (array_key_exists("cart", $_SESSION)) {
             $products = array();
             foreach ($_SESSION["cart"] as $item) {
                 $doc = Document::getDocumentInstance($item);
                 if ($doc) {
                     $cnt = $_SESSION["num"][$item];
                     if (!$cnt) {
                         $cnt = 1;
                     }
                     $price = $doc->getPrice();
                     $price = $price * $cnt;
                     echo "price:" . $price . "<br>";
                     $totalPrice += $price;
                 }
             }
             $totalPrice += round($totalPrice * (UtilsHelper::Settings("taxes") / 100), 2);
         }
         require_once sfConfig::get('sf_web_dir') . '/anet_php_sdk/AuthorizeNet.php';
         $transaction = new AuthorizeNetAIM();
         $transaction->setSandbox(AUTHORIZENET_SANDBOX);
         $transaction->setFields(array('amount' => $totalPrice, 'card_num' => $this->getRequestParameter('x_card_num'), 'exp_date' => $this->getRequestParameter('x_exp_date'), 'first_name' => $this->getRequestParameter('x_first_name'), 'last_name' => $this->getRequestParameter('x_last_name'), 'address' => $this->getRequestParameter('x_address'), 'email' => $this->getRequestParameter('x_email'), 'city' => $this->getRequestParameter('x_city'), 'state' => $this->getRequestParameter('x_state'), 'country' => $this->getRequestParameter('x_country'), 'zip' => $this->getRequestParameter('x_zip'), 'email' => $this->getRequestParameter('x_email'), 'card_code' => $this->getRequestParameter('x_card_code')));
         $transaction->setCustomFields(array('products' => $this->getRequestParameter('x_delivery_address')));
         $response = $transaction->authorizeAndCapture();
         $this->response = $response;
         if (!$this->getRequestParameter('terms')) {
             $request->setError('errterms', "Please accept the terms of use");
             UtilsHelper::setFlashMsg('', UtilsHelper::MSG_ERROR);
         } else {
             if ($response->approved) {
                 $this->result = "success";
                 $this->transaction_id = $response->transaction_id;
                 $message = "\n\t\t\t\t\tYou successfully ordered products from SubcommPools.com<br>\n\t\t\t\t\t<br>Date:" . date('l jS \\of F Y h:i:s A') . "<br>\n\t\t\t\t\t<br>Transaction number:" . $response->transaction_id . "<br>\n\t\t\t\t\t<br>Name: " . $this->getRequestParameter('x_first_name') . " " . $this->getRequestParameter('x_last_name') . "<br>\n\t\t\t\t\t<br>-------------------<br><br>";
                 foreach ($_SESSION["cart"] as $item) {
                     $doc = Document::getDocumentInstance($item);
                     if ($doc) {
                         $itemCnt = $_SESSION["num"][$item];
                         if (!$itemCnt) {
                             $itemCnt = 1;
                         }
                         $itemPrice = $doc->getPrice();
                         $itemPrice = $itemPrice * $cnt;
                         $message .= $doc->getLabel() . ", Quantity: " . $itemCnt . ", \$" . $itemPrice . "<br>";
                     }
                 }
                 $message .= "<br>Total+Tax: \$" . $totalPrice . "<br>\n\t\t\t\t\t<br>Thank you for your purchase.";
                 UtilsHelper::sendEmail($this->getRequestParameter('x_email'), $message, "SubcommPools Purchase", UtilsHelper::Settings("main_email"), "SubcommPools", UtilsHelper::Settings("main_email"));
                 $_SESSION["cart"] = null;
                 $_SESSION["num"] = null;
             } else {
                 $this->response_text = $response->response_reason_text;
                 //var_dump($response);
                 $request->setError('errsubmit', $response->response_reason_text);
                 UtilsHelper::setFlashMsg('', UtilsHelper::MSG_ERROR);
                 //$this->result = $response->response_reason_text;
                 //header('Location: error_page.php?response_reason_code='.$response->response_reason_code.'&response_code='.$response->response_code.'&response_reason_text=' .$response->response_reason_text);
             }
         }
     }
 }
Exemplo n.º 25
0
<?php

require_once 'coffee_store_settings.php';
/**
* Demonstrates how to void a charge using the Authorize.Net SDK.
*/
$transaction = new AuthorizeNetAIM();
$response = $transaction->void($_POST['transaction_id']);
if ($response->approved) {
    // Transaction approved! Do your logic here.
    header('Location: refund_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);
}
Exemplo n.º 26
0
 public function setup(\Foundation\Form\Input $input)
 {
     parent::setup($input);
     $this->_paymentType->setClass('\\Jazzee\\PaymentType\\AuthorizeNetDPM');
 }
Exemplo n.º 27
0
 public function get_login($plan)
 {
     if ($plan == 'A') {
         $userdata = array('first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name'), 'email' => Input::get('email'), 'username' => Input::get('username'), 'password' => Hash::make(Input::get('password')), 'address' => Input::get('address'), 'city' => Input::get('city'), 'state' => Input::get('state'), 'zipcode' => Input::get('zipcode'), 'country' => Input::get('country'), 'bgcolor' => "58,104,210", 'fontcolor' => "255,255,255", 'logo' => "http://minitmeet.com/img/logo.png", 'company_name' => Input::get('company_name'));
         $rules = array('first_name' => 'required', 'last_name' => 'required', 'email' => 'required|min:3|max:32|Unique:users,email', 'username' => 'Required|Min:3|Max:80|Regex:/^([a-z0-9- ])+$/i|Unique:users', 'password' => 'required|min:6|max:32', 'captcha' => 'required', 'address' => 'required', 'state' => 'required', 'country' => 'required', 'zipcode' => 'required', 'company_name' => 'required|alpha_num');
         $input = Input::all();
         $v = Validator::make($input, $rules);
         if ($v->fails()) {
             return Redirect::to('register')->withInput(Input::except('password'))->withErrors($v);
         } else {
             $data = $userdata;
             $pass = Input::get('password');
             DB::table('users')->insert($data);
             DB::table('users')->where('email', $data['email'])->update(array('plan' => $plan));
             $mail = Mail::send('emails.message', array('data' => $data, 'plan' => $plan, 'pass' => $pass), function ($message) {
                 $data = Session::get('data');
                 $message->to($data['email'])->subject('Minitmeet');
             });
             return Redirect::to('login')->with('success', 'You Have been Registered Succesfully');
         }
     } elseif ($plan == 'B' or $plan == 'C') {
         $rules = array('payment_type' => 'required');
         $input = Input::all();
         $v = Validator::make($input, $rules);
         if ($v->fails()) {
             return Redirect::to('register')->withInput(Input::except('password'))->withErrors($v);
         } else {
             if ($_POST['payment_type'] == "1") {
                 $userdata = array('first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name'), 'email' => Input::get('email'), 'username' => Input::get('username'), 'password' => Hash::make(Input::get('password')), 'address' => Input::get('address'), 'city' => Input::get('city'), 'state' => Input::get('state'), 'zipcode' => Input::get('zipcode'), 'country' => Input::get('country'), 'bgcolor' => "58,104,210", 'fontcolor' => "255,255,255", 'logo' => "http://minitmeet.com/img/logo.png", 'company_name' => Input::get('company_name'));
                 $rules = array('first_name' => 'required', 'last_name' => 'required', 'email' => 'required|min:3|max:32|Unique:users,email', 'address' => 'required', 'state' => 'required', 'country' => 'required', 'zipcode' => 'required', 'username' => 'Required|Min:3|Max:80|Regex:/^([a-z0-9- ])+$/i|Unique:users', 'password' => 'required|min:6|max:32', 'company_name' => 'required|alpha_num');
                 $input = Input::all();
                 $v = Validator::make($input, $rules);
                 if ($v->fails()) {
                     return Redirect::to('register')->withInput(Input::except('password'))->withErrors($v);
                 } else {
                     Session::put('get_plan', $plan);
                     Session::put('data', $userdata);
                     return Redirect::to('onepagecheckout');
                 }
             }
             if ($_POST['payment_type'] == "2") {
                 $userdata = array('first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name'), 'email' => Input::get('email'), 'username' => Input::get('username'), 'password' => Hash::make(Input::get('password')), 'address' => Input::get('address'), 'city' => Input::get('city'), 'state' => Input::get('state'), 'zipcode' => Input::get('zipcode'), 'country' => Input::get('country'), 'bgcolor' => "58,104,210", 'fontcolor' => "255,255,255", 'logo' => "http://minitmeet.com/img/logo.png", 'company_name' => Input::get('company_name'));
                 $rules = array('first_name' => 'required', 'last_name' => 'required', 'email' => 'required|min:3|max:32|Unique:users,email', 'address' => 'required', 'state' => 'required', 'country' => 'required', 'zipcode' => 'required', 'username' => 'Required|Min:3|Max:80|Regex:/^([a-z0-9- ])+$/i|Unique:users', 'password' => 'required|min:6|max:32', 'company_name' => 'required|alpha_num', 'card_number' => 'required', 'month' => 'required');
                 $input = Input::all();
                 $v = Validator::make($input, $rules);
                 if ($v->fails()) {
                     return Redirect::to('register')->withInput(Input::except('password'))->withErrors($v);
                 } else {
                     $card_num = Input::get('card_number');
                     $month = Input::get('month');
                     $year = Input::get('year');
                     $type = Input::get('card_type');
                     $plan = Session::get('plan');
                     $am = DB::table('plan')->where('plan_name', Session::get('plan'))->first();
                     $amount = $am->plan_price;
                     $data = $userdata;
                     $pass = Input::get('password');
                     require_once 'anet_php_sdk/AuthorizeNet.php';
                     // Make sure this path is correct.
                     $transaction = new AuthorizeNetAIM('9Hs3U7ePV', '7Fjj4kLu39LL62V2');
                     $transaction->amount = $amount;
                     $transaction->card_num = $card_num;
                     $transaction->exp_date = $month . "/" . $year;
                     //$transaction->bank_aba_code = $type;
                     $response = $transaction->authorizeAndCapture();
                     if ($response->approved) {
                         DB::table('users')->insert($data);
                         DB::table('users')->where('email', $data['email'])->update(array('plan' => $plan));
                         $id = DB::table('users')->where('email', $data['email'])->get(array('id'));
                         DB::table('transaction_id')->insert(array('user_id' => $id[0]->id, 'transaction_id' => $response->transaction_id, 'payer_email' => $data['email'], 'txn_type' => "authorise", 'payment_status' => $response->response_code, 'address' => $data['address'], 'zipcode' => $data['zipcode'], 'state' => $data['state'], 'country' => $data['country']));
                         DB::table('transaction_list')->insert(array('transaction_id' => $response->transaction_id, 'amount' => $amount, 'email' => $data['email'], 'medium' => "authorise", 'firstname' => $data['first_name'], 'lastname' => $data['last_name']));
                         $mail = Mail::send('emails.message', array('data' => $data, 'plan' => $plan, 'pass' => $pass), function ($message) {
                             $message->to(Input::get('email'))->subject('Minitmeet');
                         });
                         Session::flush();
                         $responsetext = "Transaction Done.Your transaction Id is: {$response->transaction_id}.Enter Username and password to Login";
                         //echo $responsetext; die();
                         return Redirect::to('login')->with('success', $responsetext);
                     } else {
                         return Redirect::to('register')->with('success', $response->error_message)->with('plan', $plan);
                     }
                 }
             }
         }
     }
 }
 /**
  * Get the AuthorizeNetAIM object and set up basic parameters
  * @return AuthorizeNetAIM
  */
 function get_api()
 {
     if (!class_exists('AuthorizeNetAIM')) {
         require_once 'anet_php_sdk/AuthorizeNet.php';
     }
     //Basic Credentials
     $sale = new AuthorizeNetAIM(get_option('em_' . $this->gateway . '_api_user'), get_option('em_' . $this->gateway . '_api_key'));
     if (get_option('em_' . $this->gateway . '_mode') == 'live') {
         $sale->setSandbox(false);
     } else {
         $sale->setSandbox(true);
     }
     return $sale;
 }
 public function testUpdateSplitTenderGroup()
 {
     // Create a partial auth test transaction
     $amount = 4.92;
     
     $sale = new AuthorizeNetAIM;
     $sale->amount = $amount;
     $sale->card_num = '4222222222222';
     $sale->zip = "46225";
     $sale->exp_date = '04/24';
     $sale->allow_partial_auth = true;
     $response = $sale->authorizeAndCapture();
     $this->assertTrue($response->held);
     $this->assertEquals("1.23", $response->amount);
     $this->assertEquals($amount, $response->requested_amount);
     $split_tender_id = $response->split_tender_id;
     
     // Charge a bit more
     $sale = new AuthorizeNetAIM;
     $sale->amount = 1.23;
     $sale->card_num = '6011000000000012';
     $sale->exp_date = '04/26';
     $sale->split_tender_id = $split_tender_id;
     $sale->allow_partial_auth = true;
     $response = $sale->authorizeAndCapture();
     $this->assertTrue($response->approved);
     
     // Void the group of partial auths.
     
     $request = new AuthorizeNetCIM;
     $response = $request->updateSplitTenderGroup($split_tender_id, "voided");
     $this->assertTrue($response->isOk());
 }
 public static function processPayment()
 {
     $sale = new AuthorizeNetAIM();
     $data = payment_pro_get_custom(Params::getParam('extra'));
     $sale->amount = $data['amount'];
     $sale->card_num = Params::getParam('authorize_number');
     $sale->exp_date = Params::getParam('authorize_month') . Params::getParam('authorize_year');
     $response = $sale->authorizeAndCapture();
     $status = payment_pro_check_items($data['items'], $response->amount);
     if ($response->approved) {
         Params::setParam('authorize_transaction_id', $response->transaction_id);
         $exists = ModelPaymentPro::newInstance()->getPaymentByCode($response->transaction_id, 'AUTHORIZE', PAYMENT_PRO_COMPLETED);
         if (isset($exists['pk_i_id'])) {
             return PAYMENT_PRO_ALREADY_PAID;
         }
         // SAVE TRANSACTION LOG
         $invoiceId = ModelPaymentPro::newInstance()->saveInvoice($response->transaction_id, $response->amount, $status, 'USD', $data['email'], $data['user'], 'AUTHORIZE', $data['items']);
         //source
         if ($status == PAYMENT_PRO_COMPLETED) {
             foreach ($data['items'] as $item) {
                 if (substr($item['id'], 0, 3) == 'PUB') {
                     $tmp = explode("-", $item['id']);
                     ModelPaymentPro::newInstance()->payPublishFee($tmp[count($tmp) - 1], $invoiceId);
                 } else {
                     if (substr($item['id'], 0, 3) == 'PRM') {
                         $tmp = explode("-", $item['id']);
                         ModelPaymentPro::newInstance()->payPremiumFee($tmp[count($tmp) - 1], $invoiceId);
                     } else {
                         if (substr($item['id'], 0, 3) == 'WLT') {
                             ModelPaymentPro::newInstance()->addWallet($data['user'], $item['amount']);
                         } else {
                             osc_run_hook('payment_pro_item_paid', $item);
                         }
                     }
                 }
             }
         }
         return PAYMENT_PRO_COMPLETED;
     } else {
         $tmp = explode("Reason Text: ", $response->error_message);
         Params::setParam('authorize_error', $tmp[count($tmp) - 1]);
     }
     return PAYMENT_PRO_FAILED;
 }