Class: ActiveMerchant::Billing::OgoneGateway
- Defined in:
- lib/active_merchant/billing/gateways/ogone.rb
Overview
Ogone DirectLink Gateway
DirectLink is the API version of the Ogone Payment Platform. It allows server to server communication between Ogone systems and your e-commerce website.
This implementation follows the specification provided in the DirectLink integration guide version 4.3.0 (25 April 2012), available here: secure.ogone.com/ncol/Ogone_DirectLink_EN.pdf
It also features aliases, which allow to store/unstore credit cards, as specified in the Alias Manager Option guide version 3.2.1 (25 April 2012) available here: secure.ogone.com/ncol/Ogone_Alias_EN.pdf
It also implements the 3-D Secure feature, as specified in the DirectLink with 3-D Secure guide version 3.0 (25 April 2012) available here: secure.ogone.com/ncol/Ogone_DirectLink-3-D_EN.pdf
It was last tested on Release 4.92 of Ogone DirectLink + AliasManager + Direct Link 3D (25 April 2012).
For any questions or comments, please contact one of the following:
-
Joel Cogen ([email protected])
-
Nicolas Jacobeus ([email protected]),
-
Sébastien Grosjean ([email protected]),
-
Rémy Coutable ([email protected]).
Usage
gateway = ActiveMerchant::Billing::OgoneGateway.new(
:login => "my_ogone_psp_id",
:user => "my_ogone_user_id",
:password => "my_ogone_pswd",
:signature => "my_ogone_sha_signature", # Only if you configured your Ogone environment so.
:signature_encryptor => "sha512" # Can be "none" (default), "sha1", "sha256" or "sha512".
# Must be the same as the one configured in your Ogone account.
)
# set up credit card object as in main ActiveMerchant example
creditcard = ActiveMerchant::Billing::CreditCard.new(
:type => 'visa',
:number => '4242424242424242',
:month => 8,
:year => 2009,
:first_name => 'Bob',
:last_name => 'Bobsen'
)
# run request
response = gateway.purchase(1000, creditcard, :order_id => "1") # charge 10 EUR
If you don't provide an :order_id, the gateway will generate a random one for you.
puts response.success? # Check whether the transaction was successful
puts response.message # Retrieve the message returned by Ogone
puts response.authorization # Retrieve the unique transaction ID returned by Ogone
puts response.order_id # Retrieve the order ID
Alias feature
To use the alias feature, simply add :billing_id in the options hash:
# Associate the alias to that credit card
gateway.purchase(1000, creditcard, :order_id => "1", :billing_id => "myawesomecustomer")
# You can use the alias instead of the credit card for subsequent orders
gateway.purchase(2000, "myawesomecustomer", :order_id => "2")
# You can also create an alias without making a purchase using store
gateway.store(creditcard, :billing_id => "myawesomecustomer")
# When using store, you can also let Ogone generate the alias for you
response = gateway.store(creditcard)
puts response.billing_id # Retrieve the generated alias
# By default, Ogone tries to authorize 0.01 EUR but you can change this
# amount using the :store_amount option when creating the gateway object:
gateway = ActiveMerchant::Billing::OgoneGateway.new(
:login => "my_ogone_psp_id",
:user => "my_ogone_user_id",
:password => "my_ogone_pswd",
:signature => "my_ogone_sha_signature",
:signature_encryptor => "sha512",
:store_amount => 100 # The store method will try to authorize 1 EUR instead of 0.01 EUR
)
response = gateway.store(creditcard) # authorize 1 EUR and void the authorization right away
3-D Secure feature
To use the 3-D Secure feature, simply add :d3d => true in the options hash:
gateway.purchase(2000, "myawesomecustomer", :order_id => "2", :d3d => true)
Specific 3-D Secure request options are (please refer to the documentation for more infos about these options):
:win_3ds => :main_window (default), :pop_up or :pop_ix.
:http_accept => "*/*" (default), or any other HTTP_ACCEPT header value.
:http_user_agent => The cardholder's User-Agent string
:accept_url => URL of the web page to show the customer when the payment is authorized.
(or waiting to be authorized).
:decline_url => URL of the web page to show the customer when the acquirer rejects the authorization
more than the maximum permitted number of authorization attempts (10 by default, but can
be changed in the "Global transaction parameters" tab, "Payment retry" section of the
Technical Information page).
:exception_url => URL of the web page to show the customer when the payment result is uncertain.
:paramplus => Field to submit the miscellaneous parameters and their values that you wish to be
returned in the post sale request or final redirection.
:complus => Field to submit a value you wish to be returned in the post sale request or output.
:language => Customer's language, for example: "en_EN"
Direct Known Subclasses
Constant Summary collapse
- CVV_MAPPING =
{ 'OK' => 'M', 'KO' => 'N', 'NO' => 'P' }
- AVS_MAPPING =
{ 'OK' => 'M', 'KO' => 'N', 'NO' => 'R' }
- SUCCESS_MESSAGE =
"The transaction was successful"
- THREE_D_SECURE_DISPLAY_WAYS =
{ :main_window => 'MAINW', # display the identification page in the main window # (default value). :pop_up => 'POPUP', # display the identification page in a pop-up window # and return to the main window at the end. :pop_ix => 'POPIX' }
- OGONE_NO_SIGNATURE_DEPRECATION_MESSAGE =
display the identification page in a pop-up window and remain in the pop-up window.
"Signature usage will be the default for a future release of ActiveMerchant. You should either begin using it, or update your configuration to explicitly disable it (signature_encryptor: none)"
- OGONE_STORE_OPTION_DEPRECATION_MESSAGE =
"The 'store' option has been renamed to 'billing_id', and its usage is deprecated."
Constants inherited from Gateway
Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::DEBIT_CARDS, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE
Instance Attribute Summary
Attributes inherited from Gateway
Instance Method Summary collapse
-
#authorize(money, payment_source, options = {}) ⇒ Object
Verify and reserve the specified amount on the account, without actually doing the transaction.
-
#capture(money, authorization, options = {}) ⇒ Object
Complete a previously authorized transaction.
-
#credit(money, identification_or_credit_card, options = {}) ⇒ Object
Credit the specified account by a specific amount.
-
#initialize(options = {}) ⇒ OgoneGateway
constructor
A new instance of OgoneGateway.
-
#purchase(money, payment_source, options = {}) ⇒ Object
Verify and transfer the specified amount.
-
#refund(money, reference, options = {}) ⇒ Object
Refund of a settled transaction.
- #scrub(transcript) ⇒ Object
-
#store(payment_source, options = {}) ⇒ Object
Store a credit card by creating an Ogone Alias.
- #supports_scrubbing? ⇒ Boolean
- #verify(credit_card, options = {}) ⇒ Object
-
#void(identification, options = {}) ⇒ Object
Cancels a previously authorized transaction.
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
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
#initialize(options = {}) ⇒ OgoneGateway
Returns a new instance of OgoneGateway.
146 147 148 149 |
# File 'lib/active_merchant/billing/gateways/ogone.rb', line 146 def initialize( = {}) requires!(, :login, :user, :password) super end |
Instance Method Details
#authorize(money, payment_source, options = {}) ⇒ Object
Verify and reserve the specified amount on the account, without actually doing the transaction.
152 153 154 155 156 157 158 159 160 161 |
# File 'lib/active_merchant/billing/gateways/ogone.rb', line 152 def (money, payment_source, = {}) post = {} action = (payment_source.brand == "mastercard") ? "PAU" : "RES" add_invoice(post, ) add_payment_source(post, payment_source, ) add_address(post, payment_source, ) add_customer_data(post, ) add_money(post, money, ) commit(action, post) end |
#capture(money, authorization, options = {}) ⇒ Object
Complete a previously authorized transaction.
176 177 178 179 180 181 182 183 184 |
# File 'lib/active_merchant/billing/gateways/ogone.rb', line 176 def capture(money, , = {}) post = {} action = [:action] || 'SAL' (post, reference_from()) add_invoice(post, ) add_customer_data(post, ) add_money(post, money, ) commit(action, post) end |
#credit(money, identification_or_credit_card, options = {}) ⇒ Object
Credit the specified account by a specific amount.
194 195 196 197 198 199 200 201 202 |
# File 'lib/active_merchant/billing/gateways/ogone.rb', line 194 def credit(money, identification_or_credit_card, = {}) if reference_transaction?(identification_or_credit_card) ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE # Referenced credit: refund of a settled transaction refund(money, identification_or_credit_card, ) else # must be a credit card or card reference perform_non_referenced_credit(money, identification_or_credit_card, ) end end |
#purchase(money, payment_source, options = {}) ⇒ Object
Verify and transfer the specified amount.
164 165 166 167 168 169 170 171 172 173 |
# File 'lib/active_merchant/billing/gateways/ogone.rb', line 164 def purchase(money, payment_source, = {}) post = {} action = [:action] || 'SAL' add_invoice(post, ) add_payment_source(post, payment_source, ) add_address(post, payment_source, ) add_customer_data(post, ) add_money(post, money, ) commit(action, post) end |
#refund(money, reference, options = {}) ⇒ Object
Refund of a settled transaction
205 206 207 |
# File 'lib/active_merchant/billing/gateways/ogone.rb', line 205 def refund(money, reference, = {}) perform_reference_credit(money, reference, ) end |
#scrub(transcript) ⇒ Object
228 229 230 231 232 233 234 |
# File 'lib/active_merchant/billing/gateways/ogone.rb', line 228 def scrub(transcript) transcript. gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]'). gsub(%r((&?cardno=)[^&]*)i, '\1[FILTERED]'). gsub(%r((&?cvc=)[^&]*)i, '\1[FILTERED]'). gsub(%r((&?pswd=)[^&]*)i, '\1[FILTERED]') end |
#store(payment_source, options = {}) ⇒ Object
Store a credit card by creating an Ogone Alias
217 218 219 220 221 222 |
# File 'lib/active_merchant/billing/gateways/ogone.rb', line 217 def store(payment_source, = {}) .merge!(:alias_operation => 'BYPSP') unless(.has_key?(:billing_id) || .has_key?(:store)) response = (@options[:store_amount] || 1, payment_source, ) void(response.) if response.success? response end |
#supports_scrubbing? ⇒ Boolean
224 225 226 |
# File 'lib/active_merchant/billing/gateways/ogone.rb', line 224 def supports_scrubbing? true end |
#verify(credit_card, options = {}) ⇒ Object
209 210 211 212 213 214 |
# File 'lib/active_merchant/billing/gateways/ogone.rb', line 209 def verify(credit_card, ={}) MultiResponse.run(:use_first_response) do |r| r.process { (100, credit_card, ) } r.process(:ignore_result) { void(r., ) } end end |
#void(identification, options = {}) ⇒ Object
Cancels a previously authorized transaction.
187 188 189 190 191 |
# File 'lib/active_merchant/billing/gateways/ogone.rb', line 187 def void(identification, = {}) post = {} (post, reference_from(identification)) commit('DES', post) end |