Class: Samurai::Processor
- Inherits:
-
Base
- Object
- ActiveResource::Base
- Base
- Samurai::Processor
- 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
-
.authorize(*args) ⇒ Object
Convenience method that calls the authorize method on the default processor.
-
.purchase(*args) ⇒ Object
Convenience method that calls the purchase method on the default processor.
-
.the_processor ⇒ Object
Returns the default processor specified by Samurai.processor_token if you passed it into Samurai.setup_site.
Instance Method Summary collapse
-
#authorize(payment_method_token, amount, options = {}) ⇒ Object
Authorize a payment_method for a particular amount.
-
#purchase(payment_method_token, amount, options = {}) ⇒ Object
Convenience method to authorize and capture a payment_method for a particular amount in one transaction.
Methods inherited from Base
Class Method Details
.authorize(*args) ⇒ Object
Convenience method that calls the authorize method on the default processor.
19 20 21 |
# File 'lib/samurai/processor.rb', line 19 def self.(*args) the_processor.(*args) end |
.purchase(*args) ⇒ Object
Convenience method that calls the purchase method on the default processor.
14 15 16 |
# File 'lib/samurai/processor.rb', line 14 def self.purchase(*args) the_processor.purchase(*args) end |
.the_processor ⇒ Object
Returns the default processor specified by Samurai.processor_token if you passed it into Samurai.setup_site.
9 10 11 |
# File 'lib/samurai/processor.rb', line 9 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:
-
‘descriptor`: descriptor for the transaction
-
‘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.
52 53 54 |
# File 'lib/samurai/processor.rb', line 52 def (payment_method_token, amount, = {}) execute(:authorize, .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:
-
‘descriptor`: descriptor for the transaction
-
‘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.
35 36 37 |
# File 'lib/samurai/processor.rb', line 35 def purchase(payment_method_token, amount, = {}) execute(:purchase, .merge(:payment_method_token => payment_method_token, :amount => amount)) end |