Skip to content

Commit

Permalink
StripeのBillingPortalへのリンクを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
komagata committed Apr 8, 2022
1 parent b265c77 commit a1f459d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/controllers/billing_portal_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

class BillingPortalController < ApplicationController
before_action :require_login

def create
session = Stripe::BillingPortal::Session.create(customer: current_user.customer_id)
redirect_to session.url
end
end
2 changes: 2 additions & 0 deletions app/views/application/_user_menu.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
| 登録情報変更
- if !current_user.adviser? && !current_user.mentor? && !current_user.trainee?
- if current_user.card?
li.header-dropdown__item
= link_to 'お支払い情報', billing_portal_path, method: :post, class: 'header-dropdown__item-link'
li.header-dropdown__item
= link_to 'クレジットカード情報', card_path, class: 'header-dropdown__item-link'
li.header-dropdown__item
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
resources :products, only: %i(index), controller: "companies/products"
end
resources :generations, only: %i(show index)
resource :billing_portal, only: :create, controller: "billing_portal"
get "articles/tags/:tag", to: "articles#index", as: :tag, tag: /.+/
get "pages/tags/:tag", to: "pages#index", as: :pages_tag, tag: /.+/, format: "html"
get "questions/tags/:tag", to: "questions#index", as: :questions_tag, tag: /.+/, format: "html"
Expand Down

0 comments on commit a1f459d

Please sign in to comment.