当前位置: 首页>>代码示例>>PHP>>正文


PHP Cart66Common::getRandString方法代码示例

本文整理汇总了PHP中Cart66Common::getRandString方法的典型用法代码示例。如果您正苦于以下问题:PHP Cart66Common::getRandString方法的具体用法?PHP Cart66Common::getRandString怎么用?PHP Cart66Common::getRandString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cart66Common的用法示例。


在下文中一共展示了Cart66Common::getRandString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: doSale

 public function doSale()
 {
     $transId = 'MT-' . Cart66Common::getRandString();
     return $transId;
 }
开发者ID:rbredow,项目名称:allyzabbacart,代码行数:5,代码来源:Cart66ManualGateway.php

示例2: _newSessionId

 /**
  * 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;
 }
开发者ID:rbredow,项目名称:allyzabbacart,代码行数:17,代码来源:Cart66SessionDb.php

示例3: get_class

 }
 // 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);
开发者ID:rbredow,项目名称:allyzabbacart,代码行数:31,代码来源:checkout.php

示例4: doSale

 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;
 }
开发者ID:arraysoftlab,项目名称:tracy-thedarkroom.com,代码行数:77,代码来源:Cart66AuthorizeNet.php

示例5: doSale

 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;
 }
开发者ID:rbredow,项目名称:allyzabbacart,代码行数:38,代码来源:Cart66Stripe.php

示例6: storeOrder

 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;
 }
开发者ID:arraysoftlab,项目名称:tracy-thedarkroom.com,代码行数:23,代码来源:Cart66Cart.php

示例7: doSale

 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;
 }
开发者ID:rbredow,项目名称:allyzabbacart,代码行数:45,代码来源:Cart66PayLeap.php

示例8: doSale

 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;
 }
开发者ID:rbredow,项目名称:allyzabbacart,代码行数:34,代码来源:Cart66Eway.php


注:本文中的Cart66Common::getRandString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。