Sha256: 1f4feb3239679a532c1323344ba540f01443e9b806adefa5eba3b05f2358eb35

Contents?: true

Size: 954 Bytes

Versions: 2

Compression:

Stored size: 954 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

2 entries across 2 versions & 1 rubygems

Version Path
firstgiving-1.0.2 lib/firstgiving/donation.rb
firstgiving-1.0.1 lib/firstgiving/donation.rb