Class: ActiveMerchant::Billing::DigitzsGateway

Inherits:
Gateway
  • Object
show all
Includes:
Empty
Defined in:
lib/active_merchant/billing/gateways/digitzs.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, #strftime_yyyymm

Methods included from PostsData

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

Constructor Details

#initialize(options = {}) ⇒ DigitzsGateway

Returns a new instance of DigitzsGateway.



17
18
19
20
# File 'lib/active_merchant/billing/gateways/digitzs.rb', line 17

def initialize(options = {})
  requires!(options, :app_key, :api_key)
  super
end

Instance Method Details

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



22
23
24
25
26
27
# File 'lib/active_merchant/billing/gateways/digitzs.rb', line 22

def purchase(money, payment, options = {})
  MultiResponse.run do |r|
    r.process { commit('auth/token', app_token_request(options)) }
    r.process { commit('payments', purchase_request(money, payment, options), options.merge({ app_token: app_token_from(r) })) }
  end
end

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



29
30
31
32
33
34
# File 'lib/active_merchant/billing/gateways/digitzs.rb', line 29

def refund(money, authorization, options = {})
  MultiResponse.run do |r|
    r.process { commit('auth/token', app_token_request(options)) }
    r.process { commit('payments', refund_request(money, authorization, options), options.merge({ app_token: app_token_from(r) })) }
  end
end

#scrub(transcript) ⇒ Object



59
60
61
62
63
64
65
66
67
68
# File 'lib/active_merchant/billing/gateways/digitzs.rb', line 59

def scrub(transcript)
  transcript.
    gsub(%r((Authorization: Bearer ).+), '\1[FILTERED]').
    gsub(%r((X-Api-Key: )\w+), '\1[FILTERED]').
    gsub(%r((\"id\\\":\\\").+), '\1[FILTERED]').
    gsub(%r((\"appKey\\\":\\\").+), '\1[FILTERED]').
    gsub(%r((\"appToken\\\":\\\").+), '\1[FILTERED]').
    gsub(%r((\"code\\\":\\\")\d+), '\1[FILTERED]').
    gsub(%r((\"number\\\":\\\")\d+), '\1[FILTERED]')
end

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



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/active_merchant/billing/gateways/digitzs.rb', line 36

def store(payment, options = {})
  MultiResponse.run do |r|
    r.process { commit('auth/token', app_token_request(options)) }
    options[:app_token] = app_token_from(r)

    if options[:customer_id].present?
      customer_id = check_customer_exists(options)

      if customer_id
        r.process { add_credit_card_to_customer(payment, options) }
      else
        r.process { add_customer_with_credit_card(payment, options) }
      end
    else
      r.process { add_customer_with_credit_card(payment, options) }
    end
  end
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/active_merchant/billing/gateways/digitzs.rb', line 55

def supports_scrubbing?
  true
end