class Transfirst::Customer

Constants

BUSINESS_PHONE
FETCH_ID
FETCH_NODE
RECURRING_PAYMENT

Attributes

address_line1[RW]
address_line2[RW]
api[RW]
city[RW]
country[RW]
email[RW]
full_name[RW]
phone_number[RW]
state[RW]
status[RW]
tf_id[RW]
zip_code[RW]

Public Class Methods

new(*args) click to toggle source
# File lib/transfirst/customer.rb, line 12
def initialize(*args)
  api, attrs = *args
  @api = api
  @body = build_request(attrs)
end

Private Instance Methods

build_request(attrs) click to toggle source
# File lib/transfirst/customer.rb, line 20
def build_request attrs
  namespaces = {
      'xmlns:soapenv' => 'http://schemas.xmlsoap.org/soap/envelope/',
      "xmlns:#{VERSION}" => XSD_PATH
  }
  req_builder = Nokogiri::XML::Builder.new do |xml|
    xml['soapenv'].Envelope(namespaces) do
      xml['soapenv'].Header
      xml['soapenv'].Body do
        xml[VERSION].send('UpdtRecurrProfRequest') do
          xml[VERSION].merc do
            xml[VERSION].id @api.gateway_id
            xml[VERSION].regKey @api.registration_key
            xml[VERSION].inType MERCHANT_WEB_SERVICE
          end
          xml[VERSION].cust do
            xml[VERSION].type 0 #0 adding new customer 1 updating customer
            xml[VERSION].contact do
              xml[VERSION].fullName attrs[:full_name]
              xml[VERSION].ctry 'US'
              xml[VERSION].type 1 #This is an indicator of where the customer profile information is used. 1 = Recurring
              xml[VERSION].stat 1 #0 = Inactive
            end
          end
        end
      end
    end
  end
  req_builder.to_xml :save_with => Nokogiri::XML::Node::SaveOptions::NO_DECLARATION
end