Class: ActiveMerchant::Billing::DibsGateway

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

Constant Summary

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::CURRENCIES_WITHOUT_FRACTIONS, Gateway::DEBIT_CARDS, 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, non_fractional_currency?, #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 = {}) ⇒ DibsGateway

Returns a new instance of DibsGateway.



15
16
17
18
# File 'lib/active_merchant/billing/gateways/dibs.rb', line 15

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

Instance Method Details

#authorize(amount, payment_method, options = {}) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/active_merchant/billing/gateways/dibs.rb', line 27

def authorize(amount, payment_method, options={})
  post = {}
  add_amount(post, amount)
  add_invoice(post, amount, options)
  if (payment_method.respond_to?(:number))
    add_payment_method(post, payment_method, options)
    commit(:authorize, post)
  else
    add_ticket_id(post, payment_method)
    commit(:authorize_ticket, post)
  end

end

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



41
42
43
44
45
46
47
# File 'lib/active_merchant/billing/gateways/dibs.rb', line 41

def capture(amount, authorization, options={})
  post = {}
  add_amount(post, amount)
  add_reference(post, authorization)

  commit(:capture, post)
end

#purchase(amount, payment_method, options = {}) ⇒ Object



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

def purchase(amount, payment_method, options={})
  MultiResponse.run(false) do |r|
    r.process { authorize(amount, payment_method, options) }
    r.process { capture(amount, r.authorization, options) }
  end
end

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



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

def refund(amount, authorization, options={})
  post = {}
  add_amount(post, amount)
  add_reference(post, authorization)

  commit(:refund, post)
end

#scrub(transcript) ⇒ Object



84
85
86
87
88
# File 'lib/active_merchant/billing/gateways/dibs.rb', line 84

def scrub(transcript)
  transcript.
    gsub(%r(("cardNumber\\?":\\?")[^"]*)i, '\1[FILTERED]').
    gsub(%r(("cvc\\?":\\?")[^"]*)i, '\1[FILTERED]')
end

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



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

def store(payment_method, options = {})
  post = {}

  add_invoice(post, 0, options)
  add_payment_method(post, payment_method, options)

  commit(:store, post)
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


80
81
82
# File 'lib/active_merchant/billing/gateways/dibs.rb', line 80

def supports_scrubbing?
  true
end

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



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

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



49
50
51
52
53
54
# File 'lib/active_merchant/billing/gateways/dibs.rb', line 49

def void(authorization, options={})
  post = {}
  add_reference(post, authorization)

  commit(:void, post)
end