Class: ActiveMerchant::Billing::DecidirPlusGateway

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

Constant Summary

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

Returns a new instance of DecidirPlusGateway.



14
15
16
17
# File 'lib/active_merchant/billing/gateways/decidir_plus.rb', line 14

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

Instance Method Details

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



26
27
28
29
30
31
# File 'lib/active_merchant/billing/gateways/decidir_plus.rb', line 26

def authorize(money, payment, options = {})
  post = {}
  build_purchase_authorize_request(post, money, payment, options)

  commit(:post, 'payments', post)
end

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



33
34
35
36
37
38
# File 'lib/active_merchant/billing/gateways/decidir_plus.rb', line 33

def capture(money, authorization, options = {})
  post = {}
  post[:amount] = money

  commit(:put, "payments/#{add_reference(authorization)}", post)
end

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



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

def purchase(money, payment, options = {})
  post = {}
  build_purchase_authorize_request(post, money, payment, options)

  commit(:post, 'payments', post)
end

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



40
41
42
43
44
45
# File 'lib/active_merchant/billing/gateways/decidir_plus.rb', line 40

def refund(money, authorization, options = {})
  post = {}
  post[:amount] = money

  commit(:post, "payments/#{add_reference(authorization)}/refunds", post)
end

#scrub(transcript) ⇒ Object



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

def scrub(transcript)
  transcript.
    gsub(%r((Apikey: )\w+), '\1[FILTERED]').
    gsub(%r(("card_number\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
    gsub(%r(("security_code\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]')
end

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



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

def store(payment, options = {})
  post = {}
  add_payment(post, payment, options)

  commit(:post, 'tokens', post)
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


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

def supports_scrubbing?
  true
end

#unstore(customer_token) ⇒ Object



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

def unstore(customer_token)
  commit(:delete, "cardtokens/#{customer_token}")
end

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



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

def verify(credit_card, options = {})
  MultiResponse.run(:use_first_response) do |r|
    r.process { store(credit_card, options) }
    r.process { authorize(100, r.authorization, options) }
    r.process(:ignore_result) { void(r.authorization, options) }
  end
end

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



47
48
49
# File 'lib/active_merchant/billing/gateways/decidir_plus.rb', line 47

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