Class: ActiveMerchant::Billing::BamboraApacGateway

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

Constant Summary collapse

STANDARD_ERROR_CODE_MAPPING =
{
  '05' => STANDARD_ERROR_CODE[:card_declined],
  '06' => STANDARD_ERROR_CODE[:processing_error],
  '14' => STANDARD_ERROR_CODE[:invalid_number],
  '54' => STANDARD_ERROR_CODE[:expired_card],
}

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?, #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 = {}) ⇒ BamboraApacGateway

Returns a new instance of BamboraApacGateway.



24
25
26
27
# File 'lib/active_merchant/billing/gateways/bambora_apac.rb', line 24

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

Instance Method Details

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



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

def authorize(money, payment, options={})
  commit('SubmitSinglePayment') do |xml|
    xml.Transaction do
      xml.CustRef options[:order_id]
      add_amount(xml, money)
      xml.TrnType '2'
      add_payment(xml, payment)
      add_credentials(xml, options)
      xml.TrnSource options[:ip]
    end
  end
end

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



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

def capture(money, authorization, options={})
  commit('SubmitSingleCapture') do |xml|
    xml.Capture do
      xml.Receipt authorization
      add_amount(xml, money)
      add_credentials(xml, options)
    end
  end
end

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



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/active_merchant/billing/gateways/bambora_apac.rb', line 29

def purchase(money, payment, options={})
  commit('SubmitSinglePayment') do |xml|
    xml.Transaction do
      xml.CustRef options[:order_id]
      add_amount(xml, money)
      xml.TrnType '1'
      add_payment(xml, payment)
      add_credentials(xml, options)
      xml.TrnSource options[:ip]
    end
  end
end

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



65
66
67
68
69
70
71
72
73
# File 'lib/active_merchant/billing/gateways/bambora_apac.rb', line 65

def refund(money, authorization, options={})
  commit('SubmitSingleRefund') do |xml|
    xml.Refund do
      xml.Receipt authorization
      add_amount(xml, money)
      add_credentials(xml, options)
    end
  end
end

#scrub(transcript) ⇒ Object



102
103
104
105
106
107
# File 'lib/active_merchant/billing/gateways/bambora_apac.rb', line 102

def scrub(transcript)
  transcript.
    gsub(%r((<CardNumber>)[^<]+(<))i, '\1[FILTERED]\2').
    gsub(%r((<CVN>)[^<]+(<))i, '\1[FILTERED]\2').
    gsub(%r((<Password>)[^<]+(<))i, '\1[FILTERED]\2')
end

#store(payment, options = {}) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/active_merchant/billing/gateways/bambora_apac.rb', line 85

def store(payment, options={})
  commit('TokeniseCreditCard') do |xml|
    xml.TokeniseCreditCard do
      xml.CardNumber payment.number
      xml.ExpM format(payment.month, :two_digits)
      xml.ExpY format(payment.year, :four_digits)
      xml.TokeniseAlgorithmID options[:tokenise_algorithm_id] || 2
      xml.UserName @options[:username]
      xml.Password @options[:password]
    end
  end
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


98
99
100
# File 'lib/active_merchant/billing/gateways/bambora_apac.rb', line 98

def supports_scrubbing?
  true
end

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



75
76
77
78
79
80
81
82
83
# File 'lib/active_merchant/billing/gateways/bambora_apac.rb', line 75

def void(money, authorization, options={})
  commit('SubmitSingleVoid') do |xml|
    xml.Void do
      xml.Receipt authorization
      add_amount(xml, money)
      add_credentials(xml, options)
    end
  end
end