Class: ActiveMerchant::Billing::KushkiGateway

Inherits:
Gateway
  • Object
show all
Defined in:
lib/active_merchant/billing/gateways/kushki.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 = {}) ⇒ KushkiGateway

Returns a new instance of KushkiGateway.



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

def initialize(options = {})
  requires!(options, :public_merchant_id, :private_merchant_id)
  super
end

Instance Method Details

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



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

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

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



34
35
36
37
38
39
40
41
42
43
# File 'lib/active_merchant/billing/gateways/kushki.rb', line 34

def capture(amount, authorization, options = {})
  action = 'capture'

  post = {}
  post[:ticketNumber] = authorization
  add_invoice(action, post, amount, options)
  add_full_response(post, options)

  commit(action, post)
end

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



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

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

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



45
46
47
48
49
50
51
52
53
54
# File 'lib/active_merchant/billing/gateways/kushki.rb', line 45

def refund(amount, authorization, options = {})
  action = 'refund'

  post = {}
  post[:ticketNumber] = authorization
  add_full_response(post, options)
  add_invoice(action, post, amount, options)

  commit(action, post, options)
end

#scrub(transcript) ⇒ Object



70
71
72
73
74
75
# File 'lib/active_merchant/billing/gateways/kushki.rb', line 70

def scrub(transcript)
  transcript.
    gsub(%r((Private-Merchant-Id: )\d+), '\1[FILTERED]').
    gsub(%r((\"card\\\":{\\\"number\\\":\\\")\d+), '\1[FILTERED]').
    gsub(%r((\"cvv\\\":\\\")\d+), '\1[FILTERED]')
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


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

def supports_scrubbing?
  true
end

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



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

def void(authorization, options = {})
  action = 'void'

  post = {}
  post[:ticketNumber] = authorization
  add_full_response(post, options)

  commit(action, post)
end