Class: ActiveMerchant::Billing::SecurionPayGateway

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

Constant Summary collapse

STANDARD_ERROR_CODE_MAPPING =
{
  'incorrect_number' => STANDARD_ERROR_CODE[:incorrect_number],
  'invalid_number' => STANDARD_ERROR_CODE[:invalid_number],
  'invalid_expiry_month' => STANDARD_ERROR_CODE[:invalid_expiry_date],
  'invalid_expiry_year' => STANDARD_ERROR_CODE[:invalid_expiry_date],
  'invalid_cvc' => STANDARD_ERROR_CODE[:invalid_cvc],
  'expired_card' => STANDARD_ERROR_CODE[:expired_card],
  'insufficient_funds' => STANDARD_ERROR_CODE[:card_declined],
  'incorrect_cvc' => STANDARD_ERROR_CODE[:incorrect_cvc],
  'incorrect_zip' => STANDARD_ERROR_CODE[:incorrect_zip],
  'card_declined' => STANDARD_ERROR_CODE[:card_declined],
  'processing_error' => STANDARD_ERROR_CODE[:processing_error],
  'lost_or_stolen' => STANDARD_ERROR_CODE[:card_declined],
  'suspected_fraud' => STANDARD_ERROR_CODE[:card_declined],
  'expired_token' => STANDARD_ERROR_CODE[:card_declined]
}

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, 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, supported_countries, #supported_countries, supported_countries=, supports?, #supports_network_tokenization?

Methods included from CreditCardFormatting

#expdate, #format

Methods included from PostsData

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

Constructor Details

#initialize(options = {}) ⇒ SecurionPayGateway

Returns a new instance of SecurionPayGateway.



35
36
37
38
# File 'lib/active_merchant/billing/gateways/securion_pay.rb', line 35

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

Instance Method Details

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



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

def authorize(money, payment, options={})
  post = create_post_for_auth_or_purchase(money, payment, options)
  post[:captured] = "false"
  commit('charges', post, options)
end

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



51
52
53
54
55
# File 'lib/active_merchant/billing/gateways/securion_pay.rb', line 51

def capture(money, authorization, options = {})
  post = {}
  add_amount(post, money, options)
  commit("charges/#{CGI.escape(authorization)}/capture", post, options)
end

#customer(options = {}) ⇒ Object



89
90
91
92
93
94
95
# File 'lib/active_merchant/billing/gateways/securion_pay.rb', line 89

def customer(options = {})
  if options[:customer_id].blank?
    return nil
  else
    commit("customers/#{CGI.escape(options[:customer_id])}", nil, options, :get)
  end
end

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



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

def purchase(money, payment, options={})
  post = create_post_for_auth_or_purchase(money, payment, options)
  commit('charges', post, options)
end

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



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

def refund(money, authorization, options = {})
  post = {}
  add_amount(post, money, options)
  commit("charges/#{CGI.escape(authorization)}/refund", post, options)
end

#scrub(transcript) ⇒ Object



101
102
103
104
105
106
# File 'lib/active_merchant/billing/gateways/securion_pay.rb', line 101

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

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



74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/active_merchant/billing/gateways/securion_pay.rb', line 74

def store(credit_card, options = {})
  if options[:customer_id].blank?
    MultiResponse.run() do |r|
      #create charge object
      r.process { authorize(100, credit_card, options) }
      #create customer and save card
      r.process { create_customer_add_card(r.authorization, options) }
      #void the charge
      r.process(:ignore_result) { void(r.params["metadata"]["chargeId"], options) }
    end
  else
    verify(credit_card, options)
  end
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


97
98
99
# File 'lib/active_merchant/billing/gateways/securion_pay.rb', line 97

def supports_scrubbing?
  true
end

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



67
68
69
70
71
72
# File 'lib/active_merchant/billing/gateways/securion_pay.rb', line 67

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



63
64
65
# File 'lib/active_merchant/billing/gateways/securion_pay.rb', line 63

def void(authorization, options = {})
  commit("charges/#{CGI.escape(authorization)}/refund", {}, options)
end