app/controllers/effective/providers/stripe_connect.rb
# So this is the postback after Stripe does its oAuth authentication
So this is the postback after Stripe does its oAuth authentication
So this is the postback after Stripe does its oAuth authentication
def stripe_connect_redirect_uri
        if params[:code].present?
          token_params = request_access_token(params[:code]) 
          customer = Effective::Customer.for_user(current_user)
          if token_params['access_token'].present? && customer.present?
            if customer.update_attributes(stripe_connect_access_token: token_params['access_token'])
              flash[:success] = 'Successfully Connected with Stripe Connect'
            else
              flash[:danger] = "Unable to update customer: #{customer.errors[:base].first}"
            end
          else
            flash[:danger] = "Error when connecting to Stripe /oauth/token: #{token_params[:error]}.  Please try again."
          end
        else
          flash[:danger] = "Error when connecting to Stripe /oauth/authorize: #{params[:error]}.  Please try again."
        end
        redirect_to URI.parse(@stripe_state_params['redirect_to']).path rescue effective_orders.orders_path
      end
def stripe_connect_redirect_uri if params [ :code ] . present? token_params = request_access_token ( params [ :code ] ) customer = Effective :: Customer . for_user ( current_user ) if token_params [ 'access_token' ] . present? && customer . present? if customer . update_attributes ( stripe_connect_access_token : token_params [ 'access_token' ] ) flash [ :success ] = 'Successfully Connected with Stripe Connect' else flash [ :danger ] = "Unable to update customer: #{customer.errors[:base].first}" end else flash [ :danger ] = "Error when connecting to Stripe /oauth/token: #{token_params[:error]}.  Please try again." end else flash [ :danger ] = "Error when connecting to Stripe /oauth/authorize: #{params[:error]}.  Please try again." end redirect_to URI . parse ( @stripe_state_params [ 'redirect_to' ] ) . path rescue effective_orders . orders_path end
So this is the postback after Stripe does its oAuth authentication
So this is the postback after Stripe does its oAuth authentication
# We got a code, so now we make a curl request for the access_token