class Transfirst::API

Constants

ADD_ENTITY
MERCHANT_PROD_TYPE
MERCHANT_WEB_SERVICE
NO_API_ERROR
RECURRING
STATUS_ACTIVE
STATUS_INACTIVE
UPDATE_ENTITY
VERSION
XSD_PATH

Attributes

client[R]
gateway_id[R]
registration_key[R]

Public Class Methods

new(credentials = {}) click to toggle source
# File lib/transfirst.rb, line 22
def initialize(credentials = {})
  @gateway_id = credentials.fetch(:gateway_id)
  @registration_key = credentials.fetch(:registration_key)
end

Public Instance Methods

make_request(opname, body) click to toggle source
# File lib/transfirst.rb, line 27
def make_request(opname, body)
  begin
    response = soap_client.call(opname, xml: body, soap_action: nil)
    response.body
  rescue Savon::SOAPFault => e
    Transfirst::TransfirstError.new(e).message
  end
end
register() click to toggle source
# File lib/transfirst.rb, line 37
def register
  case self.class.name
    when 'Transfirst::Customer', 'Transfirst::Wallet'
      @resp = api.make_request(:updt_recurr_prof, @body)
    when 'Transfirst::WalletSale', 'Transfirst::WalletRefund', 'Transfirst::AccountVerification'
      @resp = api.make_request(:send_tran, @body)
    else
  end
  @resp
end

Private Instance Methods

soap_client() click to toggle source
# File lib/transfirst.rb, line 49
def soap_client
  document = wsdl_path
  @client ||= Savon::Client.new do
    ssl_verify_mode :none
    log true if ENV['DEBUG']
    pretty_print_xml true
    wsdl document
  end
end
wsdl_path() click to toggle source
# File lib/transfirst.rb, line 59
def wsdl_path
  File.expand_path(File.join(__FILE__, '../transfirst/wsdl/transfirst-v1.wsdl'))
end