Class Index [+]

Quicksearch

ActiveMerchant::Billing::EpayGateway

Constants

API_HOST
SOAP_URL
CURRENCY_CODES

Public Class Methods

new(options = {}) click to toggle source

login: merchant number password: referrer url (for authorize authentication)

    # File lib/active_merchant/billing/gateways/epay.rb, line 55
55:       def initialize(options = {})
56:         requires!(options, :login, :password)
57:         @options = options
58:         super
59:       end

Public Instance Methods

authorize(money, credit_card_or_reference, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/epay.rb, line 61
61:       def authorize(money, credit_card_or_reference, options = {})
62:         post = {}
63: 
64:         add_amount(post, money, options)
65:         add_invoice(post, options)
66:         add_creditcard_or_reference(post, credit_card_or_reference)
67:         add_instant_capture(post, false)
68: 
69:         commit(:authorize, post)
70:       end
capture(money, authorization, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/epay.rb, line 83
83:       def capture(money, authorization, options = {})
84:         post = {}
85: 
86:         add_reference(post, authorization)
87:         add_amount_without_currency(post, money)
88: 
89:         commit(:capture, post)
90:       end
credit(money, identification, options = {}) click to toggle source
     # File lib/active_merchant/billing/gateways/epay.rb, line 109
109:       def credit(money, identification, options = {})
110:         deprecated CREDIT_DEPRECATION_MESSAGE
111:         refund(money, identification, options)
112:       end
purchase(money, credit_card_or_reference, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/epay.rb, line 72
72:       def purchase(money, credit_card_or_reference, options = {})
73:         post = {}
74: 
75:         add_amount(post, money, options)
76:         add_creditcard_or_reference(post, credit_card_or_reference)
77:         add_invoice(post, options)
78:         add_instant_capture(post, true)
79: 
80:         commit(:authorize, post)
81:       end
refund(money, identification, options = {}) click to toggle source
     # File lib/active_merchant/billing/gateways/epay.rb, line 100
100:       def refund(money, identification, options = {})
101:         post = {}
102: 
103:         add_amount_without_currency(post, money)
104:         add_reference(post, identification)
105: 
106:         commit(:credit, post)
107:       end
void(identification, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/epay.rb, line 92
92:       def void(identification, options = {})
93:         post = {}
94: 
95:         add_reference(post, identification)
96: 
97:         commit(:void, post)
98:       end

Private Instance Methods

add_amount(post, money, options) click to toggle source
     # File lib/active_merchant/billing/gateways/epay.rb, line 116
116:       def add_amount(post, money, options)
117:         post[:amount]   = amount(money)
118:         post[:currency] = CURRENCY_CODES[(options[:currency] || currency(money)).to_sym]
119:       end
add_amount_without_currency(post, money) click to toggle source
     # File lib/active_merchant/billing/gateways/epay.rb, line 121
121:       def add_amount_without_currency(post, money)
122:         post[:amount] = amount(money)
123:       end
add_creditcard(post, credit_card) click to toggle source
     # File lib/active_merchant/billing/gateways/epay.rb, line 133
133:       def add_creditcard(post, credit_card)
134:         post[:cardno]   = credit_card.number
135:         post[:cvc]      = credit_card.verification_value
136:         post[:expmonth] = credit_card.month
137:         post[:expyear]  = credit_card.year
138:       end
add_creditcard_or_reference(post, credit_card_or_reference) click to toggle source
     # File lib/active_merchant/billing/gateways/epay.rb, line 140
140:       def add_creditcard_or_reference(post, credit_card_or_reference)
141:         if credit_card_or_reference.respond_to?(:number)
142:           add_creditcard(post, credit_card_or_reference)
143:         else
144:           add_reference(post, credit_card_or_reference.to_s)
145:         end
146:       end
add_instant_capture(post, option) click to toggle source
     # File lib/active_merchant/billing/gateways/epay.rb, line 148
148:       def add_instant_capture(post, option)
149:         post[:instantcapture] = option ? 1 : 0
150:       end
add_invoice(post, options) click to toggle source
     # File lib/active_merchant/billing/gateways/epay.rb, line 129
129:       def add_invoice(post, options)
130:         post[:orderid] = format_order_number(options[:order_id])
131:       end
add_reference(post, identification) click to toggle source
     # File lib/active_merchant/billing/gateways/epay.rb, line 125
125:       def add_reference(post, identification)
126:         post[:transaction] = identification
127:       end
authorize_post_data(params = {}) click to toggle source
     # File lib/active_merchant/billing/gateways/epay.rb, line 258
258:       def authorize_post_data(params = {})
259:         params[:language] = '2'
260:         params[:cms] = 'activemerchant'
261:         params[:accepturl] = 'https://ssl.ditonlinebetalingssystem.dk/auth/default.aspx?accept=1'
262:         params[:declineurl] = 'https://ssl.ditonlinebetalingssystem.dk/auth/default.aspx?decline=1'
263:         params[:merchantnumber] = @options[:login]
264: 
265:         params.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
266:       end
commit(action, params) click to toggle source
     # File lib/active_merchant/billing/gateways/epay.rb, line 152
152:       def commit(action, params)
153:         response = send("do_#{action}", params)
154: 
155:         if action == :authorize
156:           Response.new response['accept'].to_i == 1,
157:                        response['errortext'],
158:                        response,
159:                        :test => test?,
160:                        :authorization => response['tid']
161:         else
162:           Response.new response['result'] == 'true',
163:                        messages(response['epay'], response['pbs']),
164:                        response,
165:                        :test => test?,
166:                        :authorization => params[:transaction]
167:         end
168:       end
do_authorize(params) click to toggle source
     # File lib/active_merchant/billing/gateways/epay.rb, line 182
182:       def do_authorize(params)
183:         headers = {}
184:         headers['Referer'] = options[:password] if options[:password]
185: 
186:         response = raw_ssl_request(:post, 'https://' + API_HOST + '/auth/default.aspx', authorize_post_data(params), headers)
187: 
188:         # Authorize gives the response back by redirecting with the values in
189:         # the URL query
190:         if location = response['Location']
191:           query = CGI::parse(URI.parse(location.gsub(' ', '%20')).query)
192:         else
193:           return {
194:             'accept' => '0',
195:             'errortext' => 'No Location header returned.'
196:           }
197:         end
198: 
199:         result = {}
200:         query.each_pair do |k,v|
201:           result[k] = v.is_a?(Array) && v.size == 1 ? v[0] : v # make values like ['v'] into 'v'
202:         end
203:         result
204:       end
do_capture(params) click to toggle source
     # File lib/active_merchant/billing/gateways/epay.rb, line 206
206:       def do_capture(params)
207:         response = soap_post('capture', params)
208:         {
209:           'result' => response.elements['//captureResponse/captureResult'].text,
210:           'pbs' => response.elements['//captureResponse/pbsResponse'].text,
211:           'epay' => response.elements['//captureResponse/epayresponse'].text
212:         }
213:       end
do_credit(params) click to toggle source
     # File lib/active_merchant/billing/gateways/epay.rb, line 215
215:       def do_credit(params)
216:         response = soap_post('credit', params)
217:         {
218:           'result' => response.elements['//creditResponse/creditResult'].text,
219:           'pbs' => response.elements['//creditResponse/pbsresponse'].text,
220:           'epay' => response.elements['//creditResponse/epayresponse'].text
221:         }
222:       end
do_void(params) click to toggle source
     # File lib/active_merchant/billing/gateways/epay.rb, line 224
224:       def do_void(params)
225:         response = soap_post('delete', params)
226:         {
227:           'result' => response.elements['//deleteResponse/deleteResult'].text,
228:           'epay' => response.elements['//deleteResponse/epayresponse'].text
229:         }
230:       end
format_order_number(number) click to toggle source

Limited to 20 digits max

     # File lib/active_merchant/billing/gateways/epay.rb, line 269
269:       def format_order_number(number)
270:         number.to_s.gsub(/[^\w_]/, '').rjust(4, "0")[0...20]
271:       end
make_headers(data, soap_call) click to toggle source
     # File lib/active_merchant/billing/gateways/epay.rb, line 232
232:       def make_headers(data, soap_call)
233:         {
234:           'Content-Type' => 'text/xml; charset=utf-8',
235:           'Host' => API_HOST,
236:           'Content-Length' => data.size.to_s,
237:           'SOAPAction' => SOAP_URL + '/' + soap_call
238:         }
239:       end
messages(epay, pbs = nil) click to toggle source
     # File lib/active_merchant/billing/gateways/epay.rb, line 170
170:       def messages(epay, pbs = nil)
171:         response = "ePay: #{epay}"
172:         response << " PBS: #{pbs}" if pbs
173:         return response
174:       end
soap_post(method, params) click to toggle source
     # File lib/active_merchant/billing/gateways/epay.rb, line 176
176:       def soap_post(method, params)
177:         data = xml_builder(params, method)
178:         headers = make_headers(data, method)
179:         REXML::Document.new(ssl_post('https://' + API_HOST + '/remote/payment.asmx', data, headers))
180:       end
xml_builder(params, soap_call) click to toggle source
     # File lib/active_merchant/billing/gateways/epay.rb, line 241
241:       def xml_builder(params, soap_call)
242:         xml = Builder::XmlMarkup.new(:indent => 2)
243:         xml.instruct!
244:           xml.tag! 'soap:Envelope', { 'xmlns:xsi' => 'http://schemas.xmlsoap.org/soap/envelope/',
245:                                       'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema',
246:                                       'xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/' } do
247:             xml.tag! 'soap:Body' do
248:               xml.tag! soap_call, { 'xmlns' => SOAP_URL } do
249:                 xml.tag! 'merchantnumber', @options[:login]
250:                 xml.tag! 'transactionid', params[:transaction]
251:                 xml.tag! 'amount', params[:amount].to_s if soap_call != 'delete'
252:               end
253:             end
254:           end
255:         xml.target!
256:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.