Class: Twocheckout::Checkout

Inherits:
HashObject show all
Defined in:
lib/twocheckout/checkout.rb

Class Method Summary collapse

Methods inherited from HashObject

#initialize, #inspect, #method_missing

Constructor Details

This class inherits a constructor from Twocheckout::HashObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Twocheckout::HashObject

Class Method Details

.authorize(params = {}) ⇒ Object



37
38
39
40
# 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') ⇒ Object



23
24
25
26
27
28
29
30
# 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') ⇒ Object



6
7
8
9
10
11
12
# 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


32
33
34
35
# 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 = {}) ⇒ Object



14
15
16
17
18
19
20
21
# 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