Class Index [+]

Quicksearch

ActiveMerchant::Billing::PaySecureGateway

Constants

URL
TRANSACTIONS

Currently Authorization and Capture is not implemented because capturing requires the original credit card information

SUCCESS
SUCCESS_MESSAGE

Public Class Methods

new(options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/pay_secure.rb, line 25
25:       def initialize(options = {})
26:         requires!(options, :login, :password)
27:         @options = options
28:         super
29:       end

Public Instance Methods

purchase(money, credit_card, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/pay_secure.rb, line 31
31:       def purchase(money, credit_card, options = {})
32:         requires!(options, :order_id)
33:         
34:         post = {}
35:         add_amount(post, money)
36:         add_invoice(post, options)
37:         add_credit_card(post, credit_card)        
38:              
39:         commit(:purchase, money, post)
40:       end

Private Instance Methods

add_amount(post, money) click to toggle source
    # File lib/active_merchant/billing/gateways/pay_secure.rb, line 50
50:       def add_amount(post, money)
51:         post[:amount] = amount(money)
52:       end
add_credit_card(post, credit_card) click to toggle source
    # File lib/active_merchant/billing/gateways/pay_secure.rb, line 61
61:       def add_credit_card(post, credit_card)      
62:         post[:cardnum]  = credit_card.number
63:         post[:cardname] = credit_card.name
64:         post[:expiry]   = expdate(credit_card)
65:         post[:cvv2]     = credit_card.verification_value
66:       end
add_invoice(post, options) click to toggle source
    # File lib/active_merchant/billing/gateways/pay_secure.rb, line 54
54:       def add_invoice(post, options)
55:         post[:merchant_transid] = options[:order_id].to_s.slice(0,21)
56:         post[:memnum]           = options[:invoice]
57:         post[:custnum]          = options[:customer]
58:         post[:clientdata]       = options[:description]
59:       end
add_reference(post, identification) click to toggle source

Used for capturing, which is currently not supported.

    # File lib/active_merchant/billing/gateways/pay_secure.rb, line 44
44:       def add_reference(post, identification)
45:         auth, trans_id = identification.split(";")
46:         post[:authnum]    = auth
47:         post[:transid] = trans_id
48:       end
authorization_from(response) click to toggle source
    # File lib/active_merchant/billing/gateways/pay_secure.rb, line 89
89:       def authorization_from(response)
90:         [ response[:authnum], response[:transid] ].compact.join(";")
91:       end
commit(action, money, parameters) click to toggle source
    # File lib/active_merchant/billing/gateways/pay_secure.rb, line 75
75:       def commit(action, money, parameters)
76:         response = parse( ssl_post(URL, post_data(action, parameters)) )
77:         
78:         Response.new(successful?(response), message_from(response), response, 
79:           :test => test_response?(response), 
80:           :authorization => authorization_from(response)
81:         )
82:         
83:       end
expdate(credit_card) click to toggle source
    # File lib/active_merchant/billing/gateways/pay_secure.rb, line 68
68:       def expdate(credit_card)
69:         year  = sprintf("%.4i", credit_card.year)
70:         month = sprintf("%.2i", credit_card.month)
71: 
72:         "#{month}#{year[-2..-1]}"
73:       end
message_from(response) click to toggle source
    # File lib/active_merchant/billing/gateways/pay_secure.rb, line 97
97:       def message_from(response)
98:         successful?(response) ? SUCCESS_MESSAGE : response[:errorstring]
99:       end
parse(body) click to toggle source
     # File lib/active_merchant/billing/gateways/pay_secure.rb, line 101
101:       def parse(body)
102:         response = {}
103:         body.to_s.each_line do |l| 
104:           key, value = l.split(":", 2)
105:           response[key.to_s.downcase.to_sym] = value.strip
106:         end
107:         response
108:       end
post_data(action, parameters = {}) click to toggle source
     # File lib/active_merchant/billing/gateways/pay_secure.rb, line 110
110:       def post_data(action, parameters = {})
111:         parameters[:request_type]     = TRANSACTIONS[action]
112:         parameters[:merchant_id]      = @options[:login]
113:         parameters[:password]         = @options[:password]
114:         
115:         parameters.reject{|k,v| v.blank?}.collect { |key, value| "#{key.to_s.upcase}=#{CGI.escape(value.to_s)}" }.join("&")
116:       end
successful?(response) click to toggle source
    # File lib/active_merchant/billing/gateways/pay_secure.rb, line 85
85:       def successful?(response)
86:         response[:status] == SUCCESS
87:       end
test_response?(response) click to toggle source
    # File lib/active_merchant/billing/gateways/pay_secure.rb, line 93
93:       def test_response?(response)
94:         !!(response[:transid] =~ /SimProxy/)
95:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.