Class: Samurai::Processor

Inherits:
Base show all
Defined in:
lib/samurai/processor.rb

Overview

This class represents a Samurai Processor connection It can be used to create purchase & authorize transactions

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#has_errors?, setup_site!

Class Method Details

.authorize(*args) ⇒ Object

Convenience method that calls the authorize method on the default processor.



20
21
22
# File 'lib/samurai/processor.rb', line 20

def self.authorize(*args)
  the_processor.authorize(*args)
end

.purchase(*args) ⇒ Object

Convenience method that calls the purchase method on the default processor.



15
16
17
# File 'lib/samurai/processor.rb', line 15

def self.purchase(*args)
  the_processor.purchase(*args)
end

.the_processorObject

Returns the default processor specified by Samurai.processor_token if you passed it into Samurai.setup_site.



10
11
12
# File 'lib/samurai/processor.rb', line 10

def self.the_processor
  Samurai::Processor.new(:id => Samurai.processor_token)
end

Instance Method Details

#authorize(payment_method_token, amount, options = {}) ⇒ Object

Authorize a payment_method for a particular amount. Parameters:

  • payment_method_token: token identifying the payment method to authorize

  • amount: amount to authorize

  • options: an optional has of additional values to pass in accepted values are:

    • description: description for the transaction
    • descriptor_name: dynamic descriptor name field
    • descriptor_phone: dynamic descriptor phone field
    • custom: custom data, this data does not get passed to the processor, it is stored within api.samurai.feefighters.com only
    • customer_reference: an identifier for the customer, this will appear in the processor if supported
    • billing_reference: an identifier for the purchase, this will appear in the processor if supported

Returns a Samurai::Transaction containing the processor's response.



57
58
59
# File 'lib/samurai/processor.rb', line 57

def authorize(payment_method_token, amount, options = {})
  execute(:authorize, options.merge(:payment_method_token => payment_method_token, :amount => amount))
end

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

Convenience method to authorize and capture a payment_method for a particular amount in one transaction. Parameters:

  • payment_method_token: token identifying the payment method to authorize
  • amount: amount to authorize
  • options: an optional has of additional values to pass in accepted values are:
    • description: description for the transaction
    • descriptor_name: dynamic descriptor name field
    • descriptor_phone: dynamic descriptor phone field
    • custom: custom data, this data does not get passed to the processor, it is stored within api.samurai.feefighters.com only
    • customer_reference: an identifier for the customer, this will appear in the processor if supported
    • billing_reference: an identifier for the purchase, this will appear in the processor if supported

Returns a Samurai::Transaction containing the processor's response.



38
39
40
# File 'lib/samurai/processor.rb', line 38

def purchase(payment_method_token, amount, options = {})
  execute(:purchase, options.merge(:payment_method_token => payment_method_token, :amount => amount))
end