Пример #1
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;
 }
 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;
 }
Пример #3
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;
 }
Пример #4
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'));
     }
 }
Пример #5
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;
        }
    }
}
 public function process_refund($order_id, $amount = NULL, $reason = '')
 {
     global $woocommerce;
     $wc_order = new WC_Order($order_id);
     $trx_id = get_post_meta($order_id, '_transaction_id', true);
     $trx_metas = get_post_meta($order_id, '_' . $order_id . '_' . $trx_id . '_metas', true);
     $last_four = isset($trx_metas['account_number']) ? esc_attr($trx_metas['account_number']) : '';
     $refund = new AuthorizeNetAIM();
     $customer = (object) array();
     $customer->first_name = $wc_order->billing_first_name;
     $customer->last_name = $wc_order->billing_last_name;
     $customer->company = $wc_order->billing_company;
     $customer->address = $wc_order->billing_address_1 . ' ' . $wc_order->billing_address_2;
     $customer->city = $wc_order->billing_city;
     $customer->state = $wc_order->billing_state;
     $customer->zip = $wc_order->billing_postcode;
     $customer->country = $wc_order->billing_country;
     $customer->phone = $wc_order->billing_phone;
     $customer->email = $wc_order->billing_email;
     $customer->cust_id = $wc_order->user_id;
     $customer->invoice_num = $wc_order->get_order_number();
     $customer->description = get_bloginfo('blogname') . ' Order #' . $wc_order->get_order_number();
     $customer->ship_to_first_name = $wc_order->shipping_first_name;
     $customer->ship_to_last_name = $wc_order->shipping_last_name;
     $customer->ship_to_company = $wc_order->shipping_company;
     $customer->ship_to_address = $wc_order->shipping_address_1 . ' ' . $wc_order->shipping_address_2;
     $customer->ship_to_city = $wc_order->shipping_city;
     $customer->ship_to_state = $wc_order->shipping_state;
     $customer->ship_to_zip = $wc_order->shipping_postcode;
     $customer->ship_to_country = $wc_order->shipping_country;
     $customer->delim_char = '|';
     $customer->encap_char = '';
     $customer->customer_ip = $this->get_client_ip();
     $customer->tax = $wc_order->get_total_tax();
     $customer->freight = $wc_order->get_total_shipping();
     $customer->header_email_receipt = 'Refund From ' . get_bloginfo('blogname') . ' ' . $reason;
     $customer->footer_email_receipt = 'Thank you for Using ' . get_bloginfo('blogname');
     $refund->setFields($customer);
     $refundtrx = $refund->credit($trx_id, $amount, $last_four);
     if (1 == $refundtrx->approved) {
         $wc_order->add_order_note(__($refundtrx->response_reason_text . 'on' . date("d-m-Y h:i:s e") . 'with Transaction ID = ' . $refundtrx->transaction_id . ' using ' . strtoupper($refundtrx->transaction_type) . ' and authorization code ' . $refundtrx->authorization_code, 'woocommerce'));
         if ($wc_order->order_total == $amount) {
             $wc_order->update_status('wc-refunded');
         }
         return true;
     } else {
         if (2 == $refundtrx->response_subcode || 54 == $refundtrx->response_reason_code) {
             $refundtrx = $refund->void($trx_id);
             if (1 == $refundtrx->approved) {
                 $wc_order->add_order_note(__($refundtrx->response_reason_text . 'on ' . date("d-m-Y h:i:s e") . 'with Transaction ID = ' . $refundtrx->transaction_id . ' using ' . strtoupper($refundtrx->transaction_type) . ' and authorization code ' . $refundtrx->authorization_code, 'woocommerce'));
                 $wc_order->update_status('wc-cancelled');
                 return true;
             } else {
                 $wc_order->add_order_note(__($refundtrx->response_reason_text . '--' . $refundtrx->error_message . ' on ' . date("d-m-Y h:i:s e") . ' using ' . strtoupper($refundtrx->transaction_type), 'woocommerce'));
                 return false;
             }
         } else {
             $wc_order->add_order_note(__($refundtrx->response_reason_text . '--' . $refundtrx->error_message . ' on ' . date("d-m-Y h:i:s e") . ' using ' . strtoupper($refundtrx->transaction_type), 'woocommerce'));
             return false;
         }
         return false;
     }
     return false;
 }
