Class: ActiveMerchant::Billing::CyberSourceGateway
- Defined in:
- lib/active_merchant/billing/gateways/cyber_source.rb
Overview
Initial setup instructions can be found in cybersource.com/support_center/implementation/downloads/soap_api/SOAP_toolkits.pdf
Important Notes
-
For checks you can purchase and store.
-
AVS and CVV only work against the production server. You will always get back X for AVS and no response for CVV against the test server.
-
Nexus is the list of states or provinces where you have a physical presence. Nexus is used to calculate tax. Leave blank to tax everyone.
-
If you want to calculate VAT for overseas customers you must supply a registration number in the options hash as vat_reg_number.
-
productCode is a value in the line_items hash that is used to tell CyberSource what kind of item you are selling. It is used when calculating tax/VAT.
-
All transactions use dollar values.
-
To process pinless debit cards through the pinless debit card network, your Cybersource merchant account must accept pinless debit card payments.
-
The order of the XML elements does matter, make sure to follow the order in the documentation exactly.
Constant Summary collapse
- XSD_VERSION =
'1.121'
- @@credit_card_codes =
{ :visa => '001', :master => '002', :american_express => '003', :discover => '004', :diners_club => '005', :jcb => '007', :dankort => '034', :maestro => '042' }
- @@response_codes =
{ :r100 => 'Successful transaction', :r101 => 'Request is missing one or more required fields' , :r102 => 'One or more fields contains invalid data', :r150 => 'General failure', :r151 => 'The request was received but a server time-out occurred', :r152 => 'The request was received, but a service timed out', :r200 => 'The authorization request was approved by the issuing bank but declined by CyberSource because it did not pass the AVS check', :r201 => 'The issuing bank has questions about the request', :r202 => 'Expired card', :r203 => 'General decline of the card', :r204 => 'Insufficient funds in the account', :r205 => 'Stolen or lost card', :r207 => 'Issuing bank unavailable', :r208 => 'Inactive card or card not authorized for card-not-present transactions', :r209 => 'American Express Card Identifiction Digits (CID) did not match', :r210 => 'The card has reached the credit limit', :r211 => 'Invalid card verification number', :r221 => "The customer matched an entry on the processor's negative file", :r230 => 'The authorization request was approved by the issuing bank but declined by CyberSource because it did not pass the card verification check', :r231 => 'Invalid account number', :r232 => 'The card type is not accepted by the payment processor', :r233 => 'General decline by the processor', :r234 => 'A problem exists with your CyberSource merchant configuration', :r235 => 'The requested amount exceeds the originally authorized amount', :r236 => 'Processor failure', :r237 => 'The authorization has already been reversed', :r238 => 'The authorization has already been captured', :r239 => 'The requested transaction amount must match the previous transaction amount', :r240 => 'The card type sent is invalid or does not correlate with the credit card number', :r241 => 'The request ID is invalid', :r242 => 'You requested a capture, but there is no corresponding, unused authorization record.', :r243 => 'The transaction has already been settled or reversed', :r244 => 'The bank account number failed the validation check', :r246 => 'The capture or credit is not voidable because the capture or credit information has already been submitted to your processor', :r247 => 'You requested a credit for a capture that was previously voided', :r250 => 'The request was received, but a time-out occurred with the payment processor', :r254 => 'Your CyberSource account is prohibited from processing stand-alone refunds', :r255 => 'Your CyberSource account is not configured to process the service in the country you specified' }
Constants inherited from Gateway
Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE
Instance Attribute Summary
Attributes inherited from Gateway
Instance Method Summary collapse
- #authorize(money, creditcard_or_reference, options = {}) ⇒ Object
-
#calculate_tax(creditcard, options) ⇒ Object
CyberSource requires that you provide line item information for tax calculations.
- #capture(money, authorization, options = {}) ⇒ Object
-
#credit(money, reference, options = {}) ⇒ Object
Adds credit to a subscription (stand alone credit).
-
#initialize(options = {}) ⇒ CyberSourceGateway
constructor
These are the options that can be used when creating a new CyberSource Gateway object.
-
#purchase(money, payment_method_or_reference, options = {}) ⇒ Object
options => true # attempts to process as pinless debit card.
- #refund(money, identification, options = {}) ⇒ Object
-
#retrieve(reference, options = {}) ⇒ Object
Retrieves a customer subscription/profile.
- #scrub(transcript) ⇒ Object
-
#store(payment_method, options = {}) ⇒ Object
Stores a customer subscription/profile with type “on-demand”.
- #supports_network_tokenization? ⇒ Boolean
- #supports_scrubbing? ⇒ Boolean
-
#unstore(reference, options = {}) ⇒ Object
Removes a customer subscription/profile.
-
#update(reference, creditcard, options = {}) ⇒ Object
Updates a customer subscription/profile.
-
#validate_pinless_debit_card(creditcard, options = {}) ⇒ Object
Determines if a card can be used for Pinless Debit Card transactions.
- #verify(payment, options = {}) ⇒ Object
- #verify_credentials ⇒ Object
- #void(identification, options = {}) ⇒ Object
Methods inherited from Gateway
#card_brand, card_brand, #generate_unique_id, inherited, supported_countries, #supported_countries, supported_countries=, supports?, #test?
Methods included from CreditCardFormatting
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
#initialize(options = {}) ⇒ CyberSourceGateway
These are the options that can be used when creating a new CyberSource Gateway object.
:login => your username
:password => the transaction key you generated in the Business Center
:test => true sets the gateway to test mode
:vat_reg_number => your VAT registration number
:nexus => “WI CA QC” sets the states/provinces where you have a physical
presence for tax purposes
:ignore_avs => true don’t want to use AVS so continue processing even
if AVS would have failed
:ignore_cvv => true don’t want to use CVV so continue processing even
if CVV would have failed
109 110 111 112 |
# File 'lib/active_merchant/billing/gateways/cyber_source.rb', line 109 def initialize( = {}) requires!(, :login, :password) super end |
Instance Method Details
#authorize(money, creditcard_or_reference, options = {}) ⇒ Object
114 115 116 117 |
# File 'lib/active_merchant/billing/gateways/cyber_source.rb', line 114 def (money, creditcard_or_reference, = {}) setup_address_hash() commit(build_auth_request(money, creditcard_or_reference, ), :authorize, money, ) end |
#calculate_tax(creditcard, options) ⇒ Object
CyberSource requires that you provide line item information for tax calculations. If you do not have prices for each item or want to simplify the situation then pass in one fake line item that costs the subtotal of the order
The line_item hash goes in the options hash and should look like
:line_items => [
{
:declared_value => '1',
:quantity => '2',
:code => 'default',
:description => 'Giant Walrus',
:sku => 'WA323232323232323'
},
{
:declared_value => '6',
:quantity => '1',
:code => 'default',
:description => 'Marble Snowcone',
:sku => 'FAKE1232132113123'
}
]
This functionality is only supported by this particular gateway may be changed at any time
203 204 205 206 207 |
# File 'lib/active_merchant/billing/gateways/cyber_source.rb', line 203 def calculate_tax(creditcard, ) requires!(, :line_items) setup_address_hash() commit(build_tax_calculation_request(creditcard, ), :calculate_tax, nil, ) end |
#capture(money, authorization, options = {}) ⇒ Object
119 120 121 122 |
# File 'lib/active_merchant/billing/gateways/cyber_source.rb', line 119 def capture(money, , = {}) setup_address_hash() commit(build_capture_request(money, , ), :capture, money, ) end |
#credit(money, reference, options = {}) ⇒ Object
Adds credit to a subscription (stand alone credit).
146 147 148 |
# File 'lib/active_merchant/billing/gateways/cyber_source.rb', line 146 def credit(money, reference, = {}) commit(build_credit_request(money, reference, ), :credit, money, ) end |
#purchase(money, payment_method_or_reference, options = {}) ⇒ Object
options => true # attempts to process as pinless debit card
125 126 127 128 |
# File 'lib/active_merchant/billing/gateways/cyber_source.rb', line 125 def purchase(money, payment_method_or_reference, = {}) setup_address_hash() commit(build_purchase_request(money, payment_method_or_reference, ), :purchase, money, ) end |
#refund(money, identification, options = {}) ⇒ Object
134 135 136 |
# File 'lib/active_merchant/billing/gateways/cyber_source.rb', line 134 def refund(money, identification, = {}) commit(build_refund_request(money, identification, ), :refund, money, ) end |
#retrieve(reference, options = {}) ⇒ Object
Retrieves a customer subscription/profile
172 173 174 175 |
# File 'lib/active_merchant/billing/gateways/cyber_source.rb', line 172 def retrieve(reference, = {}) requires!(, :order_id) commit(build_retrieve_subscription_request(reference, ), :retrieve, nil, ) end |
#scrub(transcript) ⇒ Object
219 220 221 222 223 224 225 226 227 |
# File 'lib/active_merchant/billing/gateways/cyber_source.rb', line 219 def scrub(transcript) transcript. gsub(%r((<wsse:Password [^>]*>)[^<]*(</wsse:Password>))i, '\1[FILTERED]\2'). gsub(%r((<accountNumber>)[^<]*(</accountNumber>))i, '\1[FILTERED]\2'). gsub(%r((<cvNumber>)[^<]*(</cvNumber>))i, '\1[FILTERED]\2'). gsub(%r((<cavv>)[^<]*(</cavv>))i, '\1[FILTERED]\2'). gsub(%r((<xid>)[^<]*(</xid>))i, '\1[FILTERED]\2'). gsub(%r((<authenticationData>)[^<]*(</authenticationData>))i, '\1[FILTERED]\2') end |
#store(payment_method, options = {}) ⇒ Object
Stores a customer subscription/profile with type “on-demand”. To charge the card while creating a profile, pass options => money
153 154 155 156 |
# File 'lib/active_merchant/billing/gateways/cyber_source.rb', line 153 def store(payment_method, = {}) setup_address_hash() commit(build_create_subscription_request(payment_method, ), :store, nil, ) end |
#supports_network_tokenization? ⇒ Boolean
229 230 231 |
# File 'lib/active_merchant/billing/gateways/cyber_source.rb', line 229 def supports_network_tokenization? true end |
#supports_scrubbing? ⇒ Boolean
215 216 217 |
# File 'lib/active_merchant/billing/gateways/cyber_source.rb', line 215 def supports_scrubbing? true end |
#unstore(reference, options = {}) ⇒ Object
Removes a customer subscription/profile
166 167 168 169 |
# File 'lib/active_merchant/billing/gateways/cyber_source.rb', line 166 def unstore(reference, = {}) requires!(, :order_id) commit(build_delete_subscription_request(reference, ), :unstore, nil, ) end |
#update(reference, creditcard, options = {}) ⇒ Object
Updates a customer subscription/profile
159 160 161 162 163 |
# File 'lib/active_merchant/billing/gateways/cyber_source.rb', line 159 def update(reference, creditcard, = {}) requires!(, :order_id) setup_address_hash() commit(build_update_subscription_request(reference, creditcard, ), :update, nil, ) end |
#validate_pinless_debit_card(creditcard, options = {}) ⇒ Object
Determines if a card can be used for Pinless Debit Card transactions
210 211 212 213 |
# File 'lib/active_merchant/billing/gateways/cyber_source.rb', line 210 def validate_pinless_debit_card(creditcard, = {}) requires!(, :order_id) commit(build_validate_pinless_debit_request(creditcard,), :validate_pinless_debit_card, nil, ) end |
#verify(payment, options = {}) ⇒ Object
138 139 140 141 142 143 |
# File 'lib/active_merchant/billing/gateways/cyber_source.rb', line 138 def verify(payment, = {}) MultiResponse.run(:use_first_response) do |r| r.process { (100, payment, ) } r.process(:ignore_result) { void(r., ) } end end |
#verify_credentials ⇒ Object
233 234 235 236 |
# File 'lib/active_merchant/billing/gateways/cyber_source.rb', line 233 def verify_credentials response = void('0') response.params['reasonCode'] == '102' end |
#void(identification, options = {}) ⇒ Object
130 131 132 |
# File 'lib/active_merchant/billing/gateways/cyber_source.rb', line 130 def void(identification, = {}) commit(build_void_request(identification, ), :void, nil, ) end |