class Twocheckout::Checkout

Public Class Methods

authorize(params={}) click to toggle source
# File lib/twocheckout/checkout.rb, line 37
def self.authorize(params={})
  response = Twocheckout::API.request(:post, 'authService', params)
  response['response']
end
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
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