Пример #7
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);
             }
         }
     }
 }
Пример #8
0
<?php

require_once 'coffee_store_settings.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";
    }
}
Пример #9
0
 function onTP_Processpayment($data, $vars = array())
 {
     $isValid = true;
     $error = array();
     $error['code'] = '';
     $error['desc'] = '';
     if (!empty($data['payment_type']) && $data['payment_type'] == "recurring") {
         $response = plgpaymentAuthorizenet::onTP_Processpayment_recurring($data);
         return $response;
     }
     $authnet_values = array("login" => $this->login_id, "tran_key" => $this->tran_key, "version" => "3.1", "delim_char" => "|", "delim_data" => "TRUE", "type" => "AUTH_CAPTURE", "method" => "CC", "relay_response" => "FALSE", "card_num" => $data['cardnum'], "card_code" => $data['cardcvv'], "exp_date" => $data['cardexp'], "description" => "", "amount" => $data['amount'], "first_name" => $data['cardfname'], "last_name" => $data['cardlname'], "address" => $data['cardaddress1'], "city" => $data['cardcity'], "state" => $data['cardstate'], "zip" => $data['cardzip'], "country" => $data['cardcountry'], "cust_id" => $data['user_id'], "email" => $data['email'], "invoice_num" => $vars->order_id, "description" => $vars->item_name);
     require_once 'authorizenet/lib/AuthorizeNet.php';
     $sale = new AuthorizeNetAIM($this->login_id, $this->tran_key);
     //Check sandbox or live
     $plgPaymentAuthorizenetHelper = new plgPaymentAuthorizenetHelper();
     $sandbox = $plgPaymentAuthorizenetHelper->isSandboxEnabled();
     $sale->setSandbox($sandbox);
     $sale->setFields($authnet_values);
     $allresp = $sale->authorizeAndCapture();
     if ($allresp->approved) {
         //echo "Sale successful!";
     } else {
         $error['desc'] = $allresp->error_message;
     }
     //print_r($allresp);die;
     //3.compare response order id and send order id in notify URL
     $res_orderid = '';
     $res_orderid = $data['order_id'];
     if ($isValid) {
         if (!empty($vars) && $res_orderid != $vars->order_id) {
             $isValid = false;
             $error['desc'] .= " ORDER_MISMATCH" . "Invalid ORDERID; notify order_is " . $vars->order_id . ", and response " . $res_orderid;
         }
     }
     // amount check
     if ($isValid) {
         if (!empty($vars)) {
             // Check that the amount is correct
             $order_amount = (double) $vars->amount;
             $retrunamount = (double) $allresp->amount;
             $epsilon = 0.01;
             if ($order_amount - $retrunamount > $epsilon) {
                 $allresp[0] = 'ERROR';
                 // change response status to ERROR FOR AMOUNT ONLY
                 $isValid = false;
                 $error['desc'] .= "ORDER_AMOUNT_MISTMATCH - order amount= " . $order_amount . ' response order amount = ' . $retrunamount;
             }
         }
     }
     // TRANSLET PAYMENT RESPONSE
     $payment_status = $this->translateResponse($allresp->response_code);
     $transaction_id = $allresp->transaction_id;
     $result = array('transaction_id' => $transaction_id, 'order_id' => $data['order_id'], 'status' => $payment_status, 'total_paid_amt' => $allresp->amount, 'raw_data' => $allresp, 'error' => $error, 'return' => $data['return']);
     return $result;
 }
