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[: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

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.



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

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

Instance Method Details

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

Raises:

  • (ArgumentError)


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

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)


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

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



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

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

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

Raises:

  • (ArgumentError)


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

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



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

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

#scrub(transcript) ⇒ Object



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

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]')
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


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

def supports_scrubbing?
  true
end

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

Raises:

  • (ArgumentError)


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

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



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

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