Class: ActiveMerchant::Billing::CardConnectGateway

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

Constant Summary collapse

STANDARD_ERROR_CODE_MAPPING =
{
  '11' => STANDARD_ERROR_CODE[:card_declined],
  '12' => STANDARD_ERROR_CODE[:incorrect_number],
  '13' => STANDARD_ERROR_CODE[:incorrect_cvc],
  '14' => STANDARD_ERROR_CODE[:incorrect_cvc],
  '15' => STANDARD_ERROR_CODE[:invalid_expiry_date],
  '16' => STANDARD_ERROR_CODE[:expired_card],
  '17' => STANDARD_ERROR_CODE[:incorrect_zip],
  '21' => STANDARD_ERROR_CODE[:config_error],
  '22' => STANDARD_ERROR_CODE[:config_error],
  '23' => STANDARD_ERROR_CODE[:config_error],
  '24' => STANDARD_ERROR_CODE[:processing_error],
  '25' => STANDARD_ERROR_CODE[:processing_error],
  '27' => STANDARD_ERROR_CODE[:processing_error],
  '28' => STANDARD_ERROR_CODE[:processing_error],
  '29' => STANDARD_ERROR_CODE[:processing_error],
  '31' => STANDARD_ERROR_CODE[:processing_error],
  '32' => STANDARD_ERROR_CODE[:processing_error],
  '33' => STANDARD_ERROR_CODE[:card_declined],
  '34' => STANDARD_ERROR_CODE[:card_declined],
  '35' => STANDARD_ERROR_CODE[:incorrect_zip],
  '36' => STANDARD_ERROR_CODE[:processing_error],
  '37' => STANDARD_ERROR_CODE[:incorrect_cvc],
  '41' => STANDARD_ERROR_CODE[:processing_error],
  '42' => STANDARD_ERROR_CODE[:processing_error],
  '43' => STANDARD_ERROR_CODE[:processing_error],
  '44' => STANDARD_ERROR_CODE[:config_error],
  '61' => STANDARD_ERROR_CODE[:processing_error],
  '62' => STANDARD_ERROR_CODE[:processing_error],
  '63' => STANDARD_ERROR_CODE[:processing_error],
  '64' => STANDARD_ERROR_CODE[:config_error],
  '65' => STANDARD_ERROR_CODE[:processing_error],
  '66' => STANDARD_ERROR_CODE[:processing_error],
  '91' => STANDARD_ERROR_CODE[:processing_error],
  '92' => STANDARD_ERROR_CODE[:processing_error],
  '93' => STANDARD_ERROR_CODE[:processing_error],
  '94' => STANDARD_ERROR_CODE[:processing_error],
  '95' => STANDARD_ERROR_CODE[:config_error],
  '96' => STANDARD_ERROR_CODE[:processing_error],
  'NU' => STANDARD_ERROR_CODE[:card_declined],
  'N3' => STANDARD_ERROR_CODE[:card_declined],
  'NJ' => STANDARD_ERROR_CODE[:card_declined],
  '51' => STANDARD_ERROR_CODE[:card_declined],
  'C2' => STANDARD_ERROR_CODE[:incorrect_cvc],
  '54' => STANDARD_ERROR_CODE[:expired_card],
  '05' => STANDARD_ERROR_CODE[:card_declined],
  '03' => STANDARD_ERROR_CODE[:config_error],
  '60' => STANDARD_ERROR_CODE[:pickup_card]
}

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

#format

Methods included from PostsData

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

Constructor Details

#initialize(options = {}) ⇒ CardConnectGateway

Returns a new instance of CardConnectGateway.


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

def initialize(options = {})
  requires!(options, :merchant_id, :username, :password)
  require_valid_domain!(options, :domain)
  super
end

Instance Method Details

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


97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/active_merchant/billing/gateways/card_connect.rb', line 97

def authorize(money, payment, options = {})
  post = {}
  add_money(post, money)
  add_currency(post, money, options)
  add_invoice(post, options)
  add_payment(post, payment)
  add_address(post, options)
  add_customer_data(post, options)
  add_3DS(post, options)
  add_additional_data(post, options)
  commit('auth', post)
end

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


110
111
112
113
114
115
116
# File 'lib/active_merchant/billing/gateways/card_connect.rb', line 110

def capture(money, authorization, options = {})
  post = {}
  add_money(post, money)
  add_reference(post, authorization)
  add_additional_data(post, options)
  commit('capture', post)
end

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


76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/active_merchant/billing/gateways/card_connect.rb', line 76

def purchase(money, payment, options = {})
  if options[:po_number]
    MultiResponse.run do |r|
      r.process { authorize(money, payment, options) }
      r.process { capture(money, r.authorization, options) }
    end
  else
    post = {}
    add_invoice(post, options)
    add_money(post, money)
    add_payment(post, payment)
    add_currency(post, money, options)
    add_address(post, options)
    add_customer_data(post, options)
    add_3DS(post, options)
    add_additional_data(post, options)
    post[:capture] = 'Y'
    commit('auth', post)
  end
end

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


118
119
120
121
122
123
# File 'lib/active_merchant/billing/gateways/card_connect.rb', line 118

def refund(money, authorization, options = {})
  post = {}
  add_money(post, money)
  add_reference(post, authorization)
  commit('refund', post)
end

#require_valid_domain!(options, param) ⇒ Object


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

def require_valid_domain!(options, param)
  if options[param]
    raise ArgumentError.new('not a valid cardconnect domain') unless /https:\/\/\D*cardconnect.com/ =~ options[param]
  end
end

#scrub(transcript) ⇒ Object


154
155
156
157
158
159
160
161
# File 'lib/active_merchant/billing/gateways/card_connect.rb', line 154

def scrub(transcript)
  transcript.
    gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
    gsub(%r(("cvv2\\":\\")\d*), '\1[FILTERED]').
    gsub(%r(("merchid\\":\\")\d*), '\1[FILTERED]').
    gsub(%r((&?"account\\":\\")\d*), '\1[FILTERED]').
    gsub(%r((&?"token\\":\\")\d*), '\1[FILTERED]')
end

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


135
136
137
138
139
140
141
# File 'lib/active_merchant/billing/gateways/card_connect.rb', line 135

def store(payment, options = {})
  post = {}
  add_payment(post, payment)
  add_address(post, options)
  add_customer_data(post, options)
  commit('profile', post)
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)

150
151
152
# File 'lib/active_merchant/billing/gateways/card_connect.rb', line 150

def supports_scrubbing?
  true
end

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


143
144
145
146
147
148
# File 'lib/active_merchant/billing/gateways/card_connect.rb', line 143

def unstore(authorization, options = {})
  , profile_id = authorization.split('|')
  commit('profile', {},
    verb: :delete,
    path: "/#{profile_id}/#{}/#{@options[:merchant_id]}")
end

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


131
132
133
# File 'lib/active_merchant/billing/gateways/card_connect.rb', line 131

def verify(credit_card, options = {})
  authorize(0, credit_card, options)
end

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


125
126
127
128
129
# File 'lib/active_merchant/billing/gateways/card_connect.rb', line 125

def void(authorization, options = {})
  post = {}
  add_reference(post, authorization)
  commit('void', post)
end