link_to

2 views
Skip to first unread message

Erwin

unread,
Sep 2, 2010, 3:38:53 AM9/2/10
to Ruby on Rails: Talk
I am trying to use an encrypted request to PayPal using my own submit
button link
I googled a little but, but could not find a clear & neat solution, so
I ended writing this :

== Rails 2.3.8 script code ====
...
<% form_tag APP_CONFIG[:paypal_url], {:id => 'form_paypal'} do %>
<%= hidden_field_tag :cmd, "_s-xclick" %>
<%= hidden_field_tag :encrypted, @cart.paypal_encrypted(root_url,
payment_notifications_url(:secret => APP_CONFIG[:paypal_secret])) %>
<p><%= link_to_function "OK", "$('form_paypal').submit()" , :class
=> 'buy' %></p>
<% end %>
...
=====

The display is fine (I get my button..), the generated code seems ok,
but when I hit the button, nothing happen......

=== generated source code ====
...
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr"
id="form_paypal" method="post">

<div style="margin:0;padding:0;display:inline">
<input name="authenticity_token" type="hidden"
value="hswuJS6f7BRIcPx5zWDcxkQwX6JiFPGC/XxgGf5vyzM=" />
</div>

<input id="cmd" name="cmd" type="hidden" value="_s-xclick" />
<input id="encrypted" name="encrypted" type="hidden" value="-----BEGIN
PKCS7-----
MIIH3QYJKoZIhvcNAQcDoIIHzjCCB8oCAQAxggE6MIIBNgIBADCBnjCBmDELMAkGA1UEBhMCVVMxEzARB….
5l/cKPVZW2/h9QPBq44h
+F948cJ3lgAgQnSAACqkmxGWugL9v5MC8Nh3JtSrnvPCfINGQl8zWDIz74bM+
+au4g==-----END PKCS7-----" />

<p><a class="buy" href="#" onclick="$('form_paypal').submit(); return
false;">OK</a></p>
</form>

where am I wrong ?

Erwin

unread,
Sep 2, 2010, 3:55:31 AM9/2/10
to Ruby on Rails: Talk
[SOLVED] I realized that I was using jQuery and not Prototype
anymore ..
so the link_to function was not right and should have been written
with the correct jQuery id # : ('#form_paypal').submit()

<%= link_to_function "OK", "$('#form_paypal').submit()" , :class =>
'buy' %>
> MIIH3QYJKoZIhvcNAQcDoIIHzjCCB8oCAQAxggE6MIIBNgIBADCBnjCBmDELMAkGA1UEBhMCVVM xEzARB….
Reply all
Reply to author
Forward
0 new messages