Sha256: a7d59b8737bf7698e370fb2127b30f0073fbff9a33e55b4f13f059145a8d124b

Contents?: true

Size: 958 Bytes

Versions: 1

Compression:

Stored size: 958 Bytes

Contents

require 'crack'

module FirstGiving

  class Donation

    include Base

    module Actions
      CREDITCARD = "/donation/creditcard"
      RECURRING_CREDITCARD_PROFILE = "/donation/recurringcreditcardprofile"
      VERIFY = "/verify"
    end

    def initialize
      @api_endpoint = DONATION_PRODUCTION_ENDPOINT
      @api_endpoint = DONATION_SANDBOX_ENDPOINT if FirstGiving.configuration.options[:use_staging]
    end

    def headers
      headers_json.merge!(headers_security)
    end

    def creditcard(params)
      response = post_call(@api_endpoint, Actions::CREDITCARD, params, headers)
      parse(response.body)
    end

    def verify(params)
      response = get_call(@api_endpoint, Actions::VERIFY, params, headers)
      parse(response.body)
    end

    def recurring_creditcard_profile(params)
      call(Actions::RECURRING_CREDITCARD_PROFILE, params, headers)
    end

    def parse(body)
      Crack::XML.parse(body)
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
firstgiving-1.0.0 lib/firstgiving/donation.rb