Class: ActiveMerchant::Billing::IpgGateway

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

Constant Summary collapse

CURRENCY_CODES =
{
  'UYU' => '858',
  'ARS' => '032'
}

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 = {}) ⇒ IpgGateway

Returns a new instance of IpgGateway.



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

def initialize(options = {})
  requires!(options, :store_id, :user_id, :password, :pem, :pem_password)
  @credentials = options
  super
end

Instance Method Details

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



31
32
33
34
35
# File 'lib/active_merchant/billing/gateways/ipg.rb', line 31

def authorize(money, payment, options = {})
  xml = build_purchase_and_authorize_request(money, payment, options)

  commit('preAuth', xml)
end

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



37
38
39
40
41
# File 'lib/active_merchant/billing/gateways/ipg.rb', line 37

def capture(money, authorization, options = {})
  xml = build_capture_and_refund_request(money, authorization, options)

  commit('postAuth', xml)
end

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



25
26
27
28
29
# File 'lib/active_merchant/billing/gateways/ipg.rb', line 25

def purchase(money, payment, options = {})
  xml = build_purchase_and_authorize_request(money, payment, options)

  commit('sale', xml)
end

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



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

def refund(money, authorization, options = {})
  xml = build_capture_and_refund_request(money, authorization, options)

  commit('return', xml)
end

#scrub(transcript) ⇒ Object



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

def scrub(transcript)
  transcript.
    gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
    gsub(%r((<v1:CardNumber>).+(</v1:CardNumber>)), '\1[FILTERED]\2').
    gsub(%r((<v1:CardCodeValue>).+(</v1:CardCodeValue>)), '\1[FILTERED]\2').
    gsub(%r((<v1:StoreId>).+(</v1:StoreId>)), '\1[FILTERED]\2')
end

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



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

def store(credit_card, options = {})
  @hosted_data_id = options[:hosted_data_id] || generate_unique_id
  xml = Builder::XmlMarkup.new(indent: 2)
  add_storage_item(xml, credit_card, options)

  commit('vault', xml)
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/active_merchant/billing/gateways/ipg.rb', line 71

def supports_scrubbing?
  true
end

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



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

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



49
50
51
52
53
54
# File 'lib/active_merchant/billing/gateways/ipg.rb', line 49

def void(authorization, options = {})
  xml = Builder::XmlMarkup.new(indent: 2)
  add_transaction_details(xml, options.merge!({ order_id: authorization }))

  commit('void', xml)
end