Hello, I have two forms. One of them is for keep the info in BBDD, and
the other is to pay in PayPal.

In my store I have in tienda_controller.rb an action to checkout. It
redirect you to checkout1.html.erb

#views/tienda/checkout1.html.erb

<h1>PASO 1</h1>

  <%= error_messages_for 'pedido' %>

  <% form_for :pedido, :url => { :action => :save_order } do |form| %>
    <fieldset>
      <legend>Introduce tus datos de facturación.</legend>

      <div>
        <%= form.label :nombre, "Nombre:" %>
        <%= form.text_field :nombre, :size => 40 %>
      </div>

      <div>
        <%= form.label :direccion, "Dirección:" %>
        <%= form.text_area :direccion, :rows => 3, :cols => 40 %>
      </div>

      <div>
        <%= form.label :email, "E-Mail:" %>
        <%= form.text_field :email, :size => 40 %>
      </div>

      <div>
        <%= form.label :tipo_pago, "Pago con:" %>
        <%=
          form.select :tipo_pago,
                       Pedido::TIPOS_PAGO,
                      :prompt => "Selecciona método de pago"
        %>
      </div>

      <%= submit_tag "Aceptar pedido", :class => "submit" %>
    </fieldset>
  <% end %>
</div>

Here you will introduce an billing info.

when you finish this form and submit, you will redirect to a page that
only can push a button "Pay with PayPal". The form is this:


#views/tienda/checkout.html.erb



   <% form_tag 'https://www.sandbox.paypal.com/cgi-bin/webscr' do %>
  <%= hidden_field_tag "cmd", "_cart" %>
  <%= hidden_field_tag "upload", "1" %>
  <%= hidden_field_tag "business", "alr113_1262371878_...@gmail.com" %>
    <%= hidden_field_tag "currency_code", value="EUR" %>
  <%= hidden_field_tag "country", value="ES" %>
  <%= hidden_field_tag "notify_url", "payment_notifications_url" %>

  <%= render(:partial => "paypal_item", :collection => @carrito.items)
%>

  <%= hidden_field_tag "return",
"http://localhost:3000/tienda/finalizado"; %>
  <%= submit_tag "Comprar en PayPal", :class => "submit" %>
  <% end %>

and my tienda_controller

  def save_order
    @carrito = encontrar_carrito
    @pedido = Pedido.new(params[:pedido])
    @pedido.anadir_item_lineas_de_carrito(@carrito)
   if @pedido.save
      #session[:carrito] = nil
      redirect_to_paypal("Solo queda un ultimo paso. Realiza el pago con
PayPal: un método más seguro para pagos en internet.")
    else
      render :action => :checkout1
    end
  end

Only I want that when the user want to checkout don't redirect to two
different pages. I want that fills the checkout1 form(Name, address,
email...) and when the user click the submit button, my page redirect
him directly to paypal page.

It is possible?
-- 
Posted via http://www.ruby-forum.com/.

--

You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.


Reply via email to