mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Worklow to disconnect Stripe from OFN admin interface
This commit is contained in:
committed by
Rob Harrington
parent
758f57a889
commit
05a69ff0c6
@@ -141,6 +141,15 @@ module Admin
|
||||
end
|
||||
end
|
||||
|
||||
def stripe_disconnect
|
||||
if deauthorize_stripe(params[:account_id])
|
||||
respond_to do |format|
|
||||
format.html { redirect_to main_app.edit_admin_enterprise_path(@enterprise), notice: "Stripe account disconnected."}
|
||||
format.json { render json: "Disconnected" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def build_resource_with_address
|
||||
|
||||
@@ -3,6 +3,7 @@ require File.join(Rails.root, '/lib/oauth2/client')
|
||||
require 'oauth2'
|
||||
module Admin
|
||||
module StripeHelper
|
||||
|
||||
class << self
|
||||
attr_accessor :client, :options
|
||||
end
|
||||
@@ -34,7 +35,11 @@ module Admin
|
||||
stripe_account = StripeAccount.find(account_id)
|
||||
if stripe_account
|
||||
response = StripeHelper.client.deauthorize(stripe_account.stripe_user_id).deauthorize_request
|
||||
if response # Response from OAuth2 only returned if successful
|
||||
stripe_account.destroy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
- if stripe_account = @enterprise.stripe_account
|
||||
- if @stripe_account = @enterprise.stripe_account
|
||||
= t :stripe_account_connected
|
||||
= stripe_account.inspect
|
||||
.span (Link to disconnect Stripe Acct)
|
||||
= link_to 'Delete', main_app.admin_enterprise_stripe_account_path(@enterprise,@stripe_account), method: :delete
|
||||
- else
|
||||
%a.stripe-connect{href: 'stripe_connect'}
|
||||
.span= t :connect_with_stripe
|
||||
|
||||
@@ -72,7 +72,6 @@ Openfoodnetwork::Application.routes.draw do
|
||||
post :search
|
||||
get :check_permalink
|
||||
end
|
||||
|
||||
|
||||
member do
|
||||
get :shop
|
||||
@@ -102,7 +101,7 @@ Openfoodnetwork::Application.routes.draw do
|
||||
end
|
||||
|
||||
get "/stripe_connect", to: "enterprises#stripe_connect"
|
||||
|
||||
resources :stripe_accounts
|
||||
|
||||
member do
|
||||
get :welcome
|
||||
|
||||
Reference in New Issue
Block a user