forked from tomash/spree-pp-website-standard
/
_paypal_checkout.html.erb
49 lines (40 loc) · 2.87 KB
/
_paypal_checkout.html.erb
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
<%- if(RAILS_ENV == 'development')
submit_url = Spree::Paypal::Config[:sandbox_url]
else
submit_url = Spree::Paypal::Config[:paypal_url]
end
%>
<%= form_tag submit_url do %>
<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| %>
<%- if item.variant.respond_to?(:paypal_name) %>
<input id="item_name_<%= index + 1 %>" name="item_name_<%= index + 1 %>" type="hidden" value="<%= item.variant.paypal_name %>" />
<% else %>
<input id="item_name_<%= index + 1 %>" name="item_name_<%= index + 1 %>" type="hidden" value="<%= item.variant.product.name %>" />
<% end %>
<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="currency_code" name="currency_code" type="hidden" value="<%= Spree::Paypal::Config[:currency_code] %>" />
<input id="handling_cart" name="handling_cart" type="hidden" value="<%= @order.ship_total %>" />
<input id="tax_cart" name="tax_cart" type="hidden" value="<%= @order.tax_total %>" />
<input id="cmd" name="cmd" type="hidden" value="_cart" />
<input type="hidden" name="upload" value="1" />
<input id="notify_url" name="notify_url" type="hidden" value="<%= payment_notifications_url %>" />
<input type="hidden" name="rm" value ="2" />
<input id="return" name="return" type="hidden" value="<%= Spree::Paypal::Config[:success_url] %>" />
<input id="charset" name="charset" type="hidden" value="utf-8" />
<% if(Spree::Paypal::Config[:populate_address] && @order.bill_address) %>
<input type="hidden" name="address1" id="address1" value="<%= @order.bill_address.address1 %>" />
<input type="hidden" name="address2" id="address2" value="<%= @order.bill_address.address2 %>" />
<input type="hidden" name="city" id="city" value="<%= @order.bill_address.city %>" />
<input type="hidden" name="country" id="country" value="<%= @order.bill_address.country.iso %>" />
<input type="hidden" name="email" id="email" value="<%= @order.email %>" />
<input type="hidden" name="first_name" id="first_name" value="<%= @order.bill_address.firstname %>" />
<input type="hidden" name="last_name" id="last_name" value="<%= @order.bill_address.lastname %>" />
<input type="hidden" name="zip" id="zip" value="<%= @order.bill_address.zipcode %>" />
<input type="hidden" name="night_phone_b" id="night_phone_b" value="<%= @order.bill_address.phone %>" />
<% end %>
<%= image_submit_tag "pp_checkout.gif" %>
<% end -%>