class Twocheckout::Checkout
Public Class Methods
direct(params={}, button_text='Proceed to Checkout')
click to toggle source
# File lib/twocheckout/checkout.rb, line 23 def self.direct(params={}, button_text='Proceed to Checkout') @form = "<form id=\"2checkout\" action=\"#{@checkout_url}\" method=\"post\">\n"; params.each do |k,v| @form = @form + "<input type=\"hidden\" name=\"" + k + "\" value=\"" + v.to_s + "\" />\n" end @form = @form + "<input type=\"submit\" value=\"" + button_text + "\" />\n</form>\n" @form = @form + "<script src=\"https://www.2checkout.com/static/checkout/javascript/direct.min.js\"></script>" end
form(params={}, button_text='Proceed to Checkout')
click to toggle source
# File lib/twocheckout/checkout.rb, line 6 def self.form(params={}, button_text='Proceed to Checkout') @form = "<form id=\"2checkout\" action=\"#{@checkout_url}\" method=\"post\">\n"; params.each do |k,v| @form = @form + "<input type=\"hidden\" name=\"" + k + "\" value=\"" + v.to_s + "\" />\n" end @form + "<input type=\"submit\" value=\"" + button_text + "\" />\n</form>" end
link(params={})
click to toggle source
# File lib/twocheckout/checkout.rb, line 32 def self.link(params={}) @querystring = params.map{|k,v| "#{CGI.escape(k)}=#{CGI.escape(v)}"}.join("&") @purchase_url = @checkout_url + '?' + @querystring end
submit(params={})
click to toggle source
# File lib/twocheckout/checkout.rb, line 14 def self.submit(params={}) @form = "<form id=\"2checkout\" action=\"#{@checkout_url}\" method=\"post\">\n"; params.each do |k,v| @form = @form + "<input type=\"hidden\" name=\"" + k + "\" value=\"" + v.to_s + "\" />\n" end @form = @form + "</form>\n" @form = @form + "<script type=\"text/javascript\">document.getElementById('2checkout').submit();</script>" end