Class: ActiveMerchant::Billing::MundipaggGateway

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

Constant Summary collapse

STANDARD_ERROR_CODE_MAPPING =
{
  '400' => STANDARD_ERROR_CODE[:processing_error],
  '401' => STANDARD_ERROR_CODE[:config_error],
  '404' => STANDARD_ERROR_CODE[:processing_error],
  '412' => STANDARD_ERROR_CODE[:processing_error],
  '422' => STANDARD_ERROR_CODE[:processing_error],
  '500' => STANDARD_ERROR_CODE[:processing_error]
}
STANDARD_ERROR_MESSAGE_MAPPING =
{
  '400' => 'Invalid request;',
  '401' => 'Invalid API key;',
  '404' => 'The requested resource does not exist;',
  '412' => 'Valid parameters but request failed;',
  '422' => 'Invalid parameters;',
  '500' => 'An internal error occurred;'
}

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

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

Returns a new instance of MundipaggGateway.



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

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

Instance Method Details

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



46
47
48
49
50
51
52
53
54
# File 'lib/active_merchant/billing/gateways/mundipagg.rb', line 46

def authorize(money, payment, options={})
  post = {}
  add_invoice(post, money, options)
  add_customer_data(post, options) unless payment.is_a?(String)
  add_shipping_address(post, options)
  add_payment(post, payment, options)
  add_capture_flag(post, payment)
  commit('authonly', post)
end

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



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

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

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



36
37
38
39
40
41
42
43
44
# File 'lib/active_merchant/billing/gateways/mundipagg.rb', line 36

def purchase(money, payment, options={})
  post = {}
  add_invoice(post, money, options)
  add_customer_data(post, options) unless payment.is_a?(String)
  add_shipping_address(post, options)
  add_payment(post, payment, options)

  commit('sale', post)
end

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



63
64
65
66
# File 'lib/active_merchant/billing/gateways/mundipagg.rb', line 63

def refund(money, authorization, options={})
  add_invoice(post={}, money, options)
  commit('refund', post, authorization)
end

#scrub(transcript) ⇒ Object



91
92
93
94
95
96
# File 'lib/active_merchant/billing/gateways/mundipagg.rb', line 91

def scrub(transcript)
  transcript
    .gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]')
    .gsub(%r(("cvv\\":\\")\d*), '\1[FILTERED]')
    .gsub(%r((card\\":{\\"number\\":\\")\d*), '\1[FILTERED]')
end

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



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

def store(payment, options={})
  post = {}
  options.update(name: payment.name)
  options = add_customer(options) unless options[:customer_id]
  add_payment(post, payment, options)
  commit('store', post, options[:customer_id])
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/active_merchant/billing/gateways/mundipagg.rb', line 87

def supports_scrubbing?
  true
end

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



80
81
82
83
84
85
# File 'lib/active_merchant/billing/gateways/mundipagg.rb', line 80

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



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

def void(authorization, options={})
  commit('void', nil, authorization)
end