コード例 #1
0
 public function doSale()
 {
     $transId = 'MT-' . Cart66Common::getRandString();
     return $transId;
 }
コード例 #2
0
 /**
  * Return a 40 character random string that is not already in the database
  * 
  * @return string
  */
 protected static function _newSessionId()
 {
     global $wpdb;
     do {
         $sessionId = Cart66Common::getRandString(40);
         $tableName = Cart66Common::getTableName('sessions');
         $sql = "select count(*) from {$tableName} where session_id = %s";
         $sql = $wpdb->prepare($sql, $sessionId);
         $count = $wpdb->get_var($sql);
     } while ($count > 0);
     return $sessionId;
 }
コード例 #3
0
ファイル: checkout.php プロジェクト: rbredow/allyzabbacart
 }
 // Look for mailchimp opt-in
 if (CART66_PRO) {
     include CART66_PATH . "/pro/Cart66MailChimpOptIn.php";
 }
 // Look for sendy opt-in
 if (CART66_PRO) {
     include CART66_PATH . "/pro/Cart66SendyOptIn.php";
 }
 $gatewayName = get_class($gateway);
 $gateway->initCheckout($oneTimeTotal);
 if ($oneTimeTotal > 0 || $gatewayName == 'Cart66ManualGateway') {
     $transactionId = $gateway->doSale();
 } else {
     // Do not attempt to charge $0.00 transactions to live gateways
     $transactionId = $transId = 'MT-' . Cart66Common::getRandString();
 }
 if ($transactionId) {
     // Set order status based on Cart66 settings
     $statusOptions = Cart66Common::getOrderStatusOptions();
     $status = $statusOptions[0];
     // Check for account creation
     $accountId = 0;
     Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Should an account be created? " . print_r($createAccount));
     if ($createAccount) {
         $account->save();
         $accountId = $account->id;
         Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Just created account with id: accountId");
     }
     if ($mp = Cart66Session::get('Cart66Cart')->getMembershipProduct()) {
         $account->attachMembershipProduct($mp, $account->firstName, $account->lastName);
コード例 #4
0
 function doSale()
 {
     // This function actually processes the payment.  This function will
     // load the $response array with all the returned information.
     // The response code values are:
     // 1 - Approved
     // 2 - Declined
     // 3 - Error
     $sale = false;
     if ($this->fields['x_amount'] > 0) {
         // Construct the fields string to pass to authorize.net
         foreach ($this->fields as $key => $value) {
             $this->field_string .= "{$key}=" . urlencode($value) . "&";
         }
         if (!Cart66Setting::getValue('disable_authorizenet_items')) {
             $items = Cart66Session::get('Cart66Cart')->getItems();
             foreach ($items as $i) {
                 $itemNumber = str_replace("\t", " ", substr($i->getItemNumber(), 0, 31));
                 $product = new Cart66Product($i->getProductId());
                 $itemName = str_replace("\t", " ", substr($product->name, 0, 31));
                 $itemOptions = str_replace("\t", " ", substr($i->getOptionInfo(), 0, 29));
                 if ($itemOptions != '') {
                     $itemOptions = '(' . $itemOptions . ')';
                 }
                 $itemQuantity = $i->getQuantity();
                 $itemTaxable = $product->taxable == 1 ? 'Y' : 'N';
                 $itemPrice = number_format($i->getProductPrice(), 2, '.', '');
                 $this->field_string .= "x_line_item=" . urlencode("{$itemNumber}<|>{$itemName}<|>{$itemOptions}<|>{$itemQuantity}<|>{$itemPrice}<|>{$itemTaxable}") . "&";
             }
         }
         Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] string: " . $this->field_string);
         // Execute the HTTPS post via CURL
         $ch = curl_init($this->gateway_url);
         curl_setopt($ch, CURLOPT_HEADER, 0);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS, rtrim($this->field_string, "& "));
         // Do not worry about checking for SSL certs
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
         $this->response_string = urldecode(curl_exec($ch));
         if (curl_errno($ch)) {
             $this->response['Response Reason Text'] = curl_error($ch);
         } else {
             curl_close($ch);
         }
         // Load a temporary array with the values returned from authorize.net
         $temp_values = explode('|', $this->response_string);
         // Load a temporary array with the keys corresponding to the values
         // returned from authorize.net (taken from AIM documentation)
         $temp_keys = array("Response Code", "Response Subcode", "Response Reason Code", "Response Reason Text", "Approval Code", "AVS Result Code", "Transaction ID", "Invoice Number", "Description", "Amount", "Method", "Transaction Type", "Customer ID", "Cardholder First Name", "Cardholder Last Name", "Company", "Billing Address", "City", "State", "Zip", "Country", "Phone", "Fax", "Email", "Ship to First Name", "Ship to Last Name", "Ship to Company", "Ship to Address", "Ship to City", "Ship to State", "Ship to Zip", "Ship to Country", "Tax Amount", "Duty Amount", "Freight Amount", "Tax Exempt Flag", "PO Number", "MD5 Hash", "Card Code (CVV2/CVC2/CID) Response Code", "Cardholder Authentication Verification Value (CAVV) Response Code");
         // Add additional keys for reserved fields and merchant defined fields
         for ($i = 0; $i <= 27; $i++) {
             array_push($temp_keys, 'Reserved Field ' . $i);
         }
         $i = 0;
         while (sizeof($temp_keys) < sizeof($temp_values)) {
             array_push($temp_keys, 'Merchant Defined Field ' . $i);
             $i++;
         }
         // combine the keys and values arrays into the $response array.  This
         // can be done with the array_combine() function instead if you are using
         // php 5.
         for ($i = 0; $i < sizeof($temp_values); $i++) {
             $this->response["{$temp_keys[$i]}"] = $temp_values[$i];
         }
         // $this->dump_response();
         // Prepare to return the transaction id for this sale.
         if (str_replace('"', "", $this->response['Response Code']) == 1) {
             $sale = str_replace('"', "", $this->response['Transaction ID']);
         }
     } else {
         // Process free orders without sending to the Auth.net gateway
         $this->response['Transaction ID'] = 'MT-' . Cart66Common::getRandString();
         $sale = $this->response['Transaction ID'];
     }
     return $sale;
 }
