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

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


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

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)
  add_submerchant(post, options)
  commit('authonly', post)
end

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


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

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
45
# 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)
  add_submerchant(post, options)

  commit('sale', post)
end

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


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

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

#scrub(transcript) ⇒ Object


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

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


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

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)

89
90
91
# File 'lib/active_merchant/billing/gateways/mundipagg.rb', line 89

def supports_scrubbing?
  true
end

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


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

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


70
71
72
# File 'lib/active_merchant/billing/gateways/mundipagg.rb', line 70

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