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::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

#add_field_to_post_if_present, #add_fields_to_post_if_present, 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



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/active_merchant/billing/gateways/borgun.rb', line 40

def authorize(money, payment, options = {})
  post = {}
  action = ''
  if options[:apply_3d_secure] == '1'
    add_3ds_preauth_fields(post, options)
    action = '3ds_preauth'
  else
    post[:TransType] = '5'
    add_3ds_fields(post, options)
    action = 'authonly'
  end
  add_invoice(post, money, options)
  add_payment_method(post, payment)
  commit(action, post, options)
end

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



56
57
58
59
60
61
62
# File 'lib/active_merchant/billing/gateways/borgun.rb', line 56

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
32
33
34
35
36
37
38
# File 'lib/active_merchant/billing/gateways/borgun.rb', line 24

def purchase(money, payment, options = {})
  post = {}
  action = ''
  if options[:apply_3d_secure] == '1'
    add_3ds_preauth_fields(post, options)
    action = '3ds_preauth'
  else
    post[:TransType] = '1'
    add_3ds_fields(post, options)
    action = 'sale'
  end
  add_invoice(post, money, options)
  add_payment_method(post, payment)
  commit(action, post, options)
end

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



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

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



87
88
89
90
91
# File 'lib/active_merchant/billing/gateways/borgun.rb', line 87

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



83
84
85
# File 'lib/active_merchant/billing/gateways/borgun.rb', line 83

def supports_scrubbing
  true
end

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



72
73
74
75
76
77
78
79
80
81
# File 'lib/active_merchant/billing/gateways/borgun.rb', line 72

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