Class: ActiveMerchant::Billing::CyberSourceGateway
- Inherits:
-
Gateway
- Object
- Gateway
- ActiveMerchant::Billing::CyberSourceGateway
- Defined in:
- lib/active_merchant/billing/gateways/cyber_source.rb
Overview
See the remote and mocked unit test files for example usage. Pay special attention to the contents of the options hash.
Initial setup instructions can be found in cybersource.com/support_center/implementation/downloads/soap_api/SOAP_toolkits.pdf
Debugging If you experience an issue with this gateway be sure to examine the transaction information from a general transaction search inside the CyberSource Business Center for the full error messages including field names.
Important Notes
-
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.
Constant Summary
- TEST_URL =
'https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor'- LIVE_URL =
'https://ics2ws.ic3.com/commerce/1.x/transactionProcessor'- XSD_VERSION =
"1.69"- @@credit_card_codes =
map credit card to the CyberSource expected representation
{ :visa => '001', :master => '002', :american_express => '003', :discover => '004' }
- @@response_codes =
map response codes to something humans can read
{ :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::CURRENCIES_WITHOUT_FRACTIONS, Gateway::DEBIT_CARDS
Instance Attribute Summary
Attributes inherited from Gateway
Instance Method Summary (collapse)
- - (Object) auth_reversal(money, identification, options = {})
-
- (Object) authorize(money, creditcard, options = {})
Request an authorization for an amount from CyberSource .
-
- (Object) calculate_tax(options)
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.
-
- (Object) capture(money, authorization, options = {})
Capture an authorization that has previously been requested.
- - (Object) credit(money, identification, options = {})
-
- (CyberSourceGateway) initialize(options = {})
constructor
These are the options that can be used when creating a new CyberSource Gateway object.
-
- (Object) purchase(money, payment_source, options = {})
Purchase is an auth followed by a capture You must supply an order_id in the options hash.
-
- (Object) recurring(money, credit_card_or_reference, options = {})
Creates or updates a Cybersource recurring payment profile/subscription.
- - (Object) refund(money, identification, options = {})
-
- (Object) store(credit_card_or_reference, options = {})
Creates or updates a cybersource customer profile, aka a subscription with type "on-demand" to charge the card while creating a profile, pass options => money.
-
- (Boolean) test?
Should run against the test servers or not?.
-
- (Object) unstore(reference, options = {})
removes a customer subscription/profile.
- - (Object) void(identification, options = {})
Methods inherited from Gateway
#card_brand, card_brand, inherited, supports?
Methods included from CreditCardFormatting
Constructor Details
- (CyberSourceGateway) initialize(options = {})
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 presense 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
95 96 97 98 99 |
# File 'lib/active_merchant/billing/gateways/cyber_source.rb', line 95 def initialize( = {}) requires!(, :login, :password) @options = super end |
Instance Method Details
- (Object) auth_reversal(money, identification, options = {})
115 116 117 |
# File 'lib/active_merchant/billing/gateways/cyber_source.rb', line 115 def auth_reversal(money, identification, = {}) commit(build_auth_reversal_request(money, identification, ), ) end |
- (Object) authorize(money, creditcard, options = {})
Request an authorization for an amount from CyberSource
You must supply an :order_id in the options hash
109 110 111 112 113 |
# File 'lib/active_merchant/billing/gateways/cyber_source.rb', line 109 def (money, creditcard, = {}) requires!(, :order_id, :email) setup_address_hash() commit(build_auth_request(money, creditcard, ), ) end |
- (Object) calculate_tax(options)
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
232 233 234 235 236 237 |
# File 'lib/active_merchant/billing/gateways/cyber_source.rb', line 232 def calculate_tax() requires!(, :line_items) setup_address_hash() commit(build_tax_calculation_request(), ) end |
- (Object) capture(money, authorization, options = {})
Capture an authorization that has previously been requested
120 121 122 123 |
# File 'lib/active_merchant/billing/gateways/cyber_source.rb', line 120 def capture(money, , = {}) setup_address_hash() commit(build_capture_request(money, , ), ) end |
- (Object) credit(money, identification, options = {})
146 147 148 149 |
# File 'lib/active_merchant/billing/gateways/cyber_source.rb', line 146 def credit(money, identification, = {}) deprecated CREDIT_DEPRECATION_MESSAGE refund(money, identification, ) end |
- (Object) purchase(money, payment_source, options = {})
Purchase is an auth followed by a capture You must supply an order_id in the options hash
127 128 129 130 131 132 133 134 135 136 |
# File 'lib/active_merchant/billing/gateways/cyber_source.rb', line 127 def purchase(money, payment_source, = {}) requires!(, :order_id, :email) setup_address_hash() if payment_source.is_a?(String) requires!(, [:type, :credit_card, :check]) commit(build_subscription_purchase_request(money, payment_source, ), ) else commit(build_purchase_request(money, payment_source, ), ) end end |
- (Object) recurring(money, credit_card_or_reference, options = {})
Creates or updates a Cybersource recurring payment profile/subscription
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
# File 'lib/active_merchant/billing/gateways/cyber_source.rb', line 184 def recurring(money, credit_card_or_reference, = {}) requires!(, :order_id, :subscription) requires!([:subscription], [:frequency, "on-demand", "weekly", "bi-weekly", "semi-monthly", "quarterly", "quad-weekly", "semi-annually", "annually"]) [:subscription].merge!(:amount => money) setup_address_hash() if credit_card_or_reference.respond_to?(:number) # create subscription requires!(, :billing_address, :email) requires!([:billing_address], :first_name, :last_name) setup_address_hash() request = build_create_subscription_request(credit_card_or_reference, ) else # update subscription request = build_update_subscription_request(credit_card_or_reference, ) end commit(request, ) end |
- (Object) refund(money, identification, options = {})
142 143 144 |
# File 'lib/active_merchant/billing/gateways/cyber_source.rb', line 142 def refund(money, identification, = {}) commit(build_credit_request(money, identification, ), ) end |
- (Object) store(credit_card_or_reference, options = {})
Creates or updates a cybersource customer profile, aka a subscription with type "on-demand" to charge the card while creating a profile, pass options => money
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/active_merchant/billing/gateways/cyber_source.rb', line 153 def store(credit_card_or_reference, = {}) requires!(, :order_id) setup_address_hash() if credit_card_or_reference.respond_to?(:number) # create subscription requires!(, :billing_address, :email) requires!([:billing_address], :first_name, :last_name) # set subscription options for storing the credit card [:subscription] ||={} [:subscription].merge!(:frequency => "on-demand", :amount => 0, :auto_renew => false) setup_address_hash() request = build_create_subscription_request(credit_card_or_reference, ) else # update subscription request = build_update_subscription_request(credit_card_or_reference, ) end commit(request, ) end |
- (Boolean) test?
Should run against the test servers or not?
102 103 104 |
# File 'lib/active_merchant/billing/gateways/cyber_source.rb', line 102 def test? @options[:test] || Base.gateway_mode == :test end |
- (Object) unstore(reference, options = {})
removes a customer subscription/profile
178 179 180 181 |
# File 'lib/active_merchant/billing/gateways/cyber_source.rb', line 178 def unstore(reference, = {}) requires!(, :order_id) commit(build_delete_subscription_request(reference, ), ) end |
- (Object) void(identification, options = {})
138 139 140 |
# File 'lib/active_merchant/billing/gateways/cyber_source.rb', line 138 def void(identification, = {}) commit(build_void_request(identification, ), ) end |