class ZipMoney::Capture

Attributes

params[RW]

Public Class Methods

new() click to toggle source

Initializes a ZipMoney::Capture object

Returns ZipMoney::Capture object

# File lib/zipMoney/api/capture.rb, line 12
  def initialize 
  @params      = Struct::CaptureParams.new
  @params.order    = Struct::Order.new
  @params.metadata = Struct::Metadata.new
  @params.version  = Struct::Version.new
end

Public Instance Methods

do() click to toggle source

Performs the Capture api call on zipMoney endpoint

Returns ZipMoney::Cancel object

# File lib/zipMoney/api/capture.rb, line 22
def do  
  validate
  ZipMoney.api.capture(@params)
end
validate() click to toggle source

Performs the parameters validation

# File lib/zipMoney/api/capture.rb, line 28
def validate
  raise ArgumentError, "Params emtpy" if @params.nil? 
  @errors = []
  @errors << 'txn_id must be provided' if @params.txn_id.nil? 
  @errors << 'order.id must be provided' if @params.order.id.nil? 
  @errors << 'order.total must be provided' if @params.order.total.nil? 
  @errors << 'order.shipping_value must be provided' if @params.order.shipping_value.nil? 
  @errors << 'order.tax must be provided' if @params.order.tax.nil? 

  raise ZipMoney::RequestError.new("Following error(s) occurred while making request, please resolve them to make the request: #{@errors}") if @errors.any?
end