Class: ActiveMerchant::Billing::RedsysRestGateway
- Defined in:
- lib/active_merchant/billing/gateways/redsys_rest.rb
Overview
Redsys Merchant Gateway
Gateway support for the Spanish “Redsys” payment gateway system. This is used by many banks in Spain and is particularly well supported by Catalunya Caixa’s ecommerce department.
Redsys requires an order_id be provided with each transaction and it must follow a specific format. The rules are as follows:
* First 4 digits must be numerical
* Remaining 8 digits may be alphanumeric
* Max length: 12
If an invalid order_id is provided, we do our best to clean it up.
Written by Piers Chambers (Varyonic.com)
*** SHA256 Authentication Update ***
Redsys has dropped support for the SHA1 authentication method. Developer documentation: pagosonline.redsys.es/desarrolladores.html
Constant Summary collapse
- CURRENCY_CODES =
{ 'AED' => '784', 'ARS' => '32', 'AUD' => '36', 'BRL' => '986', 'BOB' => '68', 'CAD' => '124', 'CHF' => '756', 'CLP' => '152', 'CNY' => '156', 'COP' => '170', 'CRC' => '188', 'CZK' => '203', 'DKK' => '208', 'DOP' => '214', 'EUR' => '978', 'GBP' => '826', 'GTQ' => '320', 'HUF' => '348', 'IDR' => '360', 'INR' => '356', 'JPY' => '392', 'KRW' => '410', 'MYR' => '458', 'MXN' => '484', 'NOK' => '578', 'NZD' => '554', 'PEN' => '604', 'PLN' => '985', 'RUB' => '643', 'SAR' => '682', 'SEK' => '752', 'SGD' => '702', 'THB' => '764', 'TWD' => '901', 'USD' => '840', 'UYU' => '858' }
- THREEDS_EXEMPTIONS =
{ corporate_card: 'COR', delegated_authentication: 'ATD', low_risk: 'TRA', low_value: 'LWV', stored_credential: 'MIT', trusted_merchant: 'NDF' }
- SUPPORTED_TRANSACTIONS =
The set of supported transactions for this gateway. More operations are supported by the gateway itself, but are not supported in this library.
{ purchase: '0', authorize: '1', capture: '2', refund: '3', cancel: '9', verify: '7' }
- RESPONSE_TEXTS =
These are the text meanings sent back by the acquirer when a card has been rejected. Syntax or general request errors are not covered here.
{ 0 => 'Transaction Approved', 400 => 'Cancellation Accepted', 481 => 'Cancellation Accepted', 500 => 'Reconciliation Accepted', 900 => 'Refund / Confirmation approved', 101 => 'Card expired', 102 => 'Card blocked temporarily or under susciption of fraud', 104 => 'Transaction not permitted', 107 => 'Contact the card issuer', 109 => 'Invalid identification by merchant or POS terminal', 110 => 'Invalid amount', 114 => 'Card cannot be used to the requested transaction', 116 => 'Insufficient credit', 118 => 'Non-registered card', 125 => 'Card not effective', 129 => 'CVV2/CVC2 Error', 167 => 'Contact the card issuer: suspected fraud', 180 => 'Card out of service', 181 => 'Card with credit or debit restrictions', 182 => 'Card with credit or debit restrictions', 184 => 'Authentication error', 190 => 'Refusal with no specific reason', 191 => 'Expiry date incorrect', 195 => 'Requires SCA authentication', 201 => 'Card expired', 202 => 'Card blocked temporarily or under suspicion of fraud', 204 => 'Transaction not permitted', 207 => 'Contact the card issuer', 208 => 'Lost or stolen card', 209 => 'Lost or stolen card', 280 => 'CVV2/CVC2 Error', 290 => 'Declined with no specific reason', 480 => 'Original transaction not located, or time-out exceeded', 501 => 'Original transaction not located, or time-out exceeded', 502 => 'Original transaction not located, or time-out exceeded', 503 => 'Original transaction not located, or time-out exceeded', 904 => 'Merchant not registered at FUC', 909 => 'System error', 912 => 'Issuer not available', 913 => 'Duplicate transmission', 916 => 'Amount too low', 928 => 'Time-out exceeded', 940 => 'Transaction cancelled previously', 941 => 'Authorization operation already cancelled', 942 => 'Original authorization declined', 943 => 'Different details from origin transaction', 944 => 'Session error', 945 => 'Duplicate transmission', 946 => 'Cancellation of transaction while in progress', 947 => 'Duplicate tranmission while in progress', 949 => 'POS Inoperative', 950 => 'Refund not possible', 9064 => 'Card number incorrect', 9078 => 'No payment method available', 9093 => 'Non-existent card', 9218 => 'Recursive transaction in bad gateway', 9253 => 'Check-digit incorrect', 9256 => 'Preauth not allowed for merchant', 9257 => 'Preauth not allowed for card', 9261 => 'Operating limit exceeded', 9912 => 'Issuer not available', 9913 => 'Confirmation error', 9914 => 'KO Confirmation' }
- THREE_DS_V2 =
Expected values as per documentation
'2.1.0'
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, payment, options = {}) ⇒ Object
- #capture(money, authorization, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ RedsysRestGateway
constructor
Creates a new instance.
- #purchase(money, payment, options = {}) ⇒ Object
- #refund(money, authorization, options = {}) ⇒ Object
- #scrub(transcript) ⇒ Object
- #supports_scrubbing? ⇒ Boolean
- #verify(creditcard, options = {}) ⇒ Object
- #void(authorization, options = {}) ⇒ Object
Methods inherited from Gateway
#add_field_to_post_if_present, #add_fields_to_post_if_present, #card_brand, card_brand, #generate_unique_id, inherited, #supported_countries, supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #test?
Methods included from CreditCardFormatting
#expdate, #format, #strftime_yyyymm
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
#initialize(options = {}) ⇒ RedsysRestGateway
Creates a new instance
Redsys requires a login and secret_key, and optionally also accepts a non-default terminal.
Options
-
:login
– The Redsys Merchant ID (REQUIRED) -
:secret_key
– The Redsys Secret Key. (REQUIRED) -
:terminal
– The Redsys Terminal. Defaults to 1. (OPTIONAL) -
:test
–true
orfalse
. Defaults tofalse
. (OPTIONAL)
185 186 187 188 189 190 |
# File 'lib/active_merchant/billing/gateways/redsys_rest.rb', line 185 def initialize( = {}) requires!(, :login, :secret_key) [:terminal] ||= 1 [:signature_algorithm] = 'sha256' super end |
Instance Method Details
#authorize(money, payment, options = {}) ⇒ Object
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/active_merchant/billing/gateways/redsys_rest.rb', line 209 def (money, payment, = {}) requires!(, :order_id) post = {} add_action(post, :authorize, ) add_amount(post, money, ) add_stored_credentials(post, ) add_threeds_exemption_data(post, ) add_order(post, [:order_id]) add_payment(post, payment) add_description(post, ) add_direct_payment(post, ) add_threeds(post, ) commit(post, ) end |
#capture(money, authorization, options = {}) ⇒ Object
226 227 228 229 230 231 232 233 234 235 |
# File 'lib/active_merchant/billing/gateways/redsys_rest.rb', line 226 def capture(money, , = {}) post = {} add_action(post, :capture) add_amount(post, money, ) order_id, = () add_order(post, order_id) add_description(post, ) commit(post, ) end |
#purchase(money, payment, options = {}) ⇒ Object
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/active_merchant/billing/gateways/redsys_rest.rb', line 192 def purchase(money, payment, = {}) requires!(, :order_id) post = {} add_action(post, :purchase, ) add_amount(post, money, ) add_stored_credentials(post, ) add_threeds_exemption_data(post, ) add_order(post, [:order_id]) add_payment(post, payment) add_description(post, ) add_direct_payment(post, ) add_threeds(post, ) commit(post, ) end |
#refund(money, authorization, options = {}) ⇒ Object
250 251 252 253 254 255 256 257 258 259 260 261 |
# File 'lib/active_merchant/billing/gateways/redsys_rest.rb', line 250 def refund(money, , = {}) requires!(, :order_id) post = {} add_action(post, :refund) add_amount(post, money, ) order_id, = () add_order(post, order_id) add_description(post, ) commit(post, ) end |
#scrub(transcript) ⇒ Object
282 283 284 285 286 |
# File 'lib/active_merchant/billing/gateways/redsys_rest.rb', line 282 def scrub(transcript) transcript. gsub(%r((PAN\"=>\")(\d+)), '\1[FILTERED]'). gsub(%r((CVV2\"=>\")(\d+)), '\1[FILTERED]') end |
#supports_scrubbing? ⇒ Boolean
278 279 280 |
# File 'lib/active_merchant/billing/gateways/redsys_rest.rb', line 278 def supports_scrubbing? true end |
#verify(creditcard, options = {}) ⇒ Object
263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/active_merchant/billing/gateways/redsys_rest.rb', line 263 def verify(creditcard, = {}) requires!(, :order_id) post = {} add_action(post, :verify, ) add_amount(post, 0, ) add_order(post, [:order_id]) add_payment(post, creditcard) add_description(post, ) add_direct_payment(post, ) add_threeds(post, ) commit(post, ) end |
#void(authorization, options = {}) ⇒ Object
237 238 239 240 241 242 243 244 245 246 247 248 |
# File 'lib/active_merchant/billing/gateways/redsys_rest.rb', line 237 def void(, = {}) requires!(, :order_id) post = {} add_action(post, :cancel) order_id, amount, currency = () add_amount(post, amount, currency: currency) add_order(post, order_id) add_description(post, ) commit(post, ) end |