Class Index [+]

Quicksearch

ActiveMerchant::Billing::CardStreamGateway

CardStream supports the following credit cards, which are auto-detected by the gateway based on the card number used:

Constants

URL
APPROVED
CURRENCY_CODES
TRANSACTIONS
CVV_CODE
AVS_POSTAL_MATCH

0 - No additional information available. 1 - Postcode not checked. 2 - Postcode matched. 4 - Postcode not matched. 8 - Postcode partially matched.

AVS_STREET_MATCH

0 - No additional information available. 1 - Address numeric not checked. 2 - Address numeric matched. 4 - Address numeric not matched. 8 - Address numeric partially matched.

Public Class Methods

new(options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/card_stream.rb, line 88
88:       def initialize(options = {})
89:         requires!(options, :login, :password)
90:         @options = options
91:         super
92:       end

Public Instance Methods

purchase(money, credit_card, options = {}) click to toggle source
     # File lib/active_merchant/billing/gateways/card_stream.rb, line 94
 94:       def purchase(money, credit_card, options = {})
 95:         requires!(options, :order_id)
 96:         
 97:         post = {}
 98:         
 99:         add_amount(post, money, options)
100:         add_invoice(post, money, credit_card, options)
101:         add_credit_card(post, credit_card)
102:         add_address(post, options)
103:         add_customer_data(post, options)
104: 
105:         commit(:purchase, post)
106:       end

Private Instance Methods

add_address(post, options) click to toggle source
     # File lib/active_merchant/billing/gateways/card_stream.rb, line 120
120:       def add_address(post, options)
121:         address = options[:billing_address] || options[:address]
122:         
123:         return if address.nil?
124: 
125:         add_pair(post, :BillingStreet, address[:address1])
126:         add_pair(post, :BillingHouseNumber, address[:address2])
127:         add_pair(post, :BillingCity, address[:city])
128:         add_pair(post, :BillingState, address[:state])
129:         add_pair(post, :BillingPostCode, address[:zip])
130:       end
add_amount(post, money, options) click to toggle source
     # File lib/active_merchant/billing/gateways/card_stream.rb, line 110
110:       def add_amount(post, money, options)
111:         add_pair(post, :Amount, amount(money), :required => true)
112:         add_pair(post, :CurrencyCode, currency_code(options[:currency] || currency(money)), :required => true)
113:       end
add_credit_card(post, credit_card) click to toggle source
     # File lib/active_merchant/billing/gateways/card_stream.rb, line 143
143:       def add_credit_card(post, credit_card)
144:         add_pair(post, :CardName, credit_card.name, :required => true)
145:         add_pair(post, :CardNumber, credit_card.number, :required => true)
146:          
147:         add_pair(post, :ExpiryDateMM, format(credit_card.month, :two_digits), :required => true)
148:         add_pair(post, :ExpiryDateYY, format(credit_card.year, :two_digits), :required => true)
149:          
150:         if requires_start_date_or_issue_number?(credit_card)
151:           add_pair(post, :StartDateMM, format(credit_card.start_month, :two_digits))
152:           add_pair(post, :StartDateYY, format(credit_card.start_year, :two_digits))
153:           
154:           add_pair(post, :IssueNumber, credit_card.issue_number)
155:         end
156:         
157:         add_pair(post, :CV2, credit_card.verification_value)
158:       end
add_customer_data(post, options) click to toggle source
     # File lib/active_merchant/billing/gateways/card_stream.rb, line 115
115:       def add_customer_data(post, options)
116:         add_pair(post, :BillingEmail, options[:email])
117:         add_pair(post, :BillingPhoneNumber, options[:phone])
118:       end
add_invoice(post, money, credit_card, options) click to toggle source
     # File lib/active_merchant/billing/gateways/card_stream.rb, line 132
132:       def add_invoice(post, money, credit_card, options)
133:         add_pair(post, :TransactionUnique, options[:order_id], :required => true)
134:         add_pair(post, :OrderDesc, options[:description] || options[:order_id], :required => true)
135:         
136:         if [ 'american_express', 'diners_club' ].include?(card_brand(credit_card).to_s)
137:           add_pair(post, :AEIT1Quantity,  1) 
138:           add_pair(post, :AEIT1Description,  (options[:description] || options[:order_id]).slice(0, 15)) 
139:           add_pair(post, :AEIT1GrossValue, amount(money))
140:         end
141:       end
add_pair(post, key, value, options = {}) click to toggle source
     # File lib/active_merchant/billing/gateways/card_stream.rb, line 224
224:       def add_pair(post, key, value, options = {})
225:         post[key] = value if !value.blank? || options[:required]
226:       end
commit(action, parameters) click to toggle source
     # File lib/active_merchant/billing/gateways/card_stream.rb, line 160
160:       def commit(action, parameters)
161:         response = parse( ssl_post(URL, post_data(action, parameters)) )
162: 
163:         Response.new(response[:response_code] == APPROVED, message_from(response), response,
164:           :test => test?,
165:           :authorization => response[:cross_reference],
166:           :cvv_result => CVV_CODE[ response[:avscv2_response_code].to_s[0, 1] ],
167:           :avs_result => {
168:             :street_match => AVS_STREET_MATCH[ response[:avscv2_response_code].to_s[2, 1] ],
169:             :postal_match => AVS_POSTAL_MATCH[ response[:avscv2_response_code].to_s[1, 1] ]
170:           }
171:         )
172:       end
currency_code(currency) click to toggle source
     # File lib/active_merchant/billing/gateways/card_stream.rb, line 220
220:       def currency_code(currency)
221:         CURRENCY_CODES[currency]
222:       end
message_from(results) click to toggle source
     # File lib/active_merchant/billing/gateways/card_stream.rb, line 174
174:       def message_from(results)
175:         results[:response_code] == APPROVED ? "APPROVED" : results[:message]
176:       end
parse(body) click to toggle source

VPCrossReference The value in VPCrossReference on a success transaction will contain a unique reference that you may use to run future transactions. Please note that cross reference transactions must come a static IP addressed that has been pre-registered with Cardstream. To register an IP address please send it to support@cardstream.com with your Cardstream issued merchant ID and it will be added to your account.

     # File lib/active_merchant/billing/gateways/card_stream.rb, line 205
205:       def parse(body)
206:         result = {}
207:         pairs = body.split("&")
208:         pairs.each do |pair|
209:           a = pair.split("=")
210:           result[a[0].gsub(/^VP/,'').underscore.to_sym] = a[1]
211:         end
212:         
213:         result
214:       end
post_data(action, parameters = {}) click to toggle source
     # File lib/active_merchant/billing/gateways/card_stream.rb, line 178
178:       def post_data(action, parameters = {})
179:         parameters.update(
180:           :MerchantPassword => @options[:password],
181:           :MerchantID => @options[:login],
182:           :MessageType => TRANSACTIONS[action],
183:           :CallBack => "disable",
184:           :DuplicateDelay => "0",
185:           :EchoCardType => "YES",
186:           :EchoAmount => "YES",
187:           :EchoAVSCV2ResponseCode => "YES",
188:           :ReturnAVSCV2Message => "YES",
189:           :CountryCode => '826' # 826 for UK based merchant
190:         )
191:         
192:         add_pair(parameters, :Dispatch, action == :authorization ? "LATER" : "NOW")
193:     
194:         parameters.collect { |key, value| "VP#{key}=#{CGI.escape(value.to_s)}" }.join("&")
195:       end
test?() click to toggle source
     # File lib/active_merchant/billing/gateways/card_stream.rb, line 216
216:       def test?
217:         @options[:test] || Base.gateway_mode == :test
218:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.