Class: ActiveMerchant::Billing::CecabankGateway

Inherits:
Gateway
  • Object
show all
Defined in:
lib/active_merchant/billing/gateways/cecabank.rb

Constant Summary collapse

CECA_NOTIFICATIONS_URL =

CECA’s MAGIC NUMBERS

'NONE'
CECA_ENCRIPTION =
'SHA2'
CECA_DECIMALS =
'2'
CECA_MODE =
'SSL'
CECA_UI_LESS_LANGUAGE =
'XML'
CECA_UI_LESS_LANGUAGE_REFUND =
'1'
CECA_UI_LESS_REFUND_PAGE =
'anulacion_xml'
CECA_ACTION_REFUND =

use partial refund’s URL to avoid time frame limitations and decision logic on client side

'anulaciones/anularParcial'
CECA_ACTION_PURCHASE =
'tpv/compra'
CECA_CURRENCIES_DICTIONARY =
{ 'EUR' => 978, 'USD' => 840, 'GBP' => 826 }

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

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?, #supports_scrubbing?, #test?

Methods included from CreditCardFormatting

#format

Methods included from PostsData

included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request

Constructor Details

#initialize(options = {}) ⇒ CecabankGateway

Creates a new CecabankGateway

The gateway requires four values for connection to be passed in the options hash.

Options

  • :merchant_id – Cecabank’s merchant_id (REQUIRED)

  • :acquirer_bin – Cecabank’s acquirer_bin (REQUIRED)

  • :terminal_id – Cecabank’s terminal_id (REQUIRED)

  • :key – Cecabank’s cypher key (REQUIRED)

  • :testtrue or false. If true, perform transactions against the test server. Otherwise, perform transactions against the production server.



39
40
41
42
# File 'lib/active_merchant/billing/gateways/cecabank.rb', line 39

def initialize(options = {})
  requires!(options, :merchant_id, :acquirer_bin, :terminal_id, :key)
  super
end

Instance Method Details

#purchase(money, creditcard, options = {}) ⇒ Object

Perform a purchase, which is essentially an authorization and capture in a single operation.

Parameters

  • money – The amount to be purchased as an Integer value in cents.

  • creditcard – The CreditCard details for the transaction.

  • options – A hash of optional parameters.

Options

  • :order_id – order_id passed used purchase. (REQUIRED)

  • :currency – currency. Supported: EUR, USD, GBP.

  • :description – description to be pased to the gateway.



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/active_merchant/billing/gateways/cecabank.rb', line 57

def purchase(money, creditcard, options = {})
  requires!(options, :order_id)

  post = { 'Descripcion' => options[:description],
          'Num_operacion' => options[:order_id],
          'Idioma' => CECA_UI_LESS_LANGUAGE,
          'Pago_soportado' => CECA_MODE,
          'URL_OK' => CECA_NOTIFICATIONS_URL,
          'URL_NOK' => CECA_NOTIFICATIONS_URL,
          'Importe' => amount(money),
          'TipoMoneda' => CECA_CURRENCIES_DICTIONARY[options[:currency] || currency(money)] }

  add_creditcard(post, creditcard)

  commit(CECA_ACTION_PURCHASE, post)
end

#refund(money, identification, options = {}) ⇒ Object

Refund a transaction.

This transaction indicates to the gateway that money should flow from the merchant to the customer.

Parameters

  • money – The amount to be credited to the customer as an Integer value in cents.

  • identification – The reference given from the gateway on purchase (reference, not operation).

  • options – A hash of parameters.



84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/active_merchant/billing/gateways/cecabank.rb', line 84

def refund(money, identification, options = {})
  reference, order_id = split_authorization(identification)

  post = { 'Referencia' => reference,
          'Num_operacion' => order_id,
          'Idioma' => CECA_UI_LESS_LANGUAGE_REFUND,
          'Pagina' => CECA_UI_LESS_REFUND_PAGE,
          'Importe' => amount(money),
          'TipoMoneda' => CECA_CURRENCIES_DICTIONARY[options[:currency] || currency(money)] }

  commit(CECA_ACTION_REFUND, post)
end

#scrub(transcript) ⇒ Object



101
102
103
104
105
106
# File 'lib/active_merchant/billing/gateways/cecabank.rb', line 101

def scrub(transcript)
  transcript.
    gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
    gsub(%r((&?pan=)[^&]*)i, '\1[FILTERED]').
    gsub(%r((&?cvv2=)[^&]*)i, '\1[FILTERED]')
end

#supports_scrubbingObject



97
98
99
# File 'lib/active_merchant/billing/gateways/cecabank.rb', line 97

def supports_scrubbing
  true
end