Class: NimbleshopSplitable::Processor
- Inherits:
-
Processor::Base
- Object
- Processor::Base
- NimbleshopSplitable::Processor
- Defined in:
- lib/nimbleshop_splitable/processor.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#payment_method ⇒ Object
readonly
Returns the value of attribute payment_method.
Instance Method Summary collapse
- #acknowledge(params = {}) ⇒ Object
- #create_split(options = {}) ⇒ Object
- #gateway ⇒ Object
-
#initialize(options = {}) ⇒ Processor
constructor
A new instance of Processor.
Constructor Details
#initialize(options = {}) ⇒ Processor
Returns a new instance of Processor.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/nimbleshop_splitable/processor.rb', line 10 def initialize( = {}) unless @order = [:order] invoice = [:invoice].try(:to_s) @order = Order.find_by_number(invoice) end @errors = [] @payment_method = NimbleshopSplitable::Splitable.first end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
4 5 6 |
# File 'lib/nimbleshop_splitable/processor.rb', line 4 def errors @errors end |
#order ⇒ Object (readonly)
Returns the value of attribute order.
4 5 6 |
# File 'lib/nimbleshop_splitable/processor.rb', line 4 def order @order end |
#payment_method ⇒ Object (readonly)
Returns the value of attribute payment_method.
4 5 6 |
# File 'lib/nimbleshop_splitable/processor.rb', line 4 def payment_method @payment_method end |
Instance Method Details
#acknowledge(params = {}) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/nimbleshop_splitable/processor.rb', line 35 def acknowledge(params = {}) if valid?(params) send(resolve_payment_kind(params[:payment_status]), params) else false end end |
#create_split(options = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/nimbleshop_splitable/processor.rb', line 21 def create_split( = {}) .symbolize_keys! .assert_valid_keys(:request) response = gateway.create(order, [:request]) json = ActiveSupport::JSON.decode(response) result = json.values_at('error','split_url') if result.last order.update_attributes(payment_method: payment_method) order.pending end result end |
#gateway ⇒ Object
6 7 8 |
# File 'lib/nimbleshop_splitable/processor.rb', line 6 def gateway ::NimbleshopSplitable::Gateway.new(NimbleshopSplitable::Splitable.first) end |