lib/recurly/invoice.rb in recurly-2.17.11 vs lib/recurly/invoice.rb in recurly-2.18.0

- old
+ new

@@ -107,10 +107,11 @@ subscription_id subscription_ids dunning_events_count final_dunning_event gateway_code + surcharge_in_cents ) alias to_param invoice_number_with_prefix def self.to_xml(attrs) invoice = new attrs @@ -140,15 +141,24 @@ raise Invalid, e.message end # Initiate a collection attempt on an invoice. # + # @example + # # Optionally set transaction type + # invoice.force_collect(transaction_type: 'moto') + # + # @param options [Hash] Optional set of details to send to collect endpoint. # @return [true, false] +true+ when successful, +false+ when unable to # (e.g., the invoice is no longer open). - def force_collect + def force_collect(options = {}) return false unless link? :force_collect - reload follow_link :force_collect + http_opts = {} + if options[:transaction_type] + http_opts[:body] = transaction_type_xml(options[:transaction_type]) + end + reload follow_link(:force_collect, http_opts) true end # Voids the invoice. # @@ -261,9 +271,15 @@ adj_node = node.add_element 'adjustment' adj_node.add_element 'uuid', line_item[:adjustment].uuid adj_node.add_element 'quantity', line_item[:quantity] adj_node.add_element 'prorate', line_item[:prorate] end + builder.to_s + end + + def transaction_type_xml(transaction_type) + builder = XML.new("<invoice/>") + builder.add_element 'transaction_type', transaction_type.to_s builder.to_s end # Invoices are only writeable through {Account} instances. embedded! true