Sha256: 92c09012c12c04b04210c5947d44c5351fa65fab92a03f3139d091df9cad1005

Contents?: true

Size: 835 Bytes

Versions: 3

Compression:

Stored size: 835 Bytes

Contents

module Moneytree
  module PaymentProvider
    class Stripe < Base
      # The permissions we request from Square OAuth, we store them in the database
      PERMISSION = :read_write

      def initialize(args)
        raise Error, 'Please set your Stripe credentials' if credentitals.nil?
        raise Error, 'Please include the stripe gem to your Gemfile' unless Object.const_defined?('::Stripe')

        ::Stripe.api_key = credentitals[:api_key]
        super
      end

      def get_access_token(params)
        # FIXME: add error handling
        ::Stripe::OAuth.token({
          grant_type: 'authorization_code',
          code: params[:code]
        }).to_hash
      end

      def scope
        PERMISSION.to_s
      end

      private

      def credentitals
        Moneytree.stripe_credentials
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
moneytree-rails-0.1.3 lib/moneytree/payment_provider/stripe.rb
moneytree-rails-0.1.2 lib/moneytree/payment_provider/stripe.rb
moneytree-rails-0.1.1 lib/moneytree/payment_provider/stripe.rb