class ActiveMerchant::Billing::EpayGateway
Constants
- CURRENCY_CODES
Public Class Methods
new(options = {})
click to toggle source
login: merchant number password: referrer url (for authorize authentication)
Calls superclass method
ActiveMerchant::Billing::Gateway::new
# File lib/active_merchant/billing/gateways/epay.rb, line 54 def initialize(options = {}) requires!(options, :login) super end
Public Instance Methods
capture(money, authorization, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/epay.rb, line 81 def capture(money, authorization, options = {}) post = {} add_reference(post, authorization) add_amount_without_currency(post, money) commit(:capture, post) end
credit(money, identification, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/epay.rb, line 107 def credit(money, identification, options = {}) ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE refund(money, identification, options) end
purchase(money, credit_card_or_reference, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/epay.rb, line 70 def purchase(money, credit_card_or_reference, options = {}) post = {} add_amount(post, money, options) add_creditcard_or_reference(post, credit_card_or_reference) add_invoice(post, options) add_instant_capture(post, true) commit(:authorize, post) end
refund(money, identification, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/epay.rb, line 98 def refund(money, identification, options = {}) post = {} add_amount_without_currency(post, money) add_reference(post, identification) commit(:credit, post) end
scrub(transcript)
click to toggle source
# File lib/active_merchant/billing/gateways/epay.rb, line 116 def scrub(transcript) transcript. gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]'). gsub(%r(((?:\?|&)cardno=)\d*(&?)), '\1[FILTERED]\2'). gsub(%r((&?cvc=)\d*(&?)), '\1[FILTERED]\2') end
supports_scrubbing()
click to toggle source
# File lib/active_merchant/billing/gateways/epay.rb, line 112 def supports_scrubbing true end
void(identification, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/epay.rb, line 90 def void(identification, options = {}) post = {} add_reference(post, identification) commit(:void, post) end
Private Instance Methods
add_amount(post, money, options)
click to toggle source
# File lib/active_merchant/billing/gateways/epay.rb, line 125 def add_amount(post, money, options) post[:amount] = amount(money) post[:currency] = CURRENCY_CODES[(options[:currency] || currency(money)).to_sym] end
add_amount_without_currency(post, money)
click to toggle source
# File lib/active_merchant/billing/gateways/epay.rb, line 130 def add_amount_without_currency(post, money) post[:amount] = amount(money) end
add_creditcard(post, credit_card)
click to toggle source
# File lib/active_merchant/billing/gateways/epay.rb, line 142 def add_creditcard(post, credit_card) post[:cardno] = credit_card.number post[:cvc] = credit_card.verification_value post[:expmonth] = credit_card.month post[:expyear] = credit_card.year end
add_creditcard_or_reference(post, credit_card_or_reference)
click to toggle source
# File lib/active_merchant/billing/gateways/epay.rb, line 149 def add_creditcard_or_reference(post, credit_card_or_reference) if credit_card_or_reference.respond_to?(:number) add_creditcard(post, credit_card_or_reference) else add_reference(post, credit_card_or_reference.to_s) end end
add_instant_capture(post, option)
click to toggle source
# File lib/active_merchant/billing/gateways/epay.rb, line 157 def add_instant_capture(post, option) post[:instantcapture] = option ? 1 : 0 end
add_invoice(post, options)
click to toggle source
# File lib/active_merchant/billing/gateways/epay.rb, line 138 def add_invoice(post, options) post[:orderid] = format_order_number(options[:order_id]) end
add_reference(post, identification)
click to toggle source
# File lib/active_merchant/billing/gateways/epay.rb, line 134 def add_reference(post, identification) post[:transaction] = identification end
commit(action, params)
click to toggle source
# File lib/active_merchant/billing/gateways/epay.rb, line 161 def commit(action, params) response = send("do_#{action}", params) if action == :authorize Response.new response['accept'].to_i == 1, response['errortext'], response, :test => test?, :authorization => response['tid'] else Response.new response['result'] == 'true', messages(response['epay'], response['pbs']), response, :test => test?, :authorization => params[:transaction] end end
do_capture(params)
click to toggle source
# File lib/active_merchant/billing/gateways/epay.rb, line 217 def do_capture(params) response = soap_post('capture', params) { 'result' => response.elements['//captureResponse/captureResult'].text, 'pbs' => response.elements['//captureResponse/pbsResponse'].text, 'epay' => response.elements['//captureResponse/epayresponse'].text } end
do_credit(params)
click to toggle source
# File lib/active_merchant/billing/gateways/epay.rb, line 226 def do_credit(params) response = soap_post('credit', params) { 'result' => response.elements['//creditResponse/creditResult'].text, 'pbs' => response.elements['//creditResponse/pbsresponse'].text, 'epay' => response.elements['//creditResponse/epayresponse'].text } end
do_void(params)
click to toggle source
# File lib/active_merchant/billing/gateways/epay.rb, line 235 def do_void(params) response = soap_post('delete', params) { 'result' => response.elements['//deleteResponse/deleteResult'].text, 'epay' => response.elements['//deleteResponse/epayresponse'].text } end
format_order_number(number)
click to toggle source
Limited to 20 digits max
# File lib/active_merchant/billing/gateways/epay.rb, line 280 def format_order_number(number) number.to_s.gsub(/[^\w]/, '').rjust(4, '0')[0...20] end
make_headers(data, soap_call)
click to toggle source
# File lib/active_merchant/billing/gateways/epay.rb, line 243 def make_headers(data, soap_call) { 'Content-Type' => 'text/xml; charset=utf-8', 'Host' => 'ssl.ditonlinebetalingssystem.dk', 'Content-Length' => data.size.to_s, 'SOAPAction' => self.live_url + 'remote/payment/' + soap_call } end
messages(epay, pbs = nil)
click to toggle source
# File lib/active_merchant/billing/gateways/epay.rb, line 179 def messages(epay, pbs = nil) response = "ePay: #{epay}" response << " PBS: #{pbs}" if pbs return response end
soap_post(method, params)
click to toggle source
# File lib/active_merchant/billing/gateways/epay.rb, line 185 def soap_post(method, params) data = xml_builder(params, method) headers = make_headers(data, method) REXML::Document.new(ssl_post(live_url + 'remote/payment.asmx', data, headers)) end
xml_builder(params, soap_call)
click to toggle source
# File lib/active_merchant/billing/gateways/epay.rb, line 252 def xml_builder(params, soap_call) xml = Builder::XmlMarkup.new(:indent => 2) xml.instruct! xml.tag! 'soap:Envelope', { 'xmlns:xsi' => 'http://schemas.xmlsoap.org/soap/envelope/', 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema', 'xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/' } do xml.tag! 'soap:Body' do xml.tag! soap_call, { 'xmlns' => "#{self.live_url}remote/payment" } do xml.tag! 'merchantnumber', @options[:login] xml.tag! 'transactionid', params[:transaction] xml.tag! 'amount', params[:amount].to_s if soap_call != 'delete' end end end xml.target! end