Class: Spree::Admin::BoltCallbackUrlsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/spree/admin/bolt_callback_urls_controller.rb

Instance Method Summary collapse

Instance Method Details

#editObject



6
7
8
9
10
11
12
# File 'app/controllers/spree/admin/bolt_callback_urls_controller.rb', line 6

def edit
  callback_urls = SolidusBolt::MerchantConfiguration::GetCallbackUrlsService.call

  @oauth_logout = callback_urls['callback_urls'].find { |c| c['type'] == 'oauth_logout' }&.dig('url')
  @oauth_redirect = callback_urls['callback_urls'].find { |c| c['type'] == 'oauth_redirect' }&.dig('url')
  @get_account = callback_urls['callback_urls'].find { |c| c['type'] == 'get_account' }&.dig('url')
end

#updateObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/spree/admin/bolt_callback_urls_controller.rb', line 14

def update
  SolidusBolt::MerchantConfiguration::SetCallbackUrlsService.call(
    oauth_logout: params[:bolt_callback_urls][:oauth_logout],
    oauth_redirect: params[:bolt_callback_urls][:oauth_redirect],
    get_account: params[:bolt_callback_urls][:get_account]
  )
  flash[:success] = "Successfully updated callback urls."

  redirect_to edit_admin_bolt_callback_urls_path
rescue SolidusBolt::ServerError => e
  flash[:error] = e.message

  render :new
end