Sha256: eae4b6100d93e98ae35564a5a155f9de40edc9b939d3a476c10d35107e47a1b4
Contents?: true
Size: 1.38 KB
Versions: 4
Compression:
Stored size: 1.38 KB
Contents
module Moneytree module Oauth class StripeController < ApplicationController def new redirect_to stripe_oauth_url end def callback # TODO: Remove this module prefix once we figure out how to properly autoload this. payment_gateway = Moneytree::PaymentGateway.create!(psp: 'stripe', account: current_account) payment_gateway.oauth_callback(payment_gateway_params) redirect_to Moneytree.oauth_redirect, notice: 'Connected to Stripe' end private def payment_gateway_params params.permit :scope, :code end def stripe_oauth_url # https://stripe.com/docs/connect/oauth-reference # https://stripe.com/docs/connect/oauth-reference#get-authorize URI::HTTPS.build( host: 'connect.stripe.com', path: '/oauth/authorize', query: { response_type: :code, client_id: Moneytree.stripe_credentials[:client_id], scope: PaymentProvider::Stripe::PERMISSION, redirect_uri: oauth_stripe_callback_url, 'stripe_user[email]': current_account.email, 'stripe_user[url]': current_account.website, 'stripe_user[currency]': current_account.currency_code }.to_query ).to_s end def current_account send(Moneytree.current_account) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems