class Docdata::Refund
Attributes
amount[RW]
currency[RW]
description[RW]
errors[RW]
payment[RW]
Public Class Methods
new(args=nil)
click to toggle source
Initializer to transform a Hash
into an Refund
object
@param [Hash] args
# File lib/docdata/refund.rb, line 38 def initialize(args=nil) @line_items = [] return if args.nil? args.each do |k,v| instance_variable_set("@#{k}", v) unless v.nil? end end
Public Instance Methods
perform_refund()
click to toggle source
This calls the ‘refund’ method of the SOAP API It refunds (part of) the payment and returns a Docdata::Response
object
# File lib/docdata/refund.rb, line 55 def perform_refund # make the SOAP API call response = Docdata.client.call(:refund, xml: refund_xml) response_object = Docdata::Response.parse(:refund, response) if response_object.success? return true else return false end end
refund_xml()
click to toggle source
@return [String] the xml to send in the SOAP API
# File lib/docdata/refund.rb, line 67 def refund_xml xml_file = "#{File.dirname(__FILE__)}/xml/refund.xml.erb" template = File.read(xml_file) namespace = OpenStruct.new(refund: self, payment: self.payment) xml = ERB.new(template).result(namespace.instance_eval { binding }) end
valid?()
click to toggle source
@return [Boolean] true/false, depending if this instanciated object is valid
# File lib/docdata/refund.rb, line 47 def valid? validator = RefundValidator.new validator.valid?(self) end