tribulant

checkout-pp.php

May 16th, 2011
383
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.13 KB | None | 0 0
  1. <?php $ppurl = ($this -> get_option('pp_sandbox') == "Y") ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr'; ?>
  2. <?php $buynow = (!empty($params['buynow']) && $params['buynow'] == true) ? "Y" : "N"; ?>
  3. <?php $custom = urlencode(serialize(array('order_id' => $order -> id, 'buynow' => $buynow, 'user' => $order -> user, 'user_id' => $user -> ID))); ?>
  4. <?php $tax_cart = $Order -> tax_total($order -> id); ?>
  5.  
  6. <p><img src="<?php echo $this -> url(); ?>/images/gateways/pp.jpg" alt="paypal" /></p>
  7.  
  8. <form action="<?php echo $ppurl; ?>" method="post" id="pp-form">
  9.     <input type="hidden" name="upload" value="1" />
  10.     <input type="hidden" name="cmd" value="_ext-enter" />
  11.     <input type="hidden" name="redirect_cmd" value="_cart" />
  12.     <input type="hidden" name="business" value="<?php echo $this -> get_option('pp_email'); ?>" />
  13.     <input type="hidden" name="receiver_email" value="<?php echo $this -> get_option('pp_email'); ?>" />
  14.  
  15.     <?php $amount = number_format($Order -> total($order -> id, false, true, true, true, false), 2, '.', ''); ?>
  16.     <?php $discount = $Discount -> total($order_id); ?>
  17.     <?php $total_price = $Order -> total($order -> id, true, true, true, true, false); ?>
  18.    
  19.     <?php if ($this -> get_option('enablecoupons') == "Y" && !empty($discount)) : ?>
  20.         <?php
  21.        
  22.         if ($this -> get_option('pp_surcharge') == "Y") {
  23.             $surcharge = $Order -> surcharge("pp", $total_price);
  24.             $amount += $surcharge;
  25.             $amount = number_format($amount, 2, '.', '');
  26.             $surcharge_text = $wpcoHtml -> surcharge_text("pp");
  27.         }
  28.        
  29.         ?>
  30.        
  31.         <input type="hidden" name="item_name_1" value="<?php bloginfo('name'); ?> <?php _e('Shopping Cart', $this -> plugin_name); ?>" />
  32.         <input type="hidden" name="item_number_1" value="<?php echo $order -> id; ?>" />
  33.         <input type="hidden" name="amount_1" value="<?php echo esc_attr(stripslashes($amount)); ?>" />
  34.         <input type="hidden" name="quantity_1" value="1" />
  35.     <?php else : ?>
  36.         <?php $i = 1; ?>
  37.         <?php foreach ($items as $item) : ?>
  38.             <input type="hidden" name="item_name_<?php echo $i; ?>" value="<?php echo esc_attr($item -> product -> title); ?>" />
  39.             <input type="hidden" name="item_number_<?php echo $i; ?>" value="<?php echo $item -> id; ?>" />
  40.             <input type="hidden" name="amount_<?php echo $i; ?>" value="<?php echo number_format(($Product -> unit_price($item -> product -> id, $item -> count, $item -> id, false, true)), 2, '.', ''); ?>" />
  41.             <input type="hidden" name="quantity_<?php echo $i; ?>" value="<?php echo $item -> count; ?>" />
  42.             <input type="hidden" name="num_cart_items" value="<?php echo $Item -> item_count($order -> id); ?>" />
  43.             <?php $i++; ?>
  44.         <?php endforeach; ?>
  45.        
  46.         <?php
  47.        
  48.         if ($this -> get_option('pp_surcharge') == "Y") {
  49.             $surcharge = $Order -> surcharge("pp", $total_price);
  50.             $surcharge_text = $wpcoHtml -> surcharge_text("pp");
  51.         }
  52.        
  53.         ?>
  54.        
  55.         <?php if ($this -> get_option('pp_surcharge') == "Y" && !empty($surcharge)) : ?>
  56.             <input type="hidden" name="item_name_<?php echo $i; ?>" value="<?php _e('Surcharge', $this -> plugin_name); ?> (<?php echo $surcharge_text; ?>)" />
  57.             <?php /*<input type="hidden" name="item_number_<?php echo $i; ?>" value="<?php echo $order -> id; ?>" />*/ ?>
  58.             <input type="hidden" name="amount_<?php echo $i; ?>" value="<?php echo $surcharge; ?>" />
  59.             <input type="hidden" name="quantity_<?php echo $i; ?>" value="1" />
  60.         <?php endif; ?>
  61.     <?php endif; ?>
  62.    
  63.     <!-- shipping -->
  64.     <?php if ($this -> get_option('shippingcalc') == "Y") : ?>
  65.         <input type="hidden" name="handling_cart" value="<?php echo number_format($Order -> shipping_total($amount, $order -> id), 2, '.', ''); ?>" />
  66.     <?php endif; ?>
  67.    
  68.     <!-- tax -->
  69.     <?php if ($this -> get_option('tax_calculate') == "Y" && !empty($tax_cart)) : ?>
  70.         <input type="hidden" name="tax" value="<?php echo number_format($tax_cart, 2, '.', ''); ?>" />
  71.         <input type="hidden" name="tax_rate" value="<?php echo $wpcoTax -> get_tax_percentage(); ?>" />
  72.         <input type="hidden" name="tax_cart" value="<?php echo number_format($tax_cart, 2, '.', ''); ?>" />
  73.     <?php endif; ?>
  74.    
  75.     <input type="hidden" name="no_note" value="1" />
  76.     <input type="hidden" name="currency_code" value="<?php echo $this -> get_option('currency'); ?>" />
  77.    
  78.     <input type="hidden" name="notify_url" value="<?php echo $wpcoHtml -> return_url(); ?>&type=pp" />
  79.     <?php if ($this -> get_option('pp_sandbox') == "Y") : ?>
  80.         <input type="hidden" name="notify_url" value="<?php echo $wpcoHtml -> return_url(); ?>&type=pp" />
  81.     <?php else : ?>
  82.         <input type="hidden" name="return" value="<?php echo $wpcoHtml -> success_url(); ?>" />
  83.     <?php endif; ?>
  84.     <input type="hidden" name="cbt" value="<?php _e('CLICK HERE TO COMPLETE YOUR ORDER NOW', $this -> plugin_name); ?>" />
  85.    
  86.     <input type="hidden" name="rm" value="2" />
  87.     <input type="hidden" name="custom" value="<?php echo $custom; ?>" />
  88.     <input type="hidden" name="invoice" value="<?php echo $this -> get_option('pp_invoiceprefix'); ?><?php echo $order -> id; ?>" />
  89.    
  90.     <input type="hidden" name="first_name" value="<?php echo $user -> bill_fname; ?>" />
  91.     <input type="hidden" name="last_name" value="<?php echo $user -> bill_lname; ?>" />
  92.     <input type="hidden" name="address1" value="<?php echo $user -> bill_address; ?>" />
  93.     <input type="hidden" name="city" value="<?php echo $user -> bill_city; ?>" />
  94.     <input type="hidden" name="state" value="<?php echo $user -> bill_state; ?>" />
  95.     <input type="hidden" name="zip" value="<?php echo $user -> bill_zipcode; ?>" />
  96.     <?php $wpcoDb -> model = $Country -> model; ?>
  97.     <?php $country = $wpcoDb -> field('value', array('id' => $user -> bill_country)); ?>   
  98.     <input type="hidden" name="country" value="<?php echo $country; ?>" />
  99.  
  100.     <a href="<?php echo $wpcoHtml -> bill_url(); ?>" class="button"><?php _e('&laquo; Back', $this -> plugin_name); ?></a>
  101.     <input class="button" style="cursor:pointer;" type="submit" name="payment" value="<?php _e('Continue &raquo;', $this -> plugin_name); ?>" />
  102. </form>
  103.  
  104. <script type="text/javascript">
  105. var form = document.getElementById('pp-form');
  106. form.submit();
  107. </script>
Advertisement
Add Comment
Please, Sign In to add comment