Class: ActiveMerchant::Billing::SumUpGateway

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

Constant Summary collapse

STANDARD_ERROR_CODE_MAPPING =
{
  multiple_invalid_parameters: 'MULTIPLE_INVALID_PARAMETERS'
}

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

Returns a new instance of SumUpGateway.



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

def initialize(options = {})
  requires!(options, :access_token, :pay_to_email)
  super
end

Instance Method Details

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



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

def purchase(money, payment, options = {})
  MultiResponse.run do |r|
    r.process { create_checkout(money, payment, options) } unless options[:checkout_id]
    r.process { complete_checkout(options[:checkout_id] || r.params['id'], payment, options) }
  end
end

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



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

def refund(money, authorization, options = {})
  transaction_id = authorization.split('#').last
  post = money ? { amount: amount(money) } : {}
  add_merchant_data(post, options)

  commit('me/refund/' + transaction_id, post)
end

#scrub(transcript) ⇒ Object



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

def scrub(transcript)
  transcript.
    gsub(%r((Authorization: Bearer )\w+), '\1[FILTERED]').
    gsub(%r(("pay_to_email\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
    gsub(%r(("number\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
    gsub(%r(("cvv\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]')
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/active_merchant/billing/gateways/sum_up.rb', line 40

def supports_scrubbing?
  true
end