Пример #10
0
if ($_SERVER["SERVER_PORT"] != "80") {
    $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"];
} else {
    $pageURL .= $_SERVER["SERVER_NAME"];
}
$user =& JFactory::getUser();
$site =& JFactory::getDocument();
$site->setTitle(JText::_('CHECK_OUT_BUTTON'));
$cart = $this->cart;
foreach ($cart->getAll() as $cartItem) {
    $item = $cartItem;
}
if (isset($_POST['x_process'])) {
    $transaction = new AuthorizeNetAIM();
    $transaction->setSandbox(AUTHORIZENET_SANDBOX);
    $transaction->setFields(array('amount' => $_POST['x_amount'], 'card_num' => $_POST['x_card_num'], 'exp_date' => $_POST['x_exp_month'] . "/" . $_POST['x_exp_year'], 'first_name' => $_POST['x_first_name'], 'last_name' => $_POST['x_last_name'], 'email' => $_POST['x_email'], 'card_code' => $_POST['x_card_code'], 'invoice_num' => $_POST['x_invoice_num'], 'description' => $_POST['x_description'], 'type' => $_POST['x_type']));
    if ($_POST['x_type'] == "AUTH_ONLY") {
        $response = $transaction->authorizeOnly();
    } elseif ($_POST['x_type'] == "AUTH_CAPTURE") {
        $response = $transaction->authorizeAndCapture();
    } else {
        echo "<span style=\"color: red;\">There is an error when making the transaction, please contact Administrator!</span><br/>";
    }
    if ($response->approved) {
        JFactory::getSession()->set('cart', null);
        ?>
	
		<form name="paymentForm" method="post" action="<?php 
        echo JURI::base() . "index.php?option=com_enmasse&controller=payment&task=notifyUrl&payClass=authorizenet";
        ?>
" id="checkout_form">
Пример #11
0
 public function test_payment()
 {
     if (!ci()->cart->contents()) {
         notice('Your cart is empty.', 'error');
         echo "<script>document.location.href='/order-online/'</script>";
         exit;
     }
     $card_num = ci()->input->post('card_number');
     $em = ci()->input->post('exp_month');
     $ey = ci()->input->post('exp_year');
     $store_id = ci()->input->post('store');
     $this->set_gateway_data($store_id);
     require_once APPPATH . 'libraries/anet/AuthorizeNet.php';
     $transaction = new AuthorizeNetAIM(ci()->system_settings['api_login_id'], ci()->system_settings['transaction_key']);
     $transaction->setSandbox((bool) ci()->system_settings['api_mode']);
     $transaction->setFields(array('amount' => $this->_get_grand_total(), 'card_num' => $card_num, 'exp_date' => "{$em}{$ey}"));
     $response = $transaction->authorizeOnly();
     if ($response->approved) {
         ci()->session->set_userdata('authorization_code', $response->authorization_code);
         echo '<script>showStep()</script>';
         exit;
     }
     echo $response->response_reason_text;
     exit;
 }
Пример #12
0
    } else {
        if (!preg_match("/^\\d{3}\$/", $cvv)) {
            return false;
        }
    }
    return true;
}
if (count($errors) === 0) {
    // Format the expiration date
    $expiration_date = sprintf("%04d-%02d", $expiration_year, $expiration_month);
    // Include the SDK
    require_once './config.php';
    // Process the transaction using the AIM API
    $transaction = new AuthorizeNetAIM();
    $transaction->setSandbox(AUTHORIZENET_SANDBOX);
    $transaction->setFields(array('amount' => '1.00', 'card_num' => $credit_card, 'exp_date' => $expiration_date, 'first_name' => $cardholder_first_name, 'last_name' => $cardholder_last_name, 'address' => $billing_address, 'city' => $billing_city, 'state' => $billing_state, 'zip' => $billing_zip, 'email' => $email, 'card_code' => $cvv, 'ship_to_first_name' => $recipient_first_name, 'ship_to_last_name' => $recipient_last_name, 'ship_to_address' => $shipping_address, 'ship_to_city' => $shipping_city, 'ship_to_state' => $shipping_state, 'ship_to_zip' => $shipping_zip));
    $response = $transaction->authorizeAndCapture();
    if ($response->approved) {
        // Transaction approved. Collect pertinent transaction information for saving in the database.
        $transaction_id = $response->transaction_id;
        $authorization_code = $response->authorization_code;
        $avs_response = $response->avs_response;
        $cavv_response = $response->cavv_response;
        // Put everything in a database for later review and order processing
        // How you do this depends on how your application is designed
        // and your business needs.
        // Once we're finished let's redirect the user to a receipt page
        header('Location: thank-you-page.php');
        exit;
    } else {
        if ($response->declined) {
Пример #13
0
 function authorizenet($id = NULL)
 {
     if (isset($id) && !empty($id)) {
         $Gig = $this->Gig->findbyId($id);
         if (isset($Gig) && !empty($Gig)) {
             if (!empty($this->data)) {
                 require_once APP . 'vendors/authorizenet/AuthorizeNet.php';
                 $merchant = (object) array();
                 $merchant->login = AUTHORIZENET_API_LOGIN_ID;
                 $merchant->tran_key = AUTHORIZENET_TRANSACTION_KEY;
                 $merchant->allow_partial_auth = "false";
                 $creditCard = array('exp_date' => $this->data['c_expmonth'] . '/' . $this->data['c_expyear'], 'card_num' => $this->data['c_n'], 'card_code' => $this->data['c_cvv2'], 'method' => "CC");
                 $amount = COMMISSION_PERCENT * $Gig['Gig']['price'] / 100 + $Gig['Gig']['price'];
                 $transaction = array('amount' => $amount, 'duplicate_window' => '10', 'email_customer' => 'false', 'footer_email_receipt' => 'thank you for your business!', 'header_email_receipt' => 'a copy of your receipt is below');
                 $order = array('description' => substr($Gig['Gig']['description'], 0, 250), 'invoice_num' => substr("CAL" . uniqid(), 0, 20), 'line_item' => '1<|>' . substr($Gig['Gig']['title'], 0, 30) . '<|>' . substr($Gig['Gig']['description'], 0, 250) . '<|>1<|>' . $Gig['Gig']['price'] . '<|>N');
                 $customer = (object) array();
                 $customer->first_name = substr($this->Session->read('User.name'), 0, 50);
                 //$customer->last_name = "Smith";
                 //$customer->company = "Jane Smith Enterprises Inc.";
                 //$customer->address = "20 Main Street";
                 // $customer->city = "San Francisco";
                 //  $customer->state = "CA";
                 // $customer->zip = "94110";
                 // $customer->country = "US";
                 // $customer->phone = "415-555-5557";
                 //$customer->fax = "415-555-5556";
                 $customer->email = $this->Session->read('User.email');
                 $customer->cust_id = substr($this->Session->read('User.id'), 0, 20);
                 $customer->customer_ip = substr($_SERVER['REMOTE_ADDR'], 0, 15);
                 //        $shipping_info = (object)array();
                 //        $shipping_info->ship_to_first_name = "John";
                 //        $shipping_info->ship_to_last_name = "Smith";
                 //        $shipping_info->ship_to_company = "Smith Enterprises Inc.";
                 //        $shipping_info->ship_to_address = "10 Main Street";
                 //        $shipping_info->ship_to_city = "San Francisco";
                 //        $shipping_info->ship_to_state = "CA";
                 //        $shipping_info->ship_to_zip = "94110";
                 //        $shipping_info->ship_to_country = "US";
                 //        $shipping_info->tax = "CA";
                 //        $shipping_info->freight = "Freight<|>ground overnight<|>12.95";
                 $shipping_info->duty = 'Commission<|>Commission Percent : ' . COMMISSION_PERCENT . '%<|>' . COMMISSION_PERCENT * $Gig['Gig']['price'] / 100;
                 //        $shipping_info->tax_exempt = "false";
                 //        $shipping_info->po_num = "12";
                 $sale = new AuthorizeNetAIM();
                 $sale->setFields($creditCard);
                 $sale->setFields($shipping_info);
                 $sale->setFields($customer);
                 $sale->setFields($order);
                 $sale->setFields($merchant);
                 $sale->setFields($transaction);
                 //$sale->setCustomField("Commission",'sdf');
                 $response = $sale->authorizeAndCapture();
                 return $response;
             } else {
                 $this->Session->setFlash("Invalid Payment Details!");
                 $this->redirect('/orders/index/' . $id);
             }
         } else {
             $this->Session->setFlash("Invalid Order Request!");
             $this->redirect('/');
         }
     } else {
         $this->Session->setFlash("Invalid Order Request!");
         $this->redirect('/');
     }
 }
Пример #14
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);
     }
 }
