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

#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



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

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)
  commit('auth', post)
end

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



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

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
# 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)
    post[:capture] = 'Y'
    commit('auth', post)
  end
end

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



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

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.key?(param)
    raise ArgumentError.new('not a valid cardconnect domain') unless /\Dcardconnect.com:\d{1,}\D/ =~ options[param]
  end
end

#scrub(transcript) ⇒ Object



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

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



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

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)


148
149
150
# File 'lib/active_merchant/billing/gateways/card_connect.rb', line 148

def supports_scrubbing?
  true
end

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



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

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

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



129
130
131
# File 'lib/active_merchant/billing/gateways/card_connect.rb', line 129

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

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



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

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