class DuffelAPI::Services::PaymentsService

Public Instance Methods

create(options = {}) click to toggle source

Creates an payment

@option [required, Hash] :params the payload for creating the payment @return [Resources::Payment] @raise [Errors::Error] when the Duffel API returns an error

# File lib/duffel_api/services/payments_service.rb, line 11
def create(options = {})
  path = "/air/payments"

  params = options.delete(:params) || {}
  options[:params] = {}
  options[:params]["data"] = params

  begin
    response = make_request(:post, path, options)

    # Response doesn't raise any errors until #body is called
    response.tap(&:raw_body)
  end

  return if response.raw_body.nil?

  Resources::Payment.new(unenvelope_body(response.parsed_body), response)
end