Пример #15
0
 /**
  *function to reactivate the account
  *@author Priti Kabra
  */
 public function reactivate($regType = NULL, $refId = NULL)
 {
     $userId = $this->Encryption->decode($this->Session->read('Auth.Front.id'));
     $userData = $this->User->find('first', array('conditions' => array('User.id' => $userId)));
     $this->set(compact('userData'));
     if ($this->request->is('post')) {
         $this->loadModel('Coupon');
         $this->loadModel('Transaction');
         $this->loadModel('Subscription');
         //Check Coupon Code
         if (!empty($this->request->data['BusinessOwner']['code'])) {
             $couponCheck = $this->checkCouponCode($this->request->data['BusinessOwner']['code']);
             if (isset($couponCheck['error'])) {
                 $checkCouponError = 1;
                 $this->User->validationErrors['couponcheck'] = $couponCheck['error'];
                 $this->request->data = $this->request->data;
             } else {
                 $this->request->data['BusinessOwner']['memberShipPrice'] = $couponCheck['newMembershipPrice'];
             }
         } else {
             $this->request->data['BusinessOwner']['memberShipPrice'] = Configure::read('PLANPRICE');
         }
         $this->request->data['BusinessOwner']['expiration'] = $this->request->data['BusinessOwner']['expiration_month']['month'] . '/' . $this->request->data['BusinessOwner']['expiration_year']['year'];
         if (!isset($checkCouponError)) {
             //PAYMENT
             $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();
             if (isset($response->declined) && $response->declined == "1") {
                 $errMsg = $response->response_reason_text;
                 $this->Session->setFlash(__($errMsg), 'Front/flash_bad');
                 $this->__unsetData();
             } else {
                 if (isset($response->error) && $response->error == "1") {
                     $errMsg = $response->response_reason_text;
                     $this->Session->setFlash(__($errMsg), 'Front/flash_bad');
                     $this->__unsetData();
                 } else {
                     if (isset($response->approved) && $response->approved == "1") {
                         $userDataUpdate['deactivated_by_user'] = 0;
                         $userDataUpdate['reactivate'] = 1;
                         $this->User->id = $userId;
                         if ($this->User->save($userDataUpdate)) {
                             if ($regType != NULL && $refId != NULL) {
                                 $decrypted = $this->Encryption->decode($refId);
                                 $inviteData = $this->InvitePartner->find('first', array('conditions' => array('id' => $decrypted)));
                                 if ($this->request->data['User']['user_email'] == $inviteData['InvitePartner']['invitee_email']) {
                                     $data = array('InvitePartner.referral_amount' => 'InvitePartner.referral_amount + 5', 'InvitePartner.status' => "'active'", 'invitee_userid' => $this->User->id);
                                     $this->InvitePartner->updateAll($data, array('id' => $decrypted));
                                 }
                             }
                             $transactions['user_id'] = $userId;
                             $transactions['transaction_id'] = $response->transaction_id;
                             $transactions['status'] = 1;
                             $transactions['amount_paid'] = $this->request->data['BusinessOwner']['memberShipPrice'];
                             $transactions['credit_card_number'] = $this->Encryption->encode(substr($this->request->data['BusinessOwner']['CC_Number'], -4, 4));
                             $this->Transaction->save($transactions);
                             $txId = $this->Transaction->getLastInsertID();
                             //Create Subscription
                             $this->request->data['Subscription']['transaction_id'] = $response->transaction_id;
                             $this->createSubscription($this->request->data, $userId);
                             //Update Purchase date
                             $this->Transaction->id = $txId;
                             $this->Transaction->save(array('purchase_date' => $this->Common->getCurrentActiveDate($userId)));
                             //delete goals
                             //$this->GroupGoals->resetUserGoals($userId);
                             $this->Session->write('UID', $this->Encryption->encode($this->User->id));
                             $this->Session->write('countryInfo', $this->request->data['BusinessOwner']['country_id']);
                             $this->Session->write('zipInfo', $this->request->data['BusinessOwner']['zipcode']);
                             //Create Subscripton ends
                             $this->redirect(array('controller' => 'groups', 'action' => 'group-selection'));
                         } else {
                             foreach ($this->User->validationErrors as $key => $value) {
                                 $err[] = $value[0];
                             }
                             $this->Session->setFlash(__($err), 'Front/flash_bad');
                             $this->__unsetData();
                         }
                     } else {
                         foreach ($this->BusinessOwner->validationErrors as $key => $value) {
                             $err[] = $value[0];
                         }
                         $this->Session->setFlash(__($err[0]), 'Front/flash_bad');
                         $this->__unsetData();
                     }
                 }
             }
         } else {
             $this->Session->setFlash(__($this->User->validationErrors['couponcheck']), 'Front/flash_bad');
             $this->__unsetData();
             $this->request->data = $this->request->data;
         }
     }
 }
