Class: ActiveMerchant::Billing::DecidirGateway

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

Constant Summary collapse

STANDARD_ERROR_CODE_MAPPING =
{
  -1 => STANDARD_ERROR_CODE[:processing_error],
  1 => STANDARD_ERROR_CODE[:call_issuer],
  2 => STANDARD_ERROR_CODE[:call_issuer],
  3 => STANDARD_ERROR_CODE[:config_error],
  4 => STANDARD_ERROR_CODE[:pickup_card],
  5 => STANDARD_ERROR_CODE[:card_declined],
  7 => STANDARD_ERROR_CODE[:pickup_card],
  12 => STANDARD_ERROR_CODE[:processing_error],
  14 => STANDARD_ERROR_CODE[:invalid_number],
  28 => STANDARD_ERROR_CODE[:processing_error],
  38 => STANDARD_ERROR_CODE[:incorrect_pin],
  39 => STANDARD_ERROR_CODE[:invalid_number],
  43 => STANDARD_ERROR_CODE[:pickup_card],
  45 => STANDARD_ERROR_CODE[:card_declined],
  46 => STANDARD_ERROR_CODE[:invalid_number],
  47 => STANDARD_ERROR_CODE[:card_declined],
  48 => STANDARD_ERROR_CODE[:card_declined],
  49 => STANDARD_ERROR_CODE[:invalid_expiry_date],
  51 => STANDARD_ERROR_CODE[:card_declined],
  53 => STANDARD_ERROR_CODE[:card_declined],
  54 => STANDARD_ERROR_CODE[:expired_card],
  55 => STANDARD_ERROR_CODE[:incorrect_pin],
  56 => STANDARD_ERROR_CODE[:card_declined],
  57 => STANDARD_ERROR_CODE[:card_declined],
  76 => STANDARD_ERROR_CODE[:call_issuer],
  91 => STANDARD_ERROR_CODE[:call_issuer],
  96 => STANDARD_ERROR_CODE[:processing_error],
  97 => STANDARD_ERROR_CODE[:processing_error]
}

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, #strftime_yyyymm

Methods included from PostsData

included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request

Constructor Details

#initialize(options = {}) ⇒ DecidirGateway

Returns a new instance of DecidirGateway.



46
47
48
49
50
# File 'lib/active_merchant/billing/gateways/decidir.rb', line 46

def initialize(options = {})
  requires!(options, :api_key)
  super
  @options[:preauth_mode] ||= false
end

Instance Method Details

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

Raises:

  • (ArgumentError)


60
61
62
63
64
65
66
# File 'lib/active_merchant/billing/gateways/decidir.rb', line 60

def authorize(money, payment, options = {})
  raise ArgumentError, 'Authorize is not supported on Decidir gateways unless the preauth_mode option is enabled' unless @options[:preauth_mode]

  post = {}
  add_auth_purchase_params(post, money, payment, options)
  commit(:post, 'payments', post)
end

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

Raises:

  • (ArgumentError)


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

def capture(money, authorization, options = {})
  raise ArgumentError, 'Capture is not supported on Decidir gateways unless the preauth_mode option is enabled' unless @options[:preauth_mode]

  post = {}
  add_amount(post, money, options)
  commit(:put, "payments/#{authorization}", post)
end

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



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

def inquire(authorization, options = {})
  options[:action] = 'inquire'
  commit(:get, "payments/#{authorization}", nil, options)
end

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

Raises:

  • (ArgumentError)


52
53
54
55
56
57
58
# File 'lib/active_merchant/billing/gateways/decidir.rb', line 52

def purchase(money, payment, options = {})
  raise ArgumentError, 'Purchase is not supported on Decidir gateways configured with the preauth_mode option' if @options[:preauth_mode]

  post = {}
  add_auth_purchase_params(post, money, payment, options)
  commit(:post, 'payments', post)
end

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



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

def refund(money, authorization, options = {})
  post = {}
  add_amount(post, money, options)
  commit(:post, "payments/#{authorization}/refunds", post)
end

#scrub(transcript) ⇒ Object



105
106
107
108
109
110
111
112
113
# File 'lib/active_merchant/billing/gateways/decidir.rb', line 105

def scrub(transcript)
  transcript.
    gsub(%r((apikey: )\w+)i, '\1[FILTERED]').
    gsub(%r((\"card_number\\\":\\\")\d+), '\1[FILTERED]').
    gsub(%r((\"security_code\\\":\\\")\d+), '\1[FILTERED]').
    gsub(%r((\"emv_issuer_data\\\":\\\")\d+), '\1[FILTERED]').
    gsub(%r((\"cryptogram\\\":\\\"/)\w+), '\1[FILTERED]').
    gsub(%r((\"token_card_data\\\":{.*\\\"token\\\":\\\")\d+), '\1[FILTERED]')
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


101
102
103
# File 'lib/active_merchant/billing/gateways/decidir.rb', line 101

def supports_scrubbing?
  true
end

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

Raises:

  • (ArgumentError)


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

def verify(credit_card, options = {})
  raise ArgumentError, 'Verify is not supported on Decidir gateways unless the preauth_mode option is enabled' unless @options[:preauth_mode]

  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



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

def void(authorization, options = {})
  post = {}
  commit(:post, "payments/#{authorization}/refunds", post)
end