Gregg / spree-pp-website-standard

Paypal Website Payments Standard Extension for Spree, the open source shopping cart

spree-pp-website-standard / app / views / orders / _paypal_checkout.html.erb
100644 65 lines (54 sloc) 3.114 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<% if RAILS_ENV == 'development' %>
  <form action="<%= Spree::Paypal::Config[:sandbox_url] %>" method="post" onsubmit="return check_zipcode();">
<% else %>
  <form action="<%= Spree::Paypal::Config[:paypal_url] %>" method="post" onsubmit="return check_zipcode();">
<% end %>
 
<!-- display payment summary here -->
<input id="business" name="business" type="hidden" value="<%= Spree::Paypal::Config[:account] %>" />
<input id="invoice" name="invoice" type="hidden" value="<%= @order.number %>" />
 
<% @order.line_items.each_with_index do |item, index| %>
  <input id="item_name_<%= index + 1 %>" name="item_name_<%= index + 1 %>" type="hidden" value="<%= item.variant.product.name %>" />
  <input id="amount_<%= index + 1 %>" name="amount_<%= index + 1 %>" type="hidden" value="<%= item.price %>" />
  <input id="quantity_<%= index + 1 %>" name="quantity_<%= index + 1 %>" type="hidden" value="<%= item.quantity %>" />
<% end %>
 
<!-- input id="amount" name="amount" type="hidden" value="58.97" /-->
 
<input name="no_shipping" type="hidden" value="1" />
<input id="cmd" name="cmd" type="hidden" value="_cart" />
<input type="hidden" name="upload" value="1" />
 
<p> <%= t('please_select_your_country') %>
  <select name="country" id="country">
    <%= options_from_collection_for_select(Country.all, :id, :name, 214) %>
  </select>
</p>
<span style="color:red; font-weight:bold; display:none;" id="needZipcode">
  <%= t("please_enter_valid_zip") %>
</span>
<p>
<%= t('zip_code_if_you_have_one')%>: <input id="zip" name="zip" type="text" value="" />
</p>
 
<input id="notify_url" name="notify_url" type="hidden" value="<%= Spree::Paypal::Config[:ipn_notify_host] + order_paypal_payments_path(@order) %>" />
<input type="hidden" name="rm" value ="2"> <!-- tells paypal that the return should be POST instead of GET -->
<input id="return" name="return" type="hidden" value="<%= successful_order_paypal_payments_url(@order) %>" />
 
<!-- input id="address_override" name="address_override" type="hidden" value="0" />
<input id="charset" name="charset" type="hidden" value="utf-8" />
<input id="no_note" name="no_note" type="hidden" value="1" />
<input id="no_shipping" name="no_shipping" type="hidden" value="1" />
<input id="item_name" name="item_name" type="hidden" value="Store purchase" />
<input id="return" name="return" type="hidden" value="http://localhost:3000/account/show" />
<input id="currency_code" name="currency_code" type="hidden" value="USD" />
<input id="cancel_return" name="cancel_return" type="hidden" value="http://localhost:3000/account/show" />
<input id="custom" name="custom" type="hidden" value="11" />
<input id="item_number" name="item_number" type="hidden" value="11" / -->
<!-- input id="bn" name="bn" type="hidden" value="ActiveMerchant" /-->
 
<%= image_submit_tag "pp_checkout.gif" %>
 
</form>
 
 
<script type="text/javascript" charset="utf-8">
  function check_zipcode () {
    if ($('country').value == "United States" && ($('zip').value == null || $('zip').value.length < 5)) {
      $('needZipcode').show();
      return false;
    } else {
      return true;
    }
  }
</script>