Class: ActiveMerchant::Billing::FinixGateway

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

Constant Summary collapse

SUCCESS_CODES =
[200, 201].freeze
SOFT_DECLINE_CODES =
%w[
  INSUFFICIENT_FUNDS
  EXCEEDS_APPROVAL_LIMIT
  CARD_VELOCITY_EXCEEDED
  PROCESSOR_TIMEOUT
  TRANSACTION_NOT_ALLOWED
].freeze
COUNTRY_CODE =
{ 'US' => 'USA', 'CA' => 'CAN' }.freeze
API_VERSION =
'2018-01-01'.freeze
BASIC_AUTH_PREFIX =
'Basic '.freeze
CONTENT_TYPE =
'application/json'.freeze

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, #scrub, #supported_countries, supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #supports_scrubbing?, #test?

Methods included from CreditCardFormatting

#expdate, #format

Methods included from PostsData

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

Constructor Details

#initialize(options = {}) ⇒ FinixGateway

Returns a new instance of FinixGateway.



31
32
33
34
35
36
37
# File 'lib/active_merchant/billing/gateways/finix.rb', line 31

def initialize(options = {})
  requires!(options, :username, :password, :merchant_id)
  super
  @username = options[:username]
  @password = options[:password]
  @merchant_id = options[:merchant_id]
end

Instance Method Details

#purchase(amount, payment_source, options = {}) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/active_merchant/billing/gateways/finix.rb', line 39

def purchase(amount, payment_source, options = {})
  post = {}
  add_invoice(post, amount, options)

  result = add_payment_source(post, payment_source, options)
  return result if result.is_a?(Response) && !result.success?

  add_idempotency_id(post, options)
  add_statement_descriptor(post, options)

  verification_data = options[:verification_data] || {}
  commit('transaction', post, verification_data, options)
end

#refund(amount, authorization, options = {}) ⇒ Object



53
54
55
56
57
58
# File 'lib/active_merchant/billing/gateways/finix.rb', line 53

def refund(amount, authorization, options = {})
  post = {}
  add_refund_data(post, amount, authorization, options)

  commit('reversals', post, options)
end