Class: ActiveMerchant::Billing::BorgunGateway

Inherits:
Gateway
  • Object
show all
Defined in:
lib/active_merchant/billing/gateways/borgun.rb

Constant Summary

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::DEBIT_CARDS, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

#card_brand, card_brand, #generate_unique_id, inherited, supported_countries, #supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #supports_scrubbing?, #test?

Methods included from CreditCardFormatting

#expdate, #format

Methods included from PostsData

included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request

Constructor Details

#initialize(options = {}) ⇒ BorgunGateway

Returns a new instance of BorgunGateway.



19
20
21
22
# File 'lib/active_merchant/billing/gateways/borgun.rb', line 19

def initialize(options={})
  requires!(options, :processor, :merchant_id, :username, :password)
  super
end

Instance Method Details

#authorize(money, payment, options = {}) ⇒ Object



33
34
35
36
37
38
39
40
# File 'lib/active_merchant/billing/gateways/borgun.rb', line 33

def authorize(money, payment, options={})
  post = {}
  post[:TransType] = '5'
  add_invoice(post, money, options)
  add_payment_method(post, payment)

  commit('authonly', post)
end

#capture(money, authorization, options = {}) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/active_merchant/billing/gateways/borgun.rb', line 42

def capture(money, authorization, options={})
  post = {}
  post[:TransType] = '1'
  add_invoice(post, money, options)
  add_reference(post, authorization)
  commit('capture', post)
end

#purchase(money, payment, options = {}) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/active_merchant/billing/gateways/borgun.rb', line 24

def purchase(money, payment, options={})
  post = {}
  post[:TransType] = '1'
  add_invoice(post, money, options)
  add_payment_method(post, payment)

  commit('sale', post)
end

#refund(money, authorization, options = {}) ⇒ Object



50
51
52
53
54
55
56
# File 'lib/active_merchant/billing/gateways/borgun.rb', line 50

def refund(money, authorization, options={})
  post = {}
  post[:TransType] = '3'
  add_invoice(post, money, options)
  add_reference(post, authorization)
  commit('refund', post)
end

#scrub(transcript) ⇒ Object



72
73
74
75
76
# File 'lib/active_merchant/billing/gateways/borgun.rb', line 72

def scrub(transcript)
  transcript.gsub(%r((<PAN>)[^&]*(</PAN>))i, '\1[FILTERED]\2').
    gsub(%r((<CVC2>)[^&]*(</CVC2>))i, '\1[FILTERED]\2').
    gsub(%r(((?:\r\n)?Authorization: Basic )[^\r\n]+(\r\n)?), '\1[FILTERED]\2')
end

#supports_scrubbingObject



68
69
70
# File 'lib/active_merchant/billing/gateways/borgun.rb', line 68

def supports_scrubbing
  true
end

#void(authorization, options = {}) ⇒ Object



58
59
60
61
62
63
64
65
66
# File 'lib/active_merchant/billing/gateways/borgun.rb', line 58

def void(authorization, options={})
  post = {}
  # TransType and TrAmount must match original values from auth or purchase.
  _, _, _, _, _, transtype, tramount = split_authorization(authorization)
  post[:TransType] = transtype
  add_invoice(post, tramount.to_i, options)
  add_reference(post, authorization)
  commit('void', post)
end