Пример #16
0
    }
    $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;
        }
    }
} else {
    $error = Yii::t("default", "Sorry but we cannot find what your are looking for.");
 public function PaymentCreditGift()
 {
     $excludeArr = array('creditvalue', 'cardType', 'email', 'cardNumber', 'CCExpDay', 'CCExpMnth', 'creditCardIdentifier', 'total_price', 'CreditSubmit');
     $dataArr = array();
     $condition = array('id' => $this->checkLogin('U'));
     $this->checkout_model->commonInsertUpdate(USERS, 'update', $excludeArr, $dataArr, $condition);
     //User ID
     $loginUserId = $this->checkLogin('U');
     if ($this->input->post('creditvalue') == 'authorize') {
         $Auth_Details = unserialize(API_LOGINID);
         $Auth_Setting_Details = unserialize($Auth_Details['settings']);
         error_reporting(-1);
         define("AUTHORIZENET_API_LOGIN_ID", $Auth_Setting_Details['Login_ID']);
         // Add your API LOGIN ID
         define("AUTHORIZENET_TRANSACTION_KEY", $Auth_Setting_Details['Transaction_Key']);
         // Add your API transaction key
         define("API_MODE", $Auth_Setting_Details['mode']);
         if (API_MODE == 'sandbox') {
             define("AUTHORIZENET_SANDBOX", true);
             // Set to false to test against production
         } else {
             define("AUTHORIZENET_SANDBOX", false);
         }
         define("TEST_REQUEST", "FALSE");
         require_once './authorize/AuthorizeNet.php';
         $transaction = new AuthorizeNetAIM();
         $transaction->setSandbox(AUTHORIZENET_SANDBOX);
         $transaction->setFields(array('amount' => $this->input->post('total_price'), 'card_num' => $this->input->post('cardNumber'), 'exp_date' => $this->input->post('CCExpDay') . '/' . $this->input->post('CCExpMnth'), 'first_name' => $this->input->post('full_name'), 'last_name' => '', 'address' => $this->input->post('address'), 'city' => $this->input->post('city'), 'state' => $this->input->post('state'), 'country' => $this->input->post('country'), 'phone' => $this->input->post('phone_no'), 'email' => $this->input->post('email'), 'card_code' => $this->input->post('creditCardIdentifier')));
         $response = $transaction->authorizeAndCapture();
         if ($response->approved) {
             //$moveShoppingDataToPayment = $this->ibrandshopping_model->moveShoppingDataToPayment();
             redirect('order/giftsuccess/' . $loginUserId . '/' . $response->transaction_id);
         } else {
             //redirect('site/shopcart/cancel?failmsg='.$response->response_reason_text);
             redirect('order/failure/' . $response->response_reason_text);
         }
     } else {
         if ($this->input->post('creditvalue') == 'paypaldodirect') {
             $PaypalDodirect = unserialize($this->data['paypal_credit_card_settings']['settings']);
             $dodirects = array('Sandbox' => $PaypalDodirect['mode'], 'APIUsername' => $PaypalDodirect['Paypal_API_Username'], 'APIPassword' => $PaypalDodirect['paypal_api_password'], 'APISignature' => $PaypalDodirect['paypal_api_Signature'], 'APISubject' => '', 'APIVersion' => '85.0');
             // Show Errors
             if ($dodirects['Sandbox']) {
                 error_reporting(E_ALL);
                 ini_set('display_errors', '1');
             }
             $this->load->library('Paypal_pro', $dodirects);
             $DPFields = array('paymentaction' => '', 'ipaddress' => $this->input->ip_address(), 'returnfmfdetails' => '1');
             $CCDetails = array('creditcardtype' => $this->input->post('cardType'), 'acct' => $this->input->post('cardNumber'), 'expdate' => $this->input->post('CCExpDay') . $this->input->post('CCExpMnth'), 'cvv2' => $this->input->post('creditCardIdentifier'), 'startdate' => '', 'issuenumber' => '');
             $PayerInfo = array('email' => $this->input->post('email'), 'payerid' => '', 'payerstatus' => '', 'business' => '');
             $PayerName = array('salutation' => 'Mr.', 'firstname' => $this->input->post('full_name'), 'middlename' => '', 'lastname' => '', 'suffix' => '');
             //'x_amount'				=> ,
             //			'x_email'				=> $this->input->post('email'),
             $BillingAddress = array('street' => $this->input->post('address'), 'street2' => '', 'city' => $this->input->post('city'), 'state' => $this->input->post('state'), 'countrycode' => $this->input->post('country'), 'zip' => $this->input->post('postal_code'), 'phonenum' => $this->input->post('phone_no'));
             $ShippingAddress = array('shiptoname' => $this->input->post('full_name'), 'shiptostreet' => $this->input->post('address'), 'shiptostreet2' => $this->input->post('address2'), 'shiptocity' => $this->input->post('city'), 'shiptostate' => $this->input->post('state'), 'shiptozip' => $this->input->post('postal_code'), 'shiptocountry' => $this->input->post('country'), 'shiptophonenum' => $this->input->post('phone_no'));
             $PaymentDetails = array('amt' => $this->input->post('total_price'), 'currencycode' => $this->data['currencyType'], 'itemamt' => '', 'shippingamt' => '', 'insuranceamt' => '', 'shipdiscamt' => '', 'handlingamt' => '', 'taxamt' => '', 'desc' => '', 'custom' => '', 'invnum' => '', 'buttonsource' => '', 'notifyurl' => '', 'recurring' => '');
             // For order items you populate a nested array with multiple $Item arrays.
             // Normally you'll be looping through cart items to populate the $Item array
             // Then push it into the $OrderItems array at the end of each loop for an entire
             // collection of all items in $OrderItems.
             $OrderItems = array();
             $Item = array('l_name' => '', 'l_desc' => '', 'l_amt' => '', 'l_number' => '', 'l_qty' => '', 'l_taxamt' => '', 'l_ebayitemnumber' => '', 'l_ebayitemauctiontxnid' => '', 'l_ebayitemorderid' => '');
             array_push($OrderItems, $Item);
             $Secure3D = array('authstatus3d' => '', 'mpivendor3ds' => '', 'cavv' => '', 'eci3ds' => '', 'xid' => '');
             $PayPalRequestData = array('DPFields' => $DPFields, 'CCDetails' => $CCDetails, 'PayerInfo' => $PayerInfo, 'PayerName' => $PayerName, 'BillingAddress' => $BillingAddress, 'ShippingAddress' => $ShippingAddress, 'PaymentDetails' => $PaymentDetails, 'OrderItems' => $OrderItems, 'Secure3D' => $Secure3D);
             $PayPalResult = $this->paypal_pro->DoDirectPayment($PayPalRequestData);
             $lastFeatureInsertId = $this->session->userdata('randomNo');
             if (!$this->paypal_pro->APICallSuccessful($PayPalResult['ACK'])) {
                 $errors = array('Errors' => $PayPalResult['ERRORS']);
                 //$this->load->view('paypal_error',$errors);
                 $newerrors = $errors['Errors'][0]['L_LONGMESSAGE'];
                 redirect('order/failure/' . $newerrors);
             } else {
                 // Successful call.  Load view or whatever you need to do here.
                 redirect('order/success/' . $loginUserId . '/' . $lastFeatureInsertId . '/' . $PayPalResult['TRANSACTIONID']);
             }
         }
     }
 }