class Ecko::Plugins::Sponsor::Process

Attributes

account[RW]
package[RW]

Public Class Methods

new(package_id, account) click to toggle source

Get the donation package and set it here. If it is not found, RecordNotFound error will be raised

# File lib/ecko/plugins/sponsor/process.rb, line 16
def initialize(package_id, account)
  # Find the package through which we can donate.
  @package = ::DonationPackage.find(package_id)

  # A sponsor should always be associated with an account
  @account = account
end

Private Class Methods

run(package_id, account) click to toggle source
# File lib/ecko/plugins/sponsor/process.rb, line 49
def run(package_id, account)
  new(package_id, account).run
end

Public Instance Methods

run() click to toggle source

This will run the gateway process based on the object set during configuration

# File lib/ecko/plugins/sponsor/process.rb, line 25
def run
  send("run_#{gateways[:run]}")
end

Private Instance Methods

gateways() click to toggle source

Gets all the gateways that was registered for this plugin.

# File lib/ecko/plugins/sponsor/process.rb, line 44
def gateways
  @gateways ||= Ecko::Plugins::Sponsor::Configurations.instance.gateways
end
run_choice() click to toggle source

Currently we just have a stripe parser which will never run this process so it is an empty runner currently. TODO: Set this up when we have multiple parsers. It should not run gateway process but redirect to a choice of gateway

# File lib/ecko/plugins/sponsor/process.rb, line 34
def run_choice; end
run_default() click to toggle source

When we have only a default processor, we just parse the gateway object and then run the checkout flow for it.

# File lib/ecko/plugins/sponsor/process.rb, line 38
def run_default
  value = Object.const_get("Ecko::Plugins::Sponsor::Parser::#{gateways[:default][:name]}").build(package, account)
  gateways[:default][:checkout].execute(value)
end