コード例 #5
0
 function doSale()
 {
     $sale = false;
     if ($this->params['amount'] > 0) {
         // Execute the HTTPS post via CURL
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $this->gateway_url);
         curl_setopt($ch, CURLOPT_HEADER, 0);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
         curl_setopt($ch, CURLOPT_TIMEOUT, 80);
         curl_setopt($ch, CURLOPT_USERPWD, $this->_apiKey);
         curl_setopt($ch, CURLOPT_POST, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS, self::encodeParams($this->params));
         // Do not worry about checking for SSL certs
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
         $this->response_string = json_decode(curl_exec($ch));
         Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] response: " . print_r($this->response_string, true));
         //$errno = curl_errno($ch);
         curl_close($ch);
         if (isset($this->response_string->error)) {
             $this->response['Response Reason Text'] = $this->response_string->error->message;
             $this->response['Response Reason Code'] = $this->response_string->error->type;
         } else {
             if (isset($this->response_string->paid) && $this->response_string->paid == 1) {
                 $sale = $this->response_string->id;
             } else {
                 $this->response['Response Reason Text'] = 'No Transaction ID Provided';
             }
         }
     } else {
         // Process free orders without sending to the Stripe gateway
         $this->response_string->id = 'MT-' . Cart66Common::getRandString();
         $sale = $this->response_string->id;
     }
     return $sale;
 }
コード例 #6
0
 public function storeOrder($orderInfo)
 {
     Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] orderinfo: " . print_r($orderInfo, true));
     $order = new Cart66Order();
     $pre_string = isset($orderInfo['status']) && $orderInfo['status'] == 'checkout_pending' ? 'CP-' : 'MT-';
     $orderInfo['trans_id'] = empty($orderInfo['trans_id']) ? $pre_string . Cart66Common::getRandString() : $orderInfo['trans_id'];
     $orderInfo['ip'] = $_SERVER['REMOTE_ADDR'];
     if (Cart66Session::get('Cart66Promotion')) {
         $orderInfo['discount_amount'] = Cart66Session::get('Cart66Promotion')->getDiscountAmount(Cart66Session::get('Cart66Cart'));
     } else {
         $orderInfo['discount_amount'] = 0;
     }
     $order->setInfo($orderInfo);
     $order->setItems($this->getItems());
     $orderId = $order->save();
     //update the number of redemptions for the promotion code.
     if (Cart66Session::get('Cart66Promotion')) {
         Cart66Session::get('Cart66Promotion')->updateRedemptions();
     }
     $orderInfo['id'] = $orderId;
     do_action('cart66_after_order_saved', $orderInfo);
     return $orderId;
 }
