From a1f459dacf2d63c7ce4c3dbe2bbfdb35c51b56fe Mon Sep 17 00:00:00 2001 From: komagata Date: Fri, 8 Apr 2022 17:20:15 +0900 Subject: [PATCH 1/2] =?UTF-8?q?Stripe=E3=81=AEBillingPortal=E3=81=B8?= =?UTF-8?q?=E3=81=AE=E3=83=AA=E3=83=B3=E3=82=AF=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/billing_portal_controller.rb | 10 ++++++++++ app/views/application/_user_menu.html.slim | 2 ++ config/routes.rb | 1 + 3 files changed, 13 insertions(+) create mode 100644 app/controllers/billing_portal_controller.rb diff --git a/app/controllers/billing_portal_controller.rb b/app/controllers/billing_portal_controller.rb new file mode 100644 index 00000000000..a01cc8f9ab5 --- /dev/null +++ b/app/controllers/billing_portal_controller.rb @@ -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 diff --git a/app/views/application/_user_menu.html.slim b/app/views/application/_user_menu.html.slim index 678bfd9fca9..48ee21b58e5 100644 --- a/app/views/application/_user_menu.html.slim +++ b/app/views/application/_user_menu.html.slim @@ -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 diff --git a/config/routes.rb b/config/routes.rb index 1330b2db0ec..6831ceee8fc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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" From 1c30120a3cd5c43eee75b8b35ebee1ebfb894f40 Mon Sep 17 00:00:00 2001 From: teppei machida Date: Sun, 10 Apr 2022 13:21:14 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=E3=82=AF=E3=83=AC=E3=82=B8=E3=83=83?= =?UTF-8?q?=E3=83=88=E3=82=AB=E3=83=BC=E3=83=89=E5=A4=89=E6=9B=B4=E7=94=BB?= =?UTF-8?q?=E9=9D=A2=E3=81=AE=E3=83=87=E3=82=B6=E3=82=A4=E3=83=B3=E5=B4=A9?= =?UTF-8?q?=E3=82=8C=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/card/edit.html.slim | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/app/views/card/edit.html.slim b/app/views/card/edit.html.slim index f8c2d590e7a..317a6b966c6 100644 --- a/app/views/card/edit.html.slim +++ b/app/views/card/edit.html.slim @@ -3,15 +3,14 @@ header.page-header .container .page-header__inner - h2.page-header__title = title + h2.page-header__title + = title .page-body - .container - .auth-form.is-sign-up.a-card.is-in-app - .a-card - header.auth-form__header - h1.auth-form__title - | クレジットカード変更 - .auth-form__body - = render 'form', action: :edit - = render 'notice' + .auth-form.is-sign-up.a-card.is-in-app + header.auth-form__header + h1.auth-form__title + | クレジットカード変更 + .auth-form__body + = render 'form', action: :edit + = render 'notice'