Class: ActiveMerchant::Billing::QuickpayV10Gateway

Inherits:
Gateway
  • Object
show all
Includes:
QuickpayCommon
Defined in:
lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb

Constant Summary collapse

API_VERSION =
10

Constants included from QuickpayCommon

QuickpayCommon::MD5_CHECK_FIELDS, QuickpayCommon::RESPONSE_CODES

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 included from QuickpayCommon

#expdate, included

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

Returns a new instance of QuickpayV10Gateway.



12
13
14
15
# File 'lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb', line 12

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

Instance Method Details

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



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb', line 36

def authorize(money, credit_card_or_reference, options = {})
  MultiResponse.run do |r|
    if credit_card_or_reference.is_a?(String)
      r.process { create_token(credit_card_or_reference, options) }
      credit_card_or_reference = r.authorization
    end
    r.process { create_payment(money, options) }
    r.process {
      post = authorization_params(money, credit_card_or_reference, options)
      commit(synchronized_path("/payments/#{r.responses.last.params["id"]}/authorize"), post)
    }
  end
end

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



59
60
61
62
# File 'lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb', line 59

def capture(money, identification, options = {})
  post = capture_params(money, identification, options)
  commit(synchronized_path("/payments/#{identification}/capture"), post)
end

#credit(money, identification, options = {}) ⇒ Object



54
55
56
57
# File 'lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb', line 54

def credit(money, identification, options = {})
  ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
  refund(money, identification, options)
end

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



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb', line 17

def purchase(money, credit_card_or_reference, options = {})
  MultiResponse.run do |r|
    if credit_card_or_reference.is_a?(String)
      r.process { create_token(credit_card_or_reference, options) }
      credit_card_or_reference = r.authorization
    end
    r.process { create_payment(money, options) }
    r.process {
      post = authorization_params(money, credit_card_or_reference, options)
      add_autocapture(post, false)
      commit(synchronized_path("/payments/#{r.responses.last.params["id"]}/authorize"), post)
    }
    r.process {
      post = capture_params(money, credit_card_or_reference, options)
      commit(synchronized_path("/payments/#{r.responses.last.params["id"]}/capture"), post)
    }
  end
end

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



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

def refund(money, identification, options = {})
  post = {}
  add_amount(post, money, options)
  add_additional_params(:refund, post, options)
  commit(synchronized_path("/payments/#{identification}/refund"), post)
end

#scrub(transcript) ⇒ Object



93
94
95
96
97
98
# File 'lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb', line 93

def scrub(transcript)
  transcript.
    gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
    gsub(%r(("card\\?":{\\?"number\\?":\\?")\d+), '\1[FILTERED]').
    gsub(%r(("cvd\\?":\\?")\d+), '\1[FILTERED]')
end

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



78
79
80
81
82
83
# File 'lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb', line 78

def store(credit_card, options = {})
  MultiResponse.run do |r|
    r.process { create_store(options) }
    r.process { authorize_store(r.authorization, credit_card, options) }
  end
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


89
90
91
# File 'lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb', line 89

def supports_scrubbing?
  true
end

#unstore(identification) ⇒ Object



85
86
87
# File 'lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb', line 85

def unstore(identification)
  commit(synchronized_path "/cards/#{identification}/cancel")
end

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



71
72
73
74
75
76
# File 'lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb', line 71

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(identification, _options = {}) ⇒ Object



50
51
52
# File 'lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb', line 50

def void(identification, _options = {})
  commit(synchronized_path "/payments/#{identification}/cancel")
end