コード例 #7
0
 public function doSale()
 {
     $sale = false;
     if ($this->fields['Amount'] > 0) {
         foreach ($this->fields as $key => $value) {
             $this->field_string .= "{$key}=" . urlencode($value) . "&";
         }
         $header = array("MIME-Version: 1.0", "Content-type: application/x-www-form-urlencoded", "Contenttransfer-encoding: text");
         $ch = curl_init();
         // set URL and other appropriate options
         curl_setopt($ch, CURLOPT_URL, $this->_apiEndPoint);
         curl_setopt($ch, CURLOPT_VERBOSE, 1);
         curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
         // uncomment for host with proxy server
         // curl_setopt ($ch, CURLOPT_PROXY, "http://proxyaddress:port");
         curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
         curl_setopt($ch, CURLOPT_POST, true);
         curl_setopt($ch, CURLOPT_POSTFIELDS, rtrim($this->field_string, "& "));
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($ch, CURLOPT_TIMEOUT, 10);
         // send packet and receive response
         // close the curl resource, and free system resources
         $this->response_string = urldecode(curl_exec($ch));
         if (curl_errno($ch)) {
             $this->response['Response Reason Text'] = curl_error($ch);
         } else {
             curl_close($ch);
         }
         $xml = new SimpleXMLElement($this->response_string);
         $this->response['Response Reason Text'] = $xml->RespMSG;
         $this->response['Transaction ID'] = $xml->PNRef;
         $this->response['Response Code'] = $xml->Result;
         // $this->dump_response();
         // Prepare to return the transaction id for this sale.
         if ($this->response['Response Code'] == 0) {
             $sale = $this->response['Transaction ID'];
         }
     } else {
         // Process free orders without sending to the Auth.net gateway
         $this->response['Transaction ID'] = 'MT-' . Cart66Common::getRandString();
         $sale = $this->response['Transaction ID'];
     }
     return $sale;
 }
コード例 #8
0
ファイル: Cart66Eway.php プロジェクト: rbredow/allyzabbacart
 function doSale()
 {
     $sale = false;
     if ($this->fields['ewayTotalAmount'] > 0) {
         $xmlRequest = "<ewaygateway><ewayCustomerID>" . $this->_customerId . "</ewayCustomerID>";
         foreach ($this->fields as $key => $value) {
             $xmlRequest .= "<{$key}>{$value}</{$key}>";
         }
         $xmlRequest .= "</ewaygateway>";
         Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] XML Data sent to EWAY:\n" . $xmlRequest);
         $xmlResponse = $this->sendTransactionToEway($xmlRequest);
         Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] XML Response from EWAY:\n" . $xmlResponse);
         if ($xmlResponse != "") {
             $ewayResponseFields = $this->parseResponse($xmlResponse);
             if (strtolower($ewayResponseFields["EWAYTRXNSTATUS"]) == "false") {
                 $this->response['Response Reason Text'] = $ewayResponseFields["EWAYTRXNERROR"];
             } elseif (strtolower($ewayResponseFields["EWAYTRXNSTATUS"]) == "true") {
                 $this->response['Transaction ID'] = isset($ewayResponseFields['EWAYTRXNNUMBER']) ? $ewayResponseFields['EWAYTRXNNUMBER'] : null;
                 $this->response['Response Reason Text'] = $ewayResponseFields["EWAYTRXNERROR"];
                 $this->response['Reason Response Code'] = $ewayResponseFields['EWAYTRXNNUMBER'];
                 $sale = $this->response['Transaction ID'];
             } else {
                 $this->response['Response Reason Text'] = "Error: An invalid response was received from the payment gateway.";
             }
         } else {
             $this->response['Response Reason Text'] = "Error in XML response from eWay: " + $xmlResponse;
         }
     } else {
         // Process free orders without sending to the Eway gateway
         $this->response['Transaction ID'] = 'MT-' . Cart66Common::getRandString();
         $sale = $this->response['Transaction ID'];
     }
     return $sale;
 }