Class: ActiveMerchant::Billing::CenposGateway

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

Constant Summary

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::CURRENCIES_WITHOUT_FRACTIONS, 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, non_fractional_currency?, #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 = {}) ⇒ CenposGateway

Returns a new instance of CenposGateway.



16
17
18
19
# File 'lib/active_merchant/billing/gateways/cenpos.rb', line 16

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

Instance Method Details

#authorize(amount, payment_method, options = {}) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/active_merchant/billing/gateways/cenpos.rb', line 30

def authorize(amount, payment_method, options={})
  post = {}
  add_invoice(post, amount, options)
  add_payment_method(post, payment_method)
  add_customer_data(post, options)

  commit("Auth", post)
end

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



39
40
41
42
43
44
45
46
# File 'lib/active_merchant/billing/gateways/cenpos.rb', line 39

def capture(amount, authorization, options={})
  post = {}
  add_invoice(post, amount, options)
  add_reference(post, authorization)
  add_customer_data(post, options)

  commit("SpecialForce", post)
end

#credit(amount, payment_method, options = {}) ⇒ Object



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

def credit(amount, payment_method, options={})
  post = {}
  add_invoice(post, amount, options)
  add_payment_method(post, payment_method)

  commit("Credit", post)
end

#purchase(amount, payment_method, options = {}) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/active_merchant/billing/gateways/cenpos.rb', line 21

def purchase(amount, payment_method, options={})
  post = {}
  add_invoice(post, amount, options)
  add_payment_method(post, payment_method)
  add_customer_data(post, options)

  commit("Sale", post)
end

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



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

def refund(amount, authorization, options={})
  post = {}
  add_invoice(post, amount, options)
  add_reference(post, authorization)
  add_customer_data(post, options)

  commit("SpecialReturn", post)
end

#scrub(transcript) ⇒ Object



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

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

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/active_merchant/billing/gateways/cenpos.rb', line 82

def supports_scrubbing?
  true
end

#verify(credit_card, options = {}) ⇒ Object



75
76
77
78
79
80
# File 'lib/active_merchant/billing/gateways/cenpos.rb', line 75

def verify(credit_card, options={})
  MultiResponse.run(:use_first_response) do |r|
    r.process { authorize(100, credit_card, options) }
    r.process(:ignore_result) { void(r.authorization, options) }
  end
end

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



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

def void(authorization, options={})
  post = {}
  add_void_required_elements(post)
  add_reference(post, authorization)
  add_remembered_amount(post, authorization)
  add_tax(post, options)

  commit("Void", post)
end