tribulant

Untitled

Jun 14th, 2012
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.32 KB | None | 0 0
  1. global $errors, $wpcoDb, $Product, $Order, $Item, $Country, $wpcoHtml;
  2.                                 require_once(dirname(__FILE__) . DS . 'includes' . DS . 'constants.php');
  3.  
  4.                                 $order_id = $Order -> current_order_id();
  5.                                 $wpcoDb -> model = $Order -> model;
  6.                                 $order = $wpcoDb -> find(array('id' => $order_id));
  7.                                 $wpcoDb -> model = $Item -> model;
  8.                                 $items = $wpcoDb -> find_all(array('order_id' => $order_id));
  9.                                 $user = $this -> userdata($order -> user_id);
  10.                                 $pmethod = "pp_pro";
  11.                                
  12.                                 $success = false;
  13.                                 $errors = null;
  14.                                 if (empty($_POST['creditCardNumber'])) { $errors['creditCardNumber'] = __('Please fill in a credit card number.', $this -> plugin_name); }
  15.                                 elseif (!is_numeric($_POST['creditCardNumber'])) { $errors['creditCardNumber'] = __('Only numbers are allowed in the credit card number.', $this -> plugin_name); }
  16.                                 if (empty($_POST['expDateMonth']) || empty($_POST['expDateYear'])) { $errors['expDate'] = __('Please choose an expiry date.', $this -> plugin_name); }
  17.                                 if (empty($_POST['cvv2Number'])) { $errors['cvv2Number'] = __('Please fill in a security code.', $this -> plugin_name); }
  18.                                 elseif (!is_numeric($_POST['cvv2Number'])) { $errors['cvv2Number'] = __('Only numbers are allowed for the security code.', $this -> plugin_name); }
  19.  
  20.                                 if (empty($errors)) {                                  
  21.                                     //$pp_pro = $this -> vendor('pp_pro', "gateways" . DS);
  22.                                     require_once $this -> plugin_base() . DS . 'vendors' . DS . 'gateways' . DS . 'class.pp_pro.php';
  23.                                    
  24.                                     $api_username = $this -> get_option('pp_pro_api_username');
  25.                                     $api_password = $this -> get_option('pp_pro_api_password');
  26.                                     $api_signature = $this -> get_option('pp_pro_api_signature');
  27.                                     $api_endpoint = $this -> get_option('pp_pro_api_endpoint');
  28.                                    
  29.                                     $email = urlencode($user -> user_email);
  30.                                     $firstName = urlencode($order -> bill_fname);
  31.                                     $lastName = urlencode($order -> bill_lname);
  32.                                     $creditCardType = urlencode($_POST['creditCardType']);
  33.                                     $creditCardNumber = urlencode($_POST['creditCardNumber']);
  34.                                     $expDateMonth = urlencode($_POST['expDateMonth']);
  35.                                     $expDateYear = urlencode($_POST['expDateYear']);
  36.                                     $cvv2Number = urlencode($_POST['cvv2Number']);
  37.                                     $address1 = urlencode($order -> bill_address);
  38.                                     $address2 = urlencode($order -> bill_address2);
  39.                                     $city = urlencode($order -> bill_city);
  40.                                     $state = urlencode($order -> bill_state);
  41.                                     $zip = urlencode($order -> bill_zipcode);
  42.                                     $amount = urlencode($order -> total);
  43.                                     $currencyCode = urlencode($this -> get_option('currency'));
  44.                                     $shiptophonenum = urlencode($order -> ship_phone);
  45.                                     $SHIPTONAME = urlencode($order -> ship_fname . ' ' . $order -> ship_lname);
  46.                                     $SHIPTOSTREET = urlencode($order -> ship_address);
  47.                                     $SHIPTOSTREET2 = urlencode($order -> ship_address2);
  48.                                     $shiptocity = urlencode($order -> ship_city);
  49.                                     $shiptostate = urlencode($order -> ship_state);
  50.                                     $shiptozip = urlencode($order -> ship_zipcode);
  51.                                     $wpcoDb -> model = $Country -> model;
  52.                                     $shiptocountry = $wpcoDb -> field('code', array('id' => $user -> ship_country));
  53.                                     $paymentAction = urlencode("Sale");
  54.                                     $IPADDRESS = urlencode($_SERVER['REMOTE_ADDR']);
  55.                                     $nvpRecurring = '';
  56.                                     $methodToCall = 'DoDirectPayment'; 
  57.                                    
  58.                                     $wpcoDb -> model = $Country -> model;
  59.                                     $countrycode = $wpcoDb -> field('code', array('id' => $user -> bill_country));     
  60.                                    
  61.                                     if ($countrycode == "UK") { $countrycode = "GB"; }
  62.                                     if ($shiptocountry == "UK") { $shiptocountry = "GB"; }                 
  63.                                    
  64.                                     $nvpstr =
  65.                                     '&PAYMENTACTION=' . $paymentAction .
  66.                                     '&CUSTOM=' . $shipmethod_name .
  67.                                     '&IPADDRESS=' . $IPADDRESS .
  68.                                     '&AMT=' . $amount .
  69.                                     '&CREDITCARDTYPE=' . $creditCardType .
  70.                                     '&ACCT=' . $creditCardNumber .
  71.                                     '&EXPDATE=' . $expDateMonth . $expDateYear .
  72.                                     '&CVV2=' . $cvv2Number .
  73.                                     '&EMAIL=' . $email .
  74.                                     '&FIRSTNAME=' . $firstName .
  75.                                     '&LASTNAME=' . $lastName .
  76.                                     '&STREET=' . $address1 .
  77.                                     '&STREET2=' . $address2 .                                  
  78.                                     '&CITY=' . $city .
  79.                                     '&STATE=' . $state .
  80.                                     '&ZIP=' . $zip .
  81.                                     '&COUNTRYCODE=' . $countrycode .
  82.                                     '&CURRENCYCODE=' . $currencyCode .
  83.                                     '&SHIPTOPHONENUM=' . $shiptophonenum .
  84.                                     '&SHIPTONAME=' . $SHIPTONAME .
  85.                                     '&SHIPTOSTREET=' . $SHIPTOSTREET .
  86.                                     '&SHIPTOSTREET2=' . $SHIPTOSTREET2 .
  87.                                     '&SHIPTOCITY=' . $shiptocity .
  88.                                     '&SHIPTOSTATE=' . $shiptostate .
  89.                                     '&SHIPTOZIP=' . $shiptozip .
  90.                                     '&SHIPTOCOUNTRY=' . $shiptocountry;
  91.                                    
  92.                                     if ($Order -> do_shipping($order_id)) {
  93.                                         $shipmethod_name = $wpcoHtml -> shipmethod_name($order -> shipmethod_id);
  94.                                         $nvpstr .= '&CUSTOM=' . urlencode($shipmethod_name);
  95.                                        
  96.                                         if (!empty($order -> cu_shipmethod)) {
  97.                                             $nvpstr .= urlencode(' - ' . html_entity_decode($order -> cu_shipmethod));
  98.                                         }
  99.                                     }
  100.                                    
  101.                                     $subtotal = $Order -> total($order_id, false, false, true, true, false);
  102.                                     $shipping = $Order -> shipping_total($subtotal, $order_id);
  103.                                     $tax = $Order -> tax_total($order_id);
  104.                                    
  105.                                     $n = 0;
  106.                                     $itemamt = 0;
  107.  
  108.                                     if (!empty($items)) {                                  
  109.                                         foreach ($items as $item) {
  110.                                             $itemamount = ($Product -> unit_price($item -> product -> id, $item -> count, $item -> id, false, true, false, false));
  111.                                             $nvpstr .= '&L_NAME' . $n . '=' . urlencode($item -> product -> title);
  112.                                             $nvpstr .= '&L_DESC' . $n . '=' . urlencode(substr(strip_tags($item -> product -> description), 0, 125));
  113.                                             $nvpstr .= '&L_AMT' . $n . '=' . urlencode(number_format($itemamount, 2, '.', ''));
  114.                                             $nvpstr .= '&L_NUMBER' . $n . '=' . urlencode($item -> product -> code);
  115.                                             $nvpstr .= '&L_QTY' . $n . '=' . urlencode($item -> count);
  116.                                            
  117.                                             $n++;
  118.                                             $itemamt += ($itemamount * $item -> count);
  119.                                             $itemamount = 0;
  120.                                         }
  121.                                        
  122.                                         $nvpstr .= '&ITEMAMT=' . urlencode(number_format($itemamt, 2, '.', ''));
  123.                                         $nvpstr .= '&SHIPPINGAMT=' . urlencode(number_format($shipping, 2, '.', ''));
  124.                                         $nvpstr .= '&TAXAMT=' . urlencode(number_format($tax, 2, '.', ''));
  125.                                     }
  126.                                    
  127.                                     $nvpstr .= $nvpRecurring;
  128.                                    
  129.                                     $paypalPro = new wpcopp_pro($api_username, $api_password, $api_signature, '', '', false, false, '57.0', $api_endpoint);
  130.                                     $resArray = $paypalPro -> hash_call($methodToCall, $nvpstr);
  131.                                     $ack = strtoupper($resArray["ACK"]);
  132.  
  133.                                     $ack = strtoupper($resArray["ACK"]);
  134.                                     if($ack != "SUCCESS")  {
  135.                                         $success = false;
  136.                                         ?>
  137.                                          <!--[if IE]><meta http-equiv="refresh" content="0;URL=http://iheart-this.com/tryagain.html"><![endif]-->
  138.  
  139.                         <div style="position:relative; left:40%; margin:0 auto 0 auto; top:250px; font-family:Georgia, 'Times New Roman', Times, serif; font-size:45px; font-style:italic; color:#f5edd5;">OOPS!</div>
  140.                         <div style="position:relative; left:40%; margin:0 auto 0 auto; top:250px; font-family:Stratum1WebBold, sans-serif; size:20px; color:#f5edd5; letter-spacing:1px;"><?php _e('Unfortunately, there was an error processing your order.<br />
  141. We know it&#0039;s a pain, but please try again...', $this -> plugin_name); ?><br /><input onClick="<?php echo $Javascript -> location($wpcoHtml -> bill_url()); ?>"  class="SuccessBtnSmall" type="submit" style="padding:2px 15px 2px 15px; font-size:12px; font-family:Stratum1WebBold; font-weight:bold; margin:30px auto 0 auto; position:relative;" name="" value="TRY AGAIN" />
  142. </div>
  143.  
  144.  
  145.                        
  146.                         <?php
  147.                                     } else {                                           
  148.                                         $success = true;
  149.                                         $message = __('The transaction was successful.', $this -> plugin_name);
  150.                                         $user_id = $user -> ID;                                        
  151.                                     }
  152.                                    
  153.                                     $paypalPro -> message = $message;
  154.                                     $paypalPro -> done($success, $order_id);
  155.                                 } else {
  156.                                     $title = __('Processing Order', $this -> plugin_name);
  157.                                     $this -> process_order($title, $order, $user, $pmethod);   
  158.                                 }
  159.                                 break;
Advertisement
Add Comment
Please, Sign In to add comment