Class Index [+]

Quicksearch

ActiveMerchant::Billing::PayboxDirectGateway

Constants

TEST_URL
LIVE_URL
LIVE_URL_BACKUP
API_VERSION

Payment API Version

TRANSACTIONS

Transactions hash

CURRENCY_CODES
SUCCESS_CODES
UNAVAILABILITY_CODES
FRAUD_CODES
SUCCESS_MESSAGE
FAILURE_MESSAGE

Public Class Methods

new(options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/paybox_direct.rb, line 62
62:       def initialize(options = {})
63:         requires!(options, :login, :password)
64:         @options = options
65:         super
66:       end

Public Instance Methods

authorize(money, creditcard, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/paybox_direct.rb, line 68
68:       def authorize(money, creditcard, options = {})
69:         post = {}
70:         add_invoice(post, options)
71:         add_creditcard(post, creditcard)
72:         commit('authorization', money, post)
73:       end
capture(money, authorization, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/paybox_direct.rb, line 82
82:       def capture(money, authorization, options = {})
83:         requires!(options, :order_id)
84:         post = {}
85:         add_invoice(post, options)
86:         post[:numappel] = authorization[0,10]
87:         post[:numtrans] = authorization[10,10]
88:         commit('capture', money, post)
89:       end
credit(money, identification, options = {}) click to toggle source
     # File lib/active_merchant/billing/gateways/paybox_direct.rb, line 101
101:       def credit(money, identification, options = {})
102:         deprecated CREDIT_DEPRECATION_MESSAGE
103:         refund(money, identification, options)
104:       end
purchase(money, creditcard, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/paybox_direct.rb, line 75
75:       def purchase(money, creditcard, options = {})
76:         post = {}
77:         add_invoice(post, options)
78:         add_creditcard(post, creditcard)
79:         commit('purchase', money, post)
80:       end
refund(money, identification, options = {}) click to toggle source
     # File lib/active_merchant/billing/gateways/paybox_direct.rb, line 106
106:       def refund(money, identification, options = {})
107:         post = {}
108:         add_invoice(post, options)
109:         add_reference(post, identification)
110:         commit('refund', money, post)
111:       end
test?() click to toggle source
     # File lib/active_merchant/billing/gateways/paybox_direct.rb, line 113
113:       def test?
114:         @options[:test] || Base.gateway_mode == :test
115:       end
void(identification, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/paybox_direct.rb, line 91
91:       def void(identification, options = {})
92:         requires!(options, :order_id, :amount)
93:         post ={}
94:         add_invoice(post, options)
95:         add_reference(post, identification)
96:         post[:porteur] = '000000000000000'
97:         post[:dateval] = '0000'
98:         commit('void', options[:amount], post)
99:       end

Private Instance Methods

add_creditcard(post, creditcard) click to toggle source
     # File lib/active_merchant/billing/gateways/paybox_direct.rb, line 123
123:       def add_creditcard(post, creditcard)
124:         post[:porteur] = creditcard.number
125:         post[:dateval] = expdate(creditcard)
126:         post[:cvv] = creditcard.verification_value if creditcard.verification_value?
127:       end
add_invoice(post, options) click to toggle source
     # File lib/active_merchant/billing/gateways/paybox_direct.rb, line 119
119:       def add_invoice(post, options)
120:         post[:reference] = options[:order_id]
121:       end
add_reference(post, identification) click to toggle source
     # File lib/active_merchant/billing/gateways/paybox_direct.rb, line 129
129:       def add_reference(post, identification)
130:         post[:numappel] = identification[0,10]
131:         post[:numtrans] = identification[10,10]
132:       end
commit(action, money = nil, parameters = nil) click to toggle source
     # File lib/active_merchant/billing/gateways/paybox_direct.rb, line 144
144:       def commit(action, money = nil, parameters = nil)
145:         parameters[:montant] = ('0000000000' + (money ? amount(money) : ''))[10..1]
146:         parameters[:devise] = CURRENCY_CODES[options[:currency] || currency(money)]
147:         request_data = post_data(action,parameters)
148:         response = parse(ssl_post(test? ? TEST_URL : LIVE_URL, request_data))
149:         response = parse(ssl_post(LIVE_URL_BACKUP, request_data)) if service_unavailable?(response) && !test?
150:         Response.new(success?(response), message_from(response), response.merge(
151:           :timestamp => parameters[:dateq]),
152:           :test => test?,
153:           :authorization => response[:numappel].to_s + response[:numtrans].to_s,
154:           :fraud_review => fraud_review?(response),
155:           :sent_params => parameters.delete_if{|key,value| ['porteur','dateval','cvv'].include?(key.to_s)}
156:         )
157:       end
expdate(credit_card) click to toggle source
     # File lib/active_merchant/billing/gateways/paybox_direct.rb, line 198
198:       def expdate(credit_card)
199:         year  = sprintf("%.4i", credit_card.year)
200:         month = sprintf("%.2i", credit_card.month)
201: 
202:         "#{month}#{year[-2..-1]}"
203:       end
fraud_review?(response) click to toggle source
     # File lib/active_merchant/billing/gateways/paybox_direct.rb, line 163
163:       def fraud_review?(response)
164:         FRAUD_CODES.include?(response[:codereponse])
165:       end
message_from(response) click to toggle source
     # File lib/active_merchant/billing/gateways/paybox_direct.rb, line 171
171:       def message_from(response)
172:         success?(response) ? SUCCESS_MESSAGE : (response[:commentaire]  || FAILURE_MESSAGE)
173:       end
parse(body) click to toggle source
     # File lib/active_merchant/billing/gateways/paybox_direct.rb, line 134
134:       def parse(body)
135:         body = Iconv.iconv("UTF-8","LATIN1", body.to_s).join
136:         results = {}
137:         body.split(/&/).each do |pair|
138:           key,val = pair.split(/\=/)
139:           results[key.downcase.to_sym] = CGI.unescape(val) if val
140:         end
141:         results
142:       end
post_data(action, parameters = {}) click to toggle source
     # File lib/active_merchant/billing/gateways/paybox_direct.rb, line 175
175:       def post_data(action, parameters = {})
176: 
177:         parameters.update(
178:           :version => API_VERSION,
179:           :type => TRANSACTIONS[action.to_sym],
180:           :dateq => Time.now.strftime('%d%m%Y%H%M%S'),
181:           :numquestion => unique_id(parameters[:order_id]),
182:           :site => @options[:login].to_s[0,7],
183:           :rang => @options[:login].to_s[7..1],
184:           :cle => @options[:password],
185:           :pays => '',
186:           :archivage => parameters[:order_id]
187:         )
188: 
189:         parameters.collect { |key, value| "#{key.to_s.upcase}=#{CGI.escape(value.to_s)}" }.join("&")
190:       end
service_unavailable?(response) click to toggle source
     # File lib/active_merchant/billing/gateways/paybox_direct.rb, line 167
167:       def service_unavailable?(response)
168:         UNAVAILABILITY_CODES.include?(response[:codereponse])
169:       end
success?(response) click to toggle source
     # File lib/active_merchant/billing/gateways/paybox_direct.rb, line 159
159:       def success?(response)
160:         SUCCESS_CODES.include?(response[:codereponse])
161:       end
unique_id(seed = 0) click to toggle source
     # File lib/active_merchant/billing/gateways/paybox_direct.rb, line 192
192:       def unique_id(seed = 0)
193:         randkey = "#{seed}#{Time.now.usec}".to_i % 2147483647 # Max paybox value for the question number
194: 
195:         "0000000000#{randkey}"[10..1